MRESULT APIENTRY wpDlg ( HWND hwnd, MSG_TYPE msg, MPARAM mp1, MPARAM mp2) { /* wpDlg Start */ MRESULT Result = 0; switch (msg) { /* switch (msg) START */ case WM_INITDLG: { /* WM_INITDLG Start */ HWND hwndMenu; ULONG id; /* load the menu, since currently it seems to be impossible ** to get the menu otherwise during startup of the dialog */ id = WinQueryWindowUShort (hwnd, (ULONG) QWS_ID); hwndMenu = WinLoadMenu (hwnd, (HMODULE) 0, id); } /* WM_INITDLG End */ break; case WM_COMMAND: { /* WM_COMMAND Start */ switch (LOUSHORT(mp1)) { case ID_MENU_1: { WinAlarm (HWND_DESKTOP, (ULONG) WA_ERROR); WinAlarm (HWND_DESKTOP, (ULONG) WA_NOTE); WinAlarm (HWND_DESKTOP, (ULONG) WA_ERROR); WinAlarm (HWND_DESKTOP, (ULONG) WA_NOTE); } break; case DID_OK: { /* do anything... */ } break; default: Result = WinDefDlgProc ( hwnd, msg, mp1, mp2 ); break; } } /* WM_COMMAND End */ break; case WM_CLOSE: default: /* any other message will be handled here, ** also the button problem... */ Result = WinDefDlgProc ( hwnd, msg, mp1, mp2 ); break; } /* switch (msg) END */ return (Result); } /* wpDlg End */
nsresult nsNativeBrowserWindow::CreateMenuBar(PRInt32 aWidth) { HWND hwnd = (HWND)mWindow->GetNativeData(NS_NATIVE_WIDGET); HWND hwndFrame = WinQueryWindow( hwnd, QW_PARENT); HWND hwndMenu = WinLoadMenu( hwndFrame, 0, IDM_VIEWERBAR); WinSendMsg( hwndFrame, WM_UPDATEFRAME, MPFROMLONG(FCF_MENU), 0); return NS_OK; }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) { static HWND hwndMenuPopup ; HPS hps ; POINTL ptlMouse ; switch (msg) { case WM_CREATE: hwndMenuPopup = WinLoadMenu (hwnd, NULL, ID_POPUP) ; WinSetWindowPos (hwndMenuPopup, NULL, 0, 0, 0, 0, SWP_SIZE) ; WinSetParent (hwndMenuPopup, HWND_DESKTOP, FALSE) ; return 0 ; case WM_BUTTON2UP: WinQueryPointerPos (HWND_DESKTOP, &ptlMouse) ; ptlMouse.y += WinQuerySysValue (HWND_DESKTOP, SV_CYMENU) ; WinSetWindowPos (hwndMenuPopup, NULL, (SHORT) ptlMouse.x, (SHORT) ptlMouse.y, 0, 0, SWP_MOVE) ; WinSendMsg (hwndMenuPopup, MM_SELECTITEM, MPFROM2SHORT (IDM_POPUP, FALSE), MPFROMSHORT (FALSE)) ; WinSetCapture (HWND_DESKTOP, hwndMenuPopup) ; return 0 ; case WM_COMMAND: switch (COMMANDMSG(&msg)->cmd) { case IDM_ABOUT: WinDlgBox (HWND_DESKTOP, hwnd, AboutDlgProc, NULL, IDD_ABOUT, NULL) ; return 0 ; } break ; case WM_PAINT: hps = WinBeginPaint (hwnd, NULL, NULL) ; GpiErase (hps) ; WinEndPaint (hps) ; return 0 ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
/*------------------------------------------------------------------------- CreatePopup --------------------------------------------------------------------------*/ void CreatePopup( HAB hab, HWND client, HWND frame ) { HACCEL haccel; if (Popup != NULLHANDLE) DestroyPopup(); Popup = WinLoadMenu( client, NULL, ID_POPUP ); haccel = WinLoadAccelTable( hab, NULLHANDLE, ID_ACCEL ); WinSetAccelTable( hab, haccel, frame ); return; }
static void kstMenu(HWND hwnd, KSTPTR p) { POINTL pt ; ULONG opts ; if (p->hwndMn == NULLHANDLE) { p->hwndMn = WinLoadMenu(hwnd, NULLHANDLE, IDM_KEYST) ; } if (p->hwndMn == NULLHANDLE) { return ; } WinQueryPointerPos(HWND_DESKTOP, &pt) ; opts = PU_HCONSTRAIN | PU_VCONSTRAIN | PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 ; WinPopupMenu(HWND_DESKTOP, hwnd, p->hwndMn, pt.x, pt.y, IDM_KEYTGL, opts) ; }
VOID main() { if ( (hab = WinInitialize( 0L )) == (HAB) NULL ){ printf( "ToolBar Error: WinInitialize failed \n" ); return; } else { if ( (hmq = WinCreateMsgQueue( hab, 0 )) == (HMQ) NULL ){ printf( "ToolBar Error: WinCreateMsgQueue failed \n" ); return; } else { ULONG fulCreate= FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX | FCF_SHELLPOSITION | FCF_ICON ; /* * Note: no menu was specificed in create flags */ WinSetPointer( HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,TRUE)); WinRegisterClass(hab, szClassName, (PFNWP)MainWindowProc, CS_SIZEREDRAW, 0); hwndFrame = WinCreateStdWindow(HWND_DESKTOP, 0L, (PULONG)&fulCreate, szClassName , szMainTitle, 0L, (HMODULE)NULL, ID_MAIN_WIN, &hwndClient); if ( hwndFrame == NULLHANDLE ) { ShowErrorWindow( "Error creating Main window !", TRUE ); } else { PFNWP pfnwpOldFrameProc ; /* --------- subclass frame proc ------------------ */ pfnwpOldFrameProc = WinSubclassWindow( hwndFrame, (PFNWP) NewFrameProc ); if ( pfnwpOldFrameProc == (PFNWP)0L ){ ShowErrorWindow( "Error subclassing frame window !", TRUE ); } else { PID pid ; SWCNTRL swCntrl; HSWITCH hSwitch ; LONG lRGB; /* ------- store old frame proc with handle ------- */ WinSetWindowULong( hwndFrame, QWL_USER, (ULONG) pfnwpOldFrameProc ); /* ------------------ load menus ------------------- */ hwndMenuBar = WinLoadMenu( hwndFrame, (HMODULE)NULL, MID_MENUBAR ); hwndToolBar = WinLoadMenu( hwndFrame, (HMODULE)NULL, MID_TOOLBAR ); /* * Note that the last menu loaded, the toolbar, is the * one that is associated with the frame as "the" menu. * this means that hwndMenuBar is the only link to the * regular action bar, so hang onto it tightly */ /* ---------- set toolbar background color ---------- */ lRGB = WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONDARK, 0L ); WinSetPresParam( hwndToolBar, PP_BACKGROUNDCOLOR, 4L, (PVOID)lRGB ); /* --------- set window size and pos -------------- */ WinSetWindowPos( hwndFrame, HWND_TOP, 0, 0, 370, 300, SWP_SIZE | SWP_SHOW | SWP_ACTIVATE ); /* ----------- add program to tasklist --------------- */ WinQueryWindowProcess( hwndFrame, &pid, NULL ); swCntrl.hwnd = hwndFrame ; swCntrl.hwndIcon = (HWND) NULL ; swCntrl.hprog = (HPROGRAM) NULL ; swCntrl.idProcess = pid ; swCntrl.idSession = (LONG) NULL ; swCntrl.uchVisibility = SWL_VISIBLE ; swCntrl.fbJump = SWL_JUMPABLE ; sprintf( swCntrl.szSwtitle, szMainTitle ); hSwitch = WinAddSwitchEntry((PSWCNTRL)&swCntrl); WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE)); /* ---------- start the main processing loop ----------- */ while (WinGetMsg(hab, &qmsg,NULLHANDLE,0,0)){ WinDispatchMsg(hab, &qmsg); } WinRemoveSwitchEntry( hSwitch ); } /* end of else ( pfnwpOldFrameProc ) */ WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE)); WinDestroyWindow(hwndFrame); } /* end of else (hwndFrame == NULLHANDLE) */ WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE)); WinDestroyMsgQueue(hmq); } /* end of else ( ...WinCreateMsgQueue() */ WinTerminate(hab); } /* end of else (...WinInitialize(NULL) */ } /* end of main() */
/****************************************************************\ * *-------------------------------------------------------------- * * Name:ClkCreate() * * Purpose:Intialize a newly created client window * * * * Usage: * * Method: * - * * - * - * * - * - * * Returns: * 1 - if sucessful execution completed * 0 - if error \****************************************************************/ VOID ClkCreate ( HWND hwnd ) { LONG cxScreen , cyScreen; /* screen dimensions */ LONG xLeft , yBottom ; /* frame window location */ ULONG cbBuf; LONG cyHeight; LONG cxWidth; hwndClient = hwnd; WinLoadString(hab, NULLHANDLE, IDS_TITLE, 0, (PSZ)szTitle ); WinLoadString(hab, NULLHANDLE, IDS_HELPTITLE, 256, (PSZ)szHelpTitle); GetCountryDependent(); /* we are called before the global hwndFrame is valid */ hwndFrame = WinQueryWindow ( hwnd , QW_PARENT) ; hwndTitleBar = WinWindowFromID ( hwndFrame , FID_TITLEBAR ) ; hwndSysMenu = WinWindowFromID ( hwndFrame , FID_SYSMENU ) ; hwndMinMax = WinWindowFromID ( hwndFrame , FID_MINMAX ) ; /* load our menus */ hwndMenu = WinLoadMenu (hwndFrame, NULLHANDLE, IDR_MAIN); /* determine screen dimensions */ /* open a device context and create a presentation space */ hdc = WinOpenWindowDC (hwnd); hps = GpiCreatePS (hab, hdc, &sizl, PU_ARBITRARY | GPIT_MICRO | GPIA_ASSOC); /* * Create our off-screen 'buffer'. */ hdcBuffer = DevOpenDC ( (HAB)0L, OD_MEMORY, "*", 0L, NULL, hdc); hpsBuffer = GpiCreatePS (hab, hdcBuffer, &sizl, PU_ARBITRARY | GPIT_MICRO | GPIA_ASSOC); GpiCreateLogColorTable (hpsBuffer, 0, LCOLF_RGB, 0, 0, (PLONG)NULL); /* get the device resolutions so we can make the face appear circular */ DevQueryCaps (hdc, (LONG)CAPS_VERTICAL_RESOLUTION,(LONG) 1L, &cyRes); DevQueryCaps (hdc, CAPS_HORIZONTAL_RESOLUTION, 1L, &cxRes); DevQueryCaps (hdc, CAPS_COLOR_PLANES, 1L, &cColorPlanes); DevQueryCaps (hdc, CAPS_COLOR_BITCOUNT, 1L, &cColorBitcount); cxScreen = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN); cyScreen = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN); /* * Calculate an initial window position and size. */ xLeft = cxScreen / 8; yBottom = cyScreen / 2; cxWidth = cxScreen / 3; cyHeight = cyScreen / 2; WinSetWindowPos (hwndFrame, NULLHANDLE, xLeft, yBottom, cxWidth, cyHeight, SWP_SIZE | SWP_MOVE | SWP_ACTIVATE); cbBuf = sizeof(cp); if (!PrfQueryProfileData(HINI_USER, SZ_APPNAME, SZ_KEYNAME, &cp, &cbBuf)) { cp.usMajorTickPref = CLKTM_ALWAYS; cp.usMinorTickPref = CLKTM_NOTICONIC; cp.clrBackground = 0x00008080; cp.clrFace = 0x00008080; cp.clrHourHand = RGB_RED; cp.clrMinuteHand = RGB_RED; cp.fControlsHidden = FALSE; cp.usDispMode = DM_TIME | DM_ANALOG | DM_SECONDHAND; cp.alarm.uchHour = 0; cp.alarm.uchMinutes = 0; cp.alarm.usMode = 0; SetRGBColors(); /* position the window and make it visible */ WinSetWindowPos( hwndFrame , NULLHANDLE , xLeft , yBottom , cxWidth , cyHeight , SWP_SIZE | SWP_MOVE | SWP_ACTIVATE); WinQueryWindowPos(hwndFrame, &cp.swp); } else { /*Protect against garbage swp*/ cp.swp.hwnd = hwndFrame; cp.swp.hwndInsertBehind = HWND_TOP; cp.swp.fl = (cp.swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE)) | SWP_SIZE | SWP_MOVE | SWP_ACTIVATE; SetRGBColors(); WinSetMultWindowPos(hab, &cp.swp, 1); } if (cp.fControlsHidden) ClkHideFrameControls (hwndFrame); /* * Check relevant items. */ WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_TIME, TRUE), MPFROM2SHORT( MIA_CHECKED, ( (cp.usDispMode & DM_TIME)? MIA_CHECKED : ~MIA_CHECKED) ) ); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_DATE, TRUE), MPFROM2SHORT( MIA_DISABLED, ( (!(cp.usDispMode & DM_TIME))? MIA_DISABLED : ~MIA_DISABLED) ) ); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_DATE, TRUE), MPFROM2SHORT( MIA_CHECKED, ( (cp.usDispMode & DM_DATE)? MIA_CHECKED : ~MIA_CHECKED) ) ); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_TIME, TRUE), MPFROM2SHORT( MIA_DISABLED, ( ((!(cp.usDispMode & DM_DATE) || (cp.usDispMode & DM_ANALOG)))? MIA_DISABLED : ~MIA_DISABLED) ) ); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( (cp.usDispMode & DM_DIGITAL) ?IDM_DIGITAL :IDM_ANALOG, TRUE), MPFROM2SHORT( MIA_CHECKED, MIA_CHECKED)); WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(IDM_SECONDHAND, TRUE), MPFROM2SHORT( MIA_CHECKED, ( (cp.usDispMode & DM_SECONDHAND) ? MIA_CHECKED : ~MIA_CHECKED))); /* * Disable these items if the digital clock is visible * since they won't apply. */ if (cp.usDispMode & DM_DIGITAL) { WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(IDM_SECONDHAND, TRUE), MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED)); WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_TICKS, TRUE), MPFROM2SHORT( MIA_DISABLED, MIA_DISABLED)); } /* have we been asked to start as an icon? */ if (fStartAsIcon) WinSetWindowPos(hwndFrame, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE); WinShowWindow(hwndFrame, TRUE); /* get the time in a format for dislaying */ DosGetDateTime(&dt); dt.hours = (UCHAR )(dt.hours * (UCHAR) 5) % (UCHAR) 60 + dt.minutes / (UCHAR)12; /* start a timer */ WinStartTimer (hab, hwnd, IDR_MAIN, 1000); WinLoadString(hab, NULLHANDLE, IDS_TITLE, 80, (PSZ)szTitle); GetCountryDependent(); }
static MRESULT EXPENTRY pm_vsid(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { extern int trigger_shutdown; switch (msg) { case WM_INITDLG: { HWND hmenu; HPOINTER hicon = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, DLG_VSID); if (hicon) { WinSendMsg(hwnd, WM_SETICON, MPFROMLONG(hicon), MPVOID); } // // Try to attach the menu and make it visible // hmenu = WinLoadMenu(hwnd, NULLHANDLE, IDM_VICE2); if (hmenu) { SWP swp; WinQueryWindowPos(hwnd, &swp); WinDelMenuItem(hmenu, IDM_FILE); WinDelMenuItem(hmenu, IDM_VIEW); WinDelMenuItem(hmenu, IDM_SETUP); WinDelMenuItem(hmenu, IDM_MONITOR); swp.cy += WinQuerySysValue(HWND_DESKTOP, SV_CYMENU) + 1; WinSetWindowPos(hwnd, 0, 0, 0, swp.cx, swp.cy, SWP_SIZE); WinSendMsg(hwnd, WM_UPDATEFRAME, MPFROMLONG(FID_MENU), MPVOID); } WinSubclassDlg(hwnd, ID_TBOX, pm_vsid_dragndrop); WinSubclassDlg(hwnd, ID_TNAME, pm_vsid_dragndrop); WinSubclassDlg(hwnd, ID_TAUTHOR, pm_vsid_dragndrop); WinSubclassDlg(hwnd, ID_TCOPYRIGHT, pm_vsid_dragndrop); WinSubclassDlg(hwnd, ID_TSYNC, pm_vsid_dragndrop); WinSubclassDlg(hwnd, ID_TIRQ, pm_vsid_dragndrop); WinSubclassDlg(hwnd, ID_TSID, pm_vsid_dragndrop); } return FALSE; case WM_MENUSELECT: menu_select(HWNDFROMMP(mp2), SHORT1FROMMP(mp1)); break; case WM_DESTROY: trigger_shutdown = 1; break; case WM_COMMAND: switch (LONGFROMMP(mp1)) { case DID_CLOSE: trigger_shutdown = 1; break; default: menu_action(hwnd, SHORT1FROMMP(mp1)); return FALSE; } break; case WM_CONTROL: if (mp1 == MPFROM2SHORT(SPB_SETTUNE, SPBN_ENDSPIN)) { const ULONG val = WinGetSpinVal((HWND)mp2); resources_set_int("PSIDTune", (int)val); } break; case WM_DISPLAY: { char *txt = lib_msprintf("Vice/2 SID Player - %d%%", mp1); WinSetDlgItemText(hwnd, FID_TITLEBAR, txt); lib_free(txt); } return FALSE; } return WinDefDlgProc(hwnd, msg, mp1, mp2); }
/*----------------------------------------------------------------------------*/ MRESULT EXPENTRY DLG_MAIN_Proc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) /*----------------------------------------------------------------------------*/ /* This dialog proc initializes and handles all messages for the main */ /* dialog. */ /*----------------------------------------------------------------------------*/ { static HWND ContextHwnd; /* Handle of context menu */ static SHORT ContextIndx; /* Index of item context menu was selected on */ switch (msg) { case WM_INITDLG: INSERTITEM(LIST, "Listbox item 0"); INSERTITEM(LIST, "Listbox item 1"); INSERTITEM(LIST, "Listbox item 2"); INSERTITEM(LIST, "Listbox item 3"); INSERTITEM(LIST, "Listbox item 4"); INSERTITEM(LIST, "Listbox item 5"); INSERTITEM(LIST, "Listbox item 6"); INSERTITEM(LIST, "Listbox item 7"); INSERTITEM(LIST, "Listbox item 8"); INSERTITEM(LIST, "Listbox item 9"); INSERTITEM(LIST, "Listbox item 10"); INSERTITEM(LIST, "Listbox item 11"); INSERTITEM(LIST, "Listbox item 12"); INSERTITEM(LIST, "Listbox item 13"); INSERTITEM(LIST, "Listbox item 14"); INSERTITEM(LIST, "Listbox item 15"); /* Add direct-manipulation capability to the listbox */ DMLBInitialize(CONTROLHWND(LIST), NULLHANDLE); /* Load context menu for later use */ ContextHwnd = WinLoadMenu(hwnd, NULLHANDLE, ID_MENU); return FALSE; case WM_DESTROY: /* Free resources */ WinDestroyWindow(ContextHwnd); break; case WM_COMMAND: switch (SHORT1FROMMP(mp1)) { /*******************************************************************/ /* We get WM_COMMAND messages from the context menu. The variable */ /* ContextIndx already has the index of the item on which the */ /* context menu was requested (or LIT_NONE). */ /*******************************************************************/ case ID_MENU_EDIT: { //------- Context menu "Edit" selected ----------- char Buff[MAX_LEN]; /* Run edit menu, update list if user selects OK button */ QUERYITEMTEXT(LIST, ContextIndx, Buff, sizeof(Buff)); if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)DLG_EDIT_Proc, NULLHANDLE, DLG_EDIT, Buff) == DID_OK) SETITEMTEXT(LIST, ContextIndx, Buff); return 0; } case ID_MENU_DELETE: //------- Context menu "Delete" selected ----------- WinSendMsg(CONTROLHWND(LIST), LM_DELETEITEM, MPFROMSHORT(ContextIndx), MPVOID); return 0; case ID_MENU_INSERT: {//------- Context menu "Insert" selected ---------- char Buff[MAX_LEN]; /* Run edit menu, insert into list if user selects OK button */ Buff[0] = '\0'; if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)DLG_EDIT_Proc, NULLHANDLE, DLG_EDIT, Buff) == DID_OK) { if (ContextIndx == LIT_NONE) // Insert at end of list ContextIndx = LIT_END; else ContextIndx++; // Insert AFTER selected item INSERTITEMAT(LIST, ContextIndx, Buff); } return 0; } case DID_OK: /*----------~OK (PUSHBUTTON)----------*/ // Let default dialog proc terminate us break; } break; case WM_CONTROL: switch SHORT1FROMMP(mp1) { case LIST: /*----------LIST (LISTBOX)----------*/ /*******************************************************************/ /* Notification messages from the listbox come here. These are */ /* the usual PM listbox messages, plus some new ones for DMLB. */ /*******************************************************************/ switch (SHORT2FROMMP(mp1)) { case LN_SELECT: case LN_ENTER: /* User dbl-clicked an entry or pressed ENTER. For this sample */ /* we do nothing. */ return 0; case LN_DMLB_QRYDROP: /* A listbox item is about to be dropped on this listbox. We must */ /* return a Ok-to-drop indicator, and tell what to do with the */ /* original item (copy or move). Since we have just one listbox in */ /* this sample, MOVE is the only thing that makes sense. */ return MRFROM2SHORT(TRUE, DROPMODE_MOVE); case LN_DMLB_CONTEXT: { /* The user has requested a context menu. Short 1 of mp2 is the */ /* index of the listbox item under the pointer. */ POINTL Point; ContextIndx = SHORT1FROMMP(mp2); if (ContextIndx == LIT_NONE) { // Disable Edit & Delete if pointer was not over a listbox item WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_EDIT,FALSE), MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED)); WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_DELETE,FALSE), MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED)); } else { // Otherwise, enable Edit & Delete WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_EDIT,FALSE), MPFROM2SHORT(MIA_DISABLED, ~MIA_DISABLED)); WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_DELETE,FALSE), MPFROM2SHORT(MIA_DISABLED, ~MIA_DISABLED)); } // It is not technically necessary to select the item on which the context // menu was selected, but it provides good visual feedback to the user to // show which item the context menu applies to. SETSELECTION(LIST, ContextIndx); // Popup the context menu at the pointer position. The menu will // send us WM_COMMAND messages if a menu item is selected. WinQueryMsgPos((HAB)0, &Point); WinPopupMenu(HWND_DESKTOP, hwnd, ContextHwnd, Point.x, Point.y, 0, PU_HCONSTRAIN| PU_VCONSTRAIN | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_MOUSEBUTTON3 | PU_KEYBOARD ); return (MRESULT)TRUE; } } break; } break; /* End of WM_CONTROL */ } /* End of (msg) switch */ return WinDefDlgProc(hwnd, msg, mp1, mp2); } /* End dialog procedure */
MRESULT mainwmCreate( HWND hwnd, MPARAM mp1, MPARAM mp2 ) { PCREATESTRUCT pcreate = (PCREATESTRUCT) mp2; HMLECTLDATA hmlecd; ULONG flStyle = WS_VISIBLE | HMLS_VSCROLL | HMLS_HSCROLL | HMLS_STATUSNOTIFY;// | HMLS_BORDER; //HSTCTLDATA hstcd; ToolbarItemSpec itemSpec; HWND hwndItem; char text[100]; LONG color; // printf("HMLEdit:: WM_CREATE\n"); if (readonly) { flStyle |=HMLS_READONLY; } if( wordWrap ) flStyle |= HMLS_WORDWRAP; hwndHIA = HIACreateHanAutomata(hwnd,ID_HIA); hmlecd.cb = sizeof(hmlecd); hmlecd.eol_type = eol_type; hmlecd.han_type = han_type; hmlecd.autoIndent = autoIndent; hmlecd.maxLineSize = maxLineSize; hmlecd.wordWrapSize = wordWrapSize; hmlecd.wordProtect = wordProtect; hmlecd.hwndHIA = hwndHIA; // printf("cx = %d\ncy = %d\n",pcreate->cx,pcreate->cy); // printf("maxLineSize = %d\n",maxLineSize); hwndHMLE = WinCreateWindow ( hwnd,WC_HMLE, NULL, flStyle | HMLS_ACCEPTFILEDROP, 0,(use_statbar?STATBAR_YSIZE:0),pcreate->cx,pcreate->cy-(use_statbar?STATBAR_YSIZE:0)-(use_toolbar?TOOLBAR_YSIZE:0), hwnd, HWND_TOP, ID_HANMLE, &hmlecd, NULL); WinSendMsg(hwndHMLE,HMLM_SETTEXTCOLOR,MPFROMLONG(fgColor),0); WinSendMsg(hwndHMLE,HMLM_SETBACKCOLOR,MPFROMLONG(bgColor),0); WinSendMsg(hwndHMLE,HMLM_SETSELTEXTCOLOR,MPFROMLONG(selfgColor),0); WinSendMsg(hwndHMLE,HMLM_SETSELBACKCOLOR,MPFROMLONG(selbgColor),0); WinSendMsg(hwndHMLE,HMLM_SETTABSTOP,MPFROMLONG(tabStop),0); // printf("HMLE:%x\n",hwndHMLE); // CONTROL "by ¹®À¯¼º", 104, 37, 60, 72, 8, "HanStaticText",SS_TEXT|DT_VCENTER|DT_CENTER|WS_VISIBLE // toolbar { hwndToolbar = WinCreateWindow ( hwnd,WC_TOOLBAR, NULL,WS_VISIBLE, 0,pcreate->cy-TOOLBAR_YSIZE,pcreate->cx,TOOLBAR_YSIZE, hwnd,HWND_TOP, ID_TOOLBAR, NULL,NULL); itemSpec.text = text; itemSpec.className = WC_HST; strcpy(text,"HanEdit/2"); itemSpec.style = SS_TEXT | DT_CENTER | DT_VCENTER; itemSpec.xsize = 100; itemSpec.ysize = 0; itemSpec.id = -1; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); if (hwndItem) { WinSendMsg(hwndItem,HSTM_SETTEXTCOLOR,MPFROMLONG(CLR_BLACK),0); } else printf("error! WC_HST\n"); itemSpec.className = WC_BUTTON; strcpy(text,"Open"); itemSpec.style = BS_PUSHBUTTON|BS_TEXT|BS_NOBORDER|BS_AUTOSIZE; itemSpec.xsize = -1; itemSpec.ysize = 0; itemSpec.id = IDM_OPEN; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); if (hwndItem) {} else printf("error!\n"); strcpy(text,"Save"); itemSpec.id = IDM_SAVE; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); if (hwndItem) {} else printf("error!\n"); strcpy(text,"Change"); itemSpec.id = IDM_QUICKRELOAD; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); if (hwndItem) { color = CLR_RED; WinSetPresParam(hwndItem,PP_FOREGROUNDCOLORINDEX,sizeof(LONG),&color); WinSendMsg(hwndToolbar,TOOLBAR_USERM_SHOWITEM,MPFROMLONG(TOOLBAR_RELOAD),FALSE); } else printf("error!\n"); strcpy(text,"Exit"); itemSpec.id = IDM_EXIT; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); if (hwndItem) { color = CLR_RED; WinSetPresParam(hwndItem,PP_BACKGROUNDCOLORINDEX,sizeof(LONG),&color); } else printf("error!\n"); itemSpec.className = NULL; itemSpec.xsize = 4; itemSpec.id = -1; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); itemSpec.className = WC_BUTTON; strcpy(text,"Copy"); itemSpec.xsize = -1; itemSpec.id = IDM_COPY; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); if (hwndItem) {} else printf("error!\n"); strcpy(text,"Cut"); itemSpec.id = IDM_CUT; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); if (hwndItem) {} else printf("error!\n"); strcpy(text,"Paste"); itemSpec.id = IDM_PASTE; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); if (hwndItem) {} else printf("error!\n"); strcpy(text,"Clear"); itemSpec.id = IDM_CLEAR; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); if (hwndItem) {} else printf("error!\n"); itemSpec.className = NULL; itemSpec.xsize = 4; itemSpec.id = -1; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); /* itemSpec.className = WC_HEF; strcpy(text,"HEF"); itemSpec.style = WS_VISIBLE|HES_BORDER; itemSpec.xsize = 200; itemSpec.ysize = 18; itemSpec.id = -1; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); if (hwndItem) { WinSendMsg(hwndItem,HEM_SETTEXTCOLOR,MPFROMLONG(CLR_CYAN),0); WinSendMsg(hwndItem,HEM_SETBACKCOLOR,MPFROMLONG(SYSCLR_BACKGROUND),0); WinSendMsg(hwndItem,HEM_SETSELTEXTCOLOR,MPFROMLONG(selfgColor),0); WinSendMsg(hwndItem,HEM_SETSELBACKCOLOR,MPFROMLONG(selbgColor),0); } else printf("error!\n"); itemSpec.className = NULL; itemSpec.xsize = 4; itemSpec.id = -1; hwndItem = (HWND)WinSendMsg(hwndToolbar,TOOLBAR_USERM_ADDITEM,&itemSpec,NULL); */ HideEditButtons(hwnd); } hwndStatbar = WinCreateWindow ( hwnd,WC_STATBAR, NULL,WS_VISIBLE, 0,0,pcreate->cx-0,STATBAR_YSIZE, hwnd,HWND_TOP, ID_STATBAR, NULL,NULL); if (hwndStatbar==NULLHANDLE) printf("error! statbar\n"); // pop-up menu hwndPopupMenu = WinLoadMenu( hwnd, NULLHANDLE, ID_POPUP ); WinPostMsg(hwnd,HEWM_INIT,0L,0L); return MRFROMLONG(FALSE); }
MRESULT EXPENTRY AirTrafficControlDlg (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { PINST pinst; pinst = (PINST) WinQueryWindowPtr(hwnd,QWL_USER); switch (msg) { case WM_INITDLG: { /* * INITIALIZE APPLICATION */ CNRINFO ccinfo; // Container info structure // Initialize instance data pinst = (PINST) calloc (1, sizeof *pinst); WinSetWindowPtr(hwnd,QWL_USER,pinst); pinst->hwndCnr = WinWindowFromID (hwnd, IDCNR_SAMPLE); pinst->hab = WinQueryAnchorBlock (hwnd); pinst->hwndAircraftMenu = // Load aircraft menu WinLoadMenu( HWND_OBJECT, 0, IDMENU_AIRCRAFT); pinst->hwndContainerMenu = // Load container menu WinLoadMenu( HWND_OBJECT, 0, IDMENU_CONTAINER); pinst->CurrentView = IDMVIEW_RADAR; // Set container info to request owner background painting memset (&ccinfo, 0, sizeof ccinfo); ccinfo.cb = sizeof ccinfo; ccinfo.flWindowAttr = CA_OWNERPAINTBACKGROUND; WinSendMsg (pinst->hwndCnr, CM_SETCNRINFO, &ccinfo, MPFROMLONG(CMA_FLWINDOWATTR)); // Subclass container window to provide background painting pfnwpCnr = WinSubclassWindow (pinst->hwndCnr, CnrSubclassWndProc); assert (pfnwpCnr); // Insert the columns into the container InsertContainerColumns (pinst); // Insert the initial records into the container InsertContainerRecords (pinst); // Start a timer to control aircraft WinStartTimer (pinst->hab, hwnd, IDTIMER_ADJUSTAIRCRAFT, AIRCRAFT_ADJUST_FREQUENCY); // The container is ready for viewing WinShowWindow (pinst->hwndCnr, TRUE); SetUpControllerHandoffValueSet (hwnd); return 0; } case WM_TIMER: /* * DO TIME-RELATED AIRCRAFT HANDLING */ if (SHORT1FROMMP (mp1) == IDTIMER_ADJUSTAIRCRAFT) { PAPPCNRREC pacrTraverse; // Loop through all container records for (pacrTraverse = FIRST_CNR_ITEM (pinst->hwndCnr); pacrTraverse; pacrTraverse = NEXT_CNR_ITEM(pinst->hwndCnr,pacrTraverse)) { BOOL fInvalid = FALSE; if (pinst->CurrentView == IDMVIEW_RADAR) { /* Erase the record from previous location. */ WinSendMsg (pinst->hwndCnr, CM_ERASERECORD, MPFROMP(pacrTraverse), NULL); } // Maneuver the aircraft if (ManeuverAircraft (pacrTraverse)) { // Update aircraft text if necessary SetRecordText (pacrTraverse); fInvalid = TRUE; } if (fInvalid || pinst->CurrentView == IDMVIEW_RADAR) /* Paint the record in its new position */ WinSendMsg (pinst->hwndCnr, CM_INVALIDATERECORD, MPFROMP(&pacrTraverse), MPFROMSHORT(1)); } } else if (SHORT1FROMMP (mp1) == IDTIMER_DISPLAYTIMEDMSG) { WinStopTimer (pinst->hab, hwnd, IDTIMER_DISPLAYTIMEDMSG); WinSetDlgItemText (hwnd, IDST_STATUSMESSAGES, ""); } return 0; case WM_CONTROL: if (SHORT1FROMMP (mp1) == IDCNR_SAMPLE) switch (SHORT2FROMMP (mp1)) { case CN_CONTEXTMENU: { /* * MENU HANDLING */ POINTL ptlMouse; HWND hwndMenu; WinQueryMsgPos (pinst->hab, &ptlMouse); // Save pointer to record mouse is over, if any pinst->pacrSelected = (PAPPCNRREC) mp2; hwndMenu = pinst->pacrSelected ? pinst->hwndAircraftMenu : pinst->hwndContainerMenu; // Display menu WinPopupMenu (HWND_DESKTOP, hwnd, hwndMenu, ptlMouse.x, ptlMouse.y, 0, PU_HCONSTRAIN | PU_VCONSTRAIN | PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_MOUSEBUTTON3); return 0; } case CN_INITDRAG: ProcessInitDrag ( WinWindowFromID (hwnd, SHORT1FROMMP (mp1)), ((PCNRDRAGINIT) (PVOIDFROMMP(mp2)))); return 0; case CN_SCROLL: WinInvalidateRect (pinst->hwndCnr, 0, 0); return 0; } else /* * HANDLE WM_CONTROL MESSAGES FROM VALUE SET CONTROL */ if (SHORT1FROMMP (mp1) == IDVS_CONTROLLERS) switch (SHORT2FROMMP (mp1)) { case VN_SELECT: DisplayTimedMsg (pinst->hab, hwnd, "Drag an airplane to one " "of the controller icons to hand off to " "another controller.", 8); return 0; case VN_DROP: { PVSDRAGINFO pvsdinfo = (PVSDRAGINFO) PVOIDFROMMP (mp2); PDRAGINFO pdinfo = pvsdinfo->pDragInfo; PDRAGITEM pditem; INT iItem; INT cHandedOffAircraft = 0; CHAR szHandedOffAircraft [100]; *szHandedOffAircraft = 0; assert (DrgAccessDraginfo(pdinfo)); for (iItem = 0; iItem < pdinfo->cditem; ++iItem) { PAPPCNRREC pacr; pditem = DrgQueryDragitemPtr (pdinfo, iItem); pacr = (PAPPCNRREC) pditem->ulItemID; if (pdinfo->usOperation == DO_MOVE) { WinSendMsg (pdinfo->hwndSource, CM_REMOVERECORD, MPFROMP(&pacr), MPFROM2SHORT (1, CMA_INVALIDATE)); if (cHandedOffAircraft++) strcat (szHandedOffAircraft, ", "); strcat (szHandedOffAircraft, pacr->pszCallsign); } } if (cHandedOffAircraft) { CHAR szMsg [200]; sprintf (szMsg, "Aircraft %s %s been handed off " "to %s Sector controller.", szHandedOffAircraft, cHandedOffAircraft > 1 ? "have" : "has", pvsdinfo->usColumn == 1 ? "West" : "East"); DisplayTimedMsg (pinst->hab, hwnd, szMsg, 8); } DrgFreeDraginfo (pdinfo); WinAlarm (HWND_DESKTOP, WA_NOTE); return 0; } } return 0; case WM_COMMAND: /* * COMMAND HANDLING */ switch (SHORT1FROMMP (mp1)) { case IDMAIRCRAFT_CONTROLINSTRUCT: // Issue instruction { // Present "Control Aircraft" dialog WinDlgBox (HWND_DESKTOP, hwnd, ControlInstructionDlg, 0, IDDLG_CONTROLAIRCRAFT, pinst); return 0; } case IDMVIEW_RADAR: case IDMVIEW_NAME: case IDMVIEW_TREE: case IDMVIEW_DETAILS: case IDMVIEW_TEXT: { static const ULONG aViews [] = { CV_ICON, CV_NAME, CV_TREE, CV_DETAIL, CV_TEXT }; CNRINFO ccinfo; memset (&ccinfo, 0, sizeof ccinfo); ccinfo.cb = sizeof ccinfo; ccinfo.flWindowAttr = CA_DETAILSVIEWTITLES | CA_TITLESEPARATOR | CA_TREELINE | CA_OWNERPAINTBACKGROUND | aViews [SHORT1FROMMP (mp1) - IDMVIEW_BASE]; WinSendMsg (pinst->hwndCnr, CM_SETCNRINFO, &ccinfo, MPFROMLONG(CMA_FLWINDOWATTR)); pinst->CurrentView = SHORT1FROMMP (mp1); WinInvalidateRect (pinst->hwndCnr, 0, 0); return 0; } } return WinDefDlgProc (hwnd, msg, mp1, mp2); default: return WinDefDlgProc (hwnd, msg, mp1, mp2); } }
MRESULT EXPENTRY XLogoWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { HPS hps; HWND hwndMenu; /* Menu resource */ RECTL rcl; /* For finding current window dimensions */ BOOL fSuccess; switch(msg) { case WM_ERASEBACKGROUND: /* * Return TRUE to request PM to paint the window background * in SYSCLR_WINDOW. */ return (MRESULT)( TRUE ); case WM_PAINT: /* * Window contents are drawn here in WM_PAINT processing. */ { HPS hps; /* Presentation Space handle */ RECTL rc; /* Rectangle coordinates */ POINTL pt; /* String screen coordinates */ LONG Lx, Ly; /* Starting points for paths A and B */ POINTL PathAStart, PathBStart; POINTL PathAPolygon[5], PathBPolygon[5]; /* Paths A, B definitions */ /* Create a presentation space */ hps = WinBeginPaint( hwnd, 0L, &rc ); GpiSetColor(hps, CLR_BLACK); /* colour of the text, */ GpiSetBackColor(hps, CLR_BACKGROUND); /* its background and */ GpiSetBackMix(hps, BM_OVERPAINT); /* how it mixes, */ /* and draw the string...*/ WinFillRect( hps, &rc, SYSCLR_WINDOW); WinQueryWindowRect(hwnd, &rcl); Lx = rcl.xRight - rcl.xLeft; /* Calculate window dimensions! */ Ly = rcl.yTop - rcl.yBottom; /* Find starting points of the two paths which make up the X */ PathAStart.x = 0.061 * Lx; PathAStart.y = Ly; PathBStart.x = 0.864 * Lx; PathBStart.y = Ly; /* Find the points for path A, the left half of the X */ PathAPolygon[0].x = 0.404 * Lx; PathAPolygon[0].y = 0.483 * Ly; PathAPolygon[1].x = 0.06 * Lx; PathAPolygon[1].y = 0; PathAPolygon[2].x = 0.141 * Lx; PathAPolygon[2].y = 0; PathAPolygon[3].x = 0.556 * Lx; PathAPolygon[3].y = 0.589 * Ly; PathAPolygon[4].x = 0.288 * Lx; PathAPolygon[4].y = Ly; /* Find the points for path B, the right half of the X */ PathBPolygon[0].x = 0.455 * Lx; PathBPolygon[0].y = 0.417 * Ly; PathBPolygon[1].x = 0.722 * Lx; PathBPolygon[1].y = 0; PathBPolygon[2].x = 0.939 * Lx; PathBPolygon[2].y = 0; PathBPolygon[3].x = 0.6 * Lx; PathBPolygon[3].y = 0.517 * Ly; PathBPolygon[4].x = 0.939 * Lx; PathBPolygon[4].y = Ly; /* Define and draw path A */ GpiBeginPath(hps, 1L); GpiMove(hps, &PathAStart); GpiPolyLine(hps, 5L, PathAPolygon); GpiCloseFigure(hps); GpiEndPath(hps); GpiFillPath(hps, 1L, FPATH_ALTERNATE); /* Define and draw path B. Path number must be 1L */ GpiBeginPath(hps, 1L); GpiMove(hps, &PathBStart); GpiPolyLine(hps, 5L, PathBPolygon); GpiCloseFigure(hps); GpiEndPath(hps); GpiFillPath(hps, 1L, FPATH_ALTERNATE); WinEndPaint(hps); break; } case WM_BUTTON2DOWN: { /* Opens the popup menu at current mouse co-ordinates */ hwndMenu = WinLoadMenu(hwnd, (HMODULE)NULL, ID_X); fSuccess = WinPopupMenu(hwnd, hwndFrame, hwndMenu, MOUSEMSG(&msg)->x, MOUSEMSG(&msg)->y, IDM_EXIT, PU_POSITIONONITEM | PU_HCONSTRAIN | PU_VCONSTRAIN | PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2); break; } case WM_CLOSE: /* * This is the place to put your termination routines */ WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 ); break; case WM_COMMAND: switch (SHORT1FROMMP (mp1)) { case IDM_ABOUT: /* Show Product information dialog box */ WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, 0, IDD_ABOUT, 0); return ((MRESULT)0); case IDM_EXIT: WinSendMsg (hwnd, WM_CLOSE, 0L, 0L); return ((MRESULT)0); } break; default: /* * Everything else comes here. This call MUST exist * in your window procedure. */ return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } return (MRESULT)FALSE; } /* End of XLogoWndProc */
ULONG SpoolerInitialize(HMODULE hDLLPc2Hook) { ULONG flCreate=FCF_SPOOLERWINDOW; /* Frame creation control flag */ SWP swp; /* According to a tip from members of OS/2 development in an article in OS/2 Developer magazine, it is more efficient to call WinSetMultWindowPos(), because WinSetWindowPos() internally calls WinSetMultWindowPos() (even if just one window is moved) */ HMODULE hDLLPmSpl; /* DLL handle of PMSPL.DLL */ UCHAR ucBuffer[80]; /* DosLoadModule() error buffer */ /* Parameter for Spl32QmInitialize. Under Merlin Beta the return code is not set when running under the WPS, but the PC/2 seems to be able to control the spooler anyway, so preset it */ ULONG ulSpoolerRc=NO_ERROR; /* Get access to the PC/2 control structure */ if(DosQueryProcAddr(hDLLPc2Hook, DLLENTRYPOINTHOOKPARAMETERS, NULL, (PFN *)(&pHP))!=NO_ERROR) return(ERROR_FILE_NOT_FOUND); /* *\ * Initialize the spooler interface of PMSPL.DLL, if PC/2 is running as a WPS * * replacement, by loading SPL32QMINITIALIZE from PMSPL.DLL. * \* */ if(DosLoadModule(ucBuffer, sizeof(ucBuffer)-1, "PMSPL", &hDLLPmSpl)!=NO_ERROR) { /* DLL couldn't be found in the current PC/2 directory or via the LIBPATH path */ return(ERROR_FILE_NOT_FOUND); } if(DosQueryProcAddr(hDLLPmSpl, 0, "SPL32QMINITIALIZE", (PFN *)(&pSpl32QmInitialize))!=NO_ERROR) { /* An error occured */ DosFreeModule(hDLLPmSpl); return(ERROR_FILE_NOT_FOUND); } /* Initialize the OS/2 2.x spooler */ pSpl32QmInitialize(&ulSpoolerRc); /* Return any error and disable Spooler Container, except for error 0x4FFD which is returned when the OS/2 Spooler is already running. Note, this error is not documented, so this assumption comes from trial and error... */ if(ulSpoolerRc==0x4FFD) ulSpoolerRc=NO_ERROR; if(ulSpoolerRc!=NO_ERROR) return(ulSpoolerRc); /* *\ * If spooler could be initialized create PC/2 Spooler Control Window. * \* */ if(!WinRegisterClass( /* Register window class */ pHP->habPc2, /* Handle of anchor block */ (PSZ)PC2_CLASSNAME_SPOOLER, /* Window class name */ (PFNWP)PC2_SpoolerWindowProc, /* Address of window procedure */ /* Class style */ CS_SIZEREDRAW | CS_SAVEBITS | CS_MOVENOTIFY, 0)) /* Extra window words */ return(1); /* Create a standard window */ if((pHP->hwndSpoolerFrame=WinCreateStdWindow( HWND_DESKTOP, /* DESKTOP is parent */ 0, /* Standard window styles */ &flCreate, /* Frame control flags */ (PSZ)PC2_CLASSNAME_SPOOLER, /* Client window class name */ "", /* No window text */ 0, /* No special class style */ pHP->hDLLPc2Spooler, /* Ressource is in PC2SPOOL.DLL file */ ID_PC2SPOOLERWINDOW, /* Frame window identifier */ &pHP->hwndSpoolerClient) /* Client window handle */ )==NULLHANDLE) return(2); WinSetWindowText(pHP->hwndSpoolerFrame, PC2_SPOOLER_WINDOW); swp.fl=SWP_HIDE|SWP_MOVE|SWP_SIZE|SWP_DEACTIVATE; swp.x=pHP->swpPC2Spooler.x; swp.y=pHP->swpPC2Spooler.y; swp.cx=pHP->swpPC2Spooler.cx; swp.cy=pHP->swpPC2Spooler.cy; swp.hwndInsertBehind=NULLHANDLE; swp.hwnd=pHP->hwndSpoolerFrame; WinSetMultWindowPos(pHP->habPc2, &swp, 1); hwndSpoolerPopupMenu=WinLoadMenu(pHP->hwndSpoolerClient, pHP->hDLLPc2Spooler, ID_SPOOLERPOPUPMENU); return(NO_ERROR); }
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 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); }