int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd) { MSG msg; HACCEL hAccel; TCHAR arg[MAX_PATH]; TCHAR * pszCmdline; EnableCrashingOnCrashes(); //INITCOMMONCONTROLSEX icx = { sizeof(icx), ICC_ g_hInstance = hInst; // This program requires COM OleInitialize(0); // // Commandline processing // pszCmdline = GetArg(GetCommandLineW(), arg, MAX_PATH); if(pszCmdline && *pszCmdline == '-') { pszCmdline = GetArg(pszCmdline, arg, MAX_PATH); // 'touch' the specified file! if(lstrcmpi(arg, TEXT("-touch")) == 0) { // check to see if it's a quoted filename if(*pszCmdline == '\"') { GetArg(pszCmdline, arg, MAX_PATH); pszCmdline = arg; } if(!TouchFile(pszCmdline)) { HexWinErrorBox(GetLastError(), 0); return 1; } return 0; } else { pszCmdline = GetArg(pszCmdline, arg, MAX_PATH); } } { INITCOMMONCONTROLSEX icex = { sizeof(icex), -1 }; InitCommonControlsEx(&icex); } /*g_Config = OpenConfig(TEXT("mapsize.exe.129082349834.bookmarks")); smeg(g_Config, TEXT("bookmarks.bookmark."), TEXT("mapsize.exe")); SaveConfig(TEXT("oof.config"), g_Config);*/ LoadSettings(); RegisterTabView(); InitMainWnd(); CreateMainWnd(); // open file specified on commmand line? if(pszCmdline && *pszCmdline) { // check to see if it's a quoted filename if(*pszCmdline == '\"') { GetArg(pszCmdline, arg, MAX_PATH); pszCmdline = arg; } if(!HexeditOpenFile(g_hwndMain, pszCmdline, DefaultFileMode()))//HVOF_DEFAULT)) { SendMessage(g_hwndMain, WM_COMMAND, IDM_FILE_NEW, 0); } } // automatically create new document if none specified else { SendMessage(g_hwndMain, WM_COMMAND, IDM_FILE_NEW, 0); } InitDockingBars(g_hwndMain); if(g_fRestoreWinPos) nShowCmd = SW_SHOW; ShowWindow(g_hwndMain, nShowCmd); // force any floating popups (i.e. the DOCKWNDs) to // become visible at the same time //ShowOwnedPopups(g_hwndMain, TRUE); DockWnd_ShowDeferredPopups(g_hwndMain); // // load keyboard accelerator table // hAccel = LoadAccelerators(GetModuleHandle(0)/*g_hResourceModule*/, MAKEINTRESOURCE(IDR_ACCELERATOR1)); // // message-pump // while(GetMessage(&msg, 0, 0, 0) > 0) { if(!TranslateAccelerator(g_hwndMain, hAccel, &msg)) { if( !IsDialogMessage(g_hwndSearch, &msg) && !IsDialogMessage(g_hwndGoto, &msg) && !DockWnd_IsDialogMessage(g_hwndMain, DWID_TYPEVIEW, &msg) && !DockWnd_IsDialogMessage(g_hwndMain, DWID_SEARCHBAR, &msg) && !DockWnd_IsDialogMessage(g_hwndMain, DWID_HIGHLIGHT, &msg) ) { TranslateMessage(&msg); DispatchMessage(&msg); } } } SaveSettings(); // Shutdown COM OleUninitialize(); return 0; }
LRESULT CALLBACK DockPanelProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { DOCKPANEL *dpp = (DOCKPANEL *)GetWindowLongPtr(hwnd, 0); switch(msg) { case WM_NCCREATE: dpp = (DOCKPANEL*)((CREATESTRUCT *)lParam)->lpCreateParams; dpp->hwndPanel = hwnd; SetWindowLongPtr(hwnd, 0, (LONG_PTR)dpp); SetWindowText(hwnd, ((CREATESTRUCT *)lParam)->lpszName); return TRUE; case WM_NCACTIVATE: return HANDLE_NCACTIVATE(dpp->hwndMain, hwnd, wParam, lParam, NULL); case WM_CREATE: dpp->fVisible = TRUE; // if the tabview hasn't already been created... if((dpp->dwStyle & DWS_TABSTRIP) && dpp->hwndTabView == 0) { RegisterTabView(); dpp->hwndTabView = CreateWindowEx(0, WC_TABVIEW, 0, WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, 0); } return 0; //case WM_ENABLE: // return HANDLE_ENABLE(dpp->hwndMain, hwnd, wParam, lParam); case WM_CLOSE: DestroyWindow(hwnd); dpp->fVisible = FALSE; return 0; case WM_ERASEBKGND: DrawDockPanelBackground(dpp, (HDC)wParam); return 1; case WM_COMMAND: return SendMessage(dpp->hwndMain, msg, wParam, lParam); case WM_NOTIFY: return DockPanel_OnNotify(dpp, wParam, (NMHDR *)lParam); case WM_SETFOCUS: SetFocus(dpp->hwndContents); return 0; case WM_SETCURSOR: return DockPanel_SetCursor(dpp, wParam, lParam); case WM_LBUTTONDOWN: return DockPanel_OnLButtonDown(dpp, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); case WM_MOUSEMOVE: return DockPanel_OnMouseMove(dpp, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); case WM_LBUTTONUP: return DockPanel_OnLButtonUp(dpp, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); case WM_MOVING: return DockPanel_OnMoving(dpp); case WM_EXITSIZEMOVE: return DockPanel_ExitSizeMove(dpp); case WM_NCLBUTTONDOWN: DockPanel_OnNcLButtonDown(dpp, wParam); break; case WM_SIZE: return DockPanel_OnSize(dpp); case WM_GETMINMAXINFO: DockPanel_GetMinMaxInfo(dpp, (MINMAXINFO *)lParam); break; case WM_DESTROY: return DockPanel_OnDestroy(dpp, hwnd); case WM_TIMER: return DockPanel_Timer(dpp, wParam); } return DefWindowProc(hwnd, msg, wParam, lParam); }