Results 1 to 5 of 5

Thread: [RESOLVED] Shelling internet Explorer and then moving the window.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    308

    Resolved [RESOLVED] Shelling internet Explorer and then moving the window.

    Hey Guys,

    I managed to shell internet explorer to a specific URL but:

    a) it only shells to the taskbar, regardless of me trying to open it vbmaximised
    b) I can't seem to move the window (I am using this article http://support.microsoft.com/kb/q242308/
    to find the handle from the instance returned by the shell), but it won't move ?!?! (using movewindow, or setwindowpos).

    Any help, very much appreicated !
    Code:
    Dim hinst As Long              ' Instance handle from Shell function.
       Dim hWndApp As Long           ' Window handle from GetWinHandle.
       Dim buffer As String          ' Holds caption of Window.
       Dim numChars As Integer       ' Count of bytes returned.
    
        'Still only hits the taskbar
       hinst = Shell("C:\Program Files\Internet Explorer\IEXPLORE.EXE www.google.ie", vbMaximizedFocus)
      
       'search for handle
       hWndApp = GetWinHandle(hinst)
       
       If hWndApp <> 0 Then      
            MoveWindow hWndApp, 12, 24, 3333, 222, 1
            'Doesn't Work!
            DestroyWindow hWndApp
       End If
    Thanks

    Chubby.

  2. #2
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Shelling internet Explorer and then moving the window.

    From MS help:
    If the Shell function successfully executes the named file, it returns the task ID of the started program. The task ID is a unique number that identifies the running program.
    The Task ID is not the same thing as the handle.

    Use the ShellExecute API to get a valid handle.

    You may also need to introduce a small delay before calling MoveWindow - the window has to be fully loaded first. (I've got some c0d somewhere that demos something similar - but it may be a while before I find it)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    308

    Re: Shelling internet Explorer and then moving the window.

    Thanks

    I'm using the task id to find the handle using the code in the article: http://support.microsoft.com/kb/q242308/ this gives a valid windows handle, but not quite sure its the right 'valid' windows handle ? If that makes sense.. i.e. it is a handle, but not convinced its the right one..

    Chub.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Shelling internet Explorer and then moving the window.

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    308

    Re: [RESOLVED] Shelling internet Explorer and then moving the window.



    exactly wot I needed.

    Thanks

    Chub.

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