Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

OnSize questions

Posted on 2002-07-18
5
Medium Priority
?
569 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 600 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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