Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimizing Forms in Shell Apps

Status
Not open for further replies.

lmb3

Programmer
Jul 10, 2001
16
US
I'm trying to control the window state of one application from another VB app. The ShowWindow API works great, except for one thing, code in the Form_Resize event doesn't fire when the application is minimized by a ShowWindow call. When I run both apps I'm able to Min/Max/Restore the other window from my application, but the code in Form_Resize is only triggered by SW_RESTORE and SW_MAXIMIZE. Any idea why this is happening? Am I missing something?

Here's some sample code I drew up to test this. Yep, same problem occurs..

I made an application called SampleApp and added this code:
Private Sub Form_Resize()
Select Case Me.WindowState
Case vbMinimized
MsgBox "form is minimized"
Case vbMaximized
MsgBox "form is maximized"
Case vbNormal
MsgBox "form is in normal state"
End Select
End Sub

I made another app called ControlApp, added the ShowWindow declarations, then this code:
Private Sub cmdRestore_Click()
tempHWND = FindWindow(vbNullString, "SampleApp")
retval = ShowWindow(tempHWND, SW_RESTORE)
End Sub
---
Private Sub cmdMinimize_Click()
tempHWND = FindWindow(vbNullString, "SampleApp")
retval = ShowWindow(tempHWND, SW_MINIMIZE)
End Sub
---
Private Sub cmdMaximize_Click()
tempHWND = FindWindow(vbNullString, "SampleApp")
retval = ShowWindow(tempHWND, SW_MAXIMIZE)
End Sub

Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top