static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; switch (msg) { case WM_CREATE: ClientResize(hWnd, 1000, 450); OnWindowCreate(hWnd); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); { cairo_surface_t *surface = cairo_win32_surface_create(hdc); cairo_t *cr = cairo_create(surface); cairo_surface_t *shell = cairo_image_surface_create_from_png("../res/smatch-shell.png"); cairo_set_source_surface(cr, shell, 0, 0); cairo_paint(cr); cairo_surface_finish(surface); // Cleanup. cairo_destroy(cr); cairo_surface_destroy(surface); } EndPaint(hWnd, &ps); break; case WM_COMMAND: OnCommand(hWnd, msg, wParam, lParam); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, msg, wParam, lParam); break; } return 0; }
WDL_DLGRET MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: gHWND=hwndDlg; if(!AttachGUI()) printf("couldn't attach gui\n"); #ifdef _WIN32 ClientResize(hwndDlg, GUI_WIDTH, GUI_HEIGHT); //SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON1))); //SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON1))); #else // OSX CenterWindow(hwndDlg); #endif ShowWindow(hwndDlg,SW_SHOW); return 1; case WM_DESTROY: gHWND=NULL; #ifdef _WIN32 PostQuitMessage(0); #else SWELL_PostQuitMessage(hwndDlg); #endif return 0; case WM_CLOSE: DestroyWindow(hwndDlg); return 0; // case WM_GETDLGCODE: { // LPARAM lres; // lres = CallWindowProc(/*TODO GET PROC */, hWnd, WM_GETDLGCODE, wParam, lParam); // if (lParam && ((MSG*)lParam)->message == WM_KEYDOWN && wParam == VK_LEFT) { // lres |= DLGC_WANTMESSAGE; // } // return lres; // } case WM_COMMAND: switch (LOWORD(wParam)) { case ID_QUIT: DestroyWindow(hwndDlg); return 0; case ID_ABOUT: if(!gPluginInstance->HostRequestingAboutBox()) { char version[50]; sprintf(version, BUNDLE_MFR"\nBuilt on " __DATE__); MessageBox(hwndDlg,version, BUNDLE_NAME, MB_OK); } return 0; case ID_PREFERENCES: { INT_PTR ret = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_PREF), hwndDlg, PreferencesDlgProc); if(ret == IDOK) { UpdateINI(); } return 0; } } return 0; } return 0; }