Solved

OnSize questions

Posted on 2002-07-18
5
561 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 176
only14 challenge 19 75
Unix Command -- Challenging  question 7 88
mapBully challenge 6 127
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 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