CWnd::Create -> program terminates immediately after window creation


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: CWnd::Create -> program terminates immediately after window creation

  1. #1
    Join Date
    May 2004
    Posts
    70

    CWnd::Create -> program terminates immediately after window creation

    hi, i am new in MFC so i would need detail explaination and preferbly some codes

    here is the application initialization


    Code:
    /////////////////////////////////////////////////////////////////////////////
    CAsevApp theApp;
    // CAsevApp initialization
    
    BOOL CAsevApp::InitInstance()
    {
    	// Standard initialization
    	// If you are not using these features and wish to reduce the size
    	//  of your final executable, you should remove from the following
    	//  the specific initialization routines you do not need.
    	RECT rec;
    	rec.bottom=100;
    	rec.left = 100;
    	rec.right = 100;
    	rec.top = 100;
    
    	main_window *m_pMainWnd = new main_window;
    	m_pMainWnd->Create(
    		"myWindowClass",
    		"title",
    		WS_OVERLAPPEDWINDOW,
    		rec,  CWnd::GetDesktopWindow(),0,0);
    return TRUE;
    main_window is a derived class from CWnd, no extra stuff has been added

    here i am trying to create a simple window with the "create" command
    or more specifically, CWnd::Create command
    what happens is that the program terminates immediately

    i was expecting an empty movable/resizable window with the titlebar "title" to appear and stay there

    is there something i did wrong?

    please assist

  2. #2
    Join Date
    Dec 2003
    Posts
    3,366
    try a domodal or other creation method, or somehow trap the on-close of the window before you return (which ends the program!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center