Solved

OnSize questions

Posted on 2002-07-18
5
566 Views
Last Modified: 2013-11-20
I'm using OnSize to make a dialog resizeable.
So, in OnSize I compute where the various
buttons, etc need to be, given the size of the
panel.  Its working except for details.  

A few questions:

1) How can I call my OnSize code once when the
   panel is popped.  All the widgets in the panel
   jump just a bit when you first start to resize
   it.  If I could just resize once when the dialog
   is brought up, it would be fine.  Note: bad idea
   to call OnSize in OnInitDialog.

2) I  must be missing something simple, but I don't
   get this:  In Visual Studio, when I am laying out
   a panel, it shows (near lower right) the position
   and size of the control in pixels.  However, If
   I use those pixels values in my OnSize code, the
   control doesn't move to the same place.  By
   experimenting, I found that if I use 1.5 times
   the value I recorded while in dialog design, it
   works fine.  What is this factor of 1.5?

3) I declared the border of the dialog to be "resizing"
   and it works, but there's no visual clue (in the style
   of the border) that it is resizeable.  How do you get
   that little "textured triangle" at the lower right
   of the border, as I see on many applications? (e.g.
   on the IE window that I'm staring at now)

Thanks!
0
Comment
Question by:tullhead
  • 3
  • 2
5 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 7164406
1) I use the following 'trick' in OnInitDialog():

  WINDOWPLACEMENT wndpl;
  CRect rect;
  GetWindowPlacement(&wndpl);
  rect = wndpl.rcNormalPosition;
  rect.right++;

2) What you see in VS are Dialog base units.

 // Dialog base unit -> pixel unit conversion macros
 #define DLGUNIT_TO_PIXEL_X(dlgX)     \
  ( (dlgX * LOWORD( ::GetDialogBaseUnits() )) / 4)

 #define DLGUNIT_TO_PIXEL_Y(dlgY)     \
  ( (dlgY * HIWORD( ::GetDialogBaseUnits() )) / 8)

 Also read the info in MSDN on MapDialogRect()

3) For me it works when adding as the last command in my OnSize() function:

m_pWnd->RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
0
 

Author Comment

by:tullhead
ID: 7165570
zzynx --

1) This 'trick' doesn't have any effect for me.  I still
   see a jump when I first resize the window.

2) thanks, I didn't know about "dialog base units" so
   it still seems a bit bizarre, at least I know about
   the issue.

3) The "RepositionBars" didn't have any noticable effect.
   The look of the border on my window stays the same,
   and is just a simple thin border -- the user would not
   suspect that it is resizeable.  There must be some way
   to set the "Style" of the window border....?

You got 1 of 3 and I think you for that, but I'm not
giving the points quite yet.....
0
 
LVL 37

Accepted Solution

by:
zzynx earned 150 total points
ID: 7168712
Hi tullhead,

1) Of course it doesn't have any effect!
   I forgot the most important line.
   Let's try it again:

   WINDOWPLACEMENT wndpl;
   CRect rect;
   GetWindowPlacement(&wndpl);
   rect = wndpl.rcNormalPosition;
   rect.right++;
   MoveWindow(&rect);

   So, in fact you size it 'programmatically'.

3) Of course you have to set the Border Style of your dialog to 'Resizing' ('Styles' tab, combo box: 'Border')
   [But I guess you did that already. Or didn't you?]

Success
0
 

Author Comment

by:tullhead
ID: 7168723
OK, it worked ( #1 )

So you got 2 out of 3 and you get the points!

Still, my dialog's border looks plain (sigh).  Yes,
I did set it to 'resizing' under styles...
Any other idea on this?
0
 
LVL 37

Expert Comment

by:zzynx
ID: 7168745
Hi tullhead,

    >So you got 2 out of 3 and you get the points!
Thank you! Glad I could help you.

    >Yes, I did set it to 'resizing' under styles...
That's what I was afraid of...

    >Any other idea on this?
Maybe the small details make the difference:

In fact this is the Resize() function in which that line is added:

void CMyDialog::Resize()
{
  if (m_first)
  {
    m_bFirst = FALSE;
    return;
  }
  ...
  m_pWnd->RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
}

And this function is called in

BOOL CMyDlg::OnInitDialog()
{
  ...
  Resize();
}

and in

void CMyDlg::OnSize(UINT nType, int cx, int cy)
{
  CDialog::OnSize(nType, cx, cy);
  Resize();
}

m_bFirst is set TRUE in the constructor of CMyDlg.

So, in fact I think this results in what I first told you.

Did you already had a look with 'gripper' or the like in MSDN?
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

679 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