|
-
Sep 24th, 2006, 05:46 PM
#18
Re: Open an IE Window with a give size and position
Bah! Had some code missing as I had several methods applied in the temp project. Here is the fully working code.
Place in a standard module and change the window title to what ever site you want.
VB Code:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function SetWindowPlacement Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByRef lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetActiveWindow Lib "user32.dll" ( _
ByVal hwnd As Long) As Long
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMINIMIZED As Long = 2
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Sub Main()
On Error GoTo MyError
Dim lRet As Long
Dim lRet2 As Long
Dim wPlace As WINDOWPLACEMENT
Dim rRect As RECT
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE", vbNormalFocus
Do While lRet = 0
lRet = FindWindow("IEFrame", "VBForums - Visual Basic and VB .NET Discussions and More! - Microsoft Internet Explorer")
Loop
wPlace.Length = Len(wPlace)
wPlace.showCmd = SW_SHOWNORMAL
rRect.Left = 0
rRect.Top = 0
rRect.Right = (Screen.Width / Screen.TwipsPerPixelX) / 2
rRect.Bottom = (Screen.Height / Screen.TwipsPerPixelY) / 2
wPlace.rcNormalPosition = rRect
lRet2 = SetWindowPlacement(lRet, wPlace)
SetActiveWindow lRet
Exit Sub
MyError:
MsgBox Err.Number & " - " & Err.Description
End Sub
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|