Solved

Resize Event not triggered by ShowWindow API

Posted on 2002-07-24
3
362 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
ID: 7175801
strange behavior.
0
 
LVL 4

Accepted Solution

by:
Nazdor earned 200 total points
ID: 7176899
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
ID: 8040580
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

776 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