OSDN Git Service

Add Show Whole Project Checkbox at commitdlg.
[tortoisegit/TortoiseGitJp.git] / src / crashrpt / BaseDialog.cpp
1 #include "stdafx.h"\r
2 #include "BaseDialog.h"\r
3 \r
4 \r
5 INT_PTR CDialog::DoModal(HINSTANCE hInstance, int resID, HWND hWndParent)\r
6 {\r
7         hResource = hInstance;\r
8         return DialogBoxParam(hInstance, MAKEINTRESOURCE(resID), hWndParent, &CDialog::stDlgFunc, (LPARAM)this);\r
9 }\r
10 \r
11 void CDialog::InitDialog(HWND hwndDlg, UINT iconID)\r
12 {\r
13         HWND hwndOwner; \r
14         RECT rc, rcDlg, rcOwner;\r
15 \r
16         hwndOwner = ::GetParent(hwndDlg);\r
17         if (hwndOwner == NULL)\r
18                 hwndOwner = ::GetDesktopWindow();\r
19 \r
20         GetWindowRect(hwndOwner, &rcOwner); \r
21         GetWindowRect(hwndDlg, &rcDlg); \r
22         CopyRect(&rc, &rcOwner); \r
23 \r
24         OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); \r
25         OffsetRect(&rc, -rc.left, -rc.top); \r
26         OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); \r
27 \r
28         SetWindowPos(hwndDlg, HWND_TOP, rcOwner.left + (rc.right / 2), rcOwner.top + (rc.bottom / 2), 0, 0,     SWP_NOSIZE); \r
29         HICON hIcon = (HICON)::LoadImage(hResource, MAKEINTRESOURCE(iconID), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE|LR_SHARED);\r
30         ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);\r
31         ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);\r
32 }\r
33 \r
34 INT_PTR CALLBACK CDialog::stDlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
35 {\r
36         CDialog* pWnd;\r
37         if (uMsg == WM_INITDIALOG)\r
38         {\r
39                 // get the pointer to the window from lpCreateParams\r
40                 SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);\r
41                 pWnd = (CDialog*)lParam;\r
42                 pWnd->m_hwnd = hwndDlg;\r
43         }\r
44         // get the pointer to the window\r
45         pWnd = GetObjectFromWindow(hwndDlg);\r
46 \r
47         // if we have the pointer, go to the message handler of the window\r
48         // else, use DefWindowProc\r
49         if (pWnd)\r
50         {\r
51                 LRESULT lRes = pWnd->DlgFunc(hwndDlg, uMsg, wParam, lParam);\r
52                 SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, lRes);\r
53                 return lRes;\r
54         }\r
55         else\r
56                 return DefWindowProc(hwndDlg, uMsg, wParam, lParam);\r
57 }\r