Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Resize Event not triggered by ShowWindow API

Posted on 2002-07-24
3
Medium Priority
?
389 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 600 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

927 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