/* ================ GEOptionsDlg_GeneralProc Dialog procedure for the general options tab ================ */ static INT_PTR CALLBACK GEOptionsDlg_GeneralProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: ColorButton_SetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR), RGB(gApp.GetOptions().GetSelectionColor()[0]*255, gApp.GetOptions().GetSelectionColor()[1]*255, gApp.GetOptions().GetSelectionColor()[2]*255)); CheckDlgButton(hwnd, IDC_GUIED_IGNOREDESKTOP, gApp.GetOptions().GetIgnoreDesktopSelect()?BST_CHECKED:BST_UNCHECKED); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_GUIED_SELECTIONCOLOR: { CHOOSECOLOR col; ZeroMemory(&col, sizeof(col)); col.lStructSize = sizeof(col); col.lpCustColors = gApp.GetOptions().GetCustomColors(); col.hwndOwner = hwnd; col.hInstance = NULL; col.Flags = CC_RGBINIT; col.rgbResult = ColorButton_GetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR)); if (ChooseColor(&col)) { ColorButton_SetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR), col.rgbResult); } break; } } break; case WM_DRAWITEM: ColorButton_DrawItem(GetDlgItem(hwnd, wParam), (LPDRAWITEMSTRUCT)lParam); return TRUE; case WM_NOTIFY: switch (((NMHDR FAR *) lParam)->code) { case PSN_APPLY: gApp.GetOptions().SetLastOptionsPage(PropSheet_HwndToIndex(GetParent(hwnd), PropSheet_GetCurrentPageHwnd(GetParent(hwnd)))); gApp.GetOptions().SetSelectionColor(ColorButton_GetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR))); gApp.GetOptions().SetIgnoreDesktopSelect(IsDlgButtonChecked(hwnd, IDC_GUIED_IGNOREDESKTOP) != 0); break; } break; } return FALSE; }
/* ================ GEOptionsDlg_GridProc Dialog procedure for the grid settings tab ================ */ static INT_PTR CALLBACK GEOptionsDlg_GridProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch ( msg ) { case WM_INITDIALOG: // Copy the options information to the dialog controls ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ), RGB(gApp.GetOptions().GetGridColor()[0]*255,gApp.GetOptions().GetGridColor()[1]*255,gApp.GetOptions().GetGridColor()[2]*255) ); SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGWIDTH ), va("%d", gApp.GetOptions().GetGridWidth ( ) ) ); SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGHEIGHT ), va("%d", gApp.GetOptions().GetGridHeight ( ) ) ); CheckDlgButton ( hwnd, IDC_GUIED_GRIDVISIBLE, gApp.GetOptions().GetGridVisible()?BST_CHECKED:BST_UNCHECKED ); CheckDlgButton ( hwnd, IDC_GUIED_GRIDSNAP, gApp.GetOptions().GetGridSnap()?BST_CHECKED:BST_UNCHECKED ); return TRUE; case WM_DRAWITEM: ColorButton_DrawItem ( GetDlgItem ( hwnd, wParam ), (LPDRAWITEMSTRUCT)lParam ); return TRUE; case WM_NOTIFY: switch (((NMHDR FAR *) lParam)->code) { case PSN_APPLY: { char temp[32]; // Copy the dialog control data back to the options GetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGWIDTH ), temp, 32 ); gApp.GetOptions().SetGridWidth(atol(temp)); GetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGHEIGHT ), temp, 32 ); gApp.GetOptions().SetGridHeight(atol(temp)); gApp.GetOptions().SetGridVisible ( IsDlgButtonChecked ( hwnd, IDC_GUIED_GRIDVISIBLE ) != 0 ); gApp.GetOptions().SetGridSnap ( IsDlgButtonChecked ( hwnd, IDC_GUIED_GRIDSNAP ) != 0 ); gApp.GetOptions().SetGridColor ( ColorButton_GetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ) ) ); break; } } break; case WM_COMMAND: switch ( LOWORD ( wParam ) ) { case IDC_GUIED_GRIDCOLOR: { CHOOSECOLOR col; ZeroMemory ( &col, sizeof(col) ); col.lStructSize = sizeof(col); col.lpCustColors = gApp.GetOptions().GetCustomColors ( ); col.hwndOwner = hwnd; col.hInstance = NULL; col.Flags = CC_RGBINIT; col.rgbResult = RGB(gApp.GetOptions().GetGridColor()[0]*255,gApp.GetOptions().GetGridColor()[1]*255,gApp.GetOptions().GetGridColor()[2]*255); if ( ChooseColor ( &col ) ) { ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ), col.rgbResult ); } break; } } return TRUE; } return FALSE; }
/* ================ AlphaSelectDlg_WndProc Window procedure for the alpha select dialog ================ */ INT_PTR CALLBACK AlphaSelectDlg_WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch ( msg ) { case WM_INITDIALOG: { int color; gAlphaDlg = hwnd; gAlphaHook = SetWindowsHookEx( WH_GETMESSAGE, AlphaSelectDlg_GetMsgProc, NULL, GetCurrentThreadId() ); color = GetRValue(ColorButton_GetColor ((HWND)lParam)); // The lParam for the alpha select dialog is the window handle of the button pressed SetWindowLong ( hwnd, GWL_USERDATA, lParam ); // Subclass the alpha SetWindowLong ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA, MAKELONG(0,color) ); // Numbers only on the edit box and start it with the current alpha value. NumberEdit_Attach ( GetDlgItem ( hwnd, IDC_GUIED_ALPHA ) ); SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_ALPHA ), va("%.3f", ((float)color / 255.0f) ) ); break; } case WM_DESTROY: UnhookWindowsHookEx( gAlphaHook ); ReleaseCapture ( ); gAlphaDlg = NULL; break; case WM_ACTIVATE: if ( !LOWORD(wParam) ) { EndDialog ( hwnd, 0 ); } break; case WM_COMMAND: switch ( LOWORD(wParam) ) { case IDC_GUIED_ALPHA: { char temp[64]; float value; // Get the current text in the window and convert it to a float GetDlgItemText ( hwnd, IDC_GUIED_ALPHA, temp, 64 ); value = atof ( temp ); if ( value < 0.0f ) { value = 0.0f; } else if ( value > 1.0f ) { value = 1.0f; } // Set the current alpha value in the slider SetWindowLong ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA, MAKELONG(0,(255.0f * value)) ); break; } case IDC_GUIED_ALPHASLIDER: case IDOK: { int color = (short)HIWORD(GetWindowLong ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA )); ColorButton_SetColor ( (HWND)GetWindowLong ( hwnd, GWL_USERDATA ), RGB(color,color,color) ); EndDialog ( hwnd, 0 ); break; } case IDCANCEL: EndDialog ( hwnd, 0 ); break; } break; } return FALSE; }