Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MDI Child & controls

Status
Not open for further replies.

Tereus

Programmer
Sep 10, 2003
14
0
0
GR
I would appreciate if somebody give me a reference or pair lines of code of how to put (and use events) controls on MDIChild form. I had a look at many books, msdn etc and saw
the samples where mdi childs had been used only as a text editor or had been place to draw.

Let's say I want to put a button (or better MS Hierarchical Flexgrid control :) ) to a mdi form with cpecific size, coordinates, caption and events.

regards
Vladimir
 

Put CButton cButton; in the header file of the view you want the button in, not the MDI frame as you mentioned.

Put the following code in the OnInitialUpdate()of the view you want the button in:

CRect cRect(5, 5, 100, 50);
cButton.Create("My Button", BS_DEFPUSHBUTTON,cRect,this, MY_BUTTON_ID);
cButton.ShowWindow(TRUE);

Put #define MY_BUTTON_ID 123456 in resource.h

Add afx_msg void OnMyButton(); to the message map functions in header file of the view the button will be in.

Add ON_COMMAND(MY_BUTTON_ID, OnMyButton) to the .cpp file.

To catch the message add the following:

void CYourView::OnMyButton()
{
AfxMessageBox("My button");
}

Check out help for button styles, CRect, etc.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top