How to set control position in outlook property page?

  • Thread starter ryotyankou via OfficeKB.com
  • Start date
R

ryotyankou via OfficeKB.com

My environment is VC++2005/ATL/OLK2003&2007. I added Outlook::
ApplicationEvents successfully and all are ok. But the size of propertypage
for outlook2003 and 2007 is different, so i want to adjust the controls'
position to the middle of the propertypage. But it is no use to call
SetWindowPos or MoveWindow in OnInitDialog function, what should i do? I have
a lot of controls on the propertypage.
LRESULT CPropPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled)
{
// TODO : Add Code for message handler. Call DefWindowProc if necessary.
GetDlgItem(IDC_STATIC_PROPAGE).SetFont(HFONT(boldFont_));
SetTimer(FreshGUI, 1000, NULL);

//set the window position, can't take effort, why??
m_Control = GetParent();
CRect ParentRc, CurRc;
int xCord = 0, yCord = 0;
m_Control.GetClientRect(ParentRc);
GetWindowRect(CurRc);
xCord = (ParentRc.Width()-CurRc.Width())/2;
yCord = (ParentRc.Height()-CurRc.Height())/2;
SetWindowPos(HWND_TOP, xCord, yCord, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);

return 0;
}
 
K

Ken Slovak - [MVP - Outlook]

About the best way I've found is just to get the normal sizes for both
versions and set up your code based on that.
 
R

ryotyankou via OfficeKB.com

Hi, Ken, thank you for your reply. The size, Do you mean the fixed pixels
which defined by outlook itself? 2007 is 473*440(include propertypage header)
and 2003 is 421*398. No matter what the resolution ratio is, it is not change.

The follow code can get this size(rectangle):
m_Control = GetParent();
CRect ParentRc, CurRc;
int xCord = 0, yCord = 0;
m_Control.GetClientRect(ParentRc);
GetWindowRect(CurRc);
How do i change the position? Could you please explain that more detailed?
Thanks very much.
 
K

Ken Slovak - [MVP - Outlook]

Once you have the sizes of the windows you can do one of two things. You can
just design your property page so it looks OK no matter which version of
Outlook is running. Or you can set up ratios of where each control is
related to the overall window size you have to work with. Then you would
move your controls based on the Outlook version. I usually just use a size
of 421 x 398 and place my controls based on that and leave white space if a
larger canvas is available.
 
R

ryotyankou via OfficeKB.com

I am not exactly understand your meaning, would you please show me some code
Snippets, or just Pseudocode? Thank you.
Once you have the sizes of the windows you can do one of two things. You can
just design your property page so it looks OK no matter which version of
Outlook is running. Or you can set up ratios of where each control is
related to the overall window size you have to work with. Then you would
move your controls based on the Outlook version. I usually just use a size
of 421 x 398 and place my controls based on that and leave white space if a
larger canvas is available.
Hi, Ken, thank you for your reply. The size, Do you mean the fixed pixels
which defined by outlook itself? 2007 is 473*440(include propertypage
[quoted text clipped - 13 lines]
 
K

Ken Slovak - [MVP - Outlook]

Say Control1 is at the top left of the window at a position 5% below the top
of the window and 5% from the left. If the dimensions are 421x398 then you
take 5% of those dimensions in each dimension and move your control there.
Repeat for all other controls. Same thing for any other size window.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top