Results 1 to 21 of 21

Thread: [RESOLVED] Open an IE Window with a give size and position

Threaded View

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

    Re: Open an IE Window with a give size and position

    This works without any scripting errors.

    The hard way....

    VB Code:
    1. Option Explicit
    2.  
    3. Private Type RECT
    4.     Left As Long
    5.     Top As Long
    6.     Right As Long
    7.     Bottom As Long
    8. End Type
    9.  
    10. Private Type POINTAPI
    11.     x As Long
    12.     y As Long
    13. End Type
    14.  
    15. Private Type WINDOWPLACEMENT
    16.     Length As Long
    17.     flags As Long
    18.     showCmd As Long
    19.     ptMinPosition As POINTAPI
    20.     ptMaxPosition As POINTAPI
    21.     rcNormalPosition As RECT
    22. End Type
    23.  
    24. Private Declare Function SetWindowPlacement Lib "user32.dll" ( _
    25.                         ByVal hwnd As Long, _
    26.                         ByRef lpwndpl As WINDOWPLACEMENT) As Long
    27.  
    28. Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
    29.                         ByVal lpClassName As String, _
    30.                         ByVal lpWindowName As String) As Long
    31.  
    32. Private Const SW_SHOWNORMAL As Long = 1
    33.  
    34. Private Sub Main()
    35.     On Error GoTo MyError
    36.     Dim lRet As Long
    37.     Dim wPlace As WINDOWPLACEMENT
    38.     Dim rRect As RECT
    39.    
    40.     lRet = Shell("C:\Program Files\Internet Explorer\IEXPLORE.EXE", vbNormalFocus)
    41.     Do While lRet = 0
    42.         lRet = FindWindow("IEFrame", "VBForums - Visual Basic and VB .NET Discussions and More! - Microsoft Internet Explorer")
    43.         DoEvents
    44.     Loop
    45.     wPlace.Length = Len(wPlace)
    46.     wPlace.showCmd = SW_SHOWNORMAL
    47.     rRect.Left = 0
    48.     rRect.Top = 0
    49.     rRect.Right = (Screen.Width / Screen.TwipsPerPixelX) / 2
    50.     rRect.Bottom = (Screen.Height / Screen.TwipsPerPixelY) / 2
    51.     wPlace.rcNormalPosition = rRect
    52.     lRet = SetWindowPlacement(lRet, wPlace)
    53.     Exit Sub
    54. MyError:
    55.     MsgBox Err.Number & " - " & Err.Description
    56. End Sub
    Last edited by RobDog888; Sep 24th, 2006 at 05:42 PM.
    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

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