Solved

minimise to top right hand corner of desktop?

Posted on 2000-03-09
11
340 Views
Last Modified: 2013-11-20
I've made a dialog application which has a number of child windows.  When I minimize a child window, it minimizes onto the bottom left hand corner of the desktop (just above the start button).

Does anyone know how to minimise - still on the desktop, but to the top right hand corner of the screen?

TimB
0
Comment
Question by:TimB
  • 6
  • 4
11 Comments
 
LVL 3

Accepted Solution

by:
Norbert earned 100 total points
ID: 2601242
You have to do it your self:
from online help:
CWnd::OnSize  
afx_msg void OnSize( UINT nType, int cx, int cy );

Parameters

nType

Specifies the type of resizing requested. This parameter can be one of the following values:

SIZE_MAXIMIZED   Window has been maximized.


SIZE_MINIMIZED   Window has been minimized.


SIZE_RESTORED   Window has been resized, but neither SIZE_MINIMIZED nor SIZE_MAXIMIZED applies.


SIZE_MAXHIDE   Message is sent to all pop-up windows when some other window is maximized.


SIZE_MAXSHOW   Message is sent to all pop-up windows when some other window has been restored to its former size.
cx

Specifies the new width of the client area.

cy

Specifies the new height of the client area.

<<<end of snipped online help text
you see you can be informed when the window is minimized
so you can use MoveWindow or SetWindowPos to move it to an other location.
probably you have to remember the position the window had before it was made iconic to restore it when the Iconic state is canceled
0
 
LVL 3

Expert Comment

by:Norbert
ID: 2601251
You have to do it your self:
from online help:
CWnd::OnSize  
afx_msg void OnSize( UINT nType, int cx, int cy );

Parameters

nType

Specifies the type of resizing requested. This parameter can be one of the following values:

SIZE_MAXIMIZED   Window has been maximized.


SIZE_MINIMIZED   Window has been minimized.


SIZE_RESTORED   Window has been resized, but neither SIZE_MINIMIZED nor SIZE_MAXIMIZED applies.


SIZE_MAXHIDE   Message is sent to all pop-up windows when some other window is maximized.


SIZE_MAXSHOW   Message is sent to all pop-up windows when some other window has been restored to its former size.
cx

Specifies the new width of the client area.

cy

Specifies the new height of the client area.

<<<end of snipped online help text
you see you can be informed when the window is minimized
so you can use MoveWindow or SetWindowPos to move it to an other location.
probably you have to remember the position the window had before it was made iconic to restore it when the Iconic state is canceled
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2601264
Bizarre question.
You can do that by dragging the taskbar to right side.That will do the trick.
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 3

Expert Comment

by:Norbert
ID: 2622936
>>Bizarre question.
>>You can do that by dragging the taskbar to right side.That will do the trick.

no It doesn't he wants to minimize child windows not main windows.
Child windows does not appere inside the taskbar
0
 
LVL 1

Author Comment

by:TimB
ID: 2622959
Thanks for the comments,

I've been looking at the OnSize code, and helpfile text as Norbert suggested. That seems to already know the size of the screen I have.  I'm not sure how to work out the size of the screen I'm using, and then where to minimize the child window to....

TimB
0
 
LVL 3

Expert Comment

by:Norbert
ID: 2623220
I am not sure that I understand your current problem
what do you mean with the size of the screen I'm using
do you mean the size of the window ocupied on screen if not minimized or the size of the desktop window ?
0
 
LVL 1

Author Comment

by:TimB
ID: 2623255
The size of the desktop window.
0
 
LVL 3

Expert Comment

by:Norbert
ID: 2623361
CWnd has a function GetDesktopWindow
CWnd::GetDesktopWindow  
static CWnd* PASCAL GetDesktopWindow( );

Return Value

Identifies the Windows desktop window. This pointer may be temporary and should not be stored for later use.

Remarks

Returns the Windows desktop window. The desktop window covers the entire screen and is the area on top of which all icons and other windows are painted.

CRect r
GetDesktopWindow()->GetWindowRect(&r);
should do the job
0
 
LVL 1

Author Comment

by:TimB
ID: 2623632
hmmmmm....... what am I doing wrong...



void CTestChildDlg::OnSize(UINT nType, int cx, int cy)
{
      CDialog::OnSize(nType, cx, cy);
      
      //don't resize first time this is called as is called on precreate
      if(b)
      {
            CRect rect;
            GetClientRect(&rect);


            // my bit to place the minimized poz
            if (nType == SIZE_MINIMIZED) {
                  // is its in the bottom right hand corner of the screen
                  if ((rect.top == 0) && (rect.bottom == 0) && (rect.left == 0) && (rect.right == 0)) {

                        CRect r;
                        GetDesktopWindow()->GetWindowRect(&r);
                        int iTop = r.top;
                        int iBottom = r.bottom;
                        int iLeft = r.left;
                        int iRight = r.right;

                        iTop      -= 30;
                        iBottom -= 30;
                        iLeft      -= 30;
                        iRight      -= 30;

                        if (iTop < 0)
                              iTop = 400;
                        if (iBottom < 0)
                              iBottom = 400;
                        if (iLeft < 0)
                              iLeft = 400;
                        if (iRight < 0)
                              iRight = 400;

                  /*      SetRect( int x1, int y1, int x2, int y2 );
                        
                        x1 Specifies the x-coordinate of the upper-left corner.
                        y1 Specifies the y-coordinate of the upper-left corner.
                        x2 Specifies the x-coordinate of the lower-right corner.
                        y2 Specifies the y-coordinate of the lower-right corner.
*/
                        rect.SetRect(iTop, iBottom, iLeft, iRight);
                  }
            }


            
            m_browser.MoveWindow(&rect, TRUE);
      }
      b = 1;
}



My screen size is 1024x768 and I'n still getting the minimized box in the bottom left hand corner of the screen...

TimB
0
 
LVL 3

Expert Comment

by:Norbert
ID: 2624325
CRect rect;
GetClientRect(&rect);


// my bit to place the minimized poz
if (nType == SIZE_MINIMIZED) {
// is its in the bottom right hand corner of the screen
if ((rect.top == 0) && (rect.bottom == 0) && (rect.left == 0) && (rect.right == 0)) {

the rectangle will never have this position and 0,0,0,0 is the upper left corner

Try this:
for better understanding a little peece of Classdefinition
class CTestChildDlg:public CDialog
{
....
private:
    CRect m_SizedRect;
    BOOL m_IsMinimized;
    BOOL m_IsNotFirstOnSizeCall;
};
void CTestChildDlg::OnSize(UINT nType, int cx, int cy)
{
    CDialog::OnSize(nType, cx, cy);

//don't resize first time this is called as is called on precreate
    if(m_IsNotFirstOnSizeCall) //m_IsNotFirstOnSizeCall is initialisized to FALSE inside constructor
    {
    // my bit to place the minimized poz
            switch(nType)
            {
                  CWnd *Parent=GetParent();
                  case SIZE_MINIMIZED:
                        CRect r;
                        CPoint NewPosLeftTop;
                        GetDesktopWindow()->GetWindowRect(&r);
                        NewPosLeftTop.x=r.right-m_SizedRect.Width();
                        NewPosLeftTop.y=0;
                        if(Parent)
                              Parent->ScreenToClient(NewPosLeftTop);
                        SetWindowPos(NULL,NewPosLeftTop.x,NewPosLeftTop.y,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
                        m_IsMinimized=TRUE;
                        break;
                  case SIZE_RESTORED:
                        if(m_IsMinimized)
                        {
                              m_IsMinimized=FALSE;
                              if(Parent)
                                    Parent->ScreenToClient(m_SizedRect);
                              MoveWindow(m_SizedRect,TRUE);
                        }
                        GetWindowRect(&m_SizedRect);
                  default:
                        break;
            }
      }
      else
            m_IsNotFirstOnSizeCall = TRUE;
}


this should move the minimized window to the Right/Top Position
the code is not tested and it is written on the fly so there may be some typos inside
if you have more than one window to minimize you must handle the new position.

the line
      NewPosLeftTop.y=0; then must be changed to
      NewPosLeftTop.y=previous position+Height of minimized window
0
 
LVL 1

Author Comment

by:TimB
ID: 2660058
Great, Thanks!

This seems to work fine.  Sorry about taking so long to reply.

Tim
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 198
only14 challenge 19 76
scoreUp challenge 14 62
Sed question 2 85
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

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