[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 593
  • Last Modified:

Minimize window

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
oblong
Asked:
oblong
  • 4
  • 2
1 Solution
 
oblongAuthor Commented:
Edited text of question
0
 
thresher_sharkCommented:
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
 
thresher_sharkCommented:
Please take my above comment as an "answer."
0
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!

 
psdavisCommented:
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
 
thresher_sharkCommented:
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
 
thresher_sharkCommented:
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
 
oblongAuthor Commented:
Thanks.  You were a great help.
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!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now