Solved

Resize Event not triggered by ShowWindow API

Posted on 2002-07-24
3
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

710 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