Solved

Catching WM_SIZE from a CDialog window

Posted on 1998-09-30
10
794 Views
Last Modified: 2013-11-20
I'm having an odd problem...I am trying to detect when my CDialog window gets minimized. I tried handling WM_SIZE with  OnSize, and testing for the SIZE_MINIMIZE flag. However, when I minimize the window (both with the system menu on the window tool bar and the "minimize all windows" on the taskbar)the WM_SIZE message isn't even caught. Any ideas on how I can reliably tell when my window gets minimized? Thanks in advance...

0
Comment
Question by:salmalux
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 1

Expert Comment

by:VAM345
Comment Utility
Is a Dialog based application are`n?
0
 
LVL 1

Expert Comment

by:VAM345
Comment Utility
Is a Dialog based application are`n?
0
 

Author Comment

by:salmalux
Comment Utility
Hmm...not sure what that comment means =). The application is an SDI...I'm hiding the main frame window and want to catch when the dialog box I display is minimized.
0
 
LVL 6

Expert Comment

by:snoegler
Comment Utility
Try to catch the message within PreTranslateMessage(). MFC eats some messages,
i don't know why.
As i've had several problems with this myself, i've tried many ways to understand why and
when MFC catches messages away - but i didn't get it. If you subclass the Dialog using
SetWindowLong(....,DWL_DLGPROC, MyDlgProc), you get all messages - but i think
this isn't the way to go. Most of the messages reach PreTranslateMessage(); so you should
be able to catch them there.
0
 

Expert Comment

by:schmid
Comment Utility
Handling WM_SIZE with OnSize should work if you use it in the class CMainFrame.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Expert Comment

by:Bridge
Comment Utility
WM_WINDOWPOSCHANGED
0
 
LVL 1

Expert Comment

by:Bridge
Comment Utility
WM_WINDOWPOSCHANGED
0
 
LVL 8

Expert Comment

by:Answers2000
Comment Utility
Are you catching WM_SIZE in the right place

In CDialog derived class, and NOT in MainFrame


BTW a nice function you can use after the fact is IsIconic
0
 
LVL 1

Accepted Solution

by:
Fargo earned 50 total points
Comment Utility
It's obvious that the message WM_SIZE is NOT sent when you minimize a window no matter if it is a frame window, or a dialog. Another message - WM_SYSCOMMAND is fired instead. All you have to do is handle this message in a handle function which looks like that:

void CMyDialog::OnSysCommand(UINT nID, LPARAM lParam)

.and then check if the nID parameter is equal to SC_MINIMIZE.

Take a look at the help provided for the function CWnd::OnSysCommand

I hope, I was help :)

0
 

Author Comment

by:salmalux
Comment Utility
Thanks...I eventually just checked the window size in my existing OnMove function...but thanks anyway
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

16 Experts available now in Live!

Get 1:1 Help Now