?
Solved

Minimize window

Posted on 1998-11-13
7
Medium Priority
?
583 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
[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
  • 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 2000 total points
ID: 1324666
Please take my above comment as an "answer."
0
Independent Software Vendors: 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!

 
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

Industry Leaders: 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

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

770 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