BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { BOOL AclUiAvailable; HMENU hEditMenu; TCHAR szBuffer[256]; WNDCLASSEX wcFrame; WNDCLASSEX wcChild; ATOM hFrameWndClass; ZeroMemory(&wcFrame, sizeof(WNDCLASSEX)); wcFrame.cbSize = sizeof(WNDCLASSEX); wcFrame.lpfnWndProc = FrameWndProc; wcFrame.hInstance = hInstance; wcFrame.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)); wcFrame.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); wcFrame.hCursor = LoadCursor(0, IDC_ARROW); wcFrame.lpszClassName = szFrameClass; hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */ ZeroMemory(&wcChild, sizeof(WNDCLASSEX)); wcChild.cbSize = sizeof(WNDCLASSEX); wcChild.lpfnWndProc = ChildWndProc; wcChild.cbWndExtra = sizeof(HANDLE); wcChild.hInstance = hInstance; wcChild.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)); wcChild.hCursor = LoadCursor(0, IDC_ARROW), wcChild.lpszClassName = szChildClass, wcChild.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); RegisterClassEx(&wcChild); /* register child windows class */ RegisterHexEditorClass(hInstance); hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU)); hPopupMenus = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP_MENUS)); /* Initialize the Windows Common Controls DLL */ InitCommonControls(); hEditMenu = GetSubMenu(hMenuFrame, 1); AclUiAvailable = InitializeAclUiDll(); if(!AclUiAvailable) { /* hide the Edit/Permissions... menu entry */ if(hEditMenu != NULL) { RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND); /* remove the separator after the menu item */ RemoveMenu(hEditMenu, 4, MF_BYPOSITION); } } if(hEditMenu != NULL) SetMenuDefaultItem(hEditMenu, ID_EDIT_MODIFY, MF_BYCOMMAND); nClipboardFormat = RegisterClipboardFormat(strClipboardFormat); /* if (nClipboardFormat == 0) { DWORD dwError = GetLastError(); } */ hFrameWnd = CreateWindowEx(WS_EX_WINDOWEDGE, (LPCTSTR)(UlongToPtr(hFrameWndClass)), szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenuFrame, hInstance, NULL/*lpParam*/); if (!hFrameWnd) { return FALSE; } /* Create the status bar */ hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|SBT_NOBORDERS, _T(""), hFrameWnd, STATUS_WINDOW); if (hStatusBar) { /* Create the status bar panes */ SetupStatusBar(hFrameWnd, FALSE); CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); } /* Restore position */ if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("LastKey"), szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS) { SelectNode(g_pChildWnd->hTreeWnd, szBuffer); } ShowWindow(hFrameWnd, nCmdShow); UpdateWindow(hFrameWnd); return TRUE; }
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { BOOL AclUiAvailable; HMENU hEditMenu; WNDCLASSEXW wcFrame; WNDCLASSEXW wcChild; ATOM hFrameWndClass; ZeroMemory(&wcFrame, sizeof(WNDCLASSEXW)); wcFrame.cbSize = sizeof(WNDCLASSEXW); wcFrame.lpfnWndProc = FrameWndProc; wcFrame.hInstance = hInstance; wcFrame.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT)); wcFrame.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); wcFrame.hCursor = LoadCursorW(NULL, IDC_ARROW); wcFrame.lpszClassName = szFrameClass; hFrameWndClass = RegisterClassExW(&wcFrame); /* register frame window class */ ZeroMemory(&wcChild, sizeof(WNDCLASSEXW)); wcChild.cbSize = sizeof(WNDCLASSEXW); wcChild.lpfnWndProc = ChildWndProc; wcChild.cbWndExtra = sizeof(HANDLE); wcChild.hInstance = hInstance; wcChild.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT)); wcChild.hCursor = LoadCursorW(NULL, IDC_ARROW); wcChild.lpszClassName = szChildClass; wcChild.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); RegisterClassExW(&wcChild); /* register child windows class */ RegisterHexEditorClass(hInstance); hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU)); hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS)); /* Initialize the Windows Common Controls DLL */ // TODO: Replace this call by InitCommonControlsEx(_something_) InitCommonControls(); hEditMenu = GetSubMenu(hMenuFrame, 1); AclUiAvailable = InitializeAclUiDll(); if(!AclUiAvailable) { /* hide the Edit/Permissions... menu entry */ if(hEditMenu != NULL) { RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND); /* remove the separator after the menu item */ RemoveMenu(hEditMenu, 4, MF_BYPOSITION); } } if(hEditMenu != NULL) SetMenuDefaultItem(hEditMenu, ID_EDIT_MODIFY, MF_BYCOMMAND); nClipboardFormat = RegisterClipboardFormatW(strClipboardFormat); /* if (nClipboardFormat == 0) { DWORD dwError = GetLastError(); } */ hFrameWnd = CreateWindowExW(WS_EX_WINDOWEDGE, (LPCWSTR)(UlongToPtr(hFrameWndClass)), szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenuFrame, hInstance, NULL/*lpParam*/); if (!hFrameWnd) { return FALSE; } /* Create the status bar */ hStatusBar = CreateStatusWindowW(WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | SBT_NOBORDERS, L"", hFrameWnd, STATUS_WINDOW); if (hStatusBar) { /* Create the status bar panes */ SetupStatusBar(hFrameWnd, FALSE); CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND | MF_CHECKED); } LoadSettings(); UpdateWindow(hFrameWnd); return TRUE; }