Solved

minimise to top right hand corner of desktop?

Posted on 2000-03-09
11
336 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now