Results 1 to 4 of 4

Thread: Open in same window

  1. #1

    Thread Starter
    Addicted Member slashandburn's Avatar
    Join Date
    Aug 1999
    Location
    Marietta, Ga
    Posts
    229

    Talking

    Im writing a small application to take the job of IE as the primary Jpeg Viewer. My problem is i don't want it to open up a new program when i click on another picture how can i do that?

  2. #2
    Guest
    Are you using the Webbrowser Control? Because you can make it so that no other Window will open when the user right clicks and clicks on Open in New Window.

    Code:
    Private Sub webbrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
        Cancel = True
    End Sub

  3. #3

    Thread Starter
    Addicted Member slashandburn's Avatar
    Join Date
    Aug 1999
    Location
    Marietta, Ga
    Posts
    229
    no im using an imagebox.

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    This code will actually open an other window but before that it will close the old window.
    Code:
    Private Declare Function SendMessage _
     Lib "user32" Alias "SendMessageA" ( _
     ByVal hWnd As Long, _
     ByVal wMsg As Long, _
     ByVal wParam As Long, _
     lParam As Any) As Long
    
    Private Declare Function FindWindow _
     Lib "user32" Alias "FindWindowA" ( _
     ByVal lpClassName As String, _
     ByVal lpWindowName As String) As Long
    
    Private Const WM_CLOSE = &H10
    
    Private Sub Form_Load()
        Dim hWnd As Long
        Dim sCaption As String
        sCaption = Me.Caption
        Me.Caption = ""
        If App.PrevInstance = True Then
            hWnd = FindWindow(vbNullString, sCaption)
            SendMessage hWnd, WM_CLOSE, 0&, 0&
        End If
        Me.Caption = sCaption
        'call whatever code you're using to load
        'the picture here
    End Sub
    This code will only work if you're not changing the Caption of the form after it's loaded.

    Good luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width