• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

minimise to top right hand corner of desktop?

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
TimB
Asked:
TimB
  • 6
  • 4
1 Solution
 
NorbertCommented:
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
 
NorbertCommented:
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
 
WynCommented:
Bizarre question.
You can do that by dragging the taskbar to right side.That will do the trick.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
NorbertCommented:
>>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
 
TimBAuthor Commented:
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
 
NorbertCommented:
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
 
TimBAuthor Commented:
The size of the desktop window.
0
 
NorbertCommented:
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
 
TimBAuthor Commented:
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
 
NorbertCommented:
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
 
TimBAuthor Commented:
Great, Thanks!

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

Tim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

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