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.
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.