Solved

Minimize window

Posted on 1998-11-13
7
577 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 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