Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sample ATL Dialog Window

Can anyone help me find an up-to-date, working ATL project which has a main window and some components in it? Please, for the love of god, don't tell me to use WTL/Qt or others. I need ATL. There's no up-to-date project about it. I just need a main window, that's all. I can figure out the rest.

Thanks in advance.

like image 458
John Doe Avatar asked Oct 16 '25 16:10

John Doe


1 Answers

OK, for the love of god: Visual Studio 2010 C++/ATL EXE project from template + dialog window.

Source:

  • Trac: AtlDialogSample
  • SVN: AtlDialogSample

This is of your primary interest:

////////////////////////////////////////////////////////////
// CMainDialog

class CMainDialog :
    public CDialogImpl<CMainDialog>
{
public:
    enum { IDD = IDD_MAIN };

BEGIN_MSG_MAP(CMainDialog)
    MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
    COMMAND_ID_HANDLER(IDCANCEL, OnCommand)
    COMMAND_ID_HANDLER(IDOK, OnCommand)
END_MSG_MAP()

public:
// CMainDialog

// Window Message Handlers
    LRESULT OnInitDialog(UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        ATLVERIFY(CenterWindow());
        return 0;
    }
    LRESULT OnCommand(UINT, INT nIdentifier, HWND, BOOL& bHandled)
    {
        ATLVERIFY(EndDialog(nIdentifier));
        return 0;
    }
};

and

VOID RunMessageLoop()
{
    CMainDialog Dialog;
    Dialog.DoModal();
}

enter image description here

like image 200
Roman R. Avatar answered Oct 18 '25 09:10

Roman R.