I have started to learn some MFC and am trying to get to grips with the document/view architecture. In Jeff Prosiseís book, he gives examples of creating different types of views such as CEditViews etc. What I would like to do however is create a GUI like that of an MSN messenger chat window. So I want a couple of edit boxes and a push button. I canít find any examples of how to create a view that combines a number of different types of controls. I have tried creating a standard document and view application (using the AppWizard), adding an edit box and a push button to the view object and then setting them up in the viewís OnCreate () function as follows:
Thatís the relevant part of the view class. The OnCreate() function then looks like:
class CEncryptedMessengerView : public CView
protected: // create from serialization only
afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct);
This doesnít work. It compiles and runs ok but there is no sign of the controls.
int CEncryptedMessengerView::OnCreate (LPCREATESTRUCT lpCreateStruct)
if (CView::OnCreate (lpCreateStruct))
CRect edit_rect, rect;
edit_rect.top = (edit_rect.Height () / 4) * 3;
edit_rect.right = (edit_rect.Width () / 4) * 3;
InputBox.Create(ES_AUTOHSCROLL, edit_rect, this, ID_ENTRY_WINDOW);
rect.top = (rect.Height () / 4) * 3;
rect.left = (rect.Width () / 4) * 3;
rect.DeflateRect (rect.Width () / 4, rect.Height () / 6);
SendButton.Create ("Send", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rect, this, IDC_BUTTON);
Now this method might be entirely wrong and I may not understand the system correctly but I canít find any examples or explanations of how to accomplish what I want.
Can anyone help me out with an explanation about this and maybe some example code please?