How do I add controls (CButton) to a CPropertySheet?
Posted on 1997-01-15
I have a CProperySheet derived object to which I need to add four buttons. I do not know how to do this, but I am trying to do the following in OnCreate:
int COptionSheet::OnCreate(LPCREATESTRUCT lpCreateStruct)
#define BUTTON_WIDTH 50
#define BUTTON_HEIGHT 22
#define BUTTON_SPACE 10
if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
// TODO: Add your specialized creation code here
// Get window size
GetWindowRect( lpRect );
// expand it by 150 to the right so I can add some boxes
// for statistics later
lpRect->right += 150;
// Resize the window
MoveWindow( lpRect );
// pAddButton is of type CButton * and is a public data member of COptionSheet
pAddButton = new CButton();
LPCTSTR lpszAddCaption = "Add";
// define a button size
pAddRect.left = 20;
pAddRect.right = pAddRect.left + BUTTON_WIDTH;
pAddRect.top = 360;
pAddRect.bottom = pAddRect.top + BUTTON_HEIGHT;
// create button
BOOL bReturn = pAddButton->Create(lpszAddCaption, WS_VISIBLE|BS_PUSHBUTTON, pAddRect, this, IDC_ADD_RADOBJECT);
First I get an 0xC0000005 Access viloation when I call GetWindowRect( lpRect ); at the top of this function.
Second, how do I set the font of the text on my buttons to be the same as the default Ok/Cancel/Apply buttons on the CPropertySheet and what is the default text.
Is the method for adding other controls (static text, list box etc) the same as for adding a button?