Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Resize Event not triggered by ShowWindow API

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

660 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