Solved

Resize Event not triggered by ShowWindow API

Posted on 2002-07-24
3
360 Views
Last Modified: 2008-02-26
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.

-Dave  
0
Comment
Question by:davebrennan
3 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
strange behavior.
0
 
LVL 4

Accepted Solution

by:
Nazdor earned 200 total points
Comment Utility
As you've probably guessed, this appears to be yet another case where the writers of VB6 didn't think you'd be interested in this information.

You can get around this by subclassing the form.

I'm sure you can find out how to add subclassing, so here's the interesting bit..

private const WM_SHOWWINDOW = &H18
Private Const SIZE_MINIMIZED = 1

... subclass function...
    Select Case uMsg
      Case WM_SHOWWINDOW
        If wParam = SIZE_MINIMIZED Then
            MsgBox "form is minimized"
        End If
       
    End Select

0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Hi davebrennan,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Nazdor's comment(s) as an answer.

davebrennan, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now