Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi - Trying to activate an app that may or may not be minimized. Thought I
might be able to use the GetWindowPlacement api call, but it keeps crashing. Likely due to my calculation of the WINDOWPLACEMENT struct / type size. Below is the code of what I am doing. Any ideas? ' WinAPI structured type declarations. Type POINTAPI X As Integer Y As Integer End Type Type RECT Left As Integer Top As Integer Right As Integer Bottom As Integer End Type Type WINDOWPLACEMENT length As Integer flags As Integer showCmd As Integer ptMinPosition As POINTAPI ptMaxPosition As POINTAPI rcNormalPosition As RECT End Type ' WinAPI function declarations. Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Public Declare Function GetWindowPlacement Lib "user32" (ByVal hWnd As Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer Public Declare Function SetWindowPlacement Lib "user32" (ByVal hWnd As Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer Sub Some_Sub() Dim lRC As Long Dim hWnd As Integer Dim wp As WINDOWPLACEMENT hWnd = FindWindow(vbNullString, "UltraEdit - [file.txt]") If hWnd = 0 Then GoTo gto_Exit_Function wp.length = Len(wp) lRC = GetWindowPlacement(hWnd, wp) ' == CRASHES HERE; MAYBE B/C OF LEN CALC ABOVE? <== If lRC = 0 Then GoTo gto_Exit_Function gto_Exit_Function: If Err Then Err.Clear End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
change the below "integer" to "long" and everything works fine.
"MeistersingerVonNurnberg" wrote: Hi - Trying to activate an app that may or may not be minimized. Thought I might be able to use the GetWindowPlacement api call, but it keeps crashing. Likely due to my calculation of the WINDOWPLACEMENT struct / type size. Below is the code of what I am doing. Any ideas? ' WinAPI structured type declarations. Type POINTAPI X As Integer Y As Integer End Type Type RECT Left As Integer Top As Integer Right As Integer Bottom As Integer End Type Type WINDOWPLACEMENT length As Integer flags As Integer showCmd As Integer ptMinPosition As POINTAPI ptMaxPosition As POINTAPI rcNormalPosition As RECT End Type ' WinAPI function declarations. Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Public Declare Function GetWindowPlacement Lib "user32" (ByVal hWnd As Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer Public Declare Function SetWindowPlacement Lib "user32" (ByVal hWnd As Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer Sub Some_Sub() Dim lRC As Long Dim hWnd As Integer Dim wp As WINDOWPLACEMENT hWnd = FindWindow(vbNullString, "UltraEdit - [file.txt]") If hWnd = 0 Then GoTo gto_Exit_Function wp.length = Len(wp) lRC = GetWindowPlacement(hWnd, wp) ' == CRASHES HERE; MAYBE B/C OF LEN CALC ABOVE? <== If lRC = 0 Then GoTo gto_Exit_Function gto_Exit_Function: If Err Then Err.Clear End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Arrange Icons of Minimized Excel Windows | Excel Programming | |||
Opens bhind other windows or minimized | Excel Discussion (Misc queries) | |||
AppActivate | Excel Programming | |||
appactivate | Excel Programming | |||
appactivate | Excel Programming |