CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006
    Location
    Ukraine
    Posts
    19

    Very simple GUI app with ATL

    My window application disappears just only this window appears. By another words it doesn't run the PreTranslate message cycle. It's my program's code:

    Code:
     #include <atlbase.h>
    #include <atlwin.h>
    #include <windows.h>
    #include <tchar.h>
    
    class CMainWindow : public CWindowImpl < CMainWindow, CWindow, CFrameWinTraits >
    {
    public:
    	CMainWindow()
    	{
    		Create(NULL, CWindow::rcDefault, _T("My ATL Window"));
    		ShowWindow(SW_SHOWNORMAL);
    	}
    	virtual ~CMainWindow()
    	{
    		if (m_hWnd) DestroyWindow();
    	}
    	BEGIN_MSG_MAP(CMainWindow)
    		MESSAGE_HANDLER(WM_PAINT, OnPaint)
    	END_MSG_MAP()
    public:
    	LRESULT CMainWindow::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    	{return 0;}
    }theApp;
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    {
    	return 0;
    }
    Please, help me. What do I do wrong?
    Last edited by Siddhartha; May 22nd, 2006 at 12:09 PM. Reason: Added Code-Tags...

  2. #2
    Join Date
    Sep 1999
    Posts
    137

    Re: Very simple GUI app with ATL

    You are trying to use CMainWindow like a WinMain() function. The window cannot do it all.

    Try using the ATL COM AppWizard to create a server, and then adding an ATL dialog to it with the ATL Object wizard. You can modify the project for your frame window after you get that far.

    It doesn't take all that many steps to do this. But there is a lot to understand. A book might help.

    I got Beginning ATL3 COM Programming by Richard Grimes. I like it, but I suppose that more up to date books are out by now, since ATL is up to version 7.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured