EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

#Previous question #Index of VC++/WIN32/MFC Questions #Next question

CREATESTRUCT

Attributes of main frame of a doc view/dialog based application can be described in CREATESTRUCT structure. Each memeber of this structure holds the corresponding attributes of a frame window.

typedef struct tagCREATESTRUCT {
    LPVOID      lpCreateParams; /* Create param */
    HINSTANCE   hInstance;      /* Application instance */
    HMENU       hMenu;          /* Handle to menu */
    HWND        hwndParent;     /* Parent Window */
    int         cy;             /* Height */
    int         cx;             /* Width */
    int         y;              /* Y position */
    int         x;              /* X position */
10      LONG        style;          /* Window styles */
11      LPCSTR      lpszName;       /* Window name */
12      LPCSTR      lpszClass;      /* Class name (fixed) */
13      DWORD       dwExStyle;      /* Extended style */
14  } CREATESTRUCT, *LPCREATESTRUCT;

PreCreateWindow event

DOC view framework creates CFrameWnd object after that calls PreCreateWindow() event. Verious frame attibutes can be changed in this event. Here is an example of altering style,position and height width of the window.

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    /* Call the base-class version */
   if( !CFrameWnd::PreCreateWindow(cs) )
      return FALSE;
    /* Create a window without min/max buttons or sizable border */
    cs.style = WS_OVERLAPPED | WS_SYSMENU | WS_BORDER;
10 
11      /* Size the window to 1/3 screen size and center it */
12      cs.cy = ::GetSystemMetrics(SM_CYSCREEN) / 3; 
13      cs.cx = ::GetSystemMetrics(SM_CXSCREEN) / 3; 
14      cs.= ((cs.cy * 3) - cs.cy) / 2; 
15      cs.= ((cs.cx * 3) - cs.cx) / 2;
16 
17     return TRUE;
18  }

Here is the call stack of PreCreateWindow() from MFC framework.

CMainFrame::PreCreateWindow()
CFrameWnd::GetIconWndClass()
CFrameWnd::LoadFrame()
CDocTemplate::CreateNewFrame()
CSingleDocTemplate::OpenDocumentFile()
CDocManager::OnFileNew()
CWinApp::OnFileNew()
_AfxDispatchCmdMsg()

OnCreate() event

OnCreate() event is an window event triggered by WM_CREATE message. Base function CFrameWnd::OnCreate() is called with same CREATESTRUCT pointer which is already altered in PreCreateWindow(). This is the actual creation of the frame window.

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
  if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
    return -1;
  return 0;
}

Here is the call stack of OnCreate() from MFC framework.

CMainFrame::OnCreate()
CWnd::OnWndMsg()
CWnd::WindowProc()
AfxCallWndProc()
AfxWndProc()
AfxWndProcBase()

You have viewed 1 page out of 109. Your VC++ learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

#Programming Windows, Fifth Edition (Developer Reference)
#Programming Applications for Microsoft Windows (Microsoft Programming Series)
#Programming Windows with MFC, Second Edition
#Visual C++ Programming
#Programming Microsoft Visual C++, Fifth Edition

* #1 webmaster Sun 27 Apr/2014 03:16:42(GMT)  Like 0 Unlike 0

Dear Users,

We are pleased to inform you that a forum/blog has been incorporated with www.mybestnotes.co.in. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.

Regards,
Webmaster

Your message goes here:

Name:Guest
Email:anonymous@unknown.com
My Post:*
Secutiry Code: ******  *
Preview this compose before posting this in discussion forum.
 
Note:
  1. Use [Sxx] code to show smiles. Example [S02]
  2. Use [URL ], example [URL http://www.google.com/]
  3. To display code or un formatted text use [CODE] [/CODE]. Example: [CODE] printf("Hello world"); [/CODE]
 [S01]   [S02]   [S03]   [S04]   [S05]   [S06]   [S07]   [S08] 
 [S09]   [S10]   [S11]   [S12]   [S13]   [S14]   [S15]   [S16] 
 [S17]   [S18]   [S19]   [S20]   [S21]   [S22]   [S23]   [S24] 

Note: Only members are allowed, * fields are mandatory.