Solved

Minimize window

Posted on 1998-11-13
7
573 Views
Last Modified: 2013-11-20
I will give 500 points to whoever can show me how to minimize a dialog box by clicking a button other than the minimize button.  I think it would have something to do with WM_MINIMIZE, but there is no such message.  What do I do?
0
Comment
Question by:oblong
  • 4
  • 2
7 Comments
 

Author Comment

by:oblong
ID: 1324664
Edited text of question
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324665
To minimize a window, you want to send it a message (which you knew).  However, there is no WM_MINIMIZE message.  These system messages are hidden as parameters for the WM_SYSCOMMAND message.  So, in order to minimize a window by clicking a button, put this code in the function that is called when the button is clicked:

  POINT pt;
  GetCursorPos (&pt);
  SendMessage (WM_SYSCOMMAND, SC_MINIMIZE, pt.y << 16 | pt.x);

If you have any further questions regarding this, please feel free to ask.  Thanks!
0
 
LVL 6

Accepted Solution

by:
thresher_shark earned 500 total points
ID: 1324666
Please take my above comment as an "answer."
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 7

Expert Comment

by:psdavis
ID: 1324667
Additional notes...

You can make the lParam a little bit easier with the MAKELONG macro.

GetCursorPos (&pt);
SendMessage( WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG( pt.x, pt.y ));

Thresh, is the GetCursorPos necessary?  Would SendMessage( WM_SYSCOMMAND, SC_MINIMIZE, 0 ) work ?  I haven't tried it, but was wondering why the cursor position was necessary...

Phillip
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324668
Yes, that is a good question.  I always just stuck it in there to make sure it was happy.  From there, I would go to old source code and copy it into the new source code so I have always used that method. :-)  Code re-use I suppose.

I'll give it a shot right now...

<pause>

.Indeed it does work, so oblong, you can use this code instead:
SendMessage (WM_SYSCOMMAND, SC_MINIMIZE, 0);

Thanks Phillip!  I'll have to remember that for in the future.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324669
Huh, that's strange, before the word "Indeed" I put three periods: ... but they didn't show up!  Let's try that again:

.Indeed (3 periods)
..Indeed (4 periods)
...Indeed (5 periods)
0
 

Author Comment

by:oblong
ID: 1324670
Thanks.  You were a great help.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

18 Experts available now in Live!

Get 1:1 Help Now