Commit 7369b6cf authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

regedit: Refactor window class initialization to a separate function.

parent 1054b955
...@@ -63,7 +63,37 @@ TCHAR szTitle[MAX_LOADSTRING]; ...@@ -63,7 +63,37 @@ TCHAR szTitle[MAX_LOADSTRING];
const TCHAR szFrameClass[] = {'R','E','G','E','D','I','T','_','F','R','A','M','E',0}; const TCHAR szFrameClass[] = {'R','E','G','E','D','I','T','_','F','R','A','M','E',0};
const TCHAR szChildClass[] = {'R','E','G','E','D','I','T',0}; const TCHAR szChildClass[] = {'R','E','G','E','D','I','T',0};
static BOOL RegisterWindowClasses(HINSTANCE hInstance, ATOM *hFrameWndClass, ATOM *hChildWndClass)
{
WNDCLASSEX wndclass = {0};
/* Frame class */
wndclass.cbSize = sizeof(WNDCLASSEX);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = FrameWndProc;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT));
wndclass.hCursor = LoadCursor(0, IDC_ARROW);
wndclass.lpszClassName = szFrameClass;
wndclass.hIconSm = LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), LR_SHARED);
if (!(*hFrameWndClass = RegisterClassEx(&wndclass)))
return FALSE;
/* Child class */
wndclass.lpfnWndProc = ChildWndProc;
wndclass.cbWndExtra = sizeof(HANDLE);
wndclass.lpszClassName = szChildClass;
if (!(*hChildWndClass = RegisterClassEx(&wndclass)))
{
UnregisterClass(szFrameClass, hInstance);
return FALSE;
}
return TRUE;
}
/******************************************************************************* /*******************************************************************************
* *
* *
...@@ -80,41 +110,10 @@ const TCHAR szChildClass[] = {'R','E','G','E','D','I','T',0}; ...@@ -80,41 +110,10 @@ const TCHAR szChildClass[] = {'R','E','G','E','D','I','T',0};
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{ {
WCHAR empty = 0; WCHAR empty = 0;
WNDCLASSEX wcFrame = { ATOM hFrameWndClass, hChildWndClass;
sizeof(WNDCLASSEX),
CS_HREDRAW | CS_VREDRAW/*style*/,
FrameWndProc,
0/*cbClsExtra*/,
0/*cbWndExtra*/,
hInstance,
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
LoadCursor(0, IDC_ARROW),
0/*hbrBackground*/,
0/*lpszMenuName*/,
szFrameClass,
LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
};
ATOM hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */
WNDCLASSEX wcChild = {
sizeof(WNDCLASSEX),
CS_HREDRAW | CS_VREDRAW/*style*/,
ChildWndProc,
0/*cbClsExtra*/,
sizeof(HANDLE)/*cbWndExtra*/,
hInstance,
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
LoadCursor(0, IDC_ARROW),
0/*hbrBackground*/,
0/*lpszMenuName*/,
szChildClass,
LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
}; if (!RegisterWindowClasses(hInstance, &hFrameWndClass, &hChildWndClass))
ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */ return FALSE;
hChildWndClass = hChildWndClass; /* warning eater */
hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU)); hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU));
hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS)); hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment