MRESULT EXPENTRY fnSaverWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { SWP swpDlg, swpParent; HWND hwndDlg; int rc; switch( msg ) { case WM_SUBCLASS_INIT: case WM_CREATE: { RECTL rclRect; // Any initialization of the window and variables should come here. // the timer for the moving text ulAnimationTimerID = WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, ANIMATION_TIMER_ID, 20); // setup the initial coordinates for the scrolling text WinQueryWindowRect(hwnd, &rclRect); textX = rclRect.xRight; textY = rclRect.yTop/2; // Hide mouse pointer, if we're in real screen-saving mode! if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE); // Initialize WMCHAR record internal_InitWMCHARRecord(); break; } case WM_CHAR: if (!bOnlyPreviewMode) internal_SaveWMCHAREventToRecord(mp1, mp2); break; case WM_ASKPASSWORD: { // Get parameters char *pchPwdBuff = (char *) mp1; int iPwdBuffSize = (int) mp2; // Show mouse pointer, if we're screensaving. if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, TRUE); hwndDlg = WinLoadDlg(hwnd, hwnd, fnAutoHiderDlgProc, hmodOurDLLHandle, DLG_PASSWORDPROTECTION, NULL); if (!hwndDlg) { // Could not load dialog window resources! if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE); return (MRESULT) SSMODULE_ERROR_INTERNALERROR; } // Ok, dialog window loaded! // Now set its texts (NLS) internal_SetPageFont(hwndDlg); internal_SetPwdProtWindowText(hwndDlg); // Resize the window so text will fit! internal_ArrangePwdProtWindowControls(hwndDlg); // Initialize control(s)! WinSendDlgItemMsg(hwndDlg, EF_PASSWORD, EM_SETTEXTLIMIT, (MPARAM) (iPwdBuffSize-1), (MPARAM) 0); WinSetDlgItemText(hwndDlg, EF_PASSWORD, ""); // Center dialog in screen if (WinQueryWindowPos(hwndDlg, &swpDlg)) if (WinQueryWindowPos(hwnd, &swpParent)) { // Center dialog box within the screen int ix, iy; ix = swpParent.x + (swpParent.cx - swpDlg.cx)/2; iy = swpParent.y + (swpParent.cy - swpDlg.cy)/2; WinSetWindowPos(hwndDlg, HWND_TOP, ix, iy, 0, 0, SWP_MOVE); } WinSetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER); // Re-send WM_CHAR messages if needed if (bFirstKeyGoesToPwdWindow) internal_ReplayWMCHARRecord(); // Process the dialog! rc = WinProcessDlg(hwndDlg); if (rc!=PB_OK) { // The user pressed cancel! rc = SSMODULE_ERROR_USERPRESSEDCANCEL; } else { // The user pressed OK! // Get the entered password WinQueryDlgItemText(hwndDlg, EF_PASSWORD, iPwdBuffSize, pchPwdBuff); rc = SSMODULE_NOERROR; } // Destroy window WinDestroyWindow(hwndDlg); // Hide mouse pointer again, if we're screensaving. if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE); return (MRESULT) rc; } case WM_SHOWWRONGPASSWORD: // Show mouse pointer, if we're screensaving. if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, TRUE); hwndDlg = WinLoadDlg(hwnd, hwnd, fnAutoHiderDlgProc, hmodOurDLLHandle, DLG_WRONGPASSWORD, NULL); if (!hwndDlg) { // Could not load dialog window resources! if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE); return (MRESULT) SSMODULE_ERROR_INTERNALERROR; } // Ok, dialog window loaded! // Now set its texts (NLS) internal_SetPageFont(hwndDlg); internal_SetWrongPwdWindowText(hwndDlg); // Resize the window so text will fit! internal_ArrangeWrongPwdWindowControls(hwndDlg); // Center dialog in screen if (WinQueryWindowPos(hwndDlg, &swpDlg)) if (WinQueryWindowPos(hwnd, &swpParent)) { // Center dialog box within the screen int ix, iy; ix = swpParent.x + (swpParent.cx - swpDlg.cx)/2; iy = swpParent.y + (swpParent.cy - swpDlg.cy)/2; WinSetWindowPos(hwndDlg, HWND_TOP, ix, iy, 0, 0, SWP_MOVE); } WinSetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER); // Process the dialog! rc = WinProcessDlg(hwndDlg); // Destroy window WinDestroyWindow(hwndDlg); // Hide mouse pointer again, if we're screensaving. if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE); return (MRESULT) SSMODULE_NOERROR; case WM_SUBCLASS_UNINIT: case WM_DESTROY: // All kinds of cleanup (the opposite of everything done in WM_CREATE) // should come here. WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, ulAnimationTimerID); // Restore mouse pointer, if we're in real screen-saving mode! if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, TRUE); break; case WM_ADJUSTWINDOWPOS: if (!bOnlyPreviewMode) { SWP *pSWP; // The following is required so that this window will be on // top of the xCenter window, evenif that is set to be always on top! // Real screensaving, here we should stay on top! // Set WS_TOPMOST flag again! WinSetWindowBits(hwnd, QWL_STYLE, WS_TOPMOST, WS_TOPMOST); pSWP = (SWP *) mp1; pSWP->hwndInsertBehind = HWND_TOP; pSWP->fl |= SWP_ZORDER; } break; case WM_PAINT: { HPS hpsBeginPaint; RECTL rclRect, blank, rclWindow; FONTMETRICS fm; int len; #ifdef DEBUG_LOGGING AddLog("WM_PAINT\n"); #endif hpsBeginPaint = WinBeginPaint(hwnd, NULLHANDLE, &rclRect); WinQueryWindowRect(hwnd, &rclRect); WinQueryWindowRect(hwnd, &rclWindow); WinSetWindowFontMy(hwnd, "10.Courier"); GpiQueryFontMetrics(hpsBeginPaint, sizeof(fm), &fm); rclRect.xLeft = textX; rclRect.yTop = textY; len = strlen(CfgDlgInit.pchText); rclRect.xRight = rclRect.xLeft + fm./*lAveCharWidth*/lMaxCharInc * len+5; rclRect.yBottom = rclRect.yTop - fm.lMaxBaselineExt; WinDrawText(hpsBeginPaint, len ,CfgDlgInit.pchText, &rclRect, CLR_WHITE, CLR_BLACK, DT_ERASERECT | DT_LEFT | DT_VCENTER); /* paint the black around the text*/ blank.xLeft = 0; blank.yBottom = 0; blank.xRight = rclRect.xLeft; blank.yTop = rclWindow.yTop; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK); blank.xLeft = rclRect.xLeft-2; blank.yBottom = rclRect.yTop; blank.xRight = rclWindow.xRight; blank.yTop = rclWindow.yTop; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK); blank.xLeft = rclRect.xRight; blank.yBottom = 0; blank.xRight = rclWindow.xRight; blank.yTop = rclRect.yTop; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK); blank.xLeft = rclRect.xLeft-2; blank.yBottom = 0; blank.xRight = rclRect.xRight+2; blank.yTop = rclRect.yBottom; WinFillRect(hpsBeginPaint, &blank, CLR_BLACK); if (rclRect.xRight <= -10) { WinQueryWindowRect(hwnd, &rclRect); textX = rclRect.xRight; textY = rclRect.yTop/2; } WinEndPaint(hpsBeginPaint); #ifdef DEBUG_LOGGING AddLog("WM_PAINT done\n"); #endif return (MRESULT) FALSE; } case WM_TIMER: if (((SHORT)mp1)==ANIMATION_TIMER_ID) { // Timer, so make new image position textX -= 2; WinInvalidateRect(hwnd, NULL, FALSE); } break; default: break; } return WinDefWindowProc( hwnd, msg, mp1, mp2 ); }
MRESULT EXPENTRY fnSaverWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { SWP swpDlg, swpParent; HWND hwndDlg; int rc; switch( msg ) { case WM_SUBCLASS_INIT: case WM_CREATE: // Any initialization of the window and variables should come here. // Hide mouse pointer, if we're in real screen-saving mode! if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE); // Initialize WMCHAR record internal_InitWMCHARRecord(); break; case WM_CHAR: if (!bOnlyPreviewMode) internal_SaveWMCHAREventToRecord(mp1, mp2); break; case WM_ASKPASSWORD: { // Get parameters char *pchPwdBuff = (char *) mp1; int iPwdBuffSize = (int) mp2; // Show mouse pointer, if we're screensaving. if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, TRUE); hwndDlg = WinLoadDlg(hwnd, hwnd, fnAutoHiderDlgProc, hmodOurDLLHandle, DLG_PASSWORDPROTECTION, NULL); if (!hwndDlg) { // Could not load dialog window resources! if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE); return (MRESULT) SSMODULE_ERROR_INTERNALERROR; } // Ok, dialog window loaded! // Now set its texts (NLS) internal_SetPageFont(hwndDlg); internal_SetPwdProtWindowText(hwndDlg); // Resize the window so text will fit! internal_ArrangePwdProtWindowControls(hwndDlg); // Initialize control(s)! WinSendDlgItemMsg(hwndDlg, EF_PASSWORD, EM_SETTEXTLIMIT, (MPARAM) (iPwdBuffSize-1), (MPARAM) 0); WinSetDlgItemText(hwndDlg, EF_PASSWORD, ""); // Center dialog in screen if (WinQueryWindowPos(hwndDlg, &swpDlg)) if (WinQueryWindowPos(hwnd, &swpParent)) { // Center dialog box within the screen int ix, iy; ix = swpParent.x + (swpParent.cx - swpDlg.cx)/2; iy = swpParent.y + (swpParent.cy - swpDlg.cy)/2; WinSetWindowPos(hwndDlg, HWND_TOP, ix, iy, 0, 0, SWP_MOVE); } WinSetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER); // Re-send WM_CHAR messages if needed if (bFirstKeyGoesToPwdWindow) internal_ReplayWMCHARRecord(); // Process the dialog! rc = WinProcessDlg(hwndDlg); if (rc!=PB_OK) { // The user pressed cancel! rc = SSMODULE_ERROR_USERPRESSEDCANCEL; } else { // The user pressed OK! // Get the entered password WinQueryDlgItemText(hwndDlg, EF_PASSWORD, iPwdBuffSize, pchPwdBuff); rc = SSMODULE_NOERROR; } // Destroy window WinDestroyWindow(hwndDlg); // Hide mouse pointer again, if we're screensaving. if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE); return (MRESULT) rc; } case WM_SHOWWRONGPASSWORD: // Show mouse pointer, if we're screensaving. if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, TRUE); hwndDlg = WinLoadDlg(hwnd, hwnd, fnAutoHiderDlgProc, hmodOurDLLHandle, DLG_WRONGPASSWORD, NULL); if (!hwndDlg) { // Could not load dialog window resources! if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE); return (MRESULT) SSMODULE_ERROR_INTERNALERROR; } // Ok, dialog window loaded! // Now set its texts (NLS) internal_SetPageFont(hwndDlg); internal_SetWrongPwdWindowText(hwndDlg); // Resize the window so text will fit! internal_ArrangeWrongPwdWindowControls(hwndDlg); // Center dialog in screen if (WinQueryWindowPos(hwndDlg, &swpDlg)) if (WinQueryWindowPos(hwnd, &swpParent)) { // Center dialog box within the screen int ix, iy; ix = swpParent.x + (swpParent.cx - swpDlg.cx)/2; iy = swpParent.y + (swpParent.cy - swpDlg.cy)/2; WinSetWindowPos(hwndDlg, HWND_TOP, ix, iy, 0, 0, SWP_MOVE); } WinSetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER); // Process the dialog! rc = WinProcessDlg(hwndDlg); // Destroy window WinDestroyWindow(hwndDlg); // Hide mouse pointer again, if we're screensaving. if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, FALSE); return (MRESULT) SSMODULE_NOERROR; case WM_SUBCLASS_UNINIT: case WM_DESTROY: // All kinds of cleanup (the opposite of everything done in WM_CREATE) // should come here. // Restore mouse pointer, if we're in real screen-saving mode! if (!bOnlyPreviewMode) WinShowPointer(HWND_DESKTOP, TRUE); break; case WM_ADJUSTWINDOWPOS: if (!bOnlyPreviewMode) { SWP *pSWP; // The following is required so that this window will be on // top of the xCenter window, evenif that is set to be always on top! // Real screensaving, here we should stay on top! // Set WS_TOPMOST flag again! WinSetWindowBits(hwnd, QWL_STYLE, WS_TOPMOST, WS_TOPMOST); pSWP = (SWP *) mp1; pSWP->hwndInsertBehind = HWND_TOP; pSWP->fl |= SWP_ZORDER; } break; case WM_PAINT: { HPS hpsBeginPaint; RECTL rclRect; #ifdef DEBUG_LOGGING AddLog("WM_PAINT\n"); #endif hpsBeginPaint = WinBeginPaint(hwnd, NULL, &rclRect); WinQueryWindowRect(hwnd, &rclRect); // Fill with black WinFillRect(hpsBeginPaint, &rclRect, CLR_BLACK); WinEndPaint(hpsBeginPaint); return (MRESULT) FALSE; } default: break; } return WinDefWindowProc( hwnd, msg, mp1, mp2 ); }