HWND os2FrameWindow::CreateFrameWindow(nsWindow* aParent, HWND aParentWnd, const nsIntRect& aRect, nsWindowType aWindowType, nsBorderStyle aBorderStyle) { // Create a frame window with a MozillaWindowClass window as its client. HWND hClient; PRUint32 fcfFlags = GetFCFlags(aWindowType, aBorderStyle); mFrameWnd = WinCreateStdWindow(HWND_DESKTOP, 0, (ULONG*)&fcfFlags, kWindowClassName, "Title", WS_CLIPCHILDREN, NULLHANDLE, 0, &hClient); if (!mFrameWnd) { return 0; } // Hide from the Window List until shown. SetWindowListVisibility(PR_FALSE); // This prevents a modal dialog from being covered by its disabled parent. if (aParentWnd != HWND_DESKTOP) { WinSetOwner(mFrameWnd, aParentWnd); } // Get the frame control HWNDs for use by fullscreen mode. mTitleBar = WinWindowFromID(mFrameWnd, FID_TITLEBAR); mSysMenu = WinWindowFromID(mFrameWnd, FID_SYSMENU); mMinMax = WinWindowFromID(mFrameWnd, FID_MINMAX); // Calc the size of a frame needed to contain a client area of the // specified width & height. Without this, eWindowType_dialog windows // will be truncated (toplevel windows will still display correctly). RECTL rcl = {0, 0, aRect.width, aRect.height}; WinCalcFrameRect(mFrameWnd, &rcl, FALSE); mFrameBounds = nsIntRect(aRect.x, aRect.y, rcl.xRight-rcl.xLeft, rcl.yTop-rcl.yBottom); // Move & resize the frame. PRInt32 pmY = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - mFrameBounds.y - mFrameBounds.height; WinSetWindowPos(mFrameWnd, 0, mFrameBounds.x, pmY, mFrameBounds.width, mFrameBounds.height, SWP_SIZE | SWP_MOVE); // Store the client's bounds. For windows with resizable borders, // the width includes the width of the frame controls (minmax, etc.). SWP swp; WinQueryWindowPos(hClient, &swp); mOwner->SetBounds(nsIntRect(swp.x, mFrameBounds.height - swp.y - swp.cy, swp.cx, swp.cy)); // Subclass the frame. mPrevFrameProc = WinSubclassWindow(mFrameWnd, fnwpFrame); WinSetWindowPtr(mFrameWnd, QWL_USER, this); DEBUGFOCUS(Create os2FrameWindow); return hClient; }
SHORT TOOLBAR :: AddButton (USHORT id, USHORT usBitmapID, SHORT sPos, PSZ psz, BOOL fHelp) { // room left for another button? if (c >= TOOLBARBUTTONSMAX) return -1; CHAR ach[11]; sprintf (ach, "#%u", usBitmapID); USHORT x = X_TBBUTTONS, y = Y_TBBUTTONS; USHORT cx = CX_TBBUTTONS, cy = CY_TBBUTTONS; if (id == TBID_SEPERATOR) cx = CX_TBSEPERATOR; if ((sPos > c) || (sPos == TBPOS_LAST)) sPos = c; else if (sPos == TBPOS_FIRST) sPos = 0; // shift all buttons (window and ID in id-array) to the "right" SWP swp; HWND hwndButton; for (SHORT i = c-1; i >= sPos; i--) { hwndButton = WinWindowFromID (hwnd, aid[i]); WinQueryWindowPos (hwndButton, &swp); WinSetWindowPos (hwndButton, 0L, swp.x+cx,swp.y, 0,0, SWP_MOVE); aid[i+1] = aid[i]; } // get x-position (in pixels) for button for (SHORT i = 0; i < sPos; i++) { if (aid[i] != TBID_SEPERATOR) { hwndButton = WinWindowFromID (hwnd, aid[i]); WinQueryWindowPos (hwndButton, &swp); x += swp.cx; } else x += CX_TBSEPERATOR; } // insert button id in array aid[sPos] = id; apsz[sPos] = psz; c ++; if (id != TBID_SEPERATOR) { // create button control // HWND hwndButton = if (! fHelp) WinCreateWindow (hwnd, WC_BUTTON, ach, WS_VISIBLE | WS_TABSTOP | BS_NOPOINTERFOCUS | BS_PUSHBUTTON | BS_BITMAP, x,y, cx,cy, hwnd, HWND_TOP, id, NULL, NULL); else WinCreateWindow (hwnd, WC_BUTTON, ach, WS_VISIBLE | WS_TABSTOP | BS_NOPOINTERFOCUS | BS_PUSHBUTTON | BS_BITMAP | BS_HELP, x,y, cx,cy, hwnd, HWND_TOP, id, NULL, NULL); } return sPos; }
// Frame_window - окно рамки. HPOINTER Diver_QueryWindowIcon( HWND Frame_window ) { // Для некоторых окон есть значки по умолчанию, но устанавливать их нельзя. if( IsEPMEditorWindow( Frame_window ) || WindowIsCreatedBy( APP_EPM, Frame_window ) ) { if( Diver.RTSettings.EPM_icon == NULLHANDLE ) { ULONG Boot_drive = 0; DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PULONG) &Boot_drive, sizeof( Boot_drive ) ); if( Boot_drive ) { CHAR Path[ SIZE_OF_PATH ] = "*:"; Path[ 0 ] = (CHAR) Boot_drive + 64; strcat( Path, "\\OS2\\Apps\\Epm.exe" ); if( FileExists( Path ) ) Diver.RTSettings.EPM_icon = WinLoadFileIcon( Path, 0 ); } } if( Diver.RTSettings.EPM_icon != NULLHANDLE ) return Diver.RTSettings.EPM_icon; else return Resources.Default_icons[ ICON_VIEWDOC ]; } // Для некоторых окон значки по умолчанию можно установить раз и навсегда, отправив сообщение в окно. HPOINTER Icon = NULLHANDLE; if( Icon == NULLHANDLE ) { if( IsWinListWindow( Frame_window ) ) Icon = Resources.Default_icons[ ICON_WINLIST ]; } if( Icon == NULLHANDLE ) { if( WindowIsCreatedBy( APP_VIEWDOC, Frame_window ) ) Icon = Resources.Default_icons[ ICON_VIEWDOC ]; } if( Icon == NULLHANDLE ) { if( WindowIsCreatedBy( APP_PMCHKDSK, Frame_window ) ) { if( Diver.RTSettings.HDD_icon == NULLHANDLE ) { ULONG Boot_drive = 0; DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PULONG) &Boot_drive, sizeof( Boot_drive ) ); if( Boot_drive ) { CHAR Path[ SIZE_OF_PATH ] = "*:"; Path[ 0 ] = (CHAR) Boot_drive + 64; strcat( Path, "\\eCS\\Bin\\PMFormat.exe" ); if( FileExists( Path ) ) Diver.RTSettings.HDD_icon = WinLoadFileIcon( Path, 0 ); } } if( Diver.RTSettings.HDD_icon == NULLHANDLE ) { CHAR Path[ SIZE_OF_PATH ] = ""; HOBJECT WPDrives_object = QueryWPSObject( "<WP_DRIVES>" ); if( WPDrives_object != NULLHANDLE ) WinQueryObjectPath( WPDrives_object, Path, SIZE_OF_PATH ); if( Path[ 0 ] != 0 ) Diver.RTSettings.HDD_icon = WinLoadFileIcon( Path, 0 ); } if( Diver.RTSettings.HDD_icon != NULLHANDLE ) Icon = Diver.RTSettings.HDD_icon; } } if( Icon == NULLHANDLE ) { if( WindowIsCreatedBy( APP_APPLETVIEWER, Frame_window ) ) { HWND Related_window = FindRelatedFrameWindow( Frame_window, &IsHotJavaBrowserWindow ); if( Related_window != NULLHANDLE ) { Icon = (HPOINTER) WinSendMsg( Related_window, WM_QUERYICON, 0, 0 ); } } } // Если значок был выбран - ставим и возвращаем его. if( Icon != NULLHANDLE ) { if( DrawSystemMenusSettingIsON() ) { WinPostQueueMsg( Enhancer.Modules.Changer->Message_queue, SM_CHANGE_ICON, (MPARAM) Frame_window, (MPARAM) Icon ); } return Icon; } // Узнаем значок окна. Icon = (HPOINTER) WinSendMsg( Frame_window, WM_QUERYICON, 0, 0 ); // Если это пустой значок - ставим изображение по умолчанию. HWND Desktop = QueryDesktopWindow(); if( Icon == WinQuerySysPointer( Desktop, SPTR_APPICON, 0 ) ) { Icon = WinQuerySysPointer( Desktop, SPTR_PROGRAM, 0 ); if( DrawSystemMenusSettingIsON() ) { WinPostQueueMsg( Enhancer.Modules.Changer->Message_queue, SM_CHANGE_ICON, (MPARAM) Frame_window, (MPARAM) Icon ); } return Icon; } // Если значок неизвестен - возвращаем значок владельца, главного окна, или значок по умолчанию. // Менять значок во всех случаях нельзя - может возникнуть постоянное рисование, которое выглядит как "мигание" рамки. if( Icon == NULLHANDLE ) { // Узнаем окно рабочего стола. HWND Desktop = QueryDesktopWindow(); // Просматриваем всех владельцев. HWND Owner_window = WinQueryWindow( Frame_window, QW_FRAMEOWNER ); while( Owner_window != Desktop && Owner_window != NULLHANDLE ) { // Если владелец - окно рамки: if( IsFrameWindow( Owner_window ) ) { // Узнаем его значок. Icon = (HPOINTER) WinSendMsg( Owner_window, WM_QUERYICON, 0, 0 ); // Если он есть - возвращаем его. if( Icon != NULLHANDLE ) return Icon; } // Узнаем следующего владельца. Owner_window = WinQueryWindow( Owner_window, QW_FRAMEOWNER ); } // Узнаем главное окно приложения. HWND Main_window = QueryMainWindow( Frame_window ); // Если это другое окно: if( Main_window != Frame_window ) { // Узнаем его значок. Icon = (HPOINTER) WinSendMsg( Main_window, WM_QUERYICON, 0, 0 ); // Если он есть - возвращаем его. if( Icon != NULLHANDLE ) return Icon; } // Узнаем очередь сообщений окна. HMQ Message_queue = WinQueryWindowULong( Frame_window, QWL_HMQ ); // Узнаем окно оболочки. HWND Shell_window = GetDetectedShellWindow(); if( Shell_window != NULLHANDLE ) { // Узнаем очередь сообщений для окна оболочки. HMQ Shell_queue = WinQueryWindowULong( Shell_window, QWL_HMQ ); // Если очереди совпадают - возвращаем его значок. if( Shell_queue == Message_queue ) return (HPOINTER) WinSendMsg( Shell_window, WM_QUERYICON, 0, 0 ); // Если еще как-нибудь можно установить, что окно создано оболочкой - возвращаем значок окна оболочки. if( IsWorkplaceShellWindow( Frame_window ) ) return (HPOINTER) WinSendMsg( Shell_window, WM_QUERYICON, 0, 0 ); } { // Перебираем окна в окне рабочего стола. HENUM Enumeration = WinBeginEnumWindows( Desktop ); HWND Window = NULLHANDLE; while( ( Window = WinGetNextWindow( Enumeration ) ) != NULLHANDLE ) { // Если это то же самое окно - продолжаем перебор окон. if( Window == Frame_window ) continue; // Узнаем расположение окна и его состояние. SWP Window_state = {0}; WinQueryWindowPos( Window, &Window_state ); // Если окно не скрыто и не уменьшено в значок: if( !( Window_state.fl & SWP_HIDE ) ) if( !( Window_state.fl & SWP_MINIMIZE ) ) { // Если в это окно нельзя переключиться - продолжаем перебор окон. if( !PermissionForSwitching( Window ) ) continue; } // Узнаем очередь сообщений окна. HMQ Window_queue = WinQueryWindowULong( Window, QWL_HMQ ); // Если очереди совпадают - узнаем его значок. if( Window_queue == Message_queue ) { // Узнаем значок окна. Icon = (HPOINTER) WinSendMsg( Window, WM_QUERYICON, 0, 0 ); // Если он есть - возвращаем его. if( Icon != NULLHANDLE ) { // Завершаем перебор окон. WinEndEnumWindows( Enumeration ); // Возвращаем значок. return Icon; } } } WinEndEnumWindows( Enumeration ); } // Узнаем путь к приложению, создавшему окно. CHAR Path[ SIZE_OF_PATH ] = ""; GetDetectedExePath( Frame_window, Path ); // Если его удалось определить: if( Path[ 0 ] != 0 ) { // Узнаем имя приложения, создавшего окно. CHAR Name[ SIZE_OF_PATH ] = ""; GetDetectedExeName( Frame_window, Name ); // Составляем полный путь. strcat( Path, "\\" ); strcat( Path, Name ); // Загружаем значок для файла приложения. Icon = WinLoadFileIcon( Path, 0 ); // Загрузка длится долго, поэтому в этом случае надо заменить значок окна. При // повторной загрузке возможна утечка памяти, так что лучше сделать это немедленно, // не посылая сообщений в поток Changer. WinSendMsg( Frame_window, WM_SETICON, (MPARAM) Icon, 0 ); // Запоминаем, что значок был загружен с диска. BYTE Icon_was_loaded = 1; SetProperty( Frame_window, PRP_ICON_WAS_LOADED, &Icon_was_loaded ); // Возвращаем значок. return Icon; } // Для окон постоянного размера выбираем простой значок. if( WindowIsDialog( Frame_window ) ) { return Resources.Default_icons[ ICON_LEAF ]; } // Для остальных окон - он зависит от того, можно ли переключиться в окно. else { HSWITCH Switch_handle = WinQuerySwitchHandle( Frame_window, NULLHANDLE ); if( Switch_handle != NULLHANDLE ) return Resources.Default_icons[ ICON_LEAVES ]; else return Resources.Default_icons[ ICON_LEAF ]; } // И наконец, значок мог быть задан в свойствах раньше. FindProperty( Frame_window, PRP_ICON, &Icon ); } // Возврат. return Icon; }
MRESULT EXPENTRY ClientWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { PGLOBALS pg; RECTL rectl; ULONG rc; LONG lrc; char szWork[ LEN_WORKSTRING ]; FILE *f; SWP swp; switch( msg ) { case WM_CLOSE: // mshell does not close, but at least it can minimize and get out of the way pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinSetWindowPos( pg->hwndFrame, HWND_BOTTOM, 0, 0, 0, 0, SWP_MINIMIZE ); return (MRESULT) 0; case WM_CREATE: // see create.c pg = Create( hwnd ); break; case WM_COMMAND: // see menu.c return Command( hwnd, msg, mp1, mp2 ); case WM_CONTROL: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); switch( SHORT1FROMMP( mp1 )) { case ID_LISTBOX: switch( SHORT2FROMMP( mp1 )) { case LN_ENTER: // user wants to start a program WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); // see object.c // get index from listbox; works as index to aStartem array lrc = (LONG) WinSendMsg( pg->hwndListbox, LM_QUERYSELECTION, (MPARAM)LIT_FIRST, 0 ); #ifdef DEBUG pmassert( pg->hab, LIT_NONE != lrc ); #endif // pass index of program to start in mp2 WinPostMsg( pg->hwndObject, WM_USER_START, (MPARAM) hwnd, (MPARAM) lrc ); break; } break; } return (MRESULT) 0; case WM_ERASEBACKGROUND: // see Petzold, WM_PAINT below return (MRESULT) 1; case WM_MOUSEMOVE: // display which pointer? if( WinIsWindowEnabled( hwnd )) { // not disabled; display regular pointer WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE )); } else { // disabled; display hourglass WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE )); } return (MRESULT) 0; case WM_NACK_NO_INI: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, 0, 0 ); #define PSZNOINIPROMPT "\ Can't find \\MSHELL.INI, a plain text file used to configure MShell.\n\ \n\ Create a default one?" rc = (ULONG)WinMessageBox( HWND_DESKTOP, pg->hwndFrame, PSZNOINIPROMPT, CAPTION, 0, MB_ICONEXCLAMATION | MB_YESNOCANCEL ); if( MBID_YES == rc ) { #define PSZDEFINI "\ * MSHELL.INI defines programs that MShell can start\n\ * Configure MSHELL.EXE using the RUNWORKPLACE setting in CONFIG.SYS\n\ * MSHELL.EXE finds its INI in the root of the boot drive\n\ * Each line in the INI file has two parts:\n\ * 1: program title text to appear in MShell window\n\ * 2: the CMD.EXE start command to start the program\n\ * Separate the parts with a semicolon\n\ * Lines starting with ! start automatically at bootup\n\ * Comment lines begin with *\n\ \n\ * command processors\n\ OS/2 Command Prompt; start /f\n\ DOS Command Prompt; start /f /fs /dos\n\ Win-OS/2; start /fs /dos /c winos2\n\ \n\ * other stuff\n\ Help for Start; start help start\n\ Solitaire; start /f klondike\n\ \n\ * example to start from other than C:\\\n\ * PM Program; d: & cd \\pmpgm & start pmpgm\n" if( f = fopen( "\\MSHELL.INI", "w" )) { fprintf( f, PSZDEFINI ); fclose( f ); } // make like user pressed refresh WinPostMsg( hwnd, WM_COMMAND, (MPARAM)IDM_REFRESH, 0 ); } return (MRESULT) 0; case WM_NACK_NO_SPOOLER: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinMessageBox( HWND_DESKTOP, pg->hwndFrame, "Sorry, could not start the spooler.", CAPTION, 0, MB_CANCEL ); return (MRESULT) 0; case WM_NACK_SYNTAX_ERROR: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); // line number of INI file in mp2 sprintf( szWork, "Line %d of \\mshell.ini is unrecognized.", (SHORT) mp2 ); WinMessageBox( HWND_DESKTOP, pg->hwndFrame, szWork, CAPTION, 0, MB_CANCEL ); return (MRESULT) 0; case WM_PAINT: // see WM_ERASEBACKGROUND above; // see Petzold sections on control windows which are children of the client window break; case WM_SAVEAPPLICATION: // save restored position pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinQueryWindowPos( pg->hwndFrame, &swp ); if( swp.fl & SWP_MINIMIZE ) { // mshell is currently minimized pg->profile.swpMinimized.x = swp.x; pg->profile.swpMinimized.y = swp.y; // get restored size from window words pg->profile.swp.x = WinQueryWindowUShort( pg->hwndFrame, QWS_XRESTORE ); pg->profile.swp.y = WinQueryWindowUShort( pg->hwndFrame, QWS_YRESTORE ); pg->profile.swp.cx = WinQueryWindowUShort( pg->hwndFrame, QWS_CXRESTORE ); pg->profile.swp.cy = WinQueryWindowUShort( pg->hwndFrame, QWS_CYRESTORE ); } else if( swp.fl & SWP_MAXIMIZE ) { // mshell is currently maximized // get restored size from window words pg->profile.swp.x = WinQueryWindowUShort( pg->hwndFrame, QWS_XRESTORE ); pg->profile.swp.y = WinQueryWindowUShort( pg->hwndFrame, QWS_YRESTORE ); pg->profile.swp.cx = WinQueryWindowUShort( pg->hwndFrame, QWS_CXRESTORE ); pg->profile.swp.cy = WinQueryWindowUShort( pg->hwndFrame, QWS_CYRESTORE ); // get minimized icon position from window words pg->profile.swpMinimized.x = WinQueryWindowUShort( pg->hwndFrame, QWS_XMINIMIZE ); pg->profile.swpMinimized.y = WinQueryWindowUShort( pg->hwndFrame, QWS_YMINIMIZE ); } else { // mshell is in the restored state pg->profile.swp = swp; // get minimized icon position from window words pg->profile.swpMinimized.x = WinQueryWindowUShort( pg->hwndFrame, QWS_XMINIMIZE ); pg->profile.swpMinimized.y = WinQueryWindowUShort( pg->hwndFrame, QWS_YMINIMIZE ); } // write to ini PrfWriteProfileData( HINI_PROFILE, INI_APP, INIKEY_PROFILE, (PVOID)&pg->profile, sizeof( PROFILE )); #if 0 // save restored position // TO DO: save icon position pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinQueryWindowPos( pg->hwndFrame, &(pg->profile.swp) ); if( 0 == ( pg->profile.swp.fl & ( SWP_MINIMIZE | SWP_MAXIMIZE ))) { // app in restored state, swp struct fine the way it is. }else{ // app currently min'd or max'd. pull restore info from win words pg->profile.swp.x = WinQueryWindowUShort( pg->hwndFrame, QWS_XRESTORE); pg->profile.swp.y = WinQueryWindowUShort( pg->hwndFrame, QWS_YRESTORE); pg->profile.swp.cx = WinQueryWindowUShort( pg->hwndFrame, QWS_CXRESTORE); pg->profile.swp.cy = WinQueryWindowUShort( pg->hwndFrame, QWS_CYRESTORE); } // write to ini PrfWriteProfileData( HINI_PROFILE, INI_APP, INIKEY_PROFILE, (PVOID)&(pg->profile), sizeof( PROFILE )); #endif break; case WM_SIZE: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinQueryWindowRect( hwnd, &rectl ); WinSetWindowPos( pg->hwndListbox, HWND_TOP, 0, 0, rectl.xRight, rectl.yTop, SWP_SIZE | SWP_MOVE | SWP_SHOW ); return (MRESULT) 0; case WM_USER_ACK: // re-enable the window pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); switch( (ULONG)mp1 ) { case WM_CREATE: WinSetFocus( HWND_DESKTOP, pg->hwndListbox ); break; } WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, 0, 0 ); return (MRESULT) 0; case WM_USER_DISABLE_CLIENT: // this message sent; disable menu action bar as well pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinEnableWindow( pg->hwndClient, FALSE ); WinEnableWindow( pg->hwndMenubar, FALSE ); WinEnableWindow( pg->hwndListbox, FALSE ); return (MRESULT) 0; case WM_USER_ENABLE_CLIENT: // this message sent; enable client and action bar pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinEnableWindow( pg->hwndClient, TRUE ); WinEnableWindow( pg->hwndMenubar, TRUE ); WinEnableWindow( pg->hwndListbox, TRUE ); return (MRESULT) 0; } return( WinDefWindowProc( hwnd, msg, mp1, mp2 )); }
void mouse_button(HWND hwnd, ULONG msg, MPARAM mp1) { if (!_mouse_enabled) { return; } switch (msg) { case WM_MOUSEMOVE: _mouse_x = SHORT1FROMMP(mp1); _mouse_y = SHORT2FROMMP(mp1); mouse_timestamp = vsyncarch_gettime(); { SWP swp; WinQueryWindowPos(hwnd, &swp); // // check whether the pointer is outside or inside the window // if (FullscreenIsNow()) { visible = TRUE; } if (_mouse_x >= 0 && _mouse_x < swp.cx && _mouse_y >= 0 && _mouse_y < swp.cy) { // // FIXME: Don't capture the mouse pointer if it is in front // of a client dialog! // if (WinQueryCapture(HWND_DESKTOP)!= hwnd && hide_mouseptr && !FullscreenIsNow()) { WinSetCapture(HWND_DESKTOP, hwnd); } if (visible && hide_mouseptr && !FullscreenIsNow()) { WinShowPointer(HWND_DESKTOP, FALSE); visible = FALSE; } } else { if (WinQueryCapture(HWND_DESKTOP) == hwnd && !FullscreenIsNow()) { WinSetCapture(HWND_DESKTOP, NULLHANDLE); } if (!visible && !FullscreenIsNow()) { WinShowPointer(HWND_DESKTOP, TRUE); visible = TRUE; } // // don't use 'outside'-values which appears one times // if the mouse pointer leaves the window // if (_mouse_x < 0) { _mouse_x = 0; } else { if (_mouse_x >= swp.cx) { _mouse_x = swp.cx - 1; } } if (_mouse_y < 0) { _mouse_y = 0; } else { if (_mouse_y >= swp.cy) { _mouse_y = swp.cy - 1; } } } } return; case WM_BUTTON1DOWN: mouse_button_left(1); return; case WM_BUTTON1UP: mouse_button_left(0); return; case WM_BUTTON2DOWN: mouse_button_right(1); return; case WM_BUTTON2UP: mouse_button_right(0); return; case WM_BUTTON3DOWN: mouse_button_middle(1); return; case WM_BUTTON3UP: mouse_button_middle(0); return; } }
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 ); }
static BOOL _setMode(PGROPDATA pGrop, ULONG ulModeIdx, BOOL fFullscreen) { PVIDEOMODE pMode = &pGrop->stModes.pList[ulModeIdx]; // fFirstTime - Mode was not selected, mode will be set first time. BOOL fFirstTime = pGrop->ulModeIdx == ~0; RECTL rectl; LONG lX, lY, lW, lH; BOOL fSuccess = TRUE; if ( fFirstTime ) { pGrop->swpOld.x = pGrop->ulDTWidth / 2; pGrop->swpOld.y = pGrop->ulDTHeight / 2; } fFullscreen &= ( pGrop->stUserMode.ulWidth <= pMode->ulWidth ) && ( pGrop->stUserMode.ulHeight <= pMode->ulHeight ); if ( fFullscreen ) { if ( pGrop->fActive || fFirstTime ) { // Is the fullscreen and not on the descktop now - change fulscreen mode. if ( !pGrop->fFullscreen && !fFirstTime ) // Save windows position before switching to full-screen mode. WinQueryWindowPos( pGrop->hwndFrame, &pGrop->swpOld ); // Do not change FS mode if it is the same as the current one. fSuccess = ( pGrop->fFullscreen && ( pGrop->ulModeIdx == ulModeIdx ) ) || _setFullscreen( pGrop, ulModeIdx ); } // else: FS mode but on the desktop now, change mode later in _wmActive(). pGrop->ulModeIdx = ulModeIdx; pGrop->fFullscreen = TRUE; } else //if ( pGrop->fFullscreen || ( pGrop->ulModeIdx != ulModeIdx ) ) { // Change window if mode is not same as the current one. if ( pGrop->fFullscreen ) { debug( "Return to the desktop..." ); _setDesktop( pGrop ); } debug( "Calc new window size..." ); rectl.xLeft = 0; rectl.yBottom = 0; rectl.xRight = pGrop->stUserMode.ulWidth; rectl.yTop = pGrop->stUserMode.ulHeight; WinCalcFrameRect( pGrop->hwndFrame, &rectl, FALSE ); lW = rectl.xRight - rectl.xLeft; lH = rectl.yTop - rectl.yBottom; if ( !pGrop->fFullscreen && !fFirstTime ) { // Positioning relative to the current location. debug( "Query current window position..." ); WinQueryWindowPos( pGrop->hwndFrame, &pGrop->swpOld ); } else debug( "Window's location will be relative to the location before FS." ); lX = pGrop->swpOld.x + (pGrop->swpOld.cx / 2) - (lW / 2); lY = pGrop->swpOld.y + (pGrop->swpOld.cy / 2) - (lH / 2); if ( lW > pGrop->ulDTWidth ) lX = (pGrop->ulDTWidth / 2) - ( lW / 2); else if ( (lX + lW) > pGrop->ulDTWidth ) lX = pGrop->ulDTWidth - lW; else if ( lX < 0 ) lX = 0; if ( lY < 0 ) lY = 0; if ( (lY + lH) > pGrop->ulDTHeight ) lY = pGrop->ulDTHeight - lH; pGrop->ulModeIdx = ulModeIdx; pGrop->fFullscreen = FALSE; debug( "Set window position..." ); pGrop->fInternalResize = TRUE; WinSetWindowPos( pGrop->hwndFrame, HWND_TOP, lX, lY, lW, lH, fFirstTime ? SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE : SWP_MOVE | SWP_SIZE | SWP_SHOW ); pGrop->fInternalResize = FALSE; debug( "Call _captureMouse(,%s)...", pGrop->fCapture ? "TRUE" : "FALSE" ); _captureMouse( pGrop, pGrop->fCapture ); } debug( "Call _calcViewRect(,FALSE)..." ); _calcViewRect( pGrop, FALSE ); debug( "Call pVideoSys->fnUpdate()..." ); pGrop->pVideoSys->fnUpdate( pGrop->pVSData, pGrop, 0, NULL ); return fSuccess; }
MRESULT EXPENTRY OSARecordEventsDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { Environment *ev; PRECORDER_PARM prec; HWND hwndButton; CHAR szTemp[CCHMAXPATH]; PSZ pszBuffer,pszTemp; SWP swp; PSWP pswpNew, pswpOld; MRESULT result; OSAError retVal = noErr; switch(msg) { case WM_INITDLG: prec = (PRECORDER_PARM) calloc(1,sizeof(RECORDER_PARM)); prec->pmp = (PMAIN_PARM) mp2; prec->hwnd = hwnd; prec->pmp->hwndRecordEvent = hwnd; InitRecorder(prec); break; case WM_ADD_RECORDEDEVENT: prec = (PRECORDER_PARM) WinQueryWindowULong( hwnd, QWL_USER ); AddRecordedEvents(prec, (OSAEvent *) mp1); break; case WM_WINDOWPOSCHANGED: pswpNew = (PSWP) mp1; pswpOld = pswpNew + 1; hwndButton = WinWindowFromID(hwnd, IDD_ODRECSTATUS); WinQueryWindowPos(hwndButton, &swp); WinSetWindowPos(hwndButton, HWND_TOP, swp.x, swp.y+(pswpNew->cy - pswpOld->cy), 0, 0, SWP_MOVE ); hwndButton = WinWindowFromID(hwnd, IDD_ODDISPLAYEVENTS); WinQueryWindowPos(hwndButton, &swp); WinSetWindowPos(hwndButton, HWND_TOP, 0, 0, swp.cx+(pswpNew->cx - pswpOld->cx), swp.cy+(pswpNew->cy - pswpOld->cy), SWP_SIZE ); result = WinDefDlgProc(hwnd, msg, mp1, mp2); WinInvalidateRect(hwnd, NULL, TRUE); return result; break; case WM_PAINT: { SWP Pos, DlgPos; HPS Hps; RECTL Rect; /* First let dialog do normal painting */ WinDefDlgProc(hwnd, msg, mp1, mp2); /* Paint recessed frame around the status line */ Hps = WinGetPS(hwnd); WinQueryWindowPos(WinWindowFromID(hwnd, IDD_ODRECSTATUS), &Pos); WinQueryWindowPos(hwnd, &DlgPos); Rect.xLeft = WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME); Rect.xRight= DlgPos.cx - Rect.xLeft; Rect.yBottom = Pos.y - 1; Rect.yTop = Pos.y + Pos.cy + 1; #define DB_RAISED 0x0400 // Undocumented borders #define DB_DEPRESSED 0x0800 WinDrawBorder(Hps, &Rect, 1, 1, 0, 0, DB_DEPRESSED); WinReleasePS(Hps); return 0; } case WM_COMMAND: switch (SHORT1FROMMP (mp1)){ case IDD_ODRECSTART: prec = (PRECORDER_PARM) WinQueryWindowULong( hwnd, QWL_USER ); StartRecorder(prec); WinSetWindowText(prec->hwndStatus, "recording..."); break; case IDD_ODRECSTOP: prec = (PRECORDER_PARM) WinQueryWindowULong( hwnd, QWL_USER ); StopRecorder(prec); strcpy(szTemp,prec->szTitle); WinSetWindowText(prec->hwndStatus, "idl..."); break; case IDD_ODRECCANCEL: prec = (PRECORDER_PARM) WinQueryWindowULong( hwnd, QWL_USER ); if(prec->recording) StopRecorder(prec); // Save window size/pos info WinQueryWindowPos(hwnd, &swp); prec->pmp->Profile.testrec_cx = swp.cx; prec->pmp->Profile.testrec_cy = swp.cy; prec->pmp->Profile.testrec_x = swp.x; prec->pmp->Profile.testrec_y = swp.y; WinQueryWindowPos(prec->hwndStatus, &swp); prec->pmp->Profile.testrecStat_cx = swp.cx; prec->pmp->Profile.testrecStat_cy = swp.cy; prec->pmp->Profile.testrecStat_x = swp.x; prec->pmp->Profile.testrecStat_y = swp.y; prec->pmp->hwndRecordEvent = NULL; free((PVOID)prec); WinDismissDlg(hwnd, TRUE); break; default: ; } /* endswitch */ break; case WM_CLOSE: WinPostMsg(hwnd, WM_COMMAND, MPFROMSHORT(IDD_ODRECCANCEL), NULL); break; default: return(WinDefDlgProc(hwnd, msg, mp1, mp2)); } return (MRESULT)NULL; } /* end of OSAScriptEditorDlgProc() */
void kstAdjust(HWND hwndFrame) { HWND hwndTitle = WinWindowFromID(hwndFrame, FID_TITLEBAR) ; SWP swpTitle, swpCtl, swpAlt ; int w, h ; WinQueryWindowPos(hwndTitle, &swpTitle) ; #ifdef DEBUG TRACE("kstAdjust : Title (%d,%d), %dx%d\n", swpTitle.x, swpTitle.y, swpTitle.cx, swpTitle.cy) ; #endif if (swpTitle.cx == 0 || swpTitle.cy == 0) { #ifdef DEBUG TRACE("kstAdjust - not visible title\n") ; #endif return ; } if ((h = swpTitle.cy - 4) <= 0) { #ifdef DEBUG TRACE("kstAdjust - not enough title height\n") ; #endif return ; } w = h * 2 ; swpCtl.x = swpTitle.cx - (w + 2) * 2 ; if (swpCtl.x < 0) { #ifdef DEBUG TRACE("kstAdjust - not enough width\n") ; #endif return ; } swpCtl.y = 2 ; if (swpCtl.y < 0) { #ifdef DEBUG TRACE("kstAdjust - not enough height\n") ; #endif return ; } swpCtl.cx = w ; swpCtl.cy = h ; swpAlt.x = swpCtl.x + (w + 2) ; swpAlt.y = swpCtl.y ; swpAlt.cx = w ; swpAlt.cy = h ; WinSetWindowPos(hwndStateCtl, HWND_TOP, swpCtl.x, swpCtl.y, swpCtl.cx, swpCtl.cy, SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER) ; WinSetWindowPos(hwndStateAlt, HWND_TOP, swpAlt.x, swpAlt.y, swpAlt.cx, swpAlt.cy, SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER) ; WinPostMsg(hwndStateCtl, WM_KST_UPDATE, NULL, NULL) ; WinPostMsg(hwndStateAlt, WM_KST_UPDATE, NULL, NULL) ; }
static VOID _calcViewRect(PGROPDATA pGrop, BOOL fSendSize) { PGROPSETMODE pUserMode = &pGrop->stUserMode; LONG lWinX, lWinY, lWinWidth, lWinHeight; LONG lVAWidth; LONG lVAHeight; if ( pGrop->ulModeIdx == ~0 ) // Mode was not selected. return; if ( pGrop->fFullscreen ) { PVIDEOMODE pMode = &pGrop->stModes.pList[pGrop->ulModeIdx]; lWinWidth = pMode->ulWidth; lWinHeight = pMode->ulHeight; lWinX = 0; lWinY = pGrop->ulDTHeight - lWinHeight; } else { SWP swp; POINTL pointl = { 0 }; WinQueryWindowPos( pGrop->hwnd, &swp ); lWinWidth = swp.cx; lWinHeight = swp.cy; WinMapWindowPoints( pGrop->hwnd, HWND_DESKTOP, &pointl, 1 ); lWinX = pointl.x; lWinY = pointl.y; } // Calc view rectangle size and position at center of window or screen if ( pGrop->pVideoSys->fFreeWinSize ) { // Fit output frame to window, keep proportional. if ( lWinWidth * pUserMode->ulHeight > lWinHeight * pUserMode->ulWidth ) { lVAHeight = lWinHeight; lVAWidth = ( lWinHeight * pUserMode->ulWidth ) / pUserMode->ulHeight; } else { lVAWidth = lWinWidth; lVAHeight = ( lWinWidth * pUserMode->ulHeight ) / pUserMode->ulWidth; } } else { lVAWidth = pUserMode->ulWidth; lVAHeight = pUserMode->ulHeight; } pGrop->rectlViewArea.xLeft = ( lWinWidth - lVAWidth ) / 2; pGrop->rectlViewArea.yBottom = ( lWinHeight - lVAHeight ) / 2; pGrop->rectlViewArea.xRight = pGrop->rectlViewArea.xLeft + lVAWidth; pGrop->rectlViewArea.yTop = pGrop->rectlViewArea.yBottom + lVAHeight; pGrop->rectlWinArea.xLeft = lWinX; pGrop->rectlWinArea.yBottom = lWinY; pGrop->rectlWinArea.xRight = lWinX + lWinWidth; pGrop->rectlWinArea.yTop = lWinY + lWinHeight; /* printf( "-1- %d %d %d %d - %d %d %d %d\n", pGrop->rectlViewArea.xLeft, pGrop->rectlViewArea.yBottom, pGrop->rectlViewArea.xRight, pGrop->rectlViewArea.yTop, pGrop->rectlWinArea.xLeft, pGrop->rectlWinArea.yBottom, pGrop->rectlWinArea.xRight, pGrop->rectlWinArea.yTop );*/ }
// Frame_window - окно рамки, Target и Buttons_to_detect - какое свойство надо узнать. // Update_frame_if_required - рамку можно обновить если это требуется. VOID Diver_QueryWindowProperty( HWND Frame_window, ULONG Target, LONG Buttons_to_detect = ALL_ACTIONS, BYTE Update_frame_if_required = 0 ) { // Узнаем расположение окна и его состояние. SWP Window_state = {0}; WinQueryWindowPos( Frame_window, &Window_state ); // Если окно уменьшено в значок или скрыто - возврат. if( Window_state.fl & SWP_MINIMIZE || Window_state.fl & SWP_HIDE ) return; // Узнаем значок окна. if( Target & WT_SYSMENU ) { // Узнаем значок окна. HPOINTER Icon = Diver_QueryWindowIcon( Frame_window ); // Если он есть: if( Icon != NULLHANDLE ) { // Если значок изменился - рамка должна быть перерисована. HPOINTER Previous_icon = NULLHANDLE; FindProperty( Frame_window, PRP_ICON, &Previous_icon ); if( Icon != Previous_icon ) { // Устанавливаем свойство. SetProperty( Frame_window, PRP_ICON, &Icon ); // Посылаем сообщение в поток рисования. WinPostQueueMsg( Enhancer.Modules.Painter->Message_queue, SM_DRAW_FRAME, (MPARAM) Frame_window, (MPARAM) WT_SYSMENU ); } } } // Узнаем ширину рамки окна. if( Target & WT_SYSMENU ) { // Отправляем сообщение в окно. Diver.RTSettings.FB_size.x = 0; Diver.RTSettings.FB_size.y = 0; WinSendMsg( Frame_window, WM_QUERYBORDERSIZE, (MPARAM) &Diver.RTSettings.FB_size, 0 ); // Шириной рамки будем считать наименьшее полученное значение. INT Width = min( Diver.RTSettings.FB_size.x, Diver.RTSettings.FB_size.y ); // Если оно было получено: if( Width != 0 ) { // Если ширина изменилась - рамка должна быть перерисована. INT Previous_width = 0; FindProperty( Frame_window, PRP_BORDER, &Previous_width ); if( Width != Previous_width ) { // Устанавливаем свойство. SetProperty( Frame_window, PRP_BORDER, &Width ); // Узнаем значение по умолчанию. INT System_value = FrameWidth( Frame_window ); // Если это другое значение - посылаем сообщение в поток рисования. if( Width != System_value ) { ULONG Update_all = WT_BORDER | WT_SYSMENU | WT_TITLEBAR | WT_MINMAX | WT_MENU; WinPostQueueMsg( Enhancer.Modules.Painter->Message_queue, SM_DRAW_FRAME, (MPARAM) Frame_window, (MPARAM) Update_all ); } } } } // Узнаем заголовок окна. if( Target & WT_TITLEBAR ) { // Узнаем заголовок окна. HWND TitleBar_window = WinWindowFromID( Frame_window, FID_TITLEBAR ); CHAR Title[ SIZE_OF_TITLE ] = ""; QueryWindowTitle( Frame_window, TitleBar_window, Title, Update_frame_if_required ); // Если заголовок определен: if( Title[ 0 ] != 0 ) { // Если заголовок изменился - рамка должна быть перерисована. CHAR Previous_title[ SIZE_OF_TITLE ] = ""; FindProperty( Frame_window, PRP_TITLE, Previous_title ); if( !strc( Title, Previous_title ) ) { // Устанавливаем свойство. SetProperty( Frame_window, PRP_TITLE, Title ); // Посылаем сообщение в поток рисования. WinPostQueueMsg( Enhancer.Modules.Painter->Message_queue, SM_DRAW_FRAME, (MPARAM) Frame_window, (MPARAM) WT_TITLEBAR ); } } } // Узнаем состояние кнопок в правом верхнем углу окна. if( Target & WT_MINMAX ) { // Узнаем, есть ли это свойство в списке. BYTE Actions_are_detected = 0; FindProperty( Frame_window, PRP_ACTIONS, &Actions_are_detected ); // Если его нет - узнаем состояние кнопок по умолчанию. if( !Actions_are_detected ) { // Узнаем состояние кнопок по умолчанию. LONG Buttons_state = Diver_GetPreDefinedButtonsState( Frame_window ); // Запоминаем, что состояние кнопок определено. BYTE Detected = 1; SetProperty( Frame_window, PRP_ACTIONS, &Detected ); // Если оно задано - рамка должна быть перерисована. if( Buttons_state != NO_ACTION ) { // Устанавливаем свойство. SetProperty( Frame_window, PRP_BUTTONS, &Buttons_state ); // Посылаем сообщение в поток рисования. WinPostQueueMsg( Enhancer.Modules.Painter->Message_queue, SM_DRAW_FRAME, (MPARAM) Frame_window, (MPARAM) WT_BORDER ); } } // Узнаем состояние кнопок в окне. LONG Buttons_state = QueryButtonsState( Frame_window, Buttons_to_detect, 1 ); // Если состояние кнопок изменилось - рамка должна быть перерисована. LONG Previous_state = NO_ACTION; FindProperty( Frame_window, PRP_BUTTONS, &Previous_state ); if( Buttons_state != Previous_state ) { // Устанавливаем свойство. SetProperty( Frame_window, PRP_BUTTONS, &Buttons_state ); // Посылаем сообщение в поток рисования. WinPostQueueMsg( Enhancer.Modules.Painter->Message_queue, SM_DRAW_FRAME, (MPARAM) Frame_window, (MPARAM) WT_BORDER ); } } // Возврат. return; }
// Frame_window - окно рамки, Target - какое из окон надо перерисовать. VOID Painter_DrawWindowFrame( HWND Frame_window, ULONG Target ) { // Узнаем размер и расположение окна. RECT Frame_rectangle = {0}; SWP Frame_placement = {0}; Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); // Если окно не показано - возврат. if( Frame_rectangle.yTop <= 1 || Frame_rectangle.xRight <= 1 ) return; // Узнаем, как выглядит рамка окна. LONG Frame_type = FrameType( Frame_window ); // Узнаем, выбрано ли окно. BYTE Window_is_active = WindowIsActive( Frame_window ); // Устанавливаем свойство. SetProperty( Frame_window, PRP_ACTIVATED, &Window_is_active ); // Узнаем окно заголовка. HWND TitleBar_window = WinWindowFromID( Frame_window, FID_TITLEBAR ); // Для некоторых окон можно рисовать только заголовок. BYTE Draw_TitleBar_only = 0; if( !Painter_PermissionForCompleteDrawing( Frame_window ) ) { Draw_TitleBar_only = 1; Target = WT_TITLEBAR; } // Рисуем рамку для окна. if( !Draw_TitleBar_only ) { for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawFrameRectangle( Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, Window_is_active ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } } // Подчеркиваем объем меню окна. if( Painter.Settings.Draw_menus ) if( Frame_type != FT_FLAT ) if( Target & WT_UNKNOWN || Target & WT_MENU ) { HWND Menu_window = WinWindowFromID( Frame_window, FID_MENU ); if( Menu_window != NULLHANDLE ) { for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawWindowMenu( Menu_window, Frame_window, &Frame_rectangle, &Frame_placement ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } } } // Узнаем окно обычных кнопок. HWND MinMax_window = WinWindowFromID( Frame_window, FID_MINMAX ); // Если окно плоское: if( Frame_type == FT_FLAT ) { // Если в нем есть окно обычных кнопок - скрываем его. if( Painter.Settings.Draw_buttons ) if( MinMax_window != NULLHANDLE ) WinShowWindow( MinMax_window, 0 ); // Возврат. return; } // А если это не плоское окно: else { // Если свойства окна неизвестны и могут быть определены в будущем - возврат. if( !PropertiesForDrawingAreDetected( Frame_window ) ) if( WinWindowFromID( Frame_window, FID_SYSMENU ) != NULLHANDLE ) return; } // Узнаем окно картинки. HWND SysMenu_window = WinWindowFromID( Frame_window, FID_SYSMENU ); // Узнаем высоту заголовка и картинки. INT TitleBar_height = 0; if( TitleBar_window != NULLHANDLE ) { RECT Rectangle = {0}; WinQueryWindowRect( TitleBar_window, &Rectangle ); TitleBar_height = Rectangle.yTop - 1; } else { TitleBar_height = WinQuerySysValue( QueryDesktopWindow(), SV_CYMINMAXBUTTON ) - 1; } // Окна заголовка и картинки должны быть расположены на одной линии. // Если это не так - окно надо обновить и ничего не рисовать в нем. if( SysMenu_window != NULLHANDLE ) if( TitleBar_window != NULLHANDLE ) if( WinIsWindowVisible( SysMenu_window ) ) { // Узнаем ширину рамки окна. INT Frame_width = 0; FindProperty( Frame_window, PRP_BORDER, &Frame_width ); if( !Frame_width ) Frame_width = FrameWidth( Frame_window ); // Узнаем расположение окна картинки. SWP SysMenu_placement = {0}; WinQueryWindowPos( SysMenu_window, &SysMenu_placement ); // Если оно расположено на своем месте: INT Y_middle_line = Frame_rectangle.yTop - Frame_width - TitleBar_height / 2; if( SysMenu_placement.y < Y_middle_line ) if( SysMenu_placement.y + SysMenu_placement.cy > Y_middle_line ) { // Узнаем расположение окна заголовка. SWP TitleBar_placement = {0}; WinQueryWindowPos( TitleBar_window, &TitleBar_placement ); // Если заголовок расположен не на своем месте: if( TitleBar_placement.y > Y_middle_line || TitleBar_placement.y + TitleBar_placement.cy < Y_middle_line ) { // Обновляем окно. UpdateWindow( Frame_window ); // Возврат. return; } } } // Узнаем, можно ли рисовать для окна новые кнопки. BYTE Draw_new_buttons = 0; if( Painter.Settings.Draw_buttons ) { // Узнаем, было ли определено состояние кнопок. BYTE Actions_are_detected = 0; FindProperty( Frame_window, PRP_ACTIONS, &Actions_are_detected ); // Если оно известно - кнопки можно рисовать. if( Actions_are_detected ) Draw_new_buttons = Painter_PermissionForButtonsDrawing( Frame_window ); } // Кнопки уменьшения и увеличения окна надо скрыть и сжать в "|". Кроме того, рамка // может содержать несколько кнопок слева и справа от заголовка, их надо передвинуть. BYTE Advanced_controls = 0; // Если надо рисовать рамку или заголовок: if( Target & WT_UNKNOWN || Target & WT_BORDER || Target & WT_TITLEBAR ) { // Передвигаем окна в заголовке и задаем подходящие цвета. if( TitleBar_window != NULLHANDLE || MinMax_window != NULLHANDLE ) if( Painter_PermissionForCompleteDrawing( Frame_window ) ) Advanced_controls = Painter_PrepareWindowControls( Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, TitleBar_window, SysMenu_window, MinMax_window ); // Если справа от заголовка были найдены дополнительные окна - запоминаем это. if( Advanced_controls ) SetProperty( Frame_window, PRP_CONTROLS, &Advanced_controls ); } // Рисуем новые кнопки в правом верхнем углу окна. if( Draw_new_buttons ) if( Target & WT_UNKNOWN || Target & WT_BORDER ) if( TitleBar_window != NULLHANDLE ) { for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawButtons( Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, TitleBar_window ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } } // Рисуем картинку в левом верхнем углу окна. if( Painter.Settings.Draw_system_menus ) if( Target & WT_UNKNOWN || Target & WT_SYSMENU ) if( SysMenu_window != NULLHANDLE ) { // Рисуем картинку. HPOINTER Icon = NULLHANDLE; FindProperty( Frame_window, PRP_ICON, &Icon ); for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawSystemMenu( SysMenu_window, Frame_window, &Frame_rectangle, &Frame_placement, Icon, Frame_type, 0 ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } // Если окно картинки закрывает рамку - перерисовываем ее. if( Frame_rectangle.xRight + 1 < TitleBar_height * 2 ) { for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawFrameRectangle( Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, Window_is_active ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } } } // Рисуем заголовок окна. if( Painter.Settings.Draw_titles ) if( Target & WT_UNKNOWN || Target & WT_TITLEBAR ) if( TitleBar_window != NULLHANDLE ) { // Рисуем заголовок. Только подчеркивать его объем нельзя - может получиться окно с незакрашенным заголовком и линиями по краям. CHAR Title[ SIZE_OF_TITLE ] = ""; FindProperty( Frame_window, PRP_TITLE, Title ); for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawTitleBar( TitleBar_window, Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, Title, Window_is_active, Advanced_controls ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } } // Возврат. return; }
static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { vout_display_t * vd = WinQueryWindowPtr( hwnd, 0 ); MRESULT result = ( MRESULT )TRUE; if ( !vd ) return WinDefWindowProc( hwnd, msg, mp1, mp2 ); vout_display_sys_t * sys = vd->sys; RECTL rcl; SWP swp; if ( sys->is_mouse_hidden && ((msg >= WM_MOUSEFIRST && msg <= WM_MOUSELAST) || (msg >= WM_EXTMOUSEFIRST && msg <= WM_EXTMOUSELAST) || msg == WM_MOUSELEAVE)) { WinShowPointer(HWND_DESKTOP, TRUE); sys->is_mouse_hidden = false; } switch( msg ) { /* the user wants to close the window */ case WM_CLOSE: vout_display_SendEventClose(vd); result = 0; break; case WM_MOUSEMOVE : { SHORT i_mouse_x = SHORT1FROMMP( mp1 ); SHORT i_mouse_y = SHORT2FROMMP( mp1 ); RECTL movie_rect; int i_movie_width, i_movie_height; int i_src_width, i_src_height; /* Get a current movie area */ kvaAdjustDstRect( &sys->kvas.rclSrcRect, &movie_rect ); i_movie_width = movie_rect.xRight - movie_rect.xLeft; i_movie_height = movie_rect.yTop - movie_rect.yBottom; i_src_width = sys->kvas.rclSrcRect.xRight - sys->kvas.rclSrcRect.xLeft; i_src_height = sys->kvas.rclSrcRect.yBottom - sys->kvas.rclSrcRect.yTop; int x = ( i_mouse_x - movie_rect.xLeft ) * i_src_width / i_movie_width + sys->kvas.rclSrcRect.xLeft; int y = ( i_mouse_y - movie_rect.yBottom ) * i_src_height / i_movie_height; /* Invert Y coordinate and add y offset */ y = ( i_src_height - y ) + sys->kvas.rclSrcRect.yTop;; vout_display_SendEventMouseMoved(vd, x, y); result = WinDefWindowProc( hwnd, msg, mp1,mp2 ); break; } case WM_BUTTON1DOWN : MousePressed( vd, hwnd, MOUSE_BUTTON_LEFT ); break; case WM_BUTTON2DOWN : MousePressed( vd, hwnd, MOUSE_BUTTON_RIGHT ); break; case WM_BUTTON3DOWN : MousePressed( vd, hwnd, MOUSE_BUTTON_CENTER ); break; case WM_BUTTON1UP : MouseReleased( vd, MOUSE_BUTTON_LEFT ); break; case WM_BUTTON2UP : MouseReleased( vd, MOUSE_BUTTON_RIGHT ); break; case WM_BUTTON3UP : MouseReleased( vd, MOUSE_BUTTON_CENTER ); break; case WM_BUTTON1DBLCLK : vout_display_SendEventMouseDoubleClick(vd); break; case WM_TRANSLATEACCEL : /* We have no accelerator table at all */ result = ( MRESULT )FALSE; break; case WM_CHAR : { USHORT i_flags = SHORT1FROMMP( mp1 ); USHORT i_ch = SHORT1FROMMP( mp2 ); USHORT i_vk = SHORT2FROMMP( mp2 ); int i_key = 0; /* If embedded window, let the parent process keys */ if( sys->parent_window ) { WinPostMsg( sys->parent, msg, mp1, mp2 ); break; } if( !( i_flags & KC_KEYUP )) { if( i_flags & KC_VIRTUALKEY ) /* convert the key if possible */ i_key = ConvertKey( i_vk ); else if(( i_flags & KC_CHAR ) && !HIBYTE( i_ch )) i_key = tolower( i_ch ); if( i_key ) { if( i_flags & KC_SHIFT ) i_key |= KEY_MODIFIER_SHIFT; if( i_flags & KC_CTRL ) i_key |= KEY_MODIFIER_CTRL; if( i_flags & KC_ALT ) i_key |= KEY_MODIFIER_ALT; vout_display_SendEventKey(vd, i_key); } } break; } /* Process Manage() call */ case WM_VLC_MANAGE : break; /* Fullscreen change */ case WM_VLC_FULLSCREEN_CHANGE : if( LONGFROMMP( mp1 )) { WinQueryWindowPos( sys->frame, &swp ); sys->client_rect.xLeft = swp.x; sys->client_rect.yBottom = swp.y; sys->client_rect.xRight = sys->client_rect.xLeft + swp.cx; sys->client_rect.yTop = sys->client_rect.yBottom + swp.cy; WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE ); rcl.xLeft = 0; rcl.yBottom = 0; rcl.xRight = sys->i_screen_width; rcl.yTop = sys->i_screen_height; } else rcl = sys->client_rect; WinCalcFrameRect( sys->frame, &rcl, FALSE ); WinSetWindowPos( sys->frame, HWND_TOP, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW | SWP_ACTIVATE ); break; /* Size change */ case WM_VLC_SIZE_CHANGE : rcl.xLeft = 0; rcl.yBottom = 0; rcl.xRight = LONGFROMMP( mp1 ); rcl.yTop = LONGFROMMP( mp2 ); WinCalcFrameRect( sys->frame, &rcl, FALSE ); WinSetWindowPos( sys->frame, NULLHANDLE, 0, 0, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_SIZE ); WinQueryWindowPos( sys->frame, &swp ); sys->client_rect.xLeft = swp.x; sys->client_rect.yBottom = swp.y; sys->client_rect.xRight = sys->client_rect.xLeft + swp.cx; sys->client_rect.yTop = sys->client_rect.yBottom + swp.cy; WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE ); break; default : return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } /* If embedded window, we need to change our window size according to a * parent window size */ if( sys->parent_window ) { WinQueryWindowRect( sys->parent, &rcl ); if( rcl.xLeft != sys->parent_rect.xLeft || rcl.yBottom != sys->parent_rect.yBottom || rcl.xRight != sys->parent_rect.xRight || rcl.yTop != sys->parent_rect.yTop) { sys->parent_rect = rcl; WinCalcFrameRect( sys->frame, &rcl, FALSE ); WinSetWindowPos( sys->frame, NULLHANDLE, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_SIZE | SWP_MOVE ); } } return result; }
MRESULT EXPENTRY fnConfigDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { HWND hwndOwner; SWP swpDlg, swpOwner; POINTL ptlTemp; ConfigDlgInitParams_p pCfgDlgInit; switch (msg) { case WM_INITDLG: // Store window instance data pointer in window words WinSetWindowULong(hwnd, QWL_USER, (ULONG) mp2); pCfgDlgInit = (ConfigDlgInitParams_p) mp2; // Set dialog control texts and fonts based on // current language internal_SetPageFont(hwnd); internal_SetConfigDialogText(hwnd, pCfgDlgInit->pchHomeDirectory); // Set initial position of dialog window and show it WinQueryWindowPos(hwnd, &swpDlg); hwndOwner = WinQueryWindow(hwnd, QW_OWNER); WinQueryWindowPos(hwndOwner, &swpOwner); ptlTemp.x = swpOwner.x; ptlTemp.y = swpOwner.y; WinMapWindowPoints(WinQueryWindow(hwndOwner, QW_PARENT), HWND_DESKTOP, &ptlTemp, 1); WinSetWindowPos(hwnd, HWND_TOP, ptlTemp.x + (swpOwner.cx - swpDlg.cx)/2, ptlTemp.y + (swpOwner.cy - swpDlg.cy)/2, 0, 0, SWP_MOVE | SWP_SHOW); //setup the dialog WinSendDlgItemMsg(hwnd, EF_TEXT, EM_SETTEXTLIMIT, MPFROMSHORT(256), NULL); WinSetWindowText(WinWindowFromID(hwnd, EF_TEXT), pCfgDlgInit->pchText); internal_AdjustConfigDialogControls(hwnd); return (MRESULT) FALSE; case WM_COMMAND: switch (SHORT1FROMMP(mp1)) { case PB_CONFOK: pCfgDlgInit = (ConfigDlgInitParams_p) WinQueryWindowULong(hwnd, QWL_USER); if (pCfgDlgInit) { char buff[255]; buff[0]= '\0'; WinQueryWindowText(WinWindowFromID(hwnd, EF_TEXT), 248, &buff); strcpy(pCfgDlgInit->pchText, buff); /*AddLog(buff); AddLog(pCfgDlgInit->pchText);*/ } break; case PB_CONFCANCEL: // restore the old image pCfgDlgInit = (ConfigDlgInitParams_p) WinQueryWindowULong(hwnd, QWL_USER); if (pCfgDlgInit) { } break; } break; default: break; } return WinDefDlgProc(hwnd, msg, mp1, mp2); }
void FAR wndThread(void FAR *pData) { PGROPDATA pGrop = (PGROPDATA)pData; PTIB tib; PPIB pib; ULONG ulFrameFlags; QMSG qmsg; SWP swp; PVIDEOSYS pVideoSys = aVideoSys[pGrop->ulVideoSysIdx]; // Change process type code for use Win* API from VIO session DosGetInfoBlocks( &tib, &pib ); if ( pib->pib_ultype == 2 || pib->pib_ultype == 0 ) { // VIO windowable or fullscreen protect-mode session. pib->pib_ultype = 3; // Presentation Manager protect-mode session. // ...and switch to the desktop (if we are in fullscreen now)? } // Select output video system. if ( (pGrop->ulVideoSysIdx < VIDEOSYSNUM) && pVideoSys->fnInit( &pGrop->stModes, &pGrop->pVSData ) ) { debug( "Requested video system %u initialized.", pGrop->ulVideoSysIdx ); pGrop->pVideoSys = pVideoSys; } else { ULONG ulIdx; debug( "Requested video system was not initialized. Try others..." ); pGrop->pVideoSys = NULL; for( ulIdx = 0; ulIdx < VIDEOSYSNUM; ulIdx++ ) { if ( pGrop->ulVideoSysIdx == ulIdx ) // Ignore video system requested by the user (already verifed). continue; pVideoSys = aVideoSys[ulIdx]; if ( pVideoSys->fnInit( &pGrop->stModes, &pGrop->pVSData ) ) { debug( "Video system %u initialized.", ulIdx ); pGrop->pVideoSys = pVideoSys; pGrop->ulVideoSysIdx = ulIdx; break; } } } // if ( (pGrop->ulVideoSysIdx < VIDEOSYSNUM) && pVideoSys->fnInit() ) else if ( pGrop->pVideoSys == NULL ) { debug( "Video system is not initialized." ); } else { // Output video system selected. // Prepare PM stuff. pGrop->hab = WinInitialize( 0 ); pGrop->hmq = WinCreateMsgQueue( pGrop->hab, 0 ); pGrop->hwndDT = WinQueryDesktopWindow( WinQueryAnchorBlock( HWND_DESKTOP ), 0 ); pGrop->hdcDT = WinQueryWindowDC( pGrop->hwndDT ); WinQueryWindowPos( pGrop->hwndDT, &swp ); pGrop->ulDTWidth = swp.cx; pGrop->ulDTHeight = swp.cy; pGrop->ulModeIdx = ~0; // ~0 - Mode is not selected yet. pGrop->hptrPointer = WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE ); WinRegisterClass( pGrop->hab, WIN_CLIENT_CLASS, wndProc, CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT, sizeof(PGROPDATA) ); // Create the window. ulFrameFlags = FCF_TASKLIST | FCF_DLGBORDER | FCF_TITLEBAR | FCF_SYSMENU | FCF_MINBUTTON | FCF_SHELLPOSITION | FCF_SIZEBORDER | FCF_MINBUTTON | FCF_MAXBUTTON; pGrop->hwndFrame = WinCreateStdWindow( HWND_DESKTOP, 0, &ulFrameFlags, WIN_CLIENT_CLASS, "grop", 0, 0, 1, &pGrop->hwnd ); if ( pGrop->hwndFrame == NULLHANDLE ) { debug( "WinCreateStdWindow() failed" ); } else { WinSetWindowULong( pGrop->hwnd, 0, (ULONG)pGrop ); // Subclass frame window to control size changes. pGrop->fnOldFrameWinProc = WinSubclassWindow( pGrop->hwndFrame, wndFrameProc ); WinSetVisibleRegionNotify( pGrop->hwnd, TRUE ); if ( DosCreateMutexSem( NULL, &pGrop->hmtxData, 0, FALSE ) != NO_ERROR ) debug( "DosCreateMutexSem() failed" ); else { ULONG ulRC; ulRC = DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, 31, 0 ); if ( ulRC != NO_ERROR ) debug( "DosSetPriority(), rc = %u", ulRC ); ulRC = DosPostEventSem( pGrop->hevReady ); // Ready to work. if ( ulRC != NO_ERROR ) debug( "DosPostEventSem(), rc = %u", ulRC ); while( TRUE ) { // Work... while( WinGetMsg( pGrop->hab, &qmsg, (HWND)NULLHANDLE, 0L, 0L ) ) { ulRC = DosRequestMutexSem( pGrop->hmtxData, 500 ); if ( ulRC != NO_ERROR ) debug( "DosRequestMutexSem(), rc = ", ulRC ); WinDispatchMsg( pGrop->hab, &qmsg ); DosReleaseMutexSem( pGrop->hmtxData ); } if ( pGrop->stCallback.fnQuit == NULL ) break; debug( "Call stCallback.fnQuit()" ); pGrop->stCallback.fnQuit( pGrop ); } // Return to the desktop if we are in fullscreen. debug( "Fullscreen: %u", pGrop->fFullscreen ); if ( pGrop->fFullscreen ) { PVIDEOMODE pMode = &pGrop->stModes.pList[pGrop->stModes.ulDesktopMode]; debug( "Return to the desktop..." ); pGrop->pVideoSys->fnSetMode( pGrop->pVSData, pMode, FALSE, pGrop->hwndDT, pGrop->hdcDT ); debug( "Returned to the desktop" ); } DosCloseMutexSem( pGrop->hmtxData ); } debug( "Destroy window" ); if ( !WinDestroyWindow( pGrop->hwnd ) ) debug( "WinDestroyWindow() failed" ); pGrop->hwnd = NULLHANDLE; pGrop->hwndFrame = NULLHANDLE; } // Destroy PM stuff. debug( "WinDestroyMsgQueue()..." ); WinDestroyMsgQueue( pGrop->hmq ); debug( "WinTerminate()..." ); WinTerminate( pGrop->hab ); pGrop->hwndFrame = NULLHANDLE; pGrop->hwnd = NULLHANDLE; // Destroy output video system. if ( pGrop->stUserMode.pBuffer != NULL ) { debug( "Free video system's buffer" ); pGrop->pVideoSys->fnVideoBufFree( pGrop->pVSData, pGrop->stUserMode.pBuffer ); pGrop->stUserMode.pBuffer = NULL; } debug( "Close video system" ); pGrop->pVideoSys->fnDone( pGrop->pVSData, &pGrop->stModes ); pGrop->pVideoSys = NULL; } // if ( pGrop->pVideoSys == NULL ) else pGrop->tid = ((TID)(-1)); debug( "Post semaphore..." ); DosPostEventSem( pGrop->hevReady ); // Finalized. debug( "Exit thread." ); _endthread(); }
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 ); }
/* QWL_USER+8 - reserved for text */ MRESULT EXPENTRY TestWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { PMYCDATA pCData = (PMYCDATA)WinQueryWindowULong(hwnd, QWL_USER+4); PSZ pszText = (PSZ)WinQueryWindowULong(hwnd, QWL_USER+8); PMYCDATA pCreate; PCREATESTRUCT pCreateStruct; switch (msg) { /* we are creating our control */ case WM_CREATE: /* if data was passed in */ if (pCreate=(PMYCDATA)PVOIDFROMMP(mp1)) { /* allocate memory for the control data */ DosAllocMem((PPVOID) &pCData, (ULONG) pCreate->cb, PAG_COMMIT|PAG_READ | PAG_WRITE); /* copy the data that is passed in */ memcpy((PBYTE)pCData, (PBYTE) pCreate, pCreate->cb); /* save the control data pointer */ WinSetWindowULong(hwnd, QWL_USER+4, (ULONG)pCData); } /* endif */ /* allocate memory for the text */ DosAllocMem((PPVOID) &pszText, (ULONG) MAXTEXTLENGTH+1, PAG_COMMIT|PAG_READ | PAG_WRITE); /* save the text pointer */ WinSetWindowULong(hwnd, QWL_USER+8, (ULONG)pszText); /* initialize to a NULL string */ strcpy(pszText,""); pCreateStruct=(PCREATESTRUCT)mp2; if (pCreateStruct) { /* copy the text into the buffer provided */ strncpy(pszText, pCreateStruct->pszText, MAXTEXTLENGTH); /* NULL terminate the string */ pszText[MAXTEXTLENGTH]=0; } break; case WM_QUERYWINDOWPARAMS: { PWNDPARAMS pWndParams = (PWNDPARAMS)PVOIDFROMMP(mp1); MRESULT mr; /* call the default window proc first so that presentation /* parameters are handled */ mr = WinDefWindowProc( hwnd, msg, mp1, mp2 ); if (pWndParams) { if (pCData) { if (pWndParams->fsStatus & WPM_CBCTLDATA) { pWndParams->cbCtlData = pCData->cb; mr=(MRESULT)TRUE; } /* endif */ if (pWndParams->fsStatus & WPM_CTLDATA) { pWndParams->cbCtlData = pCData->cb; memcpy((PBYTE)pWndParams->pCtlData, (PBYTE)pCData, pCData->cb); mr=(MRESULT)TRUE; } /* endif */ } /* endif */ /* responding to WinQueryWindowTextLength */ if (pWndParams->fsStatus & WPM_CCHTEXT) { pWndParams->cchText = strlen(pszText); mr=(MRESULT)TRUE; } /* endif */ /* responding to WinQueryWindowText */ if (pWndParams->fsStatus & WPM_TEXT) { /* copy the text into the buffer provided */ strncpy(pWndParams->pszText, pszText, pWndParams->cchText); /* NULL terminate the string */ pWndParams->pszText[pWndParams->cchText]=0; mr=(MRESULT)TRUE; } /* endif */ } /* endif */ return mr; } break; case WM_SETWINDOWPARAMS: { PWNDPARAMS pWndParams = (PWNDPARAMS)PVOIDFROMMP(mp1); MRESULT mr; mr = WinDefWindowProc( hwnd, msg, mp1, mp2 ); if (pWndParams) { if (pWndParams->fsStatus & WPM_CTLDATA) { if (pCData) { DosFreeMem(pCData); } /* endif */ DosAllocMem((PPVOID) &(pCData), (ULONG) pWndParams->cbCtlData, PAG_COMMIT|PAG_READ | PAG_WRITE); WinSetWindowULong(hwnd, QWL_USER+4, (ULONG)pCData); memcpy((PBYTE)pCData, (PBYTE)pWndParams->pCtlData, pWndParams->cbCtlData); WinInvalidateRect(hwnd, 0, 0); mr=(MRESULT)TRUE; } /* endif */ /* responding to WinQueryWindowText */ if (pWndParams->fsStatus & WPM_TEXT) { /* copy the text into the buffer provided */ strncpy(pszText, pWndParams->pszText, MAXTEXTLENGTH); /* NULL terminate the string */ pszText[MAXTEXTLENGTH]=0; WinInvalidateRect(hwnd, 0, 0); mr=(MRESULT)TRUE; } /* endif */ } /* endif */ return mr; } break; case WM_PAINT: { HPS hps; RECTL rectlPaint; ULONG lTextColor, lBackColor; ULONG ulPPIndex; SWP swp; POINTL ptlPoint; WinQueryWindowPos(hwnd,&swp); hps=WinBeginPaint(hwnd, 0, &rectlPaint); /* put PS into RGB color mode */ GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0 ); if (!WinQueryPresParam(hwnd,PP_BACKGROUNDCOLOR,0,&ulPPIndex, sizeof(LONG),&lBackColor,QPF_NOINHERIT)) { lBackColor=WinQuerySysColor(HWND_DESKTOP,SYSCLR_WINDOW, 0); } /* endif */ if (!WinQueryPresParam(hwnd,PP_FOREGROUNDCOLOR,0,&ulPPIndex, sizeof(LONG),&lTextColor,QPF_NOINHERIT)) { lTextColor=WinQuerySysColor(HWND_DESKTOP,SYSCLR_ICONTEXT, 0); } /* endif */ WinFillRect(hps, &rectlPaint, lBackColor); ptlPoint.x=0; ptlPoint.y=0; GpiMove(hps,&ptlPoint); ptlPoint.x=swp.cx-1; ptlPoint.y=swp.cy-1; GpiBox(hps,DRO_OUTLINE,&ptlPoint,0,0); /* draw your control and its text here */ ptlPoint.x=0; ptlPoint.y=0; GpiSetCharAngle(hps,&pCData->gradient); GpiSetCharMode(hps,CM_MODE3); GpiSetColor(hps,lTextColor); GpiSetDrawControl(hps,DCTL_DISPLAY,DCTL_OFF); GpiSetDrawControl(hps,DCTL_BOUNDARY,DCTL_ON); GpiCharStringAt(hps, &ptlPoint,strlen(pszText),pszText); GpiQueryBoundaryData(hps,&rectlPaint); GpiSetDrawControl(hps,DCTL_DISPLAY,DCTL_ON); GpiSetDrawControl(hps,DCTL_BOUNDARY,DCTL_OFF); ptlPoint.x=-rectlPaint.xLeft; ptlPoint.y=-rectlPaint.yBottom; GpiCharStringAt(hps, &ptlPoint,strlen(pszText),pszText); WinEndPaint(hps); } break; case WM_DESTROY: if (pCData) DosFreeMem(pCData); if (pszText) DosFreeMem(pszText); break; case WM_PRESPARAMCHANGED: WinInvalidateRect(hwnd,0,FALSE); break; default: return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } /* endswitch */ return (MRESULT) FALSE; }
MRESULT EXPENTRY PC2_SpoolerWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static CNRINFO CnrInfo; /* Container info structure */ static PFIELDINFO pFieldInfo; static PFIELDINFO pFieldInfoFirst; switch(msg) { case WM_CREATE: /* *\ * During spooler window creation, create a container class window as the child of the * * client area. Initialize the columns for the details view, the spooler container * * window will use. Then set the container info structure to details view with a * * splitbar. \* */ { ULONG ulColumn; PFIELDINFO pFieldInfoSplitbar; /* Pointer to a the FIELDINFO structure of the 4th column to set splitbar afterwards */ FIELDINFOINSERT FieldInfoInsert; /* Control structure for column insertation */ /* Create the container to fill in spooler queue and job data in details view. */ pHP->hwndSpoolerContainer=WinCreateWindow(hwnd, WC_CONTAINER, "", WS_VISIBLE | CCS_READONLY | CCS_MINIRECORDCORE | CCS_MULTIPLESEL, 0, 0, 0, 0, hwnd, HWND_TOP, ID_PC2SPOOLERCONTAINER, NULL, NULL); /* Set presentation parameters saved */ WinSetPresParam(pHP->hwndSpoolerContainer, PP_FONTNAMESIZE, sizeof(pHP->ucPC2SpoolerFont), pHP->ucPC2SpoolerFont); /* Subclass container window to get hold of presentation parameter changes */ pfnContainerWindowProc=WinSubclassWindow(pHP->hwndSpoolerContainer, SubclassedContainerWindowProc); /* Create fieldinfos for the columns in details view */ pFieldInfo=(PFIELDINFO)WinSendMsg(pHP->hwndSpoolerContainer, CM_ALLOCDETAILFIELDINFO, MPFROMSHORT(sizeof(ContainerFieldInfo)/sizeof(ContainerFieldInfo[0])), NULL); /* Fill the columns avaiable into container */ pFieldInfoFirst=pFieldInfo; pFieldInfoSplitbar=NULL; for(ulColumn=0; ulColumn<(sizeof(ContainerFieldInfo)/sizeof(ContainerFieldInfo[0])); ulColumn++) { /* Save 4th column to set splitbar afterwards */ if(ulColumn==3) pFieldInfoSplitbar=pFieldInfo; pFieldInfo->flTitle=ContainerFieldInfo[ulColumn].flTitle; pFieldInfo->pTitleData=strdup(ContainerFieldInfo[ulColumn].pTitleData); pFieldInfo->flData=ContainerFieldInfo[ulColumn].flData; pFieldInfo->offStruct=ContainerFieldInfo[ulColumn].offStruct; pFieldInfo=pFieldInfo->pNextFieldInfo; } /* Fill column insertation control */ FieldInfoInsert.cb=sizeof(FieldInfoInsert); /* Insert from first column */ FieldInfoInsert.pFieldInfoOrder=(PFIELDINFO)CMA_FIRST; /* Update container display now */ FieldInfoInsert.fInvalidateFieldInfo=(ULONG)TRUE; /* Number of columns to insert */ FieldInfoInsert.cFieldInfoInsert=sizeof(ContainerFieldInfo)/sizeof(ContainerFieldInfo[0]); /* Insert column field info into container */ WinSendMsg(pHP->hwndSpoolerContainer, CM_INSERTDETAILFIELDINFO, MPFROMP(pFieldInfoFirst), MPFROMP(&FieldInfoInsert)); /* Select details view */ CnrInfo.flWindowAttr=CV_DETAIL | CA_DETAILSVIEWTITLES; /* Splitbar is set to last saved position */ CnrInfo.xVertSplitbar=pHP->lSplitbarPosition; /* Splitbar occurs after the 4th column */ CnrInfo.pFieldInfoLast=pFieldInfoSplitbar; /* Setup CNRINFO into container */ WinSendMsg(pHP->hwndSpoolerContainer, CM_SETCNRINFO, MPFROMP(&CnrInfo), MPFROMLONG(CMA_FLWINDOWATTR|CMA_XVERTSPLITBAR|CMA_PFIELDINFOLAST)); RefreshSpooler(); /* Fill spooler container from queue data */ WinSetFocus(HWND_DESKTOP, pHP->hwndSpoolerContainer); } break; case WM_PAINT: { HPS hpsClient; /* Get a cached presentation space */ hpsClient=WinBeginPaint(hwnd, NULLHANDLE, NULL); WinEndPaint(hpsClient); } break; case WM_SIZE: case WM_MOVE: /* *\ * During sizing (and moving) of the spooler window, ensure that the container always * * fills the complete client area. * \* */ { LONG lXBorder=WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER); LONG lYBorder=WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER); SWP swpPC2Spooler; RECTL rectlClient; SWP swp; /* Get the frame area size */ WinQueryWindowPos(pHP->hwndSpoolerFrame, &swpPC2Spooler); if((swpPC2Spooler.cx>pHP->DesktopSize.x) || (pHP->swpPC2Spooler.cx<0)) pHP->swpPC2Spooler.cx=pHP->DesktopSize.x/2; else pHP->swpPC2Spooler.cx=swpPC2Spooler.cx; if((swpPC2Spooler.cy>pHP->DesktopSize.y) || (pHP->swpPC2Spooler.cy<0)) pHP->swpPC2Spooler.cy=pHP->DesktopSize.y/5; else pHP->swpPC2Spooler.cy=swpPC2Spooler.cy; if((swpPC2Spooler.x<(0-lXBorder)) || ((swpPC2Spooler.x+pHP->swpPC2Spooler.cx)>(pHP->DesktopSize.x+lXBorder))) pHP->swpPC2Spooler.x=0; else pHP->swpPC2Spooler.x=swpPC2Spooler.x; if((swpPC2Spooler.y<(0-lYBorder)) || ((swpPC2Spooler.y+pHP->swpPC2Spooler.cy)>(pHP->DesktopSize.y+lYBorder))) pHP->swpPC2Spooler.y=0; else pHP->swpPC2Spooler.y=swpPC2Spooler.y; WinSetWindowPos(pHP->hwndSpoolerFrame, NULLHANDLE, pHP->swpPC2Spooler.x, pHP->swpPC2Spooler.y, pHP->swpPC2Spooler.cx, pHP->swpPC2Spooler.cy, SWP_SIZE | SWP_MOVE); /* Size container to client area */ WinQueryWindowRect(hwnd, &rectlClient); swp.fl=SWP_MOVE|SWP_SIZE|SWP_SHOW|SWP_ZORDER; swp.x=swp.y=0; swp.cx=rectlClient.xRight; swp.cy=rectlClient.yTop; swp.hwndInsertBehind=HWND_TOP; swp.hwnd=pHP->hwndSpoolerContainer; WinSetMultWindowPos(pHP->habPc2, &swp, 1); } break; /* *\ * Syntax: WM_SHOWSPOOLER, NULL, NULL * \* */ case WM_SHOWSPOOLER: /* *\ * The spooler window is initially created invisible. When the user selects the * * menuentry PC2 Spooler, this message is posted to set the spooler window visible. * \* */ { SWP swp; swp.fl=SWP_SHOW|SWP_ACTIVATE|SWP_ZORDER; swp.x=pHP->swpPC2Spooler.x; swp.y=pHP->swpPC2Spooler.y; swp.cx=pHP->swpPC2Spooler.cx; swp.cy=pHP->swpPC2Spooler.cy; swp.hwndInsertBehind=HWND_TOP; swp.hwnd=pHP->hwndSpoolerFrame; WinSetMultWindowPos(pHP->habPc2, &swp, 1); } break; /* *\ * Syntax: WM_REFRESHSPOOLER, NULL, NULL * \* */ case WM_REFRESHSPOOLER: /* *\ * The spooler container regularily gets this message from a timer to update the * * container with the current printer queue data, to have a real-time status of the * * printer queue. * \* */ RefreshSpooler(); break; case WM_CONTROL: /* *\ * The child window of the client area sends its notification messages to its parent, * * so the client window procedure can expext container notification messages. * \* */ switch(SHORT2FROMMP(mp1)) { case CN_CONTEXTMENU: { SPOOLERRECORD *pListSpoolerRecord; POINTL ptlMouse; /* Mouse position during creation of notification */ USHORT fsOptions=PU_NONE | PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_HCONSTRAIN | PU_VCONSTRAIN; /* Query selected records in container and return them, or return the one below the mouse pointer if none is selected. */ pListSpoolerRecord=QuerySelectedRecords((SPOOLERRECORD *)mp2); if(pListSpoolerRecord==NULL) pHP->pSpoolerObject=NULL; else pHP->pSpoolerObject=pListSpoolerRecord->pSpoolerObject; /* Get the mouse position */ WinQueryMsgPos(pHP->habPc2, &ptlMouse); WinPopupMenu(HWND_DESKTOP, hwnd, hwndSpoolerPopupMenu, ptlMouse.x, ptlMouse.y, 0, fsOptions); } break; } break; case WM_HELP: /* Help pressed */ WinSendMsg(pHP->hwndHelp, HM_DISPLAY_HELP, MPFROMSHORT(ID_PC2SPOOLERWINDOW), HM_RESOURCEID); break; case WM_COMMAND: /* *\ * Process the messages generated by the menuentries of the spooler container popup * * menu. * \* */ switch(SHORT1FROMMP(mp1)) { case ID_SPOOLERREFRESH: /* User requested to refresh the spooler container window with the status of the actual spooler queue */ RefreshSpooler(); break; case ID_SPOOLERHOLDJOB: /* The user selected to hold a job */ case ID_SPOOLERRELEASEJOB: /* The user selected to release a job */ case ID_SPOOLERDELETEJOB: /* The user selected to delete a job */ case ID_SPOOLERHOLDQUEUE: /* The user selected to hold a queue */ case ID_SPOOLERRELEASEQUEUE: /* The user selected to release a queue */ /* Perform the action on linked list of selected records */ NotifySelectedRecords((ULONG)SHORT1FROMMP(mp1)); break; case ID_SPOOLERHELP: /* The user requested some help */ WinPostMsg(hwnd, WM_HELP, MPFROMLONG(ID_PC2SPOOLERWINDOW), MPFROM2SHORT(CMDSRC_MENU, TRUE)); break; } break; case WM_DESTROY: /* *\ * Clear container structures and free control structures used by PC/2. * \* */ { SPOOLERRECORD *pSpoolerRecord; /* Query the actual container info structure */ WinSendMsg(pHP->hwndSpoolerContainer, CM_QUERYCNRINFO, MPFROMP(&CnrInfo), MPFROMSHORT(sizeof(CnrInfo))); pHP->lSplitbarPosition=CnrInfo.xVertSplitbar; /* Prevent unnecessary container drawing */ WinEnableWindowUpdate(pHP->hwndSpoolerContainer, FALSE); /* Get first container record to delete them sequentially */ pSpoolerRecord=(SPOOLERRECORD *)WinSendMsg(pHP->hwndSpoolerContainer, CM_QUERYRECORD, NULL, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); while(pSpoolerRecord) { /* Delete and free records */ free(pSpoolerRecord->pszQueue); free(pSpoolerRecord->pszQueueStatus); free(pSpoolerRecord->pszQueueComment); free(pSpoolerRecord->pszQueueDriver); free(pSpoolerRecord->pszJob); free(pSpoolerRecord->pszJobNumber); free(pSpoolerRecord->pszJobStatus); free(pSpoolerRecord->pszJobComment); free(pSpoolerRecord->pSpoolerObject); /* Delete record in container. Warning! as this function expects an array, but we only delete one record, we have to get the address of the pointer to the record. */ WinSendMsg(pHP->hwndSpoolerContainer, CM_REMOVERECORD, MPFROMP(&pSpoolerRecord), MPFROM2SHORT(1, CMA_FREE|CMA_INVALIDATE)); /* Get next container record to delete them sequentially */ pSpoolerRecord=(SPOOLERRECORD *)WinSendMsg(pHP->hwndSpoolerContainer, CM_QUERYRECORD, NULL, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); } } break; default: /* Default window procedure must be called */ return((MRESULT)WinDefWindowProc(hwnd, msg, mp1, mp2)); } return((MRESULT)FALSE); /* We have handled the message */ }
// ------------------------------------------------------------------------- MRESULT EXPENTRY ClientWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { #define DB_RAISED 0x0400 #define DB_DEPRESSED 0x0800 switch (msg) { case WM_CREATE: break; case WM_CONTROL: if ( SHORT1FROMMP(mp1) == FID_MENU ){ if ( SHORT2FROMMP(mp1) == UCN_ITEMSELECTED ){ PUCMITEM pucmi = (PUCMITEM)mp2; if (pucmi) { HWND hwndOwner = OWNERWND(hwnd); WinSendMsg( hwndOwner, WM_COMMAND, MPFROMSHORT(pucmi->usId), MPFROMSHORT(CMDSRC_MENU) ); } } } break; case WM_PAINT: { RECTL rcl; HPS hPS = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)0 ); WinQueryWindowRect( hwnd, &rcl ); rcl.yBottom = rcl.yTop - 8; GpiErase( hPS ); WinDrawBorder( hPS, &rcl, 2, 2, CLR_DARKGRAY, CLR_PALEGRAY, DB_RAISED ); WinEndPaint( hPS ); } break; case WM_BUTTON1DOWN : case WM_BUTTON2DOWN : { TRACKINFO track; SWP swp; RECTL rclOld; HWND hwndMenu = WinWindowFromID(hwnd, ID_TOOLS); WinSetWindowPos( hwndMenu, HWND_TOP, 0, 0, 0, 0, SWP_MOVE ); RECTL rcl; WinQueryWindowRect( hwnd, &rcl ); rcl.yBottom = rcl.yTop - 8; HPS hps = WinGetPS( hwnd ); WinDrawBorder( hps, &rcl, 2, 2, CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED ); WinReleasePS( hps ); #define BORDER 2 track.cxBorder = track.cyBorder = BORDER; track.cxGrid = track.cyGrid = 1; track.cxKeyboard = track.cyKeyboard = 4; WinQueryWindowPos( hwnd, &swp ); rclOld.xLeft = swp.x - BORDER; rclOld.yBottom = swp.y - BORDER; rclOld.xRight = swp.x + swp.cx + BORDER; rclOld.yTop = swp.y + swp.cy + BORDER; track.rclTrack = rclOld; WinQueryWindowRect( PARENTWND(hwnd), &track.rclBoundary ); track.ptlMinTrackSize.x = track.ptlMinTrackSize.y = 1; //2*BOXLET_SIZE; track.ptlMaxTrackSize = *(PPOINTL)&track.rclBoundary.xRight; track.fs = TF_MOVE; if ( WinTrackRect( PARENTWND(hwnd), NULLHANDLE, &track) ) WinSetWindowPos( hwnd, HWND_TOP, track.rclTrack.xLeft+BORDER, track.rclTrack.yBottom+BORDER, 0, 0, SWP_MOVE ); WinInvalidateRect(hwnd, &rcl, TRUE); } break; default: return(WinDefWindowProc(hwnd, msg, mp1, mp2)); } return 0; }
static void internal_ArrangePwdProtWindowControls(HWND hwnd) { SWP swpWindow; ULONG CXDLGFRAME = WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME); ULONG CYDLGFRAME = WinQuerySysValue(HWND_DESKTOP, SV_CYDLGFRAME); ULONG CYTITLEBAR = WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR); int iCX, iCY; // Control size int iMaxBtnCX, iBtnCY; // Arrange password protection window controls, and // set window size so it will look nice! // First get the sizes of texts inside buttons iMaxBtnCX = 0; internal_GetStaticTextSize(hwnd, PB_OK, &iCX, &iCY); if (iMaxBtnCX<iCX) iMaxBtnCX = iCX; internal_GetStaticTextSize(hwnd, PB_CANCEL, &iCX, &iCY); if (iMaxBtnCX<iCX) iMaxBtnCX = iCX; iBtnCY = iCY; // Now get size of pwd asking text! internal_GetStaticTextSize(hwnd, ST_PLEASEENTERTHEPASSWORD, &iCX, &iCY); // Oookay, now we know how big window we want! WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 6*CXDLGFRAME + iCX, CYDLGFRAME + CYTITLEBAR + 2*CYDLGFRAME + iCY + 2*CYDLGFRAME + (iBtnCY+CYDLGFRAME) + 2*CYDLGFRAME + (iBtnCY+4*CYDLGFRAME) + 2*CYDLGFRAME, SWP_SIZE); WinQueryWindowPos(hwnd, &swpWindow); // Set the two buttons in there WinSetWindowPos(WinWindowFromID(hwnd, PB_OK), HWND_TOP, 2*CXDLGFRAME, 2*CYDLGFRAME, 6*CXDLGFRAME + iMaxBtnCX, 3*CYDLGFRAME + iBtnCY, SWP_MOVE | SWP_SIZE); WinSetWindowPos(WinWindowFromID(hwnd, PB_CANCEL), HWND_TOP, swpWindow.cx - 2*CXDLGFRAME - (6*CXDLGFRAME + iMaxBtnCX), 2*CYDLGFRAME, 6*CXDLGFRAME + iMaxBtnCX, 3*CYDLGFRAME + iBtnCY, SWP_MOVE | SWP_SIZE); // Set the position of password entry field WinSetWindowPos(WinWindowFromID(hwnd, EF_PASSWORD), HWND_TOP, 3*CXDLGFRAME, 2*CYDLGFRAME + (3*CYDLGFRAME + iBtnCY) + 2*CYDLGFRAME, swpWindow.cx - 6*CXDLGFRAME, iBtnCY, SWP_MOVE | SWP_SIZE); // Set the position of password asking text WinSetWindowPos(WinWindowFromID(hwnd, ST_PLEASEENTERTHEPASSWORD), HWND_TOP, 3*CXDLGFRAME, swpWindow.cy - CYDLGFRAME - CYTITLEBAR - 2*CYDLGFRAME - iCY, iCX, iCY, SWP_MOVE | SWP_SIZE); }
int spawnve(int mode, const char *name, char * const argv[], char * const envp[]) { int i, j, l, n, prefix_len = 0; char *ext, *tmp, *arg1, *execname, *p_arg, *p_env, *prefix = NULL; char runtype, freeexec = 0, hswValid = 0, quoteargs = 1; ULONG appflags; const char * const *p; unsigned int runflags = 0; int retcode = -1; char errbuf[MAXNAMLEN + 1], queue[MAXNAMLEN + 1]; SWCNTRL swc; HSWITCH vioHSW; errno = ENOENT; /* EMX crashes on very long filenames... */ if (strlen (name) > MAXNAMLEN - 4) { errno = ENAMETOOLONG; return -1; } /* Find extension ordinal in exec_ext array */ ext = _getext2(name); for (i = 0; i < EXEC_EXT_COUNT; i++) { if (strcmp(ext, exec_ext[i]) == 0) goto found; } if (access(name, F_OK) == 0) errno = ENOEXEC; return -1; found: { PTIB tb; PPIB pb; /* Determine our session type */ if ((DosGetInfoBlocks(&tb, &pb) == NO_ERROR) && (vioHSW = WinQuerySwitchHandle(NULLHANDLE, pb->pib_ulpid)) && (WinQuerySwitchEntry(vioHSW, &swc) == NO_ERROR)) hswValid = 1; } switch (mode & 0xFF) { case P_WAIT: runflags |= spawn_WAIT; break; case P_PM: runflags |= spawn_SESSION | spawn_TYPE_PM; break; case P_OVERLAY: runflags |= spawn_WAIT | spawn_OVERLAY; break; case P_DETACH: runflags |= spawn_DETACH; break; } if (((runtype = exec_run[i]) == 0) && (DosQueryAppType((PSZ)name, &appflags) == NO_ERROR) && ((runflags & spawn_DETACH) == 0) && (hswValid)) { /* Compare to application type */ switch (appflags & 7) { case FAPPTYP_NOTSPEC: /* Methinks its a DOS proggy */ { if (appflags & FAPPTYP_DOS) if (swc.bProgType == PROG_FULLSCREEN) runflags |= (spawn_SESSION | spawn_TYPE_VDM); else runflags |= (spawn_SESSION | spawn_TYPE_WINDOWEDVDM); else runflags |= (spawn_SESSION | spawn_TYPE_DEFAULT); break; } case FAPPTYP_NOTWINDOWCOMPAT: { if (swc.bProgType != PROG_FULLSCREEN) runflags |= (spawn_SESSION | spawn_TYPE_FULLSCREEN); break; } case FAPPTYP_WINDOWCOMPAT: { /* That'll do it */ break; } case FAPPTYP_WINDOWAPI: { runflags |= (spawn_SESSION | spawn_TYPE_PM); break; } default: { runtype = 1; /* Let $COMSPEC decide what to do */ break; } } } fallback: switch (runtype) { case 0: directrun: if ((runflags & spawn_SESSION) && (((runflags & spawn_TYPE) == spawn_TYPE_VDM) || ((runflags & spawn_TYPE) == spawn_TYPE_WINDOWEDVDM))) { /* DOS command interpreter does not understand '/'s */ execname = savestring((char *)name); freeexec = 1; for (tmp = execname; *tmp; tmp++) if (*tmp == '/') *tmp = '\\'; } else execname = (char *)name; break; case 1: execname = get_string_value ("COMSPEC"); if (!execname) { internal_error("COMSPEC variable not defined"); errno = EACCES; return -1; } prefix_len = strlen(execname) + 1; prefix = alloca(prefix_len + 2 + 1 + strlen(name) + 1); strcpy(prefix, execname); emx_deunixify(prefix); strcpy((char *)&prefix[prefix_len - 1], " /c "); prefix_len += 2 + 1; strcpy((char *)&prefix[prefix_len], name); prefix_len += strlen(name) + 1; break; case 2: default: { /* We must define HAVE_HASH_BANG_EXEC since we`re processing #! here */ FILE *f; char line[MAXNAMLEN + 3]; line[0] = 0; if (!(f = fopen(name, "rt"))) { errno = ENOENT; return -1; }; fgets((char *)&line, sizeof(line), f); fclose(f); if (line[0] != '#') /* Try to run as regular executable */ goto directrun; if (line[1] != '!') { /* Run script using current shell */ strcpy((char *)&line, "#! "); strcat((char *)&line, shell_name); } n = strlen(line); while ((n > 0) && ((line[n - 1] < ' ') || (whitespace(line[n])))) n--; for (i = 2; whitespace(line[i]) && i < n; i++) ; for (j = i; (!whitespace(line[j])) && j < n; j++) ; l = i; j++; tmp = xmalloc(j - i); _strncpy(tmp, (char *)&line[i], j - i); execname = find_user_command(tmp); free(tmp); freeexec = 1; prefix_len = n - l + 1 + 1 + strlen(name); prefix = alloca(prefix_len + 1); _strncpy(prefix, (char *)&line[l], n - l + 1); strcat(prefix, " "); strcat(prefix, name); break; } } if ((execname == NULL) || (access(execname, F_OK) != 0)) { if (execname == NULL) { errno = ENOEXEC; return -1; } execname = savestring(execname); freeexec = 1; if ((ext_file_status(&execname) & FS_EXISTS) == 0) { free(execname); errno = ENOENT; return -1; } } { char *qlist = get_string_value ("BASH_NOQUOTEARGS"); char *tmp, *name = _getname (execname); int namelen; tmp = _getext (name); namelen = (tmp ? (int) (tmp - name) : strlen (name)); while (qlist) { tmp = strchr (qlist, ';'); if (!(j = tmp ? (int) (tmp - qlist) : strlen (qlist))) break; if ((namelen == j) && (memicmp (qlist, name, namelen) == 0)) { quoteargs = 0; break; } qlist += j; while (qlist[0] == ';') qlist++; } } /* Prepare command-line string */ j = prefix_len + 2; for (i = 0; i <= 1; i++) { for (p = (const char **)argv; *p != NULL; ++p) { if (p != (const char **)argv) if (i == 0) // Add a space before args starting from 1 j++; else strcat(p_arg, " "); else if (prefix_len) continue; // Prefix already contains argv[0] // If argv[i] contains a space or tab, we should put it in quotes if (strchr(*p, ' ') || strchr(*p, '\t')) if (i == 0) j += 1 + (quoteargs ? q_strlen(*p) : strlen(*p)) + 1; else { strcat(p_arg, "\""); if (quoteargs) q_strcat (p_arg, *p); else strcat (p_arg, *p); strcat(p_arg, "\""); } else // If we`re running a EMX program, we should backquote all '"'s in argv[i] if (i == 0) j += (quoteargs ? q_strlen(*p) : strlen(*p)); else if (quoteargs) q_strcat(p_arg, *p); else strcat(p_arg, *p); } if (i == 0) { p_arg = alloca(j); if (prefix_len) { memcpy(p_arg, prefix, prefix_len); p_arg[prefix_len] = ' '; p_arg[prefix_len + 1] = 0; } else *p_arg = 0; } } p_arg[strlen(p_arg) + 1] = 0; #if 0 printf("quoteargs = %d\n", quoteargs); printf("exec{%s}\n", execname); printf("args{%s}\n", p_arg); #endif for (arg1 = p_arg; !whitespace(*arg1) && *arg1; arg1++) ; *arg1++ = 0; /* Prepare environment */ j = 1; for (p = (const char * const *)envp; *p != NULL; ++p) j += strlen (*p) + 1; p_env = tmp = alloca(j); for (p = (const char * const *)envp; *p != NULL; ++p) { i = strlen (*p); memcpy(tmp, *p, i+1); tmp += i+1; } *tmp = 0; if (runflags & spawn_SESSION) /* Use DosStartSession */ { HQUEUE hq; /* Termination queue management */ sprintf((char *)&queue, "\\QUEUES\\bash%d", getpid()); if (DosCreateQueue(&hq, QUE_FIFO | QUE_CONVERT_ADDRESS, (PSZ)queue) == NO_ERROR) { STARTDATA sd; ULONG sid,pid; APIRET r; memset(&sd, 0, sizeof(sd)); sd.Length = sizeof(sd); sd.Related = (runflags & spawn_WAIT ? SSF_RELATED_CHILD : SSF_RELATED_INDEPENDENT); sd.FgBg = SSF_FGBG_FORE; sd.PgmName = execname; sd.PgmInputs = arg1; sd.TermQ = (PBYTE)&queue; sd.Environment = p_env; sd.InheritOpt = SSF_INHERTOPT_PARENT; sd.SessionType = (runflags & spawn_TYPE) >> 16; sd.ObjectBuffer = (PSZ)&errbuf; sd.ObjectBuffLen = sizeof(errbuf); #if 0 sd.PgmControl = SSF_CONTROL_NOAUTOCLOSE; #endif r = DosStartSession(&sd, &sid, &pid); if (r == NO_ERROR || r == ERROR_SMG_START_IN_BACKGROUND) { if (runflags & spawn_WAIT) { REQUESTDATA rd; ULONG Length; PUSHORT Info = NULL; BYTE Priority; ULONG oldVis, oldJump; SWP oldpos; if (hswValid) { /* Exclude session from task list */ oldVis = swc.uchVisibility; swc.uchVisibility = SWL_INVISIBLE; oldJump = swc.fbJump; swc.fbJump = SWL_NOTJUMPABLE; WinChangeSwitchEntry(vioHSW, &swc); /* Minimize session */ WinQueryWindowPos(swc.hwnd, &oldpos); if ((oldpos.fl & SWP_MINIMIZE) == 0) WinPostMsg(swc.hwnd, WM_SYSCOMMAND, (MPARAM)SC_MINIMIZE, MPFROM2SHORT(CMDSRC_MENU, FALSE)); } DosReadQueue(hq, &rd, &Length, (PPVOID)&Info, 0, DCWW_WAIT, &Priority, 0); if (hswValid) { /* Restore jumpable & visible status */ swc.uchVisibility = oldVis; swc.fbJump = oldJump; WinChangeSwitchEntry(vioHSW, &swc); /* Restore session */ if ((oldpos.fl & SWP_MINIMIZE) == 0) { WinPostMsg(swc.hwnd, WM_SYSCOMMAND, (MPARAM)SC_RESTORE, MPFROM2SHORT(CMDSRC_MENU, FALSE)); WinSetWindowPos(swc.hwnd, oldpos.hwndInsertBehind, oldpos.x, oldpos.y, oldpos.cx, oldpos.cy, oldpos.fl); } } retcode = Info[1]; } else retcode = pid; } else internal_error("Execution failed because of module \"%s\"", (char *)&errbuf); DosCloseQueue(hq); } else
int main (void) { SHORT ix, iy; SHORT iwidth, idepth; SWP swp; ULONG ulResult; int iRes; static CHAR szClientClass[]="ZIN"; static ULONG flFrameFlags= FCF_TITLEBAR | FCF_SYSMENU | FCF_TASKLIST | FCF_ICON | FCF_SHELLPOSITION| FCF_BORDER | FCF_NOBYTEALIGN; hab=WinInitialize(0); hmq=WinCreateMsgQueue(hab, 0); //Register processing class WinRegisterClass( hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0); //Create Window hwndFrame=WinCreateStdWindow( HWND_DESKTOP, WS_VISIBLE, &flFrameFlags, szClientClass, NULL, 0L, 0, //Module handle for resources ID_RESOURCE, //ID of resources &hwndClient); //Size window WinSetWindowPos( hwndFrame, HWND_TOP, 0, 0, 640, 480, SWP_SIZE ); //Center window iwidth = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); idepth = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); WinQueryWindowPos( hwndFrame, (PSWP)&swp ); ix = (SHORT)(( iwidth - swp.cx ) / 2); iy = (SHORT)(( idepth - swp.cy ) / 2); WinSetWindowPos( hwndFrame, HWND_TOP, ix, iy, 0, 0, SWP_MOVE ); //Set focus to edit window. WinSetFocus(HWND_DESKTOP,hwndClient); //Load application title WinLoadString(hab, 0, ID_APPNAME, LITTLEBUF, (PSZ) szAppName); //Set title of frame. WinSetWindowText(hwndFrame, (PSZ) szAppName); //Show the window WinShowWindow(hwndFrame,TRUE); //Get source directory. GetCurrentDirectory(szSourceDir); //Load first message FIRSTMSG: usResponse=MsgBox(ID_FIRSTMSG, ID_APPNAME, MB_OKCANCEL); WinUpdateWindow(hwndClient); if (usResponse==MBID_OK) { //Show readme.txt file ulResult=WinDlgBox(HWND_DESKTOP, hwndClient, ReadmeDlgProc, NULLHANDLE, IDD_README, NULL); if (ulResult==FALSE) { //The installation has been cancelled. usResponse=MsgBox(ID_CANCELINSTALL, ID_APPNAME, MB_OK); goto END_INSTALL; } ulResult=WinDlgBox(HWND_DESKTOP, hwndClient, GetDirDlgProc, NULLHANDLE, IDD_GETDIR, NULL); if (ulResult==FALSE) goto FIRSTMSG; //Update the window WinUpdateWindow(hwndClient); //Load status dialog LoadStatusDlg(); //Make sure all files exist iRes=CheckFiles(szSourceDir); if (iRes!=0) { DestroyStatusDlg(); usResponse=MsgBox(ID_FILENOTFOUND, ID_APPNAME, MB_OK); goto END_INSTALL; } //Copy the files iRes=CopyFiles(szSourceDir, szInstallDir); if (iRes!=0) { DestroyStatusDlg(); usResponse=MsgBox(ID_FILESNOTCOPIED, ID_APPNAME, MB_OK); goto END_INSTALL; } iRes=PatchZed(szInstallDir); if (iRes!=0) { DestroyStatusDlg(); usResponse=MsgBox(ID_PATCHFAILED, ID_APPNAME, MB_OK); goto END_INSTALL; } iRes=CreateObject(szInstallDir); if (iRes!=0) usResponse=MsgBox(ID_CANTCREATEOBJECT, ID_APPNAME, MB_OK); //unload status window DestroyStatusDlg(); //Update the window WinUpdateWindow(hwndClient); //Success usResponse=MsgBox(ID_SUCCESS, ID_APPNAME, MB_OK); goto END_INSTALL; //Main message loop while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg(hab, &qmsg); } if (usResponse==MBID_CANCEL) { //The installation has been cancelled. usResponse=MsgBox(ID_CANCELINSTALL, ID_APPNAME, MB_OK); } END_INSTALL: //Cleanup WinDestroyWindow(hwndFrame); WinDestroyMsgQueue(hmq); WinTerminate(hab); //End return 0; }
MRESULT EXPENTRY DirDialogProc( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2) { switch ( msg ) { case WM_INITDLG: { SWP swpFileST; SWP swpDirST; SWP swpDirLB; SWP swpDriveST; SWP swpDriveCB; SWP swpDriveCBEF; SWP swpOK; SWP swpCancel; HWND hwndFileST; HWND hwndDirST; HWND hwndDirLB; HWND hwndDriveST; HWND hwndDriveCB; HWND hwndOK; HWND hwndCancel; HENUM henum; HWND hwndNext; ULONG ulCurY, ulCurX; LONG lScreenX, lScreenY, lDlgFrameX, lDlgFrameY, lTitleBarY; lScreenX = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN); lScreenY = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN); lDlgFrameX = WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME); lDlgFrameY = WinQuerySysValue(HWND_DESKTOP, SV_CYDLGFRAME); lTitleBarY = WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR); hwndFileST = WinWindowFromID(hwndDlg, DID_FILENAME_TXT); hwndDirST = WinWindowFromID(hwndDlg, DID_DIRECTORY_TXT); hwndDirLB = WinWindowFromID(hwndDlg, DID_DIRECTORY_LB); hwndDriveST = WinWindowFromID(hwndDlg, DID_DRIVE_TXT); hwndDriveCB = WinWindowFromID(hwndDlg, DID_DRIVE_CB); hwndOK = WinWindowFromID(hwndDlg, DID_OK); hwndCancel = WinWindowFromID(hwndDlg, DID_CANCEL); #define SPACING 10 // Reposition drives combobox ulCurY = SPACING; ulCurX = SPACING + lDlgFrameX; WinQueryWindowPos(hwndOK, &swpOK); WinSetWindowPos(hwndOK, 0, ulCurX, ulCurY, 0, 0, SWP_MOVE); ulCurY += swpOK.cy + SPACING; WinQueryWindowPos(hwndCancel, &swpCancel); WinSetWindowPos(hwndCancel, 0, ulCurX+swpOK.cx+10, SPACING, 0, 0, SWP_MOVE); WinQueryWindowPos(hwndDirLB, &swpDirLB); WinSetWindowPos(hwndDirLB, 0, ulCurX, ulCurY, swpDirLB.cx, swpDirLB.cy, SWP_MOVE | SWP_SIZE); ulCurY += swpDirLB.cy + SPACING; WinQueryWindowPos(hwndDirST, &swpDirST); WinSetWindowPos(hwndDirST, 0, ulCurX, ulCurY, swpDirST.cx, swpDirST.cy, SWP_MOVE | SWP_SIZE); ulCurY += swpDirST.cy + SPACING; WinQueryWindowPos(hwndDriveCB, &swpDriveCB); WinQueryWindowPos(WinWindowFromID(hwndDriveCB, CBID_EDIT), &swpDriveCBEF); WinSetWindowPos(hwndDriveCB, 0, ulCurX, ulCurY-(swpDriveCB.cy-swpDriveCBEF.cy)+5, swpDirLB.cx, swpDriveCB.cy, SWP_SIZE | SWP_MOVE); ulCurY += swpDriveCBEF.cy + SPACING; WinQueryWindowPos(hwndDriveST, &swpDriveST); WinSetWindowPos(hwndDriveST, 0, ulCurX, ulCurY, swpDriveST.cx, swpDriveST.cy, SWP_MOVE | SWP_SIZE); ulCurY += swpDriveST.cy + SPACING; WinQueryWindowPos(hwndFileST, &swpFileST); WinSetWindowPos(hwndFileST, 0, ulCurX, ulCurY, swpFileST.cx, swpFileST.cy, SWP_MOVE | SWP_SIZE); ulCurY += swpFileST.cy + SPACING; // Hide unused stuff henum = WinBeginEnumWindows(hwndDlg); while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE) { USHORT usID = WinQueryWindowUShort(hwndNext, QWS_ID); if (usID != DID_FILENAME_TXT && usID != DID_DIRECTORY_TXT && usID != DID_DIRECTORY_LB && usID != DID_DRIVE_TXT && usID != DID_DRIVE_CB && usID != DID_OK && usID != DID_CANCEL && usID != FID_TITLEBAR && usID != FID_SYSMENU && usID != FID_MINMAX) { WinShowWindow(hwndNext, FALSE); } } WinSetWindowPos(hwndDlg, HWND_TOP, (lScreenX/2)-((swpDirLB.cx+2*SPACING+2*lDlgFrameX)/2), (lScreenY/2)-((ulCurY+2*lDlgFrameY+lTitleBarY)/2), swpDirLB.cx+2*SPACING+2*lDlgFrameX, ulCurY+2*lDlgFrameY+lTitleBarY, SWP_MOVE | SWP_SIZE); } break; case WM_CONTROL: { PFILEDLG pfiledlg; pfiledlg = (PFILEDLG)WinQueryWindowPtr(hwndDlg, QWL_USER); HPS hps; SWP swp; HWND hwndST; RECTL rectlString = {0,0,1000,1000}; char *ptr = NULL; int iHalfLen; int iLength; CHAR szString[CCHMAXPATH]; hwndST = WinWindowFromID(hwndDlg, DID_FILENAME_TXT); strcpy(szString, pfiledlg->szFullFile); iLength = strlen(pfiledlg->szFullFile); /* If we are not just a drive */ if (iLength > 3) { if (szString[iLength-1] == '\\') { szString[iLength-1] = '\0'; iLength--; } } hps = WinGetPS(hwndST); WinQueryWindowPos(hwndST, &swp); WinDrawText(hps, iLength, szString, &rectlString, 0, 0, DT_BOTTOM | DT_QUERYEXTENT | DT_TEXTATTRS); while(rectlString.xRight > swp.cx) { iHalfLen = iLength / 2; if(iHalfLen == 2) break; ptr = szString + iHalfLen; memmove(ptr - 1, ptr, strlen(ptr) + 1); szString[iHalfLen - 2] = '.'; szString[iHalfLen - 1] = '.'; szString[iHalfLen] = '.'; iLength = strlen(szString); rectlString.xLeft = rectlString.yBottom = 0; rectlString.xRight = rectlString.yTop = 1000; WinDrawText(hps, iLength, szString, &rectlString, 0, 0, DT_BOTTOM | DT_QUERYEXTENT | DT_TEXTATTRS); } WinReleasePS(hps); WinSetWindowText(hwndST, szString); } break; } return WinDefFileDlgProc(hwndDlg, msg, mp1, mp2); }
message::message (PSZ pszMessage, PSZ pszTitle, HWND owner) { md.hab = WinInitialize (0); WinRegisterClass ( md.hab, // Anchor block handle "messagewin", // Name of class being registered. 'sz' prefix is used // to indicate a string variable terminated with a zero. (PFNWP) MainProc, // Window procedure for class CS_CLIPSIBLINGS | CS_SIZEREDRAW | CS_CLIPCHILDREN , // Class style 0) ; // Extra bytes to reserve md.flCreate = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX; md.hwndFrame = WinCreateStdWindow ( HWND_DESKTOP, NULL, &md.flCreate, "messagewin", pszTitle, 0, 0, ID_WINDOW, &md.hwndClient ); WinQueryWindowPos (owner, (PSWP)&md.swp); WinSetWindowPos (md.hwndFrame, HWND_TOP, md.swp.x + 20, md.swp.y + 65, md.swp.cx - 60, md.swp.cy/3, SWP_SIZE | SWP_SHOW | SWP_MOVE); // Save a pointer to the MESSAGEDATA structure in the window words. // This is needed for the MainWindowProc which is a static method and // otherwise wouldn't have access to the private data members. pmd = &md; WinSetWindowULong (md.hwndFrame, QWL_USER, (ULONG) pmd); // Set up a MLE control window in the client window. MLECTLDATA mledata; // -------------------------------------------------------------------------- // Populate an MLE control data structure. // -------------------------------------------------------------------------- mledata.cbCtlData = sizeof (MLECTLDATA); // size of structure mledata.cchText = -1L; // no text limit boundary mledata.iptAnchor = 0; // begin selection pointer mledata.iptCursor = 0; // end selection pointer mledata.cxFormat = 0; // formatrect width mledata.cyFormat = 0; // formatrect height mledata.afFormatFlags = MLFFMTRECT_MATCHWINDOW; // formatrect flags mledata.afIEFormat = MLFIE_CFTEXT; // import/export format // -------------------------------------------------------------------------- // Get the rectangle coordinates for the Client Window. // -------------------------------------------------------------------------- WinQueryWindowRect(md.hwndClient, &md.rcl); // -------------------------------------------------------------------------- // Create our editor window by drawing an MLE window within the client // window. We leave room at the top of the client window for our button // bar windows, and room at the bottom of the client window for a status // window. // -------------------------------------------------------------------------- md.hwndMLE = WinCreateWindow ( md.hwndFrame, // Parent Window Handle WC_MLE, // Window Class NULL, // Window Text MLS_HSCROLL | MLS_VSCROLL | MLS_BORDER | WS_VISIBLE, // Window Styles md.rcl.xLeft + 4, // Starting x coordinate md.rcl.yBottom + 4, // Leave room at bottom md.rcl.xRight + 1, // Horizontal Length md.rcl.yTop + 1, // Leave room at top md.hwndClient, // Client is Owner Window HWND_TOP, // Window Placement ID_WINDOW + 1, // MLE Window Identifier (PVOID) &mledata, // Control Data NULL); // Presentation Parameters WinSendMsg (md.hwndMLE, MLM_SETIMPORTEXPORT, MPFROMP (pszMessage), MPFROMLONG (strlen (pszMessage) - 1)); ULONG marker; marker = 0; WinSendMsg (md.hwndMLE, MLM_IMPORT, MPFROMP (&marker), MPFROMLONG (strlen (pszMessage) - 1)); WinSetFocus (HWND_DESKTOP, md.hwndFrame); while( WinGetMsg( md.hab, &md.qmsg, 0L, 0, 0 ) ) WinDispatchMsg( md.hab, &md.qmsg ); }
MRESULT EXPENTRY SwapProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { static HWND hwndMenu = (HWND)0; switch(msg) { case WM_CREATE: { MRESULT mr = PFNWPStatic(hwnd,msg,mp1,mp2); WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID); return mr; } case WM_MOUSEMOVE: break; case WM_PRESPARAMCHANGED: { char *rootname = "SwapMon"; switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case CLOCK_FRAME: rootname = "Clock"; break; case HARD_FRAME: rootname = "Hard"; break; case CPU_FRAME: rootname = "CPU"; break; case CLP_FRAME: rootname = "ClipMon"; break; case MEM_FRAME: rootname = "Mem"; break; case TSK_FRAME: rootname = "Task"; break; } PresParamChanged(hwnd, rootname, mp1, mp2); PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID); PostMsg(hwnd, UM_REFRESH, MPVOID, MPFROMSHORT(TRUE)); } break; case WM_APPTERMINATENOTIFY: if(WinQueryWindowUShort(hwnd,QWS_ID) == CPU_FRAME) { if(!StartCPUThreads()) WinDestroyWindow(hwnd); } break; case WM_BUTTON1MOTIONSTART: { POINTL ptl; ptl.x = SHORT1FROMMP(mp1); ptl.y = SHORT2FROMMP(mp1); WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptl, 1L); PostMsg(hwndConfig, UM_SHOWME, MPFROM2SHORT((USHORT)ptl.x,(USHORT)ptl.y), mp2); } return MRFROMSHORT(TRUE); case WM_BUTTON2MOTIONSTART: { TRACKINFO TrackInfo; SWP Position; memset(&TrackInfo,0,sizeof(TrackInfo)); TrackInfo.cxBorder = 1 ; TrackInfo.cyBorder = 1 ; TrackInfo.cxGrid = 1 ; TrackInfo.cyGrid = 1 ; TrackInfo.cxKeyboard = 8 ; TrackInfo.cyKeyboard = 8 ; WinQueryWindowPos(hwnd,&Position); TrackInfo.rclTrack.xLeft = Position.x ; TrackInfo.rclTrack.xRight = Position.x + Position.cx ; TrackInfo.rclTrack.yBottom = Position.y ; TrackInfo.rclTrack.yTop = Position.y + Position.cy ; WinQueryWindowPos(HWND_DESKTOP,&Position); TrackInfo.rclBoundary.xLeft = Position.x ; TrackInfo.rclBoundary.xRight = Position.x + Position.cx ; TrackInfo.rclBoundary.yBottom = Position.y ; TrackInfo.rclBoundary.yTop = Position.y + Position.cy ; TrackInfo.ptlMinTrackSize.x = 0 ; TrackInfo.ptlMinTrackSize.y = 0 ; TrackInfo.ptlMaxTrackSize.x = Position.cx ; TrackInfo.ptlMaxTrackSize.y = Position.cy ; TrackInfo.fs = TF_MOVE | TF_STANDARD | TF_ALLINBOUNDARY ; if(WinTrackRect(HWND_DESKTOP, (HPS)0, &TrackInfo)) { WinSetWindowPos(hwnd, HWND_TOP, TrackInfo.rclTrack.xLeft, TrackInfo.rclTrack.yBottom, 0, 0, SWP_MOVE); switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case SWAP_FRAME: WinQueryWindowPos(hwnd,&swpSwap); SavePrf("SwapSwp", &swpSwap, sizeof(SWP)); break; case CLOCK_FRAME: WinQueryWindowPos(hwnd,&swpClock); SavePrf("ClockSwp", &swpClock, sizeof(SWP)); break; case HARD_FRAME: WinQueryWindowPos(hwnd,&swpHard); SavePrf("HardSwp", &swpHard, sizeof(SWP)); break; case CPU_FRAME: WinQueryWindowPos(hwnd,&swpCPU); SavePrf("CPUSwp", &swpCPU, sizeof(SWP)); break; case CLP_FRAME: WinQueryWindowPos(hwnd,&swpClip); SavePrf("ClipSwp", &swpClip, sizeof(SWP)); break; case MEM_FRAME: WinQueryWindowPos(hwnd,&swpMem); SavePrf("MemSwp", &swpMem, sizeof(SWP)); break; case TSK_FRAME: WinQueryWindowPos(hwnd,&swpTask); SavePrf("TaskSwp", &swpTask, sizeof(SWP)); break; } } } return MRFROMSHORT(TRUE); case WM_BUTTON1DOWN: WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE); return MRFROMSHORT(TRUE); case WM_BUTTON1DBLCLK: case WM_BUTTON1CLICK: if((!fNoMonClick && msg == WM_BUTTON1CLICK) || (fNoMonClick && msg == WM_BUTTON1DBLCLK)) { switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case HARD_FRAME: { ULONG ulDriveNum,ulDriveMap,x; ulDriveMon = min(ulDriveMon,26); if(!DosQCurDisk(&ulDriveNum, &ulDriveMap)) { for(x = ulDriveMon + 1;x < 26;x++) { if(ulDriveMap & (1 << x)) { ulDriveMon = x; break; } } if(x >= 26) { for(x = 3;x < ulDriveMon - 1;x++) { if(ulDriveMap & (1 << x)) { ulDriveMon = x; break; } } } SavePrf("MonDrive", &ulDriveMon, sizeof(ULONG)); } PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID); } break; case CLP_FRAME: case MEM_FRAME: case TSK_FRAME: case SWAP_FRAME: case CLOCK_FRAME: case CPU_FRAME: { USHORT cmd = CPU_PULSE; switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case MEM_FRAME: cmd = CLOCK_CMDLINE; break; case TSK_FRAME: cmd = CPU_KILLPROC; break; case CLP_FRAME: cmd = CLOCK_CLIPBOARD; break; case SWAP_FRAME: cmd = SWAP_LAUNCHPAD; break; case CLOCK_FRAME: cmd = CLOCK_SETTINGS; if((WinGetKeyState(HWND_DESKTOP,VK_SHIFT) & 0x8000) != 0) cmd = CLOCK_CLOCK; break; } PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd,0), MPVOID); } break; } return MRFROMSHORT(TRUE); } else PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID); break; case WM_CONTEXTMENU: WinInvalidateRect(hwnd, NULL, FALSE); WinSendMsg(hwnd, UM_TIMER, MPVOID, MPVOID); WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE); { USHORT id; id = WinQueryWindowUShort(hwnd,QWS_ID); hwndMenu = WinLoadMenu(HWND_DESKTOP, 0, id); if(hwndMenu) { POINTL ptl; SWP swp; ULONG ulDriveNum,ulDriveMap,x; MENUITEM mi; char s[80]; SetPresParams(hwndMenu, -1, -1, -1, helvtext); switch(id) { case CLP_FRAME: WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(CLP_APPEND,FALSE), MPFROM2SHORT(MIA_CHECKED, ((fClipAppend) ? MIA_CHECKED : 0))); break; case HARD_FRAME: if(!DosQCurDisk(&ulDriveNum, &ulDriveMap)) { mi.iPosition = 0; mi.hwndSubMenu = (HWND)0; mi.hItem = 0L; mi.afStyle = MIS_TEXT | MIS_STATIC; mi.afAttribute = MIA_FRAMED; mi.id = -1; sprintf(s, "Current drive is %c:", (char)(ulDriveMon + '@')); WinSendMsg(hwndMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(s)); mi.iPosition = MIT_END; for(x = 2;x < 26;x++) { if(ulDriveMap & (1 << x)) { if(x != ulDriveMon - 1) { mi.afStyle = MIS_TEXT; mi.afAttribute = 0; mi.id = HARD_C + (x - 2); if(fShowFreeInMenus) SetDriveText(x + 1, s); else sprintf(s, "%c:", (char)(x + 'A')); WinSendMsg(hwndMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(s)); } } } } break; case CLOCK_FRAME: WinEnableMenuItem(hwndMenu, CLOCK_VIRTUAL, fDesktops); WinEnableMenuItem(hwndMenu, CLOCK_CLIPBOARD, (ClipHwnd != (HWND)0)); break; default: break; } WinQueryWindowPos(hwnd, &swp); ptl.x = SHORT1FROMMP(mp1); ptl.y = SHORT2FROMMP(mp1); WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptl, 1L); ptl.y = max(ptl.y,swp.y + swp.cy + 4); if(!WinPopupMenu(HWND_DESKTOP, hwnd, hwndMenu, ptl.x - 4, ptl.y - 4, 0, PU_HCONSTRAIN | PU_VCONSTRAIN | PU_KEYBOARD | PU_MOUSEBUTTON1)) { WinDestroyWindow(hwndMenu); hwndMenu = (HWND)0; } } } return MRFROMSHORT(TRUE); case WM_MENUEND: WinSetFocus(HWND_DESKTOP, HWND_DESKTOP); WinDestroyWindow((HWND)mp2); if(hwndMenu == (HWND)mp2) hwndMenu = (HWND)0; return 0; case UM_SETUP: { char *rootname = "SwapMon"; switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case SWAP_FRAME: SwapHwnd = hwnd; swaptick = 0; break; case CLOCK_FRAME: ClockHwnd = hwnd; rootname = "Clock"; break; case TSK_FRAME: TaskHwnd = hwnd; rootname = "Task"; break; case MEM_FRAME: MemHwnd = hwnd; rootname = "Mem"; break; case HARD_FRAME: HardHwnd = hwnd; rootname = "Hard"; break; case CPU_FRAME: CPUHwnd = hwnd; rootname = "CPU"; PostMsg(hwnd, UM_REFRESH, MPVOID, MPFROMSHORT(TRUE)); break; case CLP_FRAME: ClipMonHwnd = hwnd; rootname = "ClipMon"; PostMsg(hwnd, UM_REFRESH, MPVOID, MPFROMSHORT(TRUE)); break; } if(!RestorePresParams(hwnd,rootname)) SetPresParams(hwnd, RGB_WHITE, RGB_BLACK, RGB_BLACK, helvtext); } PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID); return 0; case UM_REFRESH: switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case CLP_FRAME: { char s[] = " Clip: [TtBbMmP] + ",*p; ULONG fmt[] = {CF_TEXT,CF_DSPTEXT, CF_BITMAP,CF_DSPBITMAP, CF_METAFILE,CF_DSPMETAFILE, CF_PALETTE,0}; ULONG x,ret; if(WinOpenClipbrd(WinQueryAnchorBlock(hwnd))) { p = s + 8; for(x = 0;fmt[x];x++) { ret = WinQueryClipbrdData(WinQueryAnchorBlock(hwnd), fmt[x]); if(!ret) *p = '-'; p++; } p += 2; if(!fClipAppend) *p = 0; WinCloseClipbrd(WinQueryAnchorBlock(hwnd)); } else strcpy(s + 7, "Can't open. "); SetMonitorSize(hwnd, hwndMenu, &swpClip, s); } break; case CPU_FRAME: { char s[32]; ULONG percent,lastaverage; static BOOL lastavgset = 0; *s = 0; if(mp2) { strcpy(s," CPU: -% "); if(fAverage) strcat(s,"Avg: -%) "); } else { percent = ((MaxCount - (ULONG)mp1) * 100) / MaxCount; lastaverage = AveCPU; AveCPU = (((AveCPU * NumAveCPU) + percent) / ((ULONG)NumAveCPU + 1)); NumAveCPU++; if(!NumAveCPU) NumAveCPU = 65535; if(percent != LastPercent || (AveCPU != lastaverage && fAverage) || NumAveCPU == 1 || lastavgset != fAverage) { lastavgset = fAverage; LastPercent = percent; sprintf(s, " CPU: %lu%% ", percent); if(fAverage) sprintf(s + strlen(s), "(Avg: %lu%%) ", AveCPU); } } if(*s) SetMonitorSize(hwnd, hwndMenu, &swpCPU, s); } break; } return 0; case WM_TIMER: if(fSwapFloat && !hwndMenu) WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_SHOW); if(WinQueryWindowUShort(hwnd,QWS_ID) == CLP_FRAME) { if(!ClipHwnd) WinDestroyWindow(hwnd); else TakeClipboard(); } return 0; case UM_TIMER: switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case CLP_FRAME: ClipMonHwnd = hwnd; WinSendMsg(hwnd, WM_TIMER, MPVOID, MPVOID); break; case CPU_FRAME: CPUHwnd = hwnd; WinSendMsg(hwnd, WM_TIMER, MPVOID, MPVOID); break; case HARD_FRAME: { char s[80]; HardHwnd = hwnd; SetDriveText(ulDriveMon, s); SetMonitorSize(hwnd, hwndMenu, &swpHard, s); } break; case SWAP_FRAME: { FILEFINDBUF3 ffb; ULONG nm = 1,fl = SWP_SIZE | SWP_SHOW | SWP_MOVE, sh,sl,nh; HDIR hdir = HDIR_CREATE; FSALLOCATE fsa; char s[128],ss[8],sss[8],mb,smb; static ULONG lastcbFile = 0; static BOOL warned = FALSE; static char SwapperDat[CCHMAXPATH] = ""; strcpy(s, " Unable to locate SWAPPER.DAT. "); SwapHwnd = hwnd; if(!*SwapperDat) FindSwapperDat(SwapperDat); if(*SwapperDat) { DosError(FERR_DISABLEHARDERR); if(!DosFindFirst(SwapperDat, &hdir, FILE_NORMAL | FILE_HIDDEN | FILE_SYSTEM | FILE_ARCHIVED | FILE_READONLY, &ffb, sizeof(ffb), &nm, FIL_STANDARD)) { DosFindClose(hdir); if(ffb.cbFile != lastcbFile && lastcbFile) swaptick = 9; lastcbFile = ffb.cbFile; DosError(FERR_DISABLEHARDERR); if(!DosQueryFSInfo(toupper(*SwapperDat) - '@', FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) nm = fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector); else nm = 0; if(nm <= 32768 * 1024) { swaptick = 10; if(!warned) { SetPresParams(hwnd, RGB_RED, -1, -1, NULL); warned = TRUE; DosBeep(250,15); } } else if(warned) { PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); warned = FALSE; } mb = MakeNumber(nm, &nh, &sl); *sss = 0; if(sl) sprintf(sss, ".%02lu", sl); smb = MakeNumber(ffb.cbFile, &sh, &sl); *ss = 0; if(sl) sprintf(ss, ".%02lu", sl); sprintf(s, " Swap: %lu%s%cb ", sh, ss, smb); if(fShowSwapFree) sprintf(s + strlen(s), "(%lu%s%cb free) ", nh, sss, mb); } } SetMonitorSize(hwnd, hwndMenu, &swpSwap, s); } break; case TSK_FRAME: { PROCESSINFO *ppi; BUFFHEADER *pbh = NULL; MODINFO *pmi; long numprocs = -1,numthreads = -1; char s[80]; if(!DosAllocMem((PVOID)&pbh, USHRT_MAX + 4096, PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) { if(!DosQProcStatus(pbh, USHRT_MAX)) { numprocs = numthreads = 0; ppi = pbh->ppi; while(ppi->ulEndIndicator != PROCESS_END_INDICATOR ) { pmi = pbh->pmi; while(pmi && ppi->hModRef != pmi->hMod) pmi = pmi->pNext; if(pmi) { numprocs++; numthreads += ppi->usThreadCount; } ppi = (PPROCESSINFO)(ppi->ptiFirst + ppi->usThreadCount); } } DosFreeMem(pbh); sprintf(s, " Procs: %ld Thrds: %ld ", numprocs, numthreads); SetMonitorSize(hwnd, hwndMenu, &swpTask, s); } } break; case MEM_FRAME: { ULONG sh,sl,nh,amem; char s[128],ss[8],sss[8],mb,smb; strcpy(s, "Can't check virtual memory."); MemHwnd = hwnd; if(!DosQuerySysInfo(QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &amem, sizeof(amem))) { mb = MakeNumber(amem, &nh, &sl); *ss = 0; if(sl) sprintf(ss, ".%02lu", sl); sprintf(s, " VMem: %lu%s%cb ", nh, ss, mb); } if(fShowPMem) { if(!Dos16MemAvail(&amem)) { mb = MakeNumber(amem, &nh, &sl); *ss = 0; if(sl) sprintf(ss, ".%02lu", sl); sprintf(s + strlen(s), " PMem: %lu%s%cb ", nh, ss, mb); } } SetMonitorSize(hwnd, hwndMenu, &swpMem, s); } break; case CLOCK_FRAME: { char s[80]; DATETIME dt; ClockHwnd = hwnd; if(!DosGetDateTime(&dt)) { sprintf(s, " %0*u:%02u%s ", ((ampm) ? 0 : 2), (dt.hours % ((ampm) ? 12 : 24)) + ((ampm && !(dt.hours % 12)) ? 12 : 0), dt.minutes, ((ampm) ? (dt.hours > 11) ? "pm" : "am" : "")); if(showdate) sprintf(s + strlen(s), "%02u/%02u ", dt.month, dt.day); } else strcpy(s,"Unknown time"); SetMonitorSize(hwnd, hwndMenu, &swpClock, s); } break; } return 0; case WM_COMMAND: { BOOL ctrl,shift; ctrl = ((WinGetKeyState(HWND_DESKTOP,VK_CTRL) & 0x8000) != 0); shift = ((WinGetKeyState(HWND_DESKTOP,VK_SHIFT) & 0x8000) != 0); switch(SHORT1FROMMP(mp1)) { case CLP_CLEAR: if(WinOpenClipbrd(WinQueryAnchorBlock(hwnd))) { WinEmptyClipbrd(WinQueryAnchorBlock(hwnd)); WinCloseClipbrd(WinQueryAnchorBlock(hwnd)); PostMsg(hwnd, UM_REFRESH, MPVOID, MPVOID); } break; case CLP_APPEND: fClipAppend = (fClipAppend) ? FALSE : TRUE; SavePrf("ClipAppend", &fClipAppend, sizeof(BOOL)); PostMsg(hwnd, UM_REFRESH, MPVOID, MPVOID); if(ClipSetHwnd) PostMsg(ClipSetHwnd, UM_REFRESH, MPVOID, MPVOID); break; case MSE_HELP: ViewHelp(hwnd, "Monitors page"); break; case CPU_PULSE: { PROGDETAILS pgd; WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_FOCUSACTIVATE); memset(&pgd, 0, sizeof(pgd)); pgd.Length = sizeof(pgd); pgd.swpInitial.fl = SWP_ACTIVATE | SWP_ZORDER; pgd.swpInitial.hwndInsertBehind = HWND_TOP; pgd.progt.fbVisible = SHE_VISIBLE; pgd.progt.progc = PROG_DEFAULT; pgd.pszExecutable = "PULSE.EXE"; if(WinStartApp(CPUHwnd, &pgd, NULL, NULL, 0)) { if(CPUHwnd) { closethreads = 1; DosSleep(1); PostMsg(CPUHwnd, UM_REFRESH, MPVOID, MPFROMSHORT(TRUE)); } } } break; case CPU_RESET: AveCPU = 0; NumAveCPU = 0; break; case CLOCK_VIRTUAL: case CLOCK_SWITCHLIST: case CLOCK_CMDLINE: case CLOCK_CLIPBOARD: case CLOCK_CALCULATOR: case HARD_FM2: case MSE_FRAME: { ULONG msg2 = UM_SHOWME; MPARAM mp12 = 0,mp22 = 0; HWND hwndP = hwndConfig; switch(SHORT1FROMMP(mp1)) { case CLOCK_CMDLINE: mp12 = MPFROMLONG(((WinGetKeyState(HWND_DESKTOP,VK_CTRL) & 0x8000) != 0)); msg2 = UM_CMDLINE; break; case CLOCK_CLIPBOARD: msg2 = UM_CLIPMGR; hwndP = ObjectHwnd3; break; case CLOCK_SWITCHLIST: msg2 = UM_SWITCHLIST; break; case CLOCK_VIRTUAL: msg2 = UM_VIRTUAL; break; case CLOCK_CALCULATOR: msg2 = UM_CALC; break; case HARD_FM2: msg2 = UM_STARTWIN; mp12 = MPFROM2SHORT(C_STARTFM2,0); break; } PostMsg(hwndP, msg2, mp12, mp22); } break; case CLOCK_SETTINGS: case CLOCK_CLOCK: case SWAP_LAUNCHPAD: case SWAP_WARPCENTER: case SWAP_CONNECTIONS: case SWAP_INFO: case SWAP_SETTINGS: case SWAP_SYSTEM: case SWAP_TEMPS: case SWAP_FM2: case HARD_OPEN: case CVR_COLORPALETTE: case CVR_HICOLORPALETTE: case CVR_FONTPALETTE: case CPU_KILLPROC: case CPU_HARDWARE: { char *p = "<WP_CLOCK>",*pp = defopen; char s[8]; switch(SHORT1FROMMP(mp1)) { case HARD_OPEN: sprintf(s, "%c:\\", (char)(ulDriveMon + '@')); p = s; break; case SWAP_FM2: p = "<FM3_Folder>"; break; case SWAP_TEMPS: p = "<WP_TEMPS>"; break; case SWAP_SYSTEM: p = "<WP_OS2SYS>"; break; case SWAP_SETTINGS: p = "<WP_CONFIG>"; break; case SWAP_INFO: p = "<WP_INFO>"; break; case SWAP_CONNECTIONS: p = "<WP_CONNECTIONSFOLDER>"; break; case SWAP_WARPCENTER: p = "<WP_WARPCENTER>"; break; case SWAP_LAUNCHPAD: p = "<WP_LAUNCHPAD>"; break; case CLOCK_SETTINGS: pp = setopen; break; case CVR_COLORPALETTE: p = "<WP_LORESCLRPAL>"; break; case CVR_HICOLORPALETTE: p = "<WP_HIRESCLRPAL>"; break; case CVR_FONTPALETTE: p = "<WP_FNTPAL>"; break; case CPU_KILLPROC: p = "<FM/2_KILLPROC>"; break; case CPU_HARDWARE: p = "<WP_HWMGR>"; break; } OpenObject(p, pp); } break; case HARD_VDIR: { PROGDETAILS pgd; char s[36]; sprintf(s, "/C VDIR.CMD %c:\\", (char)(ulDriveMon + '@')); memset(&pgd, 0, sizeof(pgd)); pgd.Length = sizeof(pgd); pgd.swpInitial.fl = SWP_MINIMIZE | SWP_ACTIVATE | SWP_ZORDER; pgd.swpInitial.hwndInsertBehind = HWND_TOP; pgd.progt.fbVisible = SHE_VISIBLE; pgd.progt.progc = PROG_DEFAULT; pgd.pszExecutable = "CMD.EXE"; WinStartApp((HWND)0, &pgd, s, NULL, 0); } break; case HARD_CHKDSK: { PROGDETAILS pgd; char s[8]; WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_FOCUSACTIVATE); sprintf(s, "%c:", (char)(ulDriveMon + '@')); memset(&pgd, 0, sizeof(pgd)); pgd.Length = sizeof(pgd); pgd.swpInitial.fl = SWP_ACTIVATE | SWP_ZORDER; pgd.swpInitial.hwndInsertBehind = HWND_TOP; pgd.progt.fbVisible = SHE_VISIBLE; pgd.progt.progc = PROG_DEFAULT; pgd.pszExecutable = "PMCHKDSK.EXE"; WinStartApp((HWND)0, &pgd, s, NULL, 0); } break; default: if(SHORT1FROMMP(mp1) >= HARD_C && SHORT1FROMMP(mp1) <= HARD_C + 24) { ulDriveMon = (SHORT1FROMMP(mp1) - HARD_C) + 3; PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID); if(ctrl) PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(HARD_OPEN,0), MPVOID); else if(shift) PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(HARD_VDIR,0), MPVOID); } break; } } return 0; case WM_DESTROY: switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case SWAP_FRAME: SwapHwnd = (HWND)0; break; case CLOCK_FRAME: ClockHwnd = (HWND)0; break; case HARD_FRAME: HardHwnd = (HWND)0; break; case CPU_FRAME: closethreads = 1; DosSleep(1); CPUHwnd = (HWND)0; break; case CLP_FRAME: ClipMonHwnd = (HWND)0; break; case MEM_FRAME: MemHwnd = (HWND)0; break; case TSK_FRAME: TaskHwnd = (HWND)0; break; } break; } return PFNWPStatic(hwnd,msg,mp1,mp2); }
MRESULT EXPENTRY wpCD(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { switch (msg) { case WM_INITDLG: { ULONG rc, i; HFILE CDDevice; ULONG action; ULONG len; struct { USHORT CountCD; USHORT FirstCD; } CDInfo; FIELDINFO *firstFieldInfo, *posFieldInfo, *splitFieldInfo; FIELDINFOINSERT fieldInfoInsert; CNRINFO cnrInfo; cnrInfo.cb = sizeof(cnrInfo); firstFieldInfo = posFieldInfo = allocaFieldInfo(hwnd, CT_TRACK, NUM_FIELDS); posFieldInfo->flData = CFA_BITMAPORICON | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Icon"; posFieldInfo->offStruct = FIELDOFFSET(RECORDCORE,hptrIcon); fieldInfo[0] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Filename"; posFieldInfo->offStruct = FIELDOFFSET(RECORDCORE,pszIcon); fieldInfo[1] = posFieldInfo; cnrInfo.pFieldInfoLast = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Track #"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,track); fieldInfo[2] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR | CFA_FIREADONLY; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Type"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,typepointer); fieldInfo[3] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR | CFA_FIREADONLY; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Time"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,timepointer); fieldInfo[4] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Size"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,size); fieldInfo[5] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "MP3 Size"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,mp3size); fieldInfo[6] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Title"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,titleptr); fieldInfo[7] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Artist"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,artistptr); fieldInfo[8] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Album"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,albumptr); fieldInfo[9] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Year"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,yearptr); fieldInfo[10] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Genre"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,genreptr); fieldInfo[11] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Comment"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,commentptr); fieldInfo[12] = posFieldInfo; fieldInfoInsert.cb = sizeof(fieldInfoInsert); fieldInfoInsert.pFieldInfoOrder = (FIELDINFO *) CMA_FIRST; fieldInfoInsert.fInvalidateFieldInfo = TRUE; fieldInfoInsert.cFieldInfoInsert = NUM_FIELDS; insertFieldInfo(hwnd, CT_TRACK, firstFieldInfo, &fieldInfoInsert); cnrInfo.xVertSplitbar = 100; cnrInfo.flWindowAttr = CV_DETAIL | CA_DETAILSVIEWTITLES; WinSendDlgItemMsg(hwnd,CT_TRACK,CM_SETCNRINFO, MPFROMP(&cnrInfo), MPFROMLONG(CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR | CMA_FLWINDOWATTR)); loadConfig(CFGFILE, &grabbers, &countGrabbers); for(i = 0; i < countGrabbers; i++) insertItemText(hwnd,CB_GRABBER,LIT_END,grabbers[i].id); selectItem(hwnd,CB_GRABBER,0); setText(hwnd, EF_TITLE, "Title"); /* wohw, this is too powerful, need cooling */ len = sizeof(CDInfo); if(!DosOpen("\\DEV\\CD-ROM2$", &CDDevice, &action, 0, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL)) { if(!DosDevIOCtl(CDDevice, 0x82, 0x60, NULL, 0, NULL, &CDInfo, len, &len)) { for(i = 0; i < CDInfo.CountCD; i++) { char driveLetter[3] = { (char) ('A' + CDInfo.FirstCD + i), ':', 0}; insertItemText(hwnd,CB_DRIVE,LIT_END,driveLetter); } } DosClose(CDDevice); } selectItem(hwnd,CB_DRIVE,0); wpCT = WinSubclassWindow(WinWindowFromID(hwnd,CT_TRACK),wpCTTrack); dataIco = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, ICO_DATA); trackIco = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, ICO_TRACK); loadIni(hwnd); return 0; } case WM_COMMAND: return processCommand(hwnd,mp1,mp2); case WM_CONTROL: return processControl(hwnd,mp1,mp2); case WM_ADJUSTFRAMEPOS: { SWP *pos = (SWP*) PVOIDFROMMP(mp1); static int bitRateCheck = 0; if(pos->fl & SWP_SIZE) { SWP ctpos; WinQueryWindowPos(WinWindowFromID(hwnd, CT_TRACK), &ctpos); WinSetWindowPos (WinWindowFromID(hwnd, CT_TRACK), 0, 0, ctpos.y, pos->cx, pos->cy - ctpos.y, SWP_SIZE | SWP_SHOW | SWP_MOVE); } if((pos->fl & SWP_SHOW) && bitRateChanged != bitRateCheck) { bitRateCheck = bitRateChanged; refreshFieldInfo(hwnd, CT_TRACK); } break; } case WM_MENUEND: removeSourceEmphasis(HWNDFROMMP(mp2),&sourceEmphasisInfo); return 0; case WM_CLOSE: { WinDestroyPointer(dataIco); WinDestroyPointer(trackIco); free(grabbers); saveIni(hwnd); /* delete all current records */ CDTRACKRECORD *record = (CDTRACKRECORD *) enumRecords(hwnd, CT_TRACK, NULL, CMA_FIRST); while(record && record != (CDTRACKRECORD *) -1) { free(record->record.pszIcon); record = (CDTRACKRECORD *) enumRecords(hwnd, CT_TRACK, (RECORDCORE *) record, CMA_NEXT); } removeRecords(hwnd, CT_TRACK, NULL, 0); removeFieldInfo(hwnd,CT_TRACK, NULL, 0); return 0; } case WM_CHAR: if(SHORT2FROMMP(mp2) == VK_ESC) return 0; else break; /* back from worker thread */ case DLGCD_REFRESH: dlgcd_refresh2(mp1,mp2); return 0; case CDDB_FUZZYMATCH: { CDDBQUERY_DATA *matches = (CDDBQUERY_DATA *) mp1, *chosen = (CDDBQUERY_DATA *) mp2; FUZZYMATCHCREATEPARAMS data = {matches,chosen}; WinDlgBox(HWND_DESKTOP, hwnd, wpMatch, NULLHANDLE, DLG_MATCH, &data); return 0; } } return WinDefDlgProc( hwnd, msg, mp1, mp2 ); }
MRESULT EXPENTRY fnwpReadColumnClient(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2) { static HDC hdcPs; RECTL rclRect; POINTL ptl; LONG lSaveEdge; SWP swp; HWND hwndMenu; static USHORT usMenuStyle; static CLRDLG stColor; static USHORT usLastPopupItem; switch(msg) { case WM_CHAR: if (bSendNextKeystroke) if (ProcessKeystroke(&stCFG,mp1,mp2)) return((MRESULT)TRUE); return( WinDefWindowProc(hwnd,msg,mp1,mp2)); case WM_CREATE: hdcPs = WinOpenWindowDC(hwnd); usLastPopupItem = IDMPU_SYNC; stRead.lBackgrndColor = stCFG.lReadColBackgrndColor; stRead.bActive = FALSE; stRead.lScrollIndex = 0; stRead.hwndScroll = (HWND)NULL; stRead.wDirection = CS_READ; stColor.cbSize = sizeof(CLRDLG); usMenuStyle = (PU_POSITIONONITEM | PU_MOUSEBUTTON2 | PU_HCONSTRAIN | PU_VCONSTRAIN | PU_KEYBOARD | PU_MOUSEBUTTON1); WinSendMsg(hwnd,UM_TRACKFRAME,0L,0L); break; case WM_ACTIVATE: if(SHORT1FROMMP(mp1)) { if (!bFrameActivated) { WinSetFocus(HWND_DESKTOP,hwndFrame); WinSendMsg(WinQueryHelpInstance(hwndClient),HM_SET_ACTIVE_WINDOW,0L,0L); bFrameActivated = TRUE; } } else bFrameActivated = FALSE; break; case WM_VSCROLL: switch(HIUSHORT(mp2)) { case SB_LINEDOWN: ColScroll(&stRead,1,FALSE); break; case SB_LINEUP: ColScroll(&stRead,-1,FALSE); break; case SB_PAGEDOWN: ColScroll(&stRead,stRead.lCharHeight,FALSE); break; case SB_PAGEUP: ColScroll(&stRead,-stRead.lCharHeight,FALSE); break; case SB_SLIDERPOSITION: ColScroll(&stRead,LOUSHORT(mp2),TRUE); break; } break; case WM_COMMAND: switch (SHORT1FROMMP(mp1)) { case IDMPU_ASCII_FONT: if (!stCFG.bStickyMenus) usLastPopupItem = IDMPU_FONT; else usLastPopupItem = IDMPU_SYNC; if (stCFG.wColReadFont != wASCIIfont) { stCFG.wColReadFont = wASCIIfont; WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); } break; case IDMPU_HEX_FONT: if (!stCFG.bStickyMenus) usLastPopupItem = IDMPU_FONT; else usLastPopupItem = IDMPU_SYNC; if (stCFG.wColReadFont != wHEXfont) { stCFG.wColReadFont = wHEXfont; WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); } break; case IDMPU_SYNC: usLastPopupItem = IDMPU_SYNC; if (bStopDisplayThread) stRead.lScrollIndex = stWrite.lScrollIndex; else stRead.lScrollIndex = 0; stRead.lScrollRow = GetColScrollRow(&stRead,0); WinSendMsg(stRead.hwndScroll, SBM_SETPOS, MPFROMSHORT(stRead.lScrollRow), MPFROMSHORT(0)); if (stRead.bSync) { stRow.lScrollIndex = stRead.lScrollIndex; stRow.lScrollRow = GetRowScrollRow(&stRow); } WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); break; case IDMPU_COLORS: if (!stCFG.bStickyMenus) usLastPopupItem = IDMPU_COLORS; else usLastPopupItem = IDMPU_SYNC; stColor.lForeground = stCFG.lReadColForegrndColor; stColor.lBackground = stCFG.lReadColBackgrndColor; sprintf(stColor.szCaption,"Lexical Receive Data Display Colors"); if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)fnwpSetColorDlg, (USHORT)NULL, CLR_DLG, MPFROMP(&stColor))) { stCFG.lReadColForegrndColor = stColor.lForeground; stCFG.lReadColBackgrndColor = stColor.lBackground; stRead.lBackgrndColor = stColor.lBackground; stRead.lForegrndColor = stColor.lForeground; WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); } break; case IDMPU_LOCK_WIDTH: if (!stCFG.bStickyMenus) usLastPopupItem = IDMPU_LOCK_WIDTH; else usLastPopupItem = IDMPU_SYNC; if (stCFG.fLockWidth == LOCK_READ) stCFG.fLockWidth = LOCK_NONE; else { stCFG.lLockWidth = ((stRead.lWidth / stCell.cx) + 1); stCFG.fLockWidth = LOCK_READ; } break; case IDMPU_DISP_FILTERS: if (!stCFG.bStickyMenus) usLastPopupItem = IDMPU_DISP_FILTERS; else usLastPopupItem = IDMPU_SYNC; if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)fnwpDisplaySetupDlgProc, (USHORT)NULL, DISP_FILTER_DLG, MPFROMP(&stRead))) { stCFG.bReadTestNewLine = stRead.bTestNewLine; stCFG.bSkipReadBlankLines = stRead.bSkipBlankLines; stCFG.byReadNewLineChar = stRead.byNewLineChar; stCFG.bFilterRead = stRead.bFilter; stCFG.fFilterReadMask = stRead.fFilterMask; stCFG.byReadMask = stRead.byDisplayMask; if (stRead.bSync) { if (!stCFG.bSyncToRead) { stWrite.bSync = FALSE; stCFG.bSyncToWrite = FALSE; stCFG.bSyncToRead = TRUE; if (stCFG.fDisplaying & (DISP_DATA | DISP_FILE)) { ClearColScrollBar(&stWrite); SetupColScrolling(&stRead); } } } else { if (stCFG.bSyncToRead) { stCFG.bSyncToRead = FALSE; if (stCFG.fDisplaying & (DISP_DATA | DISP_FILE)) SetupColScrolling(&stWrite); } } WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); } break; } break; // case WM_CHORD: case WM_BUTTON2DOWN: if(bFrameActivated) { hwndMenu = WinLoadMenu(stRead.hwnd,(HMODULE)NULL,IDMPU_COL_DISP_POPUP); if (mp1 != 0) { WinQueryPointerPos(HWND_DESKTOP,&ptl); if (!stCFG.bStickyMenus) usMenuStyle |= PU_MOUSEBUTTON2DOWN; else usMenuStyle &= ~PU_MOUSEBUTTON2DOWN; } else { usMenuStyle &= ~PU_MOUSEBUTTON2DOWN; WinQueryWindowPos(hwndFrame,&swp); ptl.x = (swp.x + (swp.cx - (swp.cx / 4))); ptl.y = (swp.y + (swp.cy / 2)); } if (stCFG.wColReadFont == wASCIIfont) PopupMenuItemCheck(hwndMenu,IDMPU_ASCII_FONT,TRUE); else PopupMenuItemCheck(hwndMenu,IDMPU_HEX_FONT,TRUE); if (stCFG.fLockWidth == LOCK_READ) PopupMenuItemCheck(hwndMenu,IDMPU_LOCK_WIDTH,TRUE); if (!bStopDisplayThread) WinSendMsg(hwndMenu,MM_SETITEMTEXT,(MPARAM)IDMPU_SYNC,"~Reset Display"); WinPopupMenu(HWND_DESKTOP,stRead.hwndClient,hwndMenu,ptl.x,ptl.y,usLastPopupItem,usMenuStyle); } else return WinDefWindowProc(hwnd,msg,mp1,mp2); break; case WM_BUTTON1DOWN: if(bFrameActivated) { WinCopyRect(habAnchorBlock,&rclRect,&stRead.rcl); lSaveEdge = rclRect.xLeft; if (TrackChildWindow(habAnchorBlock,hwndClient,&rclRect,TF_LEFT)) { if (rclRect.xLeft != lSaveEdge) { WinSendMsg(stWrite.hwndClient,UM_TRACKSIB,0L,(MPARAM)rclRect.xLeft); WinSendMsg(stRead.hwndClient,UM_TRACKSIB,(MPARAM)rclRect.xLeft,0L); if (stCFG.fLockWidth == LOCK_WRITE) stCFG.lLockWidth = ((stWrite.lWidth / stCell.cx) + 1); else stCFG.lLockWidth = ((stRead.lWidth / stCell.cx) + 1); } } } else return WinDefWindowProc(hwnd,msg,mp1,mp2); break; case WM_DESTROY: GpiDestroyPS(hdcPs); break; case UM_SHOWNEW: stRead.lScrollIndex = 0; stRead.lScrollRow = 0; ClearColScrollBar(&stRead); case UM_SHOWAGAIN: stRead.bActive = TRUE; if ((stCFG.fDisplaying & (DISP_DATA | DISP_FILE)) && !stCFG.bSyncToWrite) SetupColScrolling(&stRead); WinShowWindow(stRead.hwnd,TRUE); WinSendMsg(hwnd,UM_TRACKFRAME,0L,0L); WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); WinInvalidateRect(hwndStatus,(PRECTL)NULL,FALSE); break; case UM_HIDEWIN: ClearColScrollBar(&stRead); stRead.bActive = FALSE; WinShowWindow(hwnd,FALSE); WinSetWindowPos(stRead.hwnd,HWND_BOTTOM,0L,0L,0L,0L,(SWP_MOVE | SWP_SIZE | SWP_ZORDER)); break; case WM_PAINT: #ifdef this_junk if (!pstCFG->bDisplayingData && (stCFG.bSyncToRead || stCFG.bSyncToWrite)) ColumnPaint(&stRead,WinPeekMsg(habAnchorBlock,&stQmsg,stWrite.hwndClient,WM_PAINT,WM_PAINT,PM_REMOVE)); else #endif ColumnPaint(&stRead); break; case UM_TRACKSIB: ColumnSize(&stRead,(LONG)mp1,(LONG)mp2,TRUE); break; case UM_TRACKFRAME: ColumnSize(&stRead,(LONG)mp1,(LONG)mp2,FALSE); break; case WM_ERASEBACKGROUND: return (MRESULT)(TRUE); case WM_CLOSE: WinPostMsg(hwnd,WM_QUIT,0L,0L); default: return WinDefWindowProc(hwnd,msg,mp1,mp2); } return(FALSE); }
MRESULT EXPENTRY NEWCFGDlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2) { HWND hwndFrame = hwndDlg; /* ##START Form.37 Top of window procedure */ /* Code sections - Top of window procedure */ /* ##END Top of window procedure */ switch (msg) { /* Form event Opened WM_INITDLG */ case WM_INITDLG : HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); { /* ##START Form.1 */ /* Form events - Opened */ { INT x_screen, y_screen, x_offset, y_offset; POINTL pt; SWP swp; WinQueryWindowPos( hwndDlg, &swp ); WinQueryPointerPos( HWND_DESKTOP, &pt ); swp.x = pt.x - (swp.cx /2); swp.y = pt.y - (swp.cy /2); x_screen = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); y_screen = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); x_offset = x_screen*.005; y_offset = y_screen*.005; if ( swp.cx + swp.x > x_screen ) swp.x = x_screen - (swp.cx + x_offset); if ( swp.x <= 0 ) swp.x = x_offset; if ( swp.y + swp.cy > y_screen ) swp.y = y_screen - (swp.cy + y_offset); if ( swp.y <= 0 ) swp.y = y_offset; WinSetWindowPos(hwndDlg, HWND_TOP, swp.x, swp.y, 0, 0, SWP_ACTIVATE | SWP_MOVE | SWP_SHOW ); } /* ##END */ } break; /* Form event Closed WM_CLOSE */ case WM_CLOSE : /* ##START Form.2 */ /* ##END */ HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); break; case WM_COMMAND : switch (SHORT1FROMMP(mp1)) { /* Button 2001 Clicked/Selected */ case 2001: { /* ##START 2001.0 */ /* Event Clicked/selected - Update 2001 */ UPDATECONFIG = TRUE; ISCANCELLED = FALSE; WinPostMsg(hwndDlg, WM_CLOSE, 0, 0); /* ##END */ } break; /* Button 2002 Clicked/Selected */ case 2002: { /* ##START 2002.0 */ /* Event Clicked/selected - ~Cancel 2002 */ ISCANCELLED = TRUE; WinPostMsg(hwndDlg, WM_CLOSE, 0, 0); /* ##END */ } break; /* Button 2004 Clicked/Selected */ case 2004: { /* ##START 2004.0 */ /* Event Clicked/selected - Do not Update 2004 */ ISCANCELLED = FALSE; WinPostMsg(hwndDlg, WM_CLOSE, 0, 0); /* ##END */ } break; } /* end switch */ break; /* ##START Form.38 User defined messages */ /* ##END User defined messages */ default : HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); return WinDefDlgProc(hwndDlg,msg,mp1,mp2); } /* end switch for main msg dispatch */ return (MRESULT)FALSE; } /* end dialog procedure */
MRESULT EXPENTRY AboutDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) { BOOL bHandled = TRUE; MRESULT mReturn = 0; ULONG ulScrWidth, ulScrHeight; RECTL Rectl; SWP Swp; HPS hps; switch (msg) { case WM_INITDLG: /* Center dialog on screen */ ulScrWidth = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN); ulScrHeight = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN); WinQueryWindowRect (hWnd, &Rectl); WinSetWindowPos (hWnd, HWND_TOP, (ulScrWidth-Rectl.xRight)/2, (ulScrHeight-Rectl.yTop)/2, 0, 0, SWP_MOVE | SWP_ACTIVATE); /* Set application title */ WinSetDlgItemText (hWnd, 10001, (PSZ)mp2); break; case WM_PAINT: hps = WinBeginPaint (hWnd,0,0); WinQueryWindowRect (hWnd, &Rectl); WinFillRect (hps, &Rectl, CLR_PALEGRAY); WinDrawBorder (hps, &Rectl, WinQuerySysValue(HWND_DESKTOP,SV_CXDLGFRAME), WinQuerySysValue(HWND_DESKTOP,SV_CYDLGFRAME), CLR_DARKGRAY, CLR_WHITE, DB_RAISED); GpiMove (hps, (PPOINTL)&Rectl); Rectl.xRight--; Rectl.yTop--; GpiBox (hps, DRO_OUTLINE, (PPOINTL)&Rectl.xRight, 0L, 0L); WinQueryWindowPos (WinWindowFromID (hWnd, 10002), &Swp); Rectl.xLeft = Swp.x-1; Rectl.yBottom = Swp.y-1; Rectl.xRight = Swp.x + Swp.cx + 1; Rectl.yTop = Swp.y + Swp.cy + 1; WinDrawBorder (hps, &Rectl, 1L, 1L, CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED); WinQueryWindowPos (WinWindowFromID (hWnd, 10003), &Swp); Rectl.xLeft = Swp.x-1; Rectl.yBottom = Swp.y-1; Rectl.xRight = Swp.x + Swp.cx + 1; Rectl.yTop = Swp.y + Swp.cy + 1; WinDrawBorder (hps, &Rectl, 1L, 1L, CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED); WinEndPaint (hps); break; case WM_COMMAND: WinDismissDlg (hWnd, DID_OK); break; default: bHandled = FALSE; break; } if (!bHandled) mReturn = WinDefDlgProc (hWnd, msg, mp1, mp2); return (mReturn); }