/********************************************************************** * BUTTON_DrawLabel * * Common function for drawing button label. */ static void BUTTON_DrawLabel(HWND hwnd, HDC hdc, UINT dtFlags, const RECT *rc) { DRAWSTATEPROC lpOutputProc = NULL; LPARAM lp; WPARAM wp = 0; HBRUSH hbr = 0; UINT flags = IsWindowEnabled(hwnd) ? DSS_NORMAL : DSS_DISABLED; LONG state = get_button_state( hwnd ); LONG style = GetWindowLongPtrW( hwnd, GWL_STYLE ); WCHAR *text = NULL; /* FIXME: To draw disabled label in Win31 look-and-feel, we probably * must use DSS_MONO flag and COLOR_GRAYTEXT brush (or maybe DSS_UNION). * I don't have Win31 on hand to verify that, so I leave it as is. */ if ((style & BS_PUSHLIKE) && (state & BST_INDETERMINATE)) { hbr = GetSysColorBrush(COLOR_GRAYTEXT); flags |= DSS_MONO; } switch (style & (BS_ICON|BS_BITMAP)) { case BS_TEXT: /* DST_COMPLEX -- is 0 */ lpOutputProc = BUTTON_DrawTextCallback; if (!(text = get_button_text( hwnd ))) return; lp = (LPARAM)text; wp = (WPARAM)dtFlags; if (dtFlags & DT_HIDEPREFIX) flags |= DSS_HIDEPREFIX; break; case BS_ICON: flags |= DST_ICON; lp = GetWindowLongPtrW( hwnd, HIMAGE_GWL_OFFSET ); break; case BS_BITMAP: flags |= DST_BITMAP; lp = GetWindowLongPtrW( hwnd, HIMAGE_GWL_OFFSET ); break; default: return; } DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, flags); HeapFree( GetProcessHeap(), 0, text ); }
static HRESULT WINAPI NewMenu_ContextMenu3_HandleMenuMsg2(IContextMenu3 *iface, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *result) { NewMenuImpl *This = impl_from_IContextMenu3(iface); TRACE("(%p)->(%u, %lx, %lx, %p)\n", This, uMsg, wParam, lParam, result); switch (uMsg) { case WM_MEASUREITEM: { MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)lParam; if (!mis || mis->CtlType != ODT_MENU) break; if (This->folder_cmd == mis->itemID) { mis->itemWidth = GetSystemMetrics(SM_CXSMICON); mis->itemHeight = GetSystemMetrics(SM_CYSMICON); } if (result) *result = TRUE; break; } case WM_DRAWITEM: { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam; HICON icon = 0; UINT x, y; if (!dis || dis->CtlType != ODT_MENU) break; if (This->folder_cmd == dis->itemID) icon = This->icon_folder; if (!icon) break; x = (dis->rcItem.right - dis->rcItem.left - GetSystemMetrics(SM_CXSMICON)) / 2; y = (dis->rcItem.bottom - dis->rcItem.top - GetSystemMetrics(SM_CYSMICON)) / 2; DrawStateW(dis->hDC, NULL, NULL, (LPARAM)icon, 0, x, y, 0, 0, DST_ICON | DSS_NORMAL); if (result) *result = TRUE; break; } } return S_OK; }
static INT_PTR CALLBACK LockedWindowProc( IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam) { PGINA_CONTEXT pgContext; pgContext = (PGINA_CONTEXT)GetWindowLongPtr(hwndDlg, GWL_USERDATA); switch (uMsg) { case WM_INITDIALOG: { pgContext = (PGINA_CONTEXT)lParam; SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext); pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); SetLockMessage(hwndDlg, IDC_LOCKMSG, pgContext); return TRUE; } case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; if (pgContext->hBitmap) { hdc = BeginPaint(hwndDlg, &ps); DrawStateW(hdc, NULL, NULL, (LPARAM)pgContext->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP); EndPaint(hwndDlg, &ps); } return TRUE; } case WM_DESTROY: { DeleteObject(pgContext->hBitmap); return TRUE; } } return FALSE; }
WXDLLEXPORT int wxMSLU_DrawStateW(WXHDC dc, WXHBRUSH br, WXFARPROC outputFunc, WXLPARAM lData, WXWPARAM wData, int x, int y, int cx, int cy, unsigned int flags) { // VS: There's yet another bug in MSLU: DrawStateW behaves like if it was // expecting char*, not wchar_t* input. We have to use DrawStateA // explicitly. if ( wxUsingUnicowsDll() ) { return DrawStateA((HDC)dc, (HBRUSH)br, (DRAWSTATEPROC)outputFunc, (LPARAM)(const char*) wxConvLocal.cWX2MB((const wxChar*)lData), wData, x, y, cx, cy, flags); } else { return DrawStateW((HDC)dc, (HBRUSH)br, (DRAWSTATEPROC)outputFunc, lData, wData, x, y, cx, cy, flags); } }
static INT_PTR CALLBACK LoggedOutWindowProc( IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam) { PGINA_CONTEXT pgContext; pgContext = (PGINA_CONTEXT)GetWindowLongPtr(hwndDlg, GWL_USERDATA); switch (uMsg) { case WM_INITDIALOG: { /* FIXME: take care of DontDisplayLastUserName, NoDomainUI, ShutdownWithoutLogon */ pgContext = (PGINA_CONTEXT)lParam; SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext); SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME)); pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); return TRUE; } case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; if (pgContext->hBitmap) { hdc = BeginPaint(hwndDlg, &ps); DrawStateW(hdc, NULL, NULL, (LPARAM)pgContext->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP); EndPaint(hwndDlg, &ps); } return TRUE; } case WM_DESTROY: { DeleteObject(pgContext->hBitmap); return TRUE; } case WM_COMMAND: { switch (LOWORD(wParam)) { case IDOK: { LPWSTR UserName = NULL, Password = NULL; INT result = WLX_SAS_ACTION_NONE; if (GetTextboxText(hwndDlg, IDC_USERNAME, &UserName) && *UserName == '\0') break; if (GetTextboxText(hwndDlg, IDC_PASSWORD, &Password) && DoLoginTasks(pgContext, UserName, NULL, Password)) { result = WLX_SAS_ACTION_LOGON; } HeapFree(GetProcessHeap(), 0, UserName); HeapFree(GetProcessHeap(), 0, Password); EndDialog(hwndDlg, result); return TRUE; } case IDCANCEL: { EndDialog(hwndDlg, WLX_SAS_ACTION_NONE); return TRUE; } case IDC_SHUTDOWN: { EndDialog(hwndDlg, WLX_SAS_ACTION_SHUTDOWN); return TRUE; } } break; } } return FALSE; }
BOOL CALLBACK ShutDownDialogProc( HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { PGINA_CONTEXT pgContext; pgContext = (PGINA_CONTEXT)GetWindowLongPtr(hwnd, GWL_USERDATA); switch (Message) { case WM_INITDIALOG: pgContext = (PGINA_CONTEXT)lParam; SetWindowLongPtr(hwnd, GWL_USERDATA, (INT_PTR)pgContext); ShutDownOnInit(hwnd, pgContext); /* Draw the logo graphic */ pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); return TRUE; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; if (pgContext->hBitmap) { hdc = BeginPaint(hwnd, &ps); DrawStateW(hdc, NULL, NULL, (LPARAM)pgContext->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP); EndPaint(hwnd, &ps); } return TRUE; } case WM_DESTROY: DeleteObject(pgContext->hBitmap); return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: ShutDownOnOk(hwnd, pgContext); EndDialog(hwnd, IDOK); break; case IDCANCEL: EndDialog(hwnd, IDCANCEL); break; case IDC_SHUTDOWN_LIST: UpdateShutdownDesc(hwnd); break; } break; default: return FALSE; } return TRUE; }
static INT_PTR CALLBACK UnlockWindowProc( IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam) { PGINA_CONTEXT pgContext; INT result = WLX_SAS_ACTION_NONE; pgContext = (PGINA_CONTEXT)GetWindowLongPtr(hwndDlg, GWL_USERDATA); switch (uMsg) { case WM_INITDIALOG: pgContext = (PGINA_CONTEXT)lParam; SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext); SetLockMessage(hwndDlg, IDC_LOCKMSG, pgContext); SetDlgItemTextW(hwndDlg, IDC_USERNAME, pgContext->UserName); SetFocus(GetDlgItem(hwndDlg, IDC_PASSWORD)); if (pgContext->bDisableCAD == TRUE) EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE); pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); return TRUE; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; if (pgContext->hBitmap) { hdc = BeginPaint(hwndDlg, &ps); DrawStateW(hdc, NULL, NULL, (LPARAM)pgContext->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP); EndPaint(hwndDlg, &ps); } return TRUE; } case WM_DESTROY: DeleteObject(pgContext->hBitmap); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: if (DoUnlock(hwndDlg, pgContext, &result)) EndDialog(hwndDlg, result); return TRUE; case IDCANCEL: EndDialog(hwndDlg, WLX_SAS_ACTION_NONE); return TRUE; } break; } return FALSE; }
static INT_PTR CALLBACK LoggedOutWindowProc( IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam) { PGINA_CONTEXT pgContext; pgContext = (PGINA_CONTEXT)GetWindowLongPtr(hwndDlg, GWL_USERDATA); switch (uMsg) { case WM_INITDIALOG: /* FIXME: take care of NoDomainUI */ pgContext = (PGINA_CONTEXT)lParam; SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext); if (pgContext->bDontDisplayLastUserName == FALSE) SetDlgItemTextW(hwndDlg, IDC_USERNAME, pgContext->UserName); if (pgContext->bDisableCAD == TRUE) EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE); if (pgContext->bShutdownWithoutLogon == FALSE) EnableWindow(GetDlgItem(hwndDlg, IDC_SHUTDOWN), FALSE); SetDomainComboBox(GetDlgItem(hwndDlg, IDC_LOGON_TO), pgContext); SetFocus(GetDlgItem(hwndDlg, pgContext->bDontDisplayLastUserName ? IDC_USERNAME : IDC_PASSWORD)); pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); return TRUE; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; if (pgContext->hBitmap) { hdc = BeginPaint(hwndDlg, &ps); DrawStateW(hdc, NULL, NULL, (LPARAM)pgContext->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP); EndPaint(hwndDlg, &ps); } return TRUE; } case WM_DESTROY: DeleteObject(pgContext->hBitmap); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: if (DoLogon(hwndDlg, pgContext)) EndDialog(hwndDlg, WLX_SAS_ACTION_LOGON); return TRUE; case IDCANCEL: EndDialog(hwndDlg, WLX_SAS_ACTION_NONE); return TRUE; case IDC_SHUTDOWN: if (OnShutDown(hwndDlg, pgContext) == IDOK) EndDialog(hwndDlg, pgContext->nShutdownAction); return TRUE; } break; } return FALSE; }