Merge branch 'bare-repo'
[TortoiseGit.git] / src / Utils / MiscUI / BaseDialog.h
blobb69e859b2ec76ecf591df71b3a6e2cab77bcd8e6
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - Stefan Kueng
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
20 #include <string>
23 /**
24 * \ingroup Utils
25 * A base window class.
26 * Provides separate window message handlers for every window object based on
27 * this class.
29 class CDialog
31 public:
32 INT_PTR DoModal(HINSTANCE hInstance, int resID, HWND hWndParent);
33 HWND Create(HINSTANCE hInstance, int resID, HWND hWndParent);
35 virtual LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) = 0;
37 operator HWND() {return m_hwnd;}
38 protected:
39 HINSTANCE hResource;
40 HWND m_hwnd;
42 void InitDialog(HWND hwndDlg, UINT iconID);
44 // the real message handler
45 static INT_PTR CALLBACK stDlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
47 // returns a pointer the dialog (stored as the WindowLong)
48 inline static CDialog * GetObjectFromWindow(HWND hWnd)
50 return (CDialog *)GetWindowLongPtr(hWnd, GWLP_USERDATA);