Moving the Standard Buttons | CodeGuru

Moving the Standard Buttons

Your method for moving _standard_ buttons is fine – if they are all that needs moving (eg. you forgot ID_HELP). But this is not much good if you’ve added your own controls to the property sheet and need to move them too. (for example, I have a couple of different groups of pages that I […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 6, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Your method for moving _standard_ buttons is fine – if they are all that
needs moving (eg. you forgot ID_HELP). But this is not much good if you’ve
added your own controls to the property sheet and need to move them too.
(for example, I have a couple of different groups of pages that I want to
select between, rather than having lots and lots of tabs all at once, so I
have a combo box at the bottom of my property sheet that selects the group
of pages I want).

A better sort of solution is to go thru the child window list and move all
children (except perhaps the tab control)
Here is code that moves all the controls (other than the tab itself) by a
given dx and dy..

     // calculate dx and dy to move the controls
     // this could correspond to an increase in sheet size
     CTabCtrl* pTabCtrl = GetTabControl();
     for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild =
			pChild->GetNextWindow(GW_HWNDNEXT))
     {
          if (pChild == pTabCtrl) continue;
          CRect rectControlWnd;
          pChild->GetWindowRect(rectControlWnd);
          ScreenToClient(rectControlWnd);
          rectControlWnd.top.OffsetRect(dx,dy);
          pChild->MoveWindow(rectControlWnd);
     }

Because I use this code in a CPropertySheet-derived class that I use to
base my own property sheets on, I don’t know in advance exactly what
control are going to be on the sheet (because some of my other property
sheet classes add extra controls). This way ALL my control move to make
room.

Another improvement could be to compare the control position of the control
to the tab control and only move those controls which are, say, below the
tab.

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.