static MRESULT APIENTRY OK ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { /*************************************************************************** * Find the instance data. * ***************************************************************************/ PPROFILE_PARMS Parms = PPROFILE_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ; /*************************************************************************** * Verify the entered path. * ***************************************************************************/ BYTE Name [256] ; WinQueryDlgItemText ( hwnd, Parms->id+ENTRY, sizeof(Name), Name ) ; BYTE FullPath [256] ; if ( DosQueryPathInfo ( Name, FIL_QUERYFULLNAME, FullPath, sizeof(FullPath) ) ) { PSZ Message = PSZ ( "ERROR: Not a valid path." ) ; WinSetDlgItemText ( hwnd, Parms->id+ERR, Message ) ; WinAlarm ( HWND_DESKTOP, WA_ERROR ) ; WinSetFocus ( HWND_DESKTOP, WinWindowFromID ( hwnd, Parms->id+ENTRY ) ) ; return ( 0 ) ; } FILESTATUS3 Status ; if ( DosQueryPathInfo ( FullPath, FIL_STANDARD, &Status, sizeof(Status) ) ) { PSZ Message = PSZ ( "ERROR: Path does not exist." ) ; WinSetDlgItemText ( hwnd, Parms->id+ERR, Message ) ; WinAlarm ( HWND_DESKTOP, WA_ERROR ) ; WinSetFocus ( HWND_DESKTOP, WinWindowFromID ( hwnd, Parms->id+ENTRY ) ) ; return ( 0 ) ; } if ( ! ( Status.attrFile & FILE_DIRECTORY ) ) { PSZ Message = PSZ ( "ERROR: Specified path is not a directory." ) ; WinSetDlgItemText ( hwnd, Parms->id+ERR, Message ) ; WinAlarm ( HWND_DESKTOP, WA_ERROR ) ; WinSetFocus ( HWND_DESKTOP, WinWindowFromID ( hwnd, Parms->id+ENTRY ) ) ; return ( 0 ) ; } /*************************************************************************** * Return the full path to the caller. * ***************************************************************************/ strncpy ( PCHAR(Parms->Path), PCHAR(FullPath), Parms->PathSize ) ; /*************************************************************************** * Dismiss the dialog with a TRUE status. * ***************************************************************************/ WinDismissDlg ( hwnd, TRUE ) ; return ( 0 ) ; }
MRESULT mainhewmInit(HWND hwnd,MPARAM mp1,MPARAM mp2) { HWND hwndFrame = WinQueryWindow(hwnd,QW_PARENT); // printf("HEWM_INIT\n"); if (bootopen) han_type = HEFileOpenWithAutoHanCode(hwnd,bootopen,TRUE); HESetTitlebarText(hwnd); WinPostMsg(hwndHIA,HIAM_SETKBDTYPE,MPFROMLONG(kbd_type),0L); WinPostMsg(hwndHMLE,HMLM_SETTEXTFORMAT,MPFROMLONG(eol_type),0L); WinPostMsg(hwndStatbar,STATBAR_USERM_SETEOLTYPE,MPFROMLONG(eol_type),0L); WinPostMsg(hwndStatbar,STATBAR_USERM_SETHANTYPE,MPFROMLONG(han_type),0L); if (readonly) { WinEnableMenuItem(WinWindowFromID(hwndFrame,FID_MENU),IDM_IMPORT,FALSE ); WinEnableMenuItem(WinWindowFromID(hwndFrame,FID_MENU),IDM_SAVE,FALSE); //WinEnableMenuItem(WinWindowFromID(hwndFrame,FID_MENU),IDM_SAVEAS,FALSE); WinPostMsg(hwndToolbar,TOOLBAR_USERM_SHOWITEM,MPFROMLONG(TOOLBAR_SAVE),FALSE); WinPostMsg(hwndToolbar,TOOLBAR_USERM_SHOWITEM,MPFROMLONG(TOOLBAR_CUT),FALSE); WinPostMsg(hwndToolbar,TOOLBAR_USERM_SHOWITEM,MPFROMLONG(TOOLBAR_PASTE),FALSE); WinPostMsg(hwndToolbar,TOOLBAR_USERM_SHOWITEM,MPFROMLONG(TOOLBAR_CLEAR),FALSE); WinPostMsg(hwndToolbar,TOOLBAR_USERM_UPDATE,0,0); } WinEnableMenuItem(WinWindowFromID(hwndFrame,FID_MENU),IDM_PROPERTIES,FALSE); WinSetFocus(HWND_DESKTOP,hwndHMLE); return 0L; }
BOOL InitializeSpinButton(HWND hwnd) { USHORT usBitRate; USHORT ArrayIndex; char buffer[35]; char *p; if ( !WinSendDlgItemMsg( hwnd, IDC_SET_BIT_RATE, SPBM_SETARRAY, SpinSelectVals, MPFROMLONG(TOTALSPINVALS))) return FALSE; usBitRate = Get_IOCTL_Bit_Rate(hwnd); p = _itoa(usBitRate,buffer,10); for (ArrayIndex=0; ArrayIndex<TOTALSPINVALS; ArrayIndex++) { if ( strcmp( (const char * )SpinSelectVals[ArrayIndex],&buffer[0] ) == 0 ) { WinSendDlgItemMsg( hwnd, IDC_SET_BIT_RATE, SPBM_SETCURRENTVALUE, MPFROMLONG(ArrayIndex), NULL); return TRUE; } } WinSetFocus (HWND_DESKTOP, WinWindowFromID(hwnd,DID_OK)); return TRUE; }
/*-------------------------------------------------- * Sets the input focus to the window *-------------------------------------------------*/ PMWindow& PMWindow::set_focus() { if( !WinSetFocus( HWND_DESKTOP, handle())) PM_THROW_GUIERROR(); return *this; }
static void NewFilter(HWND hwnd) { const HWND ebox = WinWindowFromID(hwnd, DID_FFILTER_CB); const HWND name = WinWindowFromID(hwnd, DID_FILENAME_ED); // // Get new selection // const int item = WinQueryLboxSelectedItem(ebox); const int len = WinQueryLboxItemTextLength(ebox, item) + 1; // // set corresponding text in entry field // char *txt = malloc(len); WinQueryLboxItemText(ebox, item, txt, len); WinSetWindowText(name, strrchr(txt, '>') + 2); lib_free(txt); // // set focus to entry field and simulate an Apply // WinSetFocus(HWND_DESKTOP, name); WinDefFileDlgProc(hwnd, WM_COMMAND, (MPARAM)DID_OK, MPFROM2SHORT(CMDSRC_PUSHBUTTON, TRUE)); }
extern MRESULT EXPENTRY ShrInstallDlgProc (HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2) { MRESULT mr = NULL; CHAR szDLL[CCHMAXPATH]; CHAR szText[256]; PSZ psz; HWND hwndEntryField; switch (msg) { case WM_INITDLG: hwndEntryField = WinWindowFromID(hwndDlg, ID_PATH); WinSetWindowText(hwndEntryField, (PSZ) mp2); mr = (MRESULT) WinSetFocus(HWND_DESKTOP, hwndEntryField); break; case WM_CLOSE: WinDismissDlg(hwndDlg, MBID_CANCEL); break; case WM_COMMAND: if (SHORT1FROMMP(mp1) == MBID_OK) { WinQueryDlgItemText(hwndDlg, ID_PATH, sizeof(szDLL), szDLL); if (strlen(szDLL) >= 2) { psz = strchr(szDLL, '\0') - 1; if (*psz == '\\') strcat(szDLL, "SHARE.DLL"); else strcat(szDLL, "\\SHARE.DLL"); strupr(szDLL); if (ShrInstall(szDLL)) WinDismissDlg(hwndDlg, MBID_OK); } else { sprintf(szText, "The path must include the drive letter." " For example, %s. Please try again.", vszSysDLLPath); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szText, vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE | MB_WARNING); } } else if (SHORT1FROMMP(mp1) == MBID_CANCEL) { WinDismissDlg(hwndDlg, MBID_CANCEL); } break; default: mr = WinDefDlgProc(hwndDlg, msg, mp1, mp2); break; } return mr; }
int EDITAPI EDITFile( char *fn, char *hlib ) /***************************************************/ { CurrSession = FindSession( fn ); if( CurrSession == NULL ) { if( StartingSessionInProgress ) { return( FALSE ); } StartingSessionInProgress = TRUE; // new session must be created before we start the editor so // that we can process the WM_DDE_INITIATE message properly CurrSession = NewSession( fn, hlib ); if( CurrSession == NULL ) { return( FALSE ); } LinkSession( CurrSession ); if( spawnlp( P_NOWAIT, _Editor, _Editor, "/W", fn, NULL ) == -1 ) { DeleteSession( NULLHANDLE ); CurrSession = NULL; return( FALSE ); } } WinSetFocus( HWND_DESKTOP, CurrSession->hwnd ); return( TRUE ); }
MRESULT EXPENTRY fnwpCOMeventStatesDlg(HWND hwnd,USHORT msg, MPARAM mp1,MPARAM mp2) { WORD *pwEvent; WORD wEvent; switch (msg) { case WM_INITDLG: // CenterDlgBox(hwnd); WinSetFocus(HWND_DESKTOP,hwnd); pwEvent = PVOIDFROMMP(mp2); if (*pwEvent & 0x0001) CheckButton(hwnd,CEV_BIT0,TRUE); if (*pwEvent & 0x0002) CheckButton(hwnd,CEV_BIT1,TRUE); if (*pwEvent & 0x0004) CheckButton(hwnd,CEV_BIT2,TRUE); if (*pwEvent & 0x0008) CheckButton(hwnd,CEV_BIT3,TRUE); if (*pwEvent & 0x0010) CheckButton(hwnd,CEV_BIT4,TRUE); if (*pwEvent & 0x0020) CheckButton(hwnd,CEV_BIT5,TRUE); if (*pwEvent & 0x0040) CheckButton(hwnd,CEV_BIT6,TRUE); if (*pwEvent & 0x0080) CheckButton(hwnd,CEV_BIT7,TRUE); if (*pwEvent & 0x0100) CheckButton(hwnd,CEV_BIT8,TRUE); break; // case WM_BUTTON1DOWN: // WinDismissDlg(hwnd,TRUE); // return(FALSE); case WM_COMMAND: switch(SHORT1FROMMP(mp1)) { case DID_HELP: DisplayHelpPanel(HLPP_COM_EVENT_BITS); return((MRESULT)FALSE); case DID_CLEAR: if (GetCOMevent(&stIOctl,hCom,&wEvent) != NO_ERROR) { WinPostMsg(hwndStatAll,UM_KILL_MONITOR,(MPARAM)0L,(MPARAM)0L); WinPostMsg(hwndStatDev,UM_KILL_MONITOR,(MPARAM)0L,(MPARAM)0L); } case DID_OK: case DID_CANCEL: break; default: return WinDefDlgProc(hwnd,msg,mp1,mp2); } WinDismissDlg(hwnd,TRUE); return((MRESULT)TRUE); default: return(WinDefDlgProc(hwnd,msg,mp1,mp2)); } return FALSE; }
APIRET InitLineBits(HWND hwnd) { APIRET rc; ULONG DataPacketLen; rc = DosDevIOCtl (HandleComm, IOCTL_ASYNC, ASYNC_GETLINECTRL, NULL, //no parameter packet 0, // = 0 NULL, // length of parm packet (PULONG) &DataPacket, sizeof(DataPacket), &DataPacketLen); rc = DosDevIOCtl (HandleComm, IOCTL_ASYNC, ASYNC_GETLINECTRL, NULL, //no parameter packet 0, // = 0 NULL, // length of parm packet (PULONG) &DataPacket, sizeof(DataPacket), &DataPacketLen); if (rc) { sprintf(PrintBuf,"RC=%u Line=%u\nFile: %s",rc,__LINE__,__FILE__); WinDebugMsg(PrintBuf,hwnd); } WinSendDlgItemMsg(hwnd, (ULONG) IDC_DATA_BIT5 + (DataPacket.bDataBits - 5), (ULONG) BM_SETCHECK, MPFROM2SHORT(TRUE,0), NULL); WinSendDlgItemMsg(hwnd,IDC_PARITY_NO + DataPacket.bParity, BM_SETCHECK, MPFROM2SHORT(TRUE,0), NULL); WinSendDlgItemMsg(hwnd,IDC_STOP_BIT1 + DataPacket.bStopBits, BM_SETCHECK, MPFROM2SHORT(TRUE,0), NULL); WinSetFocus (HWND_DESKTOP, WinWindowFromID(hwnd,DID_OK)); return 0; }
ULONG HEFind(HWND hwnd) { static char findStr[ 256 ] = { 0, }; static char replaceStr[ 256 ] = { 0, }; ULONG ulrc; HWND hwndDlg; HWND hwndFind; HWND hwndReplace; //char str[255]; //int hanmode,kbdtype; hwndDlg = WinLoadDlg(HWND_DESKTOP,hwnd,&HEFindDlgProc,NULLHANDLE,IDD_FIND,NULL); hwndFind = WinWindowFromID( hwndDlg, IDHEF_FIND ); hwndReplace = WinWindowFromID( hwndDlg, IDHEF_REPLACE ); WinSetWindowText( hwndFind, findStr ); // WinSendMsg( hwndFind, HEM_SETSEL, MPFROM2SHORT( 0, strlen( findStr )), 0 ); // WinSendMsg( hwndFind, HEM_REFRESH, 0, 0 ); WinSetWindowText( hwndReplace, replaceStr ); // WinSendMsg( hwndReplace, HEM_SETSEL, // MPFROM2SHORT( strlen( replaceStr ), strlen( replaceStr )), 0 ); // WinSendMsg( hwndReplace, HEM_REFRESH, 0, 0 ); WinSetFocus(HWND_DESKTOP,WinWindowFromID(hwndDlg, DID_OK )); ulrc = WinProcessDlg(hwndDlg); // if (ulrc == DID_OK) // { // } WinQueryWindowText( hwndFind, sizeof( findStr ), findStr ); WinQueryWindowText( hwndReplace, sizeof( replaceStr ), replaceStr ); WinDestroyWindow(hwndDlg); // hanmode = (int)WinSendMsg(hwndHMLE,HMLM_QUERYHANINPUTMODE,0,0); // kbdtype = (int)WinSendMsg(hwndHMLE,HMLM_QUERYKBDTYPE,0,0); // WinPostMsg(hwndStatbar,STATBAR_USERM_SETHANMODE,MPFROMLONG(hanmode),0L); // WinPostMsg(hwndStatbar,STATBAR_USERM_SETKBDTYPE,MPFROMLONG(kbdtype),0L); WinSetFocus(HWND_DESKTOP,hwndHMLE); return 0L; }
VOID CDialog::SetFocus (int id) { #if defined(__OS2__) WinSetFocus (HWND_DESKTOP, WinWindowFromID (m_hWnd, id)); #elif defined(__NT__) ::SetFocus (GetDlgItem (m_hWnd, id)); #endif }
/* * _NewWindow - create a new window */ unsigned _NewWindow( char *name, ... ) { LPWDATA w; MENUITEM menus; HWND hwnd,frame,temp; char str[80]; int x1,x2,y1,y2; ULONG style; RECTL rcl; va_list al; _GetWindowNameAndCoords( name, str, &x1, &x2, &y1, &y2 ); style = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX | FCF_VERTSCROLL; frame = WinCreateStdWindow( _MainWindow, WS_VISIBLE | WS_CLIPSIBLINGS, &style, _ClassName, str, 0, NULL, 0, &hwnd ); if( frame == 0 ) return( FALSE ); WinSetOwner( hwnd, _MainWindow ); va_start( al, name ); w = _AnotherWindowData( hwnd, al ); w->frame = frame; w->text_color = CLR_WHITE; w->background_color = CLR_BLACK; WinSendMsg( frame, WM_SETICON, MPFROMLONG( WinQuerySysPointer( HWND_DESKTOP, SPTR_APPICON, TRUE ) ), 0 ); WinSetWindowBits( WinWindowFromID( w->frame, FID_VERTSCROLL ), QWL_STYLE, SBS_AUTOTRACK, SBS_AUTOTRACK ); _CreateFont( w ); _PositionScrollThumb( w ); WinQueryWindowRect( _MainWindow, &rcl ); WinSetWindowPos( frame, HWND_TOP, x1*w->xchar, (rcl.yTop - rcl.yBottom)-y1*w->ychar-y2*w->ychar, x2*w->xchar, y2*w->ychar, SWP_SIZE | SWP_MOVE | SWP_ZORDER ); menus.iPosition = _MainWindowData->window_count - 1; menus.afStyle = MIS_TEXT; menus.afAttribute = 0; menus.id = DID_WIND_STDIO + w->handles[0]; menus.hwndSubMenu = NULL; menus.hItem = 0; if ( MIT_ERROR == (BOOL)WinSendMsg( menuHandle, ( ULONG )MM_INSERTITEM, MPFROMP( &menus ), MPFROMP( str ) ) ) abort(); temp = WinWindowFromID( frame, FID_SYSMENU ); WinSendMsg( temp, MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, TRUE), MPFROMP((PSZ)&menus) ); WinSendMsg( menus.hwndSubMenu, MM_DELETEITEM, MPFROM2SHORT( SC_CLOSE, TRUE ), 0 ); WinUpdateWindow( hwnd ); WinSetFocus( HWND_DESKTOP, hwnd ); return( TRUE ); } /* _NewWindow */
MRESULT clbMouBtn(PCLBOX pclb, PMSEMSG pmmsg) { if (pmmsg->x >= pclb->rclcpt.xLeft && pmmsg->x < pclb->rclcpt.xRight && pmmsg->y >= pclb->rclcpt.yBottom && pmmsg->y < pclb->rclcpt.yTop) { WinSetFocus(HWND_DESKTOP, pclb->hlbx); return (MRESULT)TRUE; } /* endif */ return (MRESULT)FALSE; }
MRESULT EXPENTRY newcomboproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { PCLBOX pclb = (PCLBOX)stGetData(WinQueryWindow(hwnd, QW_PARENT)); if (msg == WM_CHAR && (CHARMSG(&msg)->fs & KC_ALT) && !(CHARMSG(&msg)->fs & KC_KEYUP) && ((CHARMSG(&msg)->vkey == VK_UP))) { WinSetFocus(HWND_DESKTOP, pclb->hlbx); return (MRESULT)TRUE; } /* endif */ return pclb->pfef(hwnd, msg, mp1, mp2); // default listsbox controls proc }
BOOL APIENTRY WprogressBar(HWND hParent, HWND hOwner, PPROGRESSDLG ppd) { QMSG qmsg; HWND hwnd; PPRGSAPPDATA pad; BOOL rc = FALSE; // allocate storage for application data if (!(pad = (PPRGSAPPDATA)malloc(sizeof(PRGSAPPDATA)))) return FALSE; memset(pad, 0, sizeof(PRGSAPPDATA)); pad->ppd = ppd; // ottiene tempo di inizio pad->start = WinGetCurrentTime(pad->hab = WinQueryAnchorBlock(hOwner)) / 1000; // window handles if (ppd->fl & PRGSS_BITMAP) { SIZEL szl; WqueryBitmapSize(pad->ppd->hbmp, &szl); pad->cxbmp = szl.cx; } /* endif */ if (NULLHANDLE != (hwnd = WinLoadDlg(hParent, hOwner, ProgressDlgProc, hmod, DLG_PROGRESS, pad))) { if (!ppd->pszPrgrss) ppd->pszPrgrss = SZ_PROGRESS; if (!ppd->pszTime) ppd->pszTime = SZ_ELAPSTIME; if (ppd->pszStop) WinSetDlgItemText(hwnd, BTN_STOP, ppd->pszStop); pad->hOwner = WinQueryWindow(hwnd, QW_OWNER); WinEnableWindow(pad->hOwner, FALSE); for(;;) { if (WinGetMsg(pad->hab, &qmsg, NULLHANDLE, 0, 0)) { // loop standard if (qmsg.msg == PRGSM_END && qmsg.hwnd == hwnd) { if (pad->qQuit.msg) WinPostMsg(pad->qQuit.hwnd, pad->qQuit.msg, pad->qQuit.mp1, pad->qQuit.mp2); break; } // end if WinDispatchMsg(pad->hab, &qmsg); } else { // WM_QUIT pad->qQuit = qmsg; if(qmsg.hwnd == NULLHANDLE) // SHUTDOWN WinPostMsg(hwnd, WM_CLOSE, MPFROMLONG(TRUE), NULL); else if(qmsg.hwnd == HWNDFROMMP(qmsg.mp2)) // TASKLIST WinPostMsg(hwnd, WM_CLOSE, 0L, 0L); else // chiusura regolare: termina break; } // end if } // end forever WinSetFocus(HWND_DESKTOP, hOwner); WinDestroyWindow(hwnd); WinEnableWindow(pad->hOwner, TRUE); rc = TRUE; } // end if free(pad); return rc; }
static void MousePressed( vout_display_t *vd, HWND hwnd, unsigned button ) { if( WinQueryFocus( HWND_DESKTOP ) != hwnd ) WinSetFocus( HWND_DESKTOP, hwnd ); if( !vd->sys->button_pressed ) WinSetCapture( HWND_DESKTOP, hwnd ); vd->sys->button_pressed |= 1 << button; vout_display_SendEventMousePressed( vd, button ); }
APIRET WmInitComSelect( HWND hwnd) { int i; if (HandleComm == 0) //no comm port open, uncheck all buttons { for (i=0; i < 4; i++) { WinSendDlgItemMsg(hwnd, IDC_COMM1_SELECT+i, BM_SETCHECK, MPFROM2SHORT(FALSE,0), NULL); WinSetFocus (HWND_DESKTOP, WinWindowFromID(hwnd,IDC_COMM1_SELECT+i)); } WinSetFocus (HWND_DESKTOP, WinWindowFromID(hwnd,DID_OK)); return 0; } //otherwise, search for the open comm port and check corresponding button for (i=0; i < 4; i++) { if (CommStruct[i].CommHandle == HandleComm) { WinSendDlgItemMsg(hwnd, IDC_COMM1_SELECT+i, BM_SETCHECK, MPFROM2SHORT(TRUE,0), NULL); WinSetFocus (HWND_DESKTOP, WinWindowFromID(hwnd,IDC_COMM1_SELECT+i)); } } return 0; }
bool DebugScreen( void ) { if( !WndMain ) return( FALSE ); if( FocusWnd && WinIsWindow( GUIGetHAB(), FocusWnd ) && FocusWnd != WinQueryFocus( HWND_DESKTOP, 0 ) ) { WinSetFocus( HWND_DESKTOP, FocusWnd ); } if( ActiveWnd && WinIsWindow( GUIGetHAB(), ActiveWnd ) && ActiveWnd != WinQueryActiveWindow( HWND_DESKTOP, 0 ) ) { WinSetActiveWindow( HWND_DESKTOP, ActiveWnd ); } return( FALSE ); }
MRESULT EXPENTRY fnwpCOMstatusStatesDlg(HWND hwnd,USHORT msg, MPARAM mp1,MPARAM mp2) { WORD *pwEvent; switch (msg) { case WM_INITDLG: // CenterDlgBox(hwnd); WinSetFocus(HWND_DESKTOP,hwnd); pwEvent = PVOIDFROMMP(mp2); if (*pwEvent & 0x0001) CheckButton(hwnd,CST_BIT0,TRUE); if (*pwEvent & 0x0002) CheckButton(hwnd,CST_BIT1,TRUE); if (*pwEvent & 0x0004) CheckButton(hwnd,CST_BIT2,TRUE); if (*pwEvent & 0x0008) CheckButton(hwnd,CST_BIT3,TRUE); if (*pwEvent & 0x0010) CheckButton(hwnd,CST_BIT4,TRUE); if (*pwEvent & 0x0020) CheckButton(hwnd,CST_BIT5,TRUE); if (*pwEvent & 0x0040) CheckButton(hwnd,CST_BIT6,TRUE); if (*pwEvent & 0x0080) CheckButton(hwnd,CST_BIT7,TRUE); break; // case WM_BUTTON1DOWN: // WinDismissDlg(hwnd,TRUE); // return(FALSE); case WM_COMMAND: switch(SHORT1FROMMP(mp1)) { case DID_HELP: DisplayHelpPanel(HLPP_COM_STATUS_BITS); return((MRESULT)FALSE); case DID_OK: case DID_CANCEL: break; default: return WinDefDlgProc(hwnd,msg,mp1,mp2); } WinDismissDlg(hwnd,TRUE); return((MRESULT)TRUE); default: return(WinDefDlgProc(hwnd,msg,mp1,mp2)); } return FALSE; }
/** * Temporary size and focus fix.... */ BOOL kSFNDetails::show() { SWP swp; BOOL fRet = kDlgBase::show(); /* Temporary size fix */ WinQueryWindowPos(hwnd, &swp); WinSetWindowPos(hwnd, NULLHANDLE, 0, 0, swp.cx, swp.cy, SWP_SIZE); /* Try set focus correctly */ WinSetFocus(HWND_DESKTOP, hwnd); return fRet; }
INT main() { HMQ hmq; /* Message queue handle */ QMSG qmsg; /* Receive PM queue message */ /* startup PM usage */ hab = WinInitialize(0); /* Get the anchor block handle*/ hmq = WinCreateMsgQueue(hab, 0); /* Create the message queue */ /* register our window class */ WinRegisterClass(hab, "RexxCalc", Calculator, 0l, 0); /* Load the calculator dialog. The dialog definitions are in */ /* rexxcalc.rc */ hwndCalc = WinLoadDlg(HWND_DESKTOP, HWND_DESKTOP, NULL, 0, REXXCALC, /* Dialog ID */ NULL); WinSendMsg(hwndCalc, WM_SETICON, /* Set program icon */ (MPARAM)WinLoadPointer(HWND_DESKTOP, 0, REXXCALC), NULL); /* set the window focus */ WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwndCalc, FID_CLIENT)); /* Process the standard Presentation Manager message loop until */ /* we are told to terminate */ /* While more messages */ while (WinGetMsg(hab, &qmsg, 0, 0, 0)) WinDispatchMsg(hab, &qmsg); /* dispatch application */ /* message handler */ /* The close option has been selected so we need to clean up */ /* our context. */ WinDestroyWindow(hwndCalc); /* Destroy the dialog window */ WinDestroyMsgQueue(hmq); /* Destroy the message queue */ WinTerminate(hab); /* Terminate PM usage */ return (0); /* Indicate successful */ /* completion */ }
MRESULT EXPENTRY wpMatch(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { static CDDBQUERY_DATA *chosen; /* somebody find me a better way to do this */ switch(msg) { case WM_INITDLG: { HWND focusHwnd = (HWND) mp1; FUZZYMATCHCREATEPARAMS *data = (FUZZYMATCHCREATEPARAMS *) mp2; int i = 0; WinSetFocus(HWND_DESKTOP, focusHwnd); while(data->matches[i].discid) { int inserted = insertItemText(hwnd,LB_MATCHES,LIT_END,data->matches[i].title); setItemHandle(hwnd, LB_MATCHES,inserted,&data->matches[i]); i++; } chosen = data->chosen; memset(chosen,0,sizeof(*chosen)); return 0; } case WM_COMMAND: { switch(SHORT1FROMMP(mp1)) { case DID_OK: { int selected = getSelectItem(hwnd, LB_MATCHES, LIT_FIRST); if(selected != LIT_NONE) memcpy(chosen,getItemHandle(hwnd,LB_MATCHES,selected),sizeof(*chosen)); WinPostMsg(hwnd,WM_CLOSE,0,0); } case DID_CANCEL: WinPostMsg(hwnd,WM_CLOSE,0,0); } return 0; } } return WinDefDlgProc(hwnd,msg,mp1,mp2); }
MRESULT EXPENTRY wpDragInfo( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { switch( msg ) { case WM_INITDLG: InitControls( hwnd ); return (MRESULT) TRUE; // Return TRUE to retain any changed focus case WM_COMMAND: if( wmCommand( hwnd, SHORT1FROMMP( mp1 ) ) ) return 0; else break; case WM_SETFOCUS: if( mp2 ) WinPostMsg( hwnd, UM_SET_FOCUS, NULL, NULL ); break; case UM_SET_FOCUS: { PPAGEDATA pPageData = WinQueryWindowPtr( hwnd, QWL_USER ); if( pPageData ) WinSetFocus( HWND_DESKTOP, WinWindowFromID( hwnd, pPageData->idFocus ) ); return 0; } case WM_CONTROL: wmControl( hwnd, SHORT1FROMMP( mp1 ), SHORT2FROMMP( mp1 ) ); return 0; case UM_GET_FOCUS_ID: return (MRESULT) CB_OPERATION; case UM_DUMP_DLGINFO: DumpDlgInfo( hwnd ); break; } return WinDefDlgProc( hwnd, msg, mp1, mp2 ); }
void SetNBPage( HWND hwndFrame, PPAGESELECTNOTIFY ppsn ) { HWND hwndDlg; // Get a pointer to the page information that is associated with this page. // It was stored in the page's PAGE DATA in the SetUpPage function. PPAGEDATA pPageData = (PPAGEDATA) WinSendMsg( ppsn->hwndBook, BKM_QUERYPAGEDATA, MPFROMLONG( ppsn->ulPageIdNew ), NULL ); if( !pPageData ) return; else if( pPageData == (PPAGEDATA) BOOKERR_INVALID_PARAMETERS ) { Msg( "SetNBPage QUERYPAGEDATA RC(%X)", HWNDERR( ppsn->hwndBook ) ); return; } hwndDlg = (HWND) WinSendMsg( ppsn->hwndBook, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG( ppsn->ulPageIdNew ), NULL ); if( hwndDlg == (HWND) BOOKERR_INVALID_PARAMETERS ) Msg( "SetNBPage QUERYPAGEHWND RC(%X)", HWNDERR( ppsn->hwndBook ) ); else if( !hwndDlg ) { // It is time to load this dialog because the user has flipped pages // to a page that hasn't yet had the dialog associated with it. hwndDlg = LoadAndAssociate( hwndFrame, pPageData, ppsn ); } if( hwndDlg ) { // Set focus to the first control in the dialog. This is not // automatically done by the notebook. WinSetFocus( HWND_DESKTOP, WinWindowFromID( hwndDlg, pPageData->idFocus ) ); } }
/* if error is TRUE, an error message can be shown */ BOOL dialog_get_float_error(HWND hwnd, int field, float *fres, BOOL error) { float ftemp ; char buf[64] ; GetDlgItemText(hwnd, field, (PBYTE)buf, sizeof(buf)-1) ; if ((1 > sscanf(buf,"%g",&ftemp)) && error) { HWND errfld = WinWindowFromID(hwnd, field); gserror(IDS_INVALIDNUMBER, NULL, MB_ICONEXCLAMATION, SOUND_NONUMBER) ; WinSetFocus(HWND_DESKTOP, errfld) ; /* Replace 100 with the end */ WinSendMsg( errfld, EM_SETSEL, MPFROM2SHORT(0, 100), MPFROMLONG(0) ); } else { *fres = ftemp ; return TRUE ; } return FALSE; }
MRESULT clbMnemonic(PCLBOX pclb, ULONG ch) { HWND hfocus; if ((ch > 0xff || ch == '+' || ch == '-')) { if (WinIsChild((hfocus = WinQueryFocus(HWND_DESKTOP)), pclb->hwnd)) { switch (ch) { case 0x9d00: // -> simula comando bottone FIND EDClbWinProc(pclb->hwnd, WM_COMMAND, (MPARAM)FID_FIND, MPFROM2SHORT(CMDSRC_OTHER, 0)); break; case '+': if (pclb->is.addon) EDClbWinProc(pclb->hwnd, WM_COMMAND, (MPARAM)FID_ADD, MPFROM2SHORT(CMDSRC_OTHER, 0)); break; case '-': if (pclb->is.remon) EDClbWinProc(pclb->hwnd, WM_COMMAND, (MPARAM)FID_REMOVE, MPFROM2SHORT(CMDSRC_OTHER, 0)); break; } /* endswitch */ } /* endif */ return (MRESULT)FALSE; } /* endif */ if (pclb->fl & CLBXS_NOCAPT) return (MRESULT)FALSE; if (pclb->fl & CLBXS_CHECK) { if (pclb->pfbtn(pclb->hchk, WM_MATCHMNEMONIC, (MPARAM)ch, MPVOID)) WinSetFocus(HWND_DESKTOP, pclb->hchk); return (MRESULT)FALSE; } else if (pclb->psz) { PSZ pmnemo = strchr(pclb->psz, '~'); if (!pmnemo) return (MRESULT)FALSE; ch = WinUpperChar(pclb->hab, 0, 0, ch); return (MRESULT)(ch == WinUpperChar(pclb->hab, 0, 0, *++pmnemo) && ch); } else { return (MRESULT)FALSE; } /* endif */ }
/************************************************************************** * * FUNCTION NAME: HandleCommand * * DESCRIPTION: * * * INPUT PARAMETERS: * None. * * OUTPUT PARAMETERS: * None. * **************************************************************************/ MRESULT EXPENTRY HandleCommand (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { HWND hwndDlg; MCI_GENERIC_PARMS mciGenericParms; switch (SHORT1FROMMP (mp1)) { /* ** Game menu items... */ case MENU_START_ID : eDemoMode = DEMO_NONE; if (gAction != PAUSED) { gAction = START; } break; case MENU_STOP_ID : eDemoMode = DEMO_NONE; gAction = STOP; break; case MENU_EXIT_ID : gAction = EXIT; break; case MENU_PAUSE_ID : /* Toggle the pause action */ if ((gAction = (gAction == PAUSED) ? NONE : PAUSED) == PAUSED) { PauseGame (); } else { ResumeGame (); } break; case MENU_DEMO_PLAY_ID : eDemoMode = DEMO_PLAY; if (gAction != PAUSED) { gAction = START; } break; case MENU_DEMO_RECORD_ID : /* Display a message box to verify they really want to do this */ if (!gfDemoLoaded || WinMessageBox (HWND_DESKTOP, HWND_DESKTOP, CHECK_RECORD, "Demo Record", 0, MB_YESNO | MB_WARNING | MB_MOVEABLE) == MBID_YES) { eDemoMode = DEMO_RECORD; if (gAction != PAUSED) { gAction = START; } } WinSetFocus (HWND_DESKTOP, hwndDefClient); break; /* ** Options menu items... */ case MENU_KEY_ID : hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessKeyDialog, 0L, KEY_DLG_ID, NULL); /* Process the dialog and then destroy it */ WinProcessDlg (hwndDlg); WinDestroyWindow (hwndDlg); break; case MENU_SPEED_ID : hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessSpeedDialog, 0L, SPEED_DLG_ID, NULL); /* Process the dialog and then destroy it */ WinProcessDlg (hwndDlg); WinDestroyWindow (hwndDlg); break; case MENU_OBJECT_SIZE_ID : hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessSizeDialog, 0L, SIZE_DLG_ID, NULL); /* Process the dialog and then destroy it */ WinProcessDlg (hwndDlg); WinDestroyWindow (hwndDlg); break; case MENU_HISCORE_ID : hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessHiScoreDialog, 0L, HISCORE_DLG_ID, NULL); /* Process the dialog and then destroy it */ WinProcessDlg (hwndDlg); WinDestroyWindow (hwndDlg); break; case MENU_REGISTER_ID : hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessRegisterDialog, 0L, REG_DLG_ID, NULL); /* Process the dialog and then destroy it */ WinProcessDlg (hwndDlg); WinDestroyWindow (hwndDlg); break; case MENU_BULLET_ID : /* Toggle the bullet menu item */ gfBullets = gfBullets ? FALSE : TRUE; WinCheckMenuItem (hwndMenu, MENU_BULLET_ID, gfBullets); break; case MENU_BUBBLES_ID : /* Toggle the bubbles menu item */ gfBubbles = gfBubbles ? FALSE : TRUE; WinCheckMenuItem (hwndMenu, MENU_BUBBLES_ID, gfBubbles); break; case MENU_SOUND_ID : /* Toggle the sound menu item */ if (gfSoundEnabled) { gfSoundOn = gfSoundOn ? FALSE : TRUE; WinCheckMenuItem (hwndMenu, MENU_SOUND_ID, gfSoundOn); if (gfSoundOn) { mciGenericParms.hwndCallback = hwnd; (*stMMPMFn[MCI_SENDCOMMAND_FN].pFn) (gusWaveDeviceID, MCI_ACQUIREDEVICE, (ULONG) MCI_NOTIFY, (PVOID) &mciGenericParms, (USHORT) 0); } } break; case MENU_MUSIC_ID : /* Toggle the menu menu item */ gfMusicEnabled = gfMusicEnabled ? FALSE : TRUE; WinCheckMenuItem (hwndMenu, MENU_MUSIC_ID, gfMusicEnabled); if (gfMusicEnabled) { (*stMMPMFn[MCI_SENDCOMMAND_FN].pFn) (gusMidiDeviceID, MCI_ACQUIREDEVICE, (ULONG) MCI_NOTIFY, (PVOID) &mciGenericParms, (USHORT) 0); } if (gsGameOn) { /* Play or stop the music */ gsMusicAction = gfMusicEnabled ? START : STOP; DosPostEventSem (hSoundEventSem); } break; case MENU_MOUSE_ID : /* Toggle the mouse menu item */ gfMouseEnabled = gfMouseEnabled ? FALSE : TRUE; WinCheckMenuItem (hwndMenu, MENU_MOUSE_ID, gfMouseEnabled); EnableMouse (gfMouseEnabled); break; case MENU_3SHIPS_ID : gsStartShips = 3; WinCheckMenuItem (hwndMenu, MENU_3SHIPS_ID, TRUE); WinCheckMenuItem (hwndMenu, MENU_4SHIPS_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_5SHIPS_ID, FALSE); break; case MENU_4SHIPS_ID : gsStartShips = 4; WinCheckMenuItem (hwndMenu, MENU_3SHIPS_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_4SHIPS_ID, TRUE); WinCheckMenuItem (hwndMenu, MENU_5SHIPS_ID, FALSE); break; case MENU_5SHIPS_ID : gsStartShips = 5; WinCheckMenuItem (hwndMenu, MENU_3SHIPS_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_4SHIPS_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_5SHIPS_ID, TRUE); break; case MENU_3SMARTS_ID : gsStartSmarts = 3; WinCheckMenuItem (hwndMenu, MENU_3SMARTS_ID, TRUE); WinCheckMenuItem (hwndMenu, MENU_5SMARTS_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_7SMARTS_ID, FALSE); break; case MENU_5SMARTS_ID : gsStartSmarts = 5; WinCheckMenuItem (hwndMenu, MENU_3SMARTS_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_5SMARTS_ID, TRUE); WinCheckMenuItem (hwndMenu, MENU_7SMARTS_ID, FALSE); break; case MENU_7SMARTS_ID : gsStartSmarts = 7; WinCheckMenuItem (hwndMenu, MENU_3SMARTS_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_5SMARTS_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_7SMARTS_ID, TRUE); break; case MENU_SONAR_FADE_ID : stScanner.sMode = SCANNER_SWEEP; WinCheckMenuItem (hwndMenu, MENU_SONAR_FADE_ID, TRUE); WinCheckMenuItem (hwndMenu, MENU_SONAR_PERSIST_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_SONAR_NO_ID, FALSE); break; case MENU_SONAR_PERSIST_ID : stScanner.sMode = SCANNER_ON; WinCheckMenuItem (hwndMenu, MENU_SONAR_FADE_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_SONAR_PERSIST_ID, TRUE); WinCheckMenuItem (hwndMenu, MENU_SONAR_NO_ID, FALSE); break; case MENU_SONAR_NO_ID : stScanner.sMode = SCANNER_OFF; WinCheckMenuItem (hwndMenu, MENU_SONAR_FADE_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_SONAR_PERSIST_ID, FALSE); WinCheckMenuItem (hwndMenu, MENU_SONAR_NO_ID, TRUE); break; case MENU_FRAME_CONTROLS_ID : if (gfShowFrame) { HideFrameControls (); } else { ShowFrameControls (); } gfShowFrame = gfShowFrame ? FALSE : TRUE; WinCheckMenuItem (hwndMenu, MENU_FRAME_CONTROLS_ID, gfShowFrame); break; /* ** Help menu items... */ case MENU_HELPINDEX_ID : WinSendMsg (hwndHelpInstance, HM_HELP_INDEX, NULL, NULL); break; case MENU_HELPEXTENDED_ID : WinSendMsg(hwndHelpInstance, HM_EXT_HELP, NULL, NULL); break; case MENU_HELPHELPFORHELP_ID : WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP, NULL, NULL); break; case MENU_HELPKEYSHELP_ID : WinSendMsg (hwndHelpInstance, HM_KEYS_HELP, NULL, NULL); break; case MENU_HELPABOUT_ID : hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessProdInfoDialog, 0L, PROD_INFO_DLG_ID, NULL); /* Process the dialog and then destroy it */ WinProcessDlg (hwndDlg); WinDestroyWindow (hwndDlg); break; default : return (WinDefWindowProc (hwnd, msg, mp1, mp2)); } }
MRESULT PDSKeyProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) { switch ( msg ) { /* Check for key strokes */ case WM_CHAR : /* Check for the key up flag in which case the */ /* condition should be ignored */ if ( SHORT1FROMMP(mp1) & KC_KEYUP ) break; /* Check for virtual keys */ if ( SHORT1FROMMP(mp1) & KC_VIRTUALKEY ) switch ( SHORT2FROMMP(mp2) ) { case VK_TAB : /* TAB key pressed, determine which control is */ /* the next tab stop and set the focus on that */ /* control */ WinSetFocus(HWND_DESKTOP, WinEnumDlgItem(hWnd, WinQueryFocus(HWND_DESKTOP), EDI_NEXTTABITEM)); break; case VK_RIGHT : case VK_DOWN : /* Right or down arrow key pressed, determine */ /* which control is the next entry and set the */ /* focus on that control */ WinSetFocus(HWND_DESKTOP, WinEnumDlgItem(hWnd, WinQueryFocus(HWND_DESKTOP), EDI_NEXTGROUPITEM)); break; case VK_BACKTAB : /* Shift+TAB key pressed, determine which */ /* control is the previous tab stop and set the */ /* focus on that control */ WinSetFocus(HWND_DESKTOP, WinEnumDlgItem(hWnd, WinQueryFocus(HWND_DESKTOP), EDI_PREVTABITEM)); break; case VK_LEFT : case VK_UP : /* Left or up arrow key pressed, determine */ /* which control is the previous entry and set */ /* the focus on that control */ WinSetFocus(HWND_DESKTOP, WinEnumDlgItem(hWnd, WinQueryFocus(HWND_DESKTOP), EDI_PREVGROUPITEM)); break; } break; /* Virtual key not TAB or Shift+TAB, fall */ /* through to default window procedure */ /* Default message processing */ default : return(WinDefWindowProc(hWnd, msg, mp1, mp2)); } return(0L); }
/************************************************************************** * * FUNCTION NAME: ProcessKeyDialog * * DESCRIPTION: * * * INPUT PARAMETERS: * None. * * OUTPUT PARAMETERS: * None. * **************************************************************************/ MRESULT EXPENTRY ProcessKeyDialog (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { USHORT usScanCode; static ULONG ulButton = UP_TEXT_ID; static KEYDEFS stLocalDefs; static PUSHORT pusKeyDef; switch (msg) { case WM_INITDLG : /* Store the current key settings */ stLocalDefs = gstKeyDefs; pusKeyDef = &(stLocalDefs.usUpKey); /* Set the text for each field in the dialog box */ WinSetDlgItemText (hwnd, UP_TEXT_ID, szScanCode[stLocalDefs.usUpKey]); WinSetDlgItemText (hwnd, DOWN_TEXT_ID, szScanCode[stLocalDefs.usDownKey]); WinSetDlgItemText (hwnd, TURN_TEXT_ID, szScanCode[stLocalDefs.usTurnKey]); WinSetDlgItemText (hwnd, THRUST_TEXT_ID, szScanCode[stLocalDefs.usThrustKey]); WinSetDlgItemText (hwnd, FIRE_TEXT_ID, szScanCode[stLocalDefs.usFireKey]); WinSetDlgItemText (hwnd, SMART_TEXT_ID, szScanCode[stLocalDefs.usSmartKey]); WinSetDlgItemText (hwnd, HYPER_TEXT_ID, szScanCode[stLocalDefs.usHyperKey]); /* Set the UP button to the clicked state */ WinPostMsg (WinWindowFromID (hwnd , UP_ID), BM_CLICK, MPFROMSHORT (TRUE), MPVOID); /* Set the appropriate button toggle */ if (stLocalDefs.fTurnThrust) { WinPostMsg (WinWindowFromID (hwnd , TURN_THRUST_ID), BM_CLICK, MPFROMSHORT (TRUE), MPVOID); WinSetDlgItemText (hwnd, TURN_ID, "Turn"); WinSetDlgItemText (hwnd, THRUST_ID, "Thrust"); } else { WinPostMsg (WinWindowFromID (hwnd , LEFT_RIGHT_ID), BM_CLICK, MPFROMSHORT (TRUE), MPVOID); WinSetDlgItemText (hwnd, TURN_ID, "Left"); WinSetDlgItemText (hwnd, THRUST_ID, "Right"); } /* Center the dialog box in the frame window of the parent */ CenterDialog (hwnd); return (0); case WM_COMMAND : switch (SHORT1FROMMP (mp1)) { case DID_OK: /* Save the key selections in the global list and save them */ gstKeyDefs = stLocalDefs; WinDismissDlg (hwnd, DID_OK); return (0); case DID_CANCEL: /* Dismiss the dialog without saving the values */ WinDismissDlg (hwnd, DID_CANCEL); return (0); case DID_HELP: /* Display the keys help panel */ WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP, MPFROM2SHORT(PANEL_KEYS, NULL), MPFROMSHORT(HM_RESOURCEID)); return (0); } break; case WM_CONTROL : switch (SHORT1FROMMP (mp1)) { case UP_ID: ulButton = UP_TEXT_ID; pusKeyDef = &(stLocalDefs.usUpKey); break; case DOWN_ID: ulButton = DOWN_TEXT_ID; pusKeyDef = &(stLocalDefs.usDownKey); break; case TURN_ID: ulButton = TURN_TEXT_ID; pusKeyDef = &(stLocalDefs.usTurnKey); break; case THRUST_ID: ulButton = THRUST_TEXT_ID; pusKeyDef = &(stLocalDefs.usThrustKey); break; case FIRE_ID: ulButton = FIRE_TEXT_ID; pusKeyDef = &(stLocalDefs.usFireKey); break; case SMART_ID: ulButton = SMART_TEXT_ID; pusKeyDef = &(stLocalDefs.usSmartKey); break; case HYPER_ID: ulButton = HYPER_TEXT_ID; pusKeyDef = &(stLocalDefs.usHyperKey); break; case TURN_THRUST_ID: WinSetDlgItemText (hwnd, TURN_ID, "Turn"); WinSetDlgItemText (hwnd, THRUST_ID, "Thrust"); stLocalDefs.fTurnThrust = TRUE; break; case LEFT_RIGHT_ID: WinSetDlgItemText (hwnd, TURN_ID, "Left"); WinSetDlgItemText (hwnd, THRUST_ID, "Right"); stLocalDefs.fTurnThrust = FALSE; break; default: break; } /* Take the focus away from the radiobuttons */ WinSetFocus (HWND_DESKTOP, WinWindowFromID (hwnd, UP_TEXT_ID)); break; case WM_CHAR : /* Get the scancode and store it in the appropriate place in array */ if (!(SHORT1FROMMP(mp1) & KC_KEYUP)) { usScanCode = CHAR4FROMMP(mp1); WinSetDlgItemText (hwnd, ulButton, szScanCode[usScanCode]); *pusKeyDef = usScanCode; } return (0); default: break; } return (WinDefDlgProc (hwnd, msg, mp1, mp2)); }
/****************************************************************\ * *-------------------------------------------------------------- * * Name:ClkCommand() * * Purpose:Handle WM_COMMAND events. * * * * Usage: * * Method: * - * * - * - * * - * - * * Returns: * VOID * \****************************************************************/ VOID ClkCommand ( HWND hwnd , MPARAM mp1, MPARAM mp2 ) { DATETIME dtNew ; switch ( SHORT1FROMMP ( mp1 ) ) { case IDM_TICKS : WinDlgBox ( HWND_DESKTOP , hwndFrame , ClkTicksDlgProc , NULLHANDLE , IDD_TICKS , (PVOID )NULL ) ; break; case IDM_EXIT: /* *post the event semaphore *for our alarm thread */ fEndThread = TRUE; DosPostEventSem(TimerResources.hTimerDev); WinPostMsg(hwnd, WM_QUIT,MPVOID, MPVOID); break; case IDM_COLORS : WinDlgBox ( HWND_DESKTOP , hwndFrame ,ClkColorsDlgProc , NULLHANDLE , IDD_COLORS , NULL ) ; SetRGBColors(); ClkSize(hwnd); break ; case IDM_TOGGLECONTROLS : if (cp.fControlsHidden) { ClkShowFrameControls( hwndFrame ); } else { ClkHideFrameControls ( hwndFrame ) ; } break ; case IDM_DATETIME: if (hDateTime == NULLHANDLE) { WinDlgBox(HWND_DESKTOP,hwndFrame,TimeDlgProc, NULLHANDLE,IDD_TIME ,NULL); dt.minutes += 2; /*Fool the ClkTimer proc. It will now think it have to redraw*/ } else { WinSetFocus (HWND_DESKTOP, hDateTime); } break; case IDM_ALARM: if (hAlarmTime == (HWND)NULL) { WinDlgBox(HWND_DESKTOP,hwndFrame,AlarmDlgProc, NULLHANDLE,IDD_ALARM ,NULL); } else { WinSetFocus(HWND_DESKTOP,hAlarmTime); } break; case IDM_SECONDHAND: cp.usDispMode = ((cp.usDispMode & DM_SECONDHAND) ? (cp.usDispMode & (~DM_SECONDHAND)) : (cp.usDispMode | DM_SECONDHAND)); GpiSetMix(hps, FM_INVERT); /* * Depending on the current mode draw or remove the second hand. */ if (cp.usDispMode & DM_SECONDHAND) { DosGetDateTime(&dtNew); ClkDrawHand(hps, HT_SECOND, dtNew.seconds); dt.seconds = dtNew.seconds; } else { ClkDrawHand(hps, HT_SECOND, dt.seconds); } WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_SECONDHAND, TRUE), MPFROM2SHORT( MIA_CHECKED, ( (cp.usDispMode & DM_SECONDHAND)? MIA_CHECKED : ~MIA_CHECKED) ) ); break; case IDM_TIME: cp.usDispMode = ((cp.usDispMode & DM_TIME) ? (cp.usDispMode & (~DM_TIME)) : (cp.usDispMode | DM_TIME)); 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) ) ); ClkSize(hwnd); WinInvalidateRect(hwnd, NULL, TRUE); break; case IDM_DATE: cp.usDispMode = ((cp.usDispMode & DM_DATE) ? (cp.usDispMode & (~DM_DATE)) : (cp.usDispMode | DM_DATE)); 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) ) ); ClkSize(hwnd); WinInvalidateRect(hwnd,(PRECTL)NULL,TRUE); break; case IDM_DIGITAL: cp.usDispMode |= DM_DIGITAL; cp.usDispMode &= (~DM_ANALOG); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_DIGITAL, TRUE), MPFROM2SHORT( MIA_CHECKED, MIA_CHECKED)); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_ANALOG , TRUE), MPFROM2SHORT( MIA_CHECKED, ~MIA_CHECKED)); 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)); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_TIME, TRUE), MPFROM2SHORT( MIA_DISABLED, ( ((!(cp.usDispMode & DM_DATE)) || (cp.usDispMode & DM_ANALOG))? MIA_DISABLED : ~MIA_DISABLED) ) ); WinInvalidateRect(hwnd,(PRECTL)NULL,TRUE); break; case IDM_ANALOG : cp.usDispMode |= DM_ANALOG; cp.usDispMode &= (~DM_DIGITAL); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_ANALOG, TRUE), MPFROM2SHORT( MIA_CHECKED, MIA_CHECKED)); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_DIGITAL, TRUE), MPFROM2SHORT( MIA_CHECKED, ~MIA_CHECKED)); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_TIME, TRUE), MPFROM2SHORT( MIA_DISABLED, MIA_DISABLED)); WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_DATE, TRUE), MPFROM2SHORT( MIA_DISABLED, ~MIA_DISABLED)); 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)); cp.usDispMode |= DM_TIME; WinSendMsg( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT( IDM_TIME, TRUE), MPFROM2SHORT( MIA_CHECKED, MIA_CHECKED)); WinInvalidateRect(hwnd,(PRECTL)NULL,TRUE); break; case IDM_HELPHELPFORHELP: HelpHelpForHelp(mp2); break; case IDM_HELPEXTENDED: HelpExtended(mp2); break; case IDM_HELPKEYS: HelpKeys(mp2); break; case IDM_HELPINDEX: HelpIndex(mp2); break; case IDM_HELPTUTORIAL: HelpTutorial(mp2); break; case IDM_HELPABOUT: HelpAbout(mp2); break; case IDM_ALARM_EXPIRED: WinMessageBox(HWND_DESKTOP, hwndFrame, (PSZ)"Alarm Expired", (PSZ)"The Bells Are Ringing", 0, MB_OK); break; } }