Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default AppActivate / Minimized Windows / GetWindowPlacement

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default AppActivate / Minimized Windows / GetWindowPlacement

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrange Icons of Minimized Excel Windows Johnny Naperville Excel Programming 5 October 6th 06 05:16 PM
Opens bhind other windows or minimized Jmmac04 Excel Discussion (Misc queries) 0 April 17th 06 05:34 PM
AppActivate BristolBloos Excel Programming 1 October 14th 05 01:01 PM
appactivate Philip Kopf Excel Programming 2 August 23rd 04 05:08 AM
appactivate Philip Kopf Excel Programming 3 August 23rd 04 05:06 AM


All times are GMT +1. The time now is 10:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"