PC Review


Reply
Thread Tools Rate Thread

AppActivate / Minimized Windows / GetWindowPlacement

 
 
MeistersingerVonNurnberg
Guest
Posts: n/a
 
      5th May 2008
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 With Quote
 
 
 
 
MeistersingerVonNurnberg
Guest
Posts: n/a
 
      5th May 2008
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
MINIMIZED WINDOWS =?Utf-8?B?Z21hbg==?= Windows XP Internet Explorer 5 12th Apr 2005 03:45 AM
Minimized windows Dave Windows XP General 1 23rd Jun 2004 06:41 AM
Minimized docs don't remain minimized when opening new doc =?Utf-8?B?V2F5bmU=?= Microsoft Word Document Management 0 6th Dec 2003 12:21 AM
minimized windows rednek264@yahoo.com Windows XP Basics 2 4th Nov 2003 06:32 PM
Minimized IE6.0 Windows Dave Windows XP Internet Explorer 3 14th Aug 2003 01:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:05 PM.