BOOL OSpinBtn::getCurrent(PVOID addr, USHORT size, USHORT control) { return((BOOL)WinSendMsg (hwnd, SPBM_QUERYVALUE, MPFROMP(addr), MPFROM2SHORT(size,control))); }
/* ConfigureDlgProc This is the dialog procedure for the module configuration dialog. The dialog contains a check box for enabling/disabling the module and two push buttons ("OK" and "Cancel") to close/cancel the dialog. Since version 1.2, it contains a slider to set the animation speed; if you don't want this slider, change the '#if 0' line in the WM_INITDLG part of this dialog procedure. This is enough for simple saver modules, but can easily be expanded for more saver modules that need more settings. */ MRESULT EXPENTRY ConfigureDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { char buf[sizeof(modulename)+20]; static HWND hwndEnabled; static HWND hwndGravity; static HWND hwndWhiteStars,hwndRedStars; static HWND hwndBlueStars,hwndYellowStars; static HWND hwndTraceName; static HWND hwndShow3d; switch(msg){ case WM_INITDLG: /* set titlebar of the dialog window */ /* to "MODULENAME configuration" */ strcpy(buf, modulename); strcat(buf, " configuration"); WinSetWindowText(hwnd, (PSZ)buf); /* get window handles of the dialog controls */ /* and set initial state of the controls */ hwndEnabled = WinWindowFromID(hwnd, IDC_ENABLED); WinSendMsg(hwndEnabled, BM_SETCHECK, MPFROMSHORT(configuration_data.enabled), MPVOID); hwndEnabled = WinWindowFromID(hwnd, IDC_ENABLED); WinSendMsg(hwndEnabled, BM_SETCHECK,MPFROMSHORT(configuration_data.enabled), MPVOID); hwndTraceName = WinWindowFromID(hwnd, IDC_TRACENAME); WinSendMsg(hwndTraceName, BM_SETCHECK,MPFROMSHORT(configuration_data.tracename), MPVOID); hwndShow3d = WinWindowFromID(hwnd, IDC_3D); WinSendMsg(hwndShow3d, BM_SETCHECK,MPFROMSHORT(configuration_data.show3d), MPVOID); hwndGravity = WinWindowFromID(hwnd, IDC_GRAVITY); WinSendMsg(hwndGravity, SPBM_SETLIMITS, (MPARAM)CONFIGURATION_MAXIMUM_GRAVITY, (MPARAM)CONFIGURATION_MINIMUM_GRAVITY); WinSendMsg(hwndGravity, SPBM_SETCURRENTVALUE, MPFROMSHORT(configuration_data.gravity), MPVOID); hwndWhiteStars = WinWindowFromID(hwnd, IDC_WHITESTARS); WinSendMsg(hwndWhiteStars, SPBM_SETLIMITS, (MPARAM)CONFIGURATION_MAXIMUM_STARS, (MPARAM)CONFIGURATION_MINIMUM_STARS); WinSendMsg(hwndWhiteStars, SPBM_SETCURRENTVALUE, MPFROMSHORT(configuration_data.whitestar_count), MPVOID); hwndRedStars = WinWindowFromID(hwnd, IDC_REDSTARS); WinSendMsg(hwndRedStars, SPBM_SETLIMITS, (MPARAM)CONFIGURATION_MAXIMUM_STARS, (MPARAM)CONFIGURATION_MINIMUM_STARS); WinSendMsg(hwndRedStars, SPBM_SETCURRENTVALUE, MPFROMSHORT(configuration_data.redstar_count), MPVOID); hwndBlueStars = WinWindowFromID(hwnd, IDC_BLUESTARS); WinSendMsg(hwndBlueStars, SPBM_SETLIMITS, (MPARAM)CONFIGURATION_MAXIMUM_STARS, (MPARAM)CONFIGURATION_MINIMUM_STARS); WinSendMsg(hwndBlueStars, SPBM_SETCURRENTVALUE, MPFROMSHORT(configuration_data.bluestar_count), MPVOID); hwndYellowStars = WinWindowFromID(hwnd, IDC_YELLOWSTARS); WinSendMsg(hwndYellowStars, SPBM_SETLIMITS, (MPARAM)CONFIGURATION_MAXIMUM_STARS, (MPARAM)CONFIGURATION_MINIMUM_STARS); WinSendMsg(hwndYellowStars, SPBM_SETCURRENTVALUE, MPFROMSHORT(configuration_data.yellowstar_count), MPVOID); /* return FALSE since we did not change the focus */ return (MRESULT)FALSE; case WM_COMMAND: switch(SHORT1FROMMP(mp1)){ case IDC_OK: /* OK button was pressed. query the control settings */ configuration_data.enabled = SHORT1FROMMR(WinSendMsg(hwndEnabled, BM_QUERYCHECK, MPVOID, MPVOID)); configuration_data.tracename = SHORT1FROMMR(WinSendMsg(hwndTraceName, BM_QUERYCHECK, MPVOID, MPVOID)); configuration_data.show3d = SHORT1FROMMR(WinSendMsg(hwndShow3d, BM_QUERYCHECK, MPVOID, MPVOID)); WinSendMsg(hwndGravity, SPBM_QUERYVALUE, MPFROMP(&configuration_data.gravity), MPFROM2SHORT(0, SPBQ_DONOTUPDATE)); WinSendMsg(hwndWhiteStars, SPBM_QUERYVALUE, MPFROMP(&configuration_data.whitestar_count), MPFROM2SHORT(0, SPBQ_DONOTUPDATE)); WinSendMsg(hwndRedStars, SPBM_QUERYVALUE, MPFROMP(&configuration_data.redstar_count), MPFROM2SHORT(0, SPBQ_DONOTUPDATE)); WinSendMsg(hwndBlueStars, SPBM_QUERYVALUE, MPFROMP(&configuration_data.bluestar_count), MPFROM2SHORT(0, SPBQ_DONOTUPDATE)); WinSendMsg(hwndYellowStars, SPBM_QUERYVALUE, MPFROMP(&configuration_data.yellowstar_count), MPFROM2SHORT(0, SPBQ_DONOTUPDATE)); /* write all configuration data to INI-file */ write_profile_data(); /* end dialog */ WinDismissDlg(hwnd, TRUE); return (MRESULT)0; case IDC_CANCEL: /* dialog was cancelled; end it */ WinDismissDlg(hwnd, FALSE); return (MRESULT)0; default: return (MRESULT)0; } } return WinDefDlgProc(hwnd, msg, mp1, mp2); }
/* ConfigureDlgProc This is the dialog procedure for the module configuration dialog. The dialog contains a check box for enabling/disabling the module and two push buttons ("OK" and "Cancel") to close/cancel the dialog. Since version 1.2, it contains a slider to set the animation speed; if you don't want this slider, change the '#if 0' line in the WM_INITDLG part of this dialog procedure. This is enough for simple saver modules, but can easily be expanded for more saver modules that need more settings. */ MRESULT EXPENTRY ConfigureDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { char buf[sizeof(modulename)+20]; static HWND hwndEnabled; static HWND hwndSpeed; /* $$$$$ insert code here $$$$$ If you need additional data for dialog processing, insert it here. $$$$$ for example $$$$$ */ static HWND hwndCount; static HWND hwndColor; static HWND hwndBlankScreen; CHAR msgtext[256]; switch(msg){ case WM_INITDLG: // set titlebar of the dialog window // to "MODULENAME configuration" strcpy(buf, modulename); strcat(buf, " configuration"); WinSetWindowText(hwnd, (PSZ)buf); // get window handles of the dialog controls // and set initial state of the controls hwndEnabled = WinWindowFromID(hwnd, IDC_ENABLED); WinSendMsg(hwndEnabled, BM_SETCHECK, MPFROMLONG(configuration_data.enabled), MPVOID); hwndSpeed = WinWindowFromID(hwnd, IDC_SPEED); WinSendMsg(hwndSpeed, SLM_SETTICKSIZE, MPFROM2SHORT(SMA_SETALLTICKS, 3), MPVOID); WinSendMsg(hwndSpeed, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), MPFROMLONG(configuration_data.animation_speed)); WinSendMsg(hwndSpeed, SLM_SETSCALETEXT, MPFROMSHORT(0), MPFROMP("slow")); WinSendMsg(hwndSpeed, SLM_SETSCALETEXT, MPFROMSHORT(4), MPFROMP("fast")); /* $$$$$ insert code here $$$$$ Get window handles of your dialog controls. Set initial state of your controls. $$$$$ for example $$$$$ */ hwndCount = WinWindowFromID(hwnd, IDC_COUNT); WinSendMsg(hwndCount, SPBM_SETLIMITS, (MPARAM)CONFIGURATION_MAXIMUM_COUNT, (MPARAM)CONFIGURATION_MINIMUM_COUNT); WinSendMsg(hwndCount, SPBM_SETCURRENTVALUE, MPFROMLONG(configuration_data.count), MPVOID); /* set window that queries how many lines will have the same color */ hwndColor = WinWindowFromID(hwnd, IDC_COLOR); WinSendMsg(hwndColor, SPBM_SETLIMITS, (MPARAM)COLORS_MAXIMUM, (MPARAM)COLORS_MINIMUM); WinSendMsg(hwndColor, SPBM_SETCURRENTVALUE, MPFROMLONG(configuration_data.colors), MPVOID); hwndBlankScreen = WinWindowFromID(hwnd, IDC_BLANKSCREEN); WinSendMsg(hwndBlankScreen, BM_SETCHECK, MPFROMSHORT(configuration_data.blank_screen), MPVOID); // return FALSE since we did not change the focus return (MRESULT)FALSE; case WM_COMMAND: switch(SHORT1FROMMP(mp1)){ case IDC_OK: // OK button was pressed. query the control settings configuration_data.enabled = SHORT1FROMMR(WinSendMsg(hwndEnabled, BM_QUERYCHECK, MPVOID, MPVOID)); configuration_data.animation_speed = SHORT1FROMMR(WinSendMsg(hwndSpeed, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), MPVOID)); /* $$$$$ insert code here $$$$$ Query control settings of your controls. $$$$$ for example $$$$$ */ WinSendMsg(hwndCount, SPBM_QUERYVALUE, MPFROMP(&configuration_data.count), MPFROM2SHORT(0, SPBQ_DONOTUPDATE)); WinSendMsg(hwndColor, SPBM_QUERYVALUE, MPFROMP(&configuration_data.colors), MPFROM2SHORT(0, SPBQ_DONOTUPDATE)); configuration_data.blank_screen = SHORT1FROMMR(WinSendMsg(hwndBlankScreen, BM_QUERYCHECK, MPVOID, MPVOID)); /* check if the values are in the allowed range */ if(CONFIGURATION_MINIMUM_COUNT > configuration_data.count || configuration_data.count > CONFIGURATION_MAXIMUM_COUNT){ sprintf( msgtext, "Sorry, but the number of lines displayed must be between %d and %d!", CONFIGURATION_MINIMUM_COUNT, CONFIGURATION_MAXIMUM_COUNT); WinMessageBox( HWND_DESKTOP, hwnd, (PSZ)msgtext, (PSZ)"Bouncing Line", 0, MB_OK | MB_INFORMATION | MB_MOVEABLE ); } else { if( COLORS_MINIMUM > configuration_data.colors || configuration_data.colors > COLORS_MAXIMUM ) { sprintf( msgtext, "Sorry, but the number of lines that are displayed in the same color must be between %d and %d!", COLORS_MINIMUM, COLORS_MAXIMUM ); WinMessageBox( HWND_DESKTOP, hwnd, (PSZ)msgtext, (PSZ)"Bouncing Line", 0, MB_OK | MB_INFORMATION | MB_MOVEABLE ); } else { /* everything is o.k. */ /* write all configuration data to INI-file */ write_profile_data(); // end dialog WinDismissDlg(hwnd, TRUE); } } return (MRESULT)0; case IDC_CANCEL: // dialog was cancelled; end it WinDismissDlg(hwnd, FALSE); return (MRESULT)0; default: return (MRESULT)0; } } return WinDefDlgProc(hwnd, msg, mp1, mp2); }
/* ConfigureDlgProc This is the dialog procedure for the module configuration dialog. The dialog contains a check box for enabling/disabling the module and two push buttons ("OK" and "Cancel") to close/cancel the dialog. Since version 1.2, it contains a slider to set the animation speed; if you don't want this slider, change the '#if 0' line in the WM_INITDLG part of this dialog procedure. This is enough for simple saver modules, but can easily be expanded for more saver modules that need more settings. */ MRESULT EXPENTRY ConfigureDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { char buf[sizeof(modulename)+20]; static HWND hwndEnabled; static HWND hwndSpeed; /* $$$$$ insert code here $$$$$ If you need additional data for dialog processing, insert it here. $$$$$ for example $$$$$ */ static HWND hwndCount; switch(msg){ case WM_INITDLG: /* set titlebar of the dialog window */ /* to "MODULENAME configuration" */ strcpy(buf, modulename); strcat(buf, " configuration"); WinSetWindowText(hwnd, (PSZ)buf); /* get window handles of the dialog controls */ /* and set initial state of the controls */ hwndEnabled = WinWindowFromID(hwnd, IDC_ENABLED); WinSendMsg(hwndEnabled, BM_SETCHECK, MPFROMSHORT(configuration_data.enabled), MPVOID); hwndSpeed = WinWindowFromID(hwnd, IDC_SPEED); WinSendMsg(hwndSpeed, SLM_SETTICKSIZE, MPFROM2SHORT(SMA_SETALLTICKS, 3), MPVOID); WinSendMsg(hwndSpeed, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), MPFROMLONG(configuration_data.animation_speed)); WinSendMsg(hwndSpeed, SLM_SETSCALETEXT, MPFROMSHORT(0), MPFROMP("slow")); WinSendMsg(hwndSpeed, SLM_SETSCALETEXT, MPFROMSHORT(4), MPFROMP("fast")); /* $$$$$ insert code here $$$$$ Get window handles of your dialog controls. Set initial state of your controls. $$$$$ for example $$$$$ */ hwndCount = WinWindowFromID(hwnd, IDC_COUNT); WinSendMsg(hwndCount, SPBM_SETLIMITS, (MPARAM)CONFIGURATION_MAXIMUM_COUNT, (MPARAM)CONFIGURATION_MINIMUM_COUNT); WinSendMsg(hwndCount, SPBM_SETCURRENTVALUE, MPFROMLONG(configuration_data.count), MPVOID); /* return FALSE since we did not change the focus */ return (MRESULT)FALSE; case WM_COMMAND: switch(SHORT1FROMMP(mp1)){ case IDC_OK: /* OK button was pressed. query the control settings */ configuration_data.enabled = SHORT1FROMMR(WinSendMsg(hwndEnabled, BM_QUERYCHECK, MPVOID, MPVOID)); configuration_data.animation_speed = SHORT1FROMMR(WinSendMsg(hwndSpeed, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), MPVOID)); /* $$$$$ insert code here $$$$$ Query control settings of your controls. $$$$$ for example $$$$$ */ WinSendMsg(hwndCount, SPBM_QUERYVALUE, MPFROMP(&configuration_data.count), MPFROM2SHORT(0, SPBQ_DONOTUPDATE)); /* write all configuration data to INI-file */ write_profile_data(); /* end dialog */ WinDismissDlg(hwnd, TRUE); return (MRESULT)0; case IDC_CANCEL: /* dialog was cancelled; end it */ WinDismissDlg(hwnd, FALSE); return (MRESULT)0; default: return (MRESULT)0; } } return WinDefDlgProc(hwnd, msg, mp1, mp2); }
void wxChoice::DoSetItemClientData(unsigned int n, void* pClientData) { ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)n, MPFROMP(pClientData)); } // end of wxChoice::DoSetItemClientData
BOOL OListBox::setItemText(const ULONG itemIndex, PCSZ text) { if (text) return((BOOL)WinSendMsg(hwnd, LM_SETITEMTEXT, MPFROMSHORT(itemIndex), MPFROMP(text))); return(FALSE); }
/**************************************************************************** * KeyDlgProc * * - Redefines keys by processing WM_CHAR's and assigning the key to the * * selected radiobutton (game key) * * - Standard dialog window I/O * ****************************************************************************/ MRESULT EXPENTRY KeyDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { int i; static KEY keyTmp[KEYS]; static SHORT id; switch (msg) { case WM_INITDLG: /* Set the associated text for each of the radio buttons */ for (i=0;i<KEYS;i++) { keyTmp[i] = prfProfile.keyDEFS[i]; SetText(hwnd, TEXT_LEFT+i, &prfProfile.keyDEFS[i]); } /* Check the first radio button and let it set up id */ WinSendDlgItemMsg(hwnd, KEY_LEFT, BM_CLICK, MPFROMSHORT(TRUE), MPVOID); return (MRESULT) TRUE; case WM_HELP: i = IDH_KEYS; WinSendMsg(hwndHelp, HM_DISPLAY_HELP, MPFROMP(&i), MPFROMSHORT(HM_RESOURCEID)); return 0; case WM_COMMAND: switch (SHORT1FROMMP(mp1)) { case DID_OK: for (i=0;i<KEYS;i++) prfProfile.keyDEFS[i] = keyTmp[i]; case DID_CANCEL: WinDismissDlg(hwnd, 0); return 0; } return 0; case WM_CONTROL: if (SHORT2FROMMP(mp1) == BN_CLICKED) { switch (SHORT1FROMMP(mp1)) { case KEY_LEFT: id = TEXT_LEFT; break; case KEY_RIGHT: id = TEXT_RIGHT; break; case KEY_THRUST: id = TEXT_THRUST; break; case KEY_HYPER: id = TEXT_HYPER; break; case KEY_FIRE: id = TEXT_FIRE; break; case KEY_SHIELD: id = TEXT_SHIELD; } WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd,id)); } return 0; case WM_CHAR: if (!(CHARMSG(&msg)->fs & KC_KEYUP)) { if ((CHARMSG(&msg)->fs & KC_VIRTUALKEY) && (CHARMSG(&msg)->vkey != VK_SHIFT) && (CHARMSG(&msg)->vkey != VK_CTRL) && (CHARMSG(&msg)->vkey != VK_ALT) && (CHARMSG(&msg)->vkey != VK_F1) && (CHARMSG(&msg)->vkey-1 < MAXVKEY)) { if (CHARMSG(&msg)->vkey == VK_F3) { WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_CANCEL, 0), MPVOID); return 0; } keyTmp[id-TEXT_LEFT].vk = (CHAR) (CHARMSG(&msg)->vkey - 1); keyTmp[id-TEXT_LEFT].chr = 0; } else if ((CHARMSG(&msg)->fs & KC_CHAR) && (CHARMSG(&msg)->chr > 32) && (CHARMSG(&msg)->chr < 127)) { keyTmp[id-TEXT_LEFT].vk = 0; keyTmp[id-TEXT_LEFT].chr = (CHAR) CHARMSG(&msg)->chr; } else { keyTmp[id-TEXT_LEFT].vk = 0; keyTmp[id-TEXT_LEFT].chr = 0; } } SetText(hwnd, id, &keyTmp[id-TEXT_LEFT]); return 0; } return WinDefDlgProc(hwnd, msg, mp1, mp2); }
MRESULT EXPENTRY DriverWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) { CHAR szFile[CCHMAXPATH]; /* File HOlder */ FILEFINDBUF3 findbuf; /* File Find Buffer */ FONTMETRICS fm; /* Font Metrics Structure */ HDIR hDir = (HDIR)HDIR_CREATE; /* Directory Handle */ HPS hPS; /* Presentation Space Handle */ HWND hwndListBox; /* List Box Window Handle */ LISTBOXCDATA lbwcd; /* List Box Window Control Data */ POWNERITEM poi; /* Owner Item */ RECTL rcl; /* Client Window Rectangle */ ULONG ulFileCnt = 1UL; /* File Counter Holder */ register INT i, k, n; /* Loop Counter */ switch ( msg ) { /* Perform window initialization */ case WM_CREATE : hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE); WinSetPointer(HWND_DESKTOP, hptrWait = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE)); memset(&lbwcd, 0, sizeof(LISTBOXCDATA)); lbwcd.cb = sizeof(LISTBOXCDATA); lbwcd.ulVersion = LBV_110; lbwcd.vdata.lbcd1_1.flExtStyles = LSXS_CHECKBOX | LSXS_EDITABLE; hwndList1 = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE, 10L, 10L, 100L, 175L, hWnd, HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL); hwndListx = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE, 125L, 10L, 100L, 175L, hWnd, HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL); hwndList2 = WinCreateWindow(hWnd, "ListBoxWindow", "", WS_VISIBLE, 10L, 190L, 250L, 200L, hWnd, HWND_TOP, 1025UL, (PVOID)&lbwcd, (PVOID)NULL); WinSendMsg(hwndList1, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_SINGLECLICK), MPFROMP("ahooga.wav")); WinSendMsg(hwndListx, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_DOUBLECLICK), MPFROMP("flush.wav")); hwndListA = WinCreateWindow(hWnd, WC_LISTBOX, "", LS_OWNERDRAW | LS_HORZSCROLL | LS_MULTIPLESEL | WS_VISIBLE, 275L, 10L, 100L, 175L, hWnd, HWND_TOP, 1026UL, (PVOID)NULL, (PVOID)NULL); /* Sub-class the default window procedure with */ /* new one which will handle specific messages */ /* allowing better control over the sizing frame */ hwndListB = WinCreateWindow(hWnd, WC_LISTBOX, "", WS_VISIBLE | LS_EXTENDEDSEL, 275L, 190L, 250L, 200L, hWnd, HWND_TOP, 1027UL, (PVOID)NULL, (PVOID)NULL); for ( i = 0; i < 10; i++ ) { sprintf(szFile, "Item %04d Item %04d Item %04d", i, i, i); WinSendMsg(hwndListx, LM_INSERTITEM, MPFROMLONG(LIT_END), MPFROMP(szFile)); } n = (INT)WinSendMsg(hwndList2, LMX_CALCLINECOUNT, MPFROMLONG(175L), 0L); k = 0; WinSendMsg(hwndList2, LM_SETITEMHEIGHT, MPFROMLONG(36L), 0L); if ( !DosFindFirst("*.*", &hDir, FILE_NORMAL, (PVOID)&findbuf, sizeof(FILEFINDBUF3), &ulFileCnt, FIL_STANDARD) ) { do { WinSendMsg(hwndList2, LM_INSERTITEM, MPFROMLONG(LIT_SORTDESCENDING), MPFROMP(findbuf.achName)); WinSendMsg(hwndList1, LM_INSERTITEM, MPFROMLONG(LIT_SORTASCENDING), MPFROMP(findbuf.achName)); if ( ++k > n ) WinSendMsg(hwndList2, LM_SETTOPINDEX, MPFROMLONG(k - n), 0L); WinSendMsg(hwndListB, LM_INSERTITEM, MPFROMLONG(LIT_SORTDESCENDING), MPFROMP(findbuf.achName)); WinSendMsg(hwndListA, LM_INSERTITEM, MPFROMLONG(LIT_SORTASCENDING), MPFROMP(findbuf.achName)); } while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) ); DosFindClose(hDir); } break; case WM_BUTTON1DOWN : WinEnableWindowUpdate(hwndListA, FALSE); WinEnableWindowUpdate(hwndList1, FALSE); WinSendMsg(hwndListA, LM_DELETEALL, 0L, 0L); WinSendMsg(hwndList1, LM_DELETEALL, 0L, 0L); i = 0; if ( !DosFindFirst("*.*", &hDir, FILE_NORMAL, (PVOID)&findbuf, sizeof(FILEFINDBUF3), &ulFileCnt, FIL_STANDARD) ) { do { WinSendMsg(hwndListA, LM_INSERTITEM, MPFROMLONG(LIT_SORTASCENDING), MPFROMP(findbuf.achName)); WinSendMsg(hwndList1, LM_INSERTITEM, MPFROMLONG(LIT_SORTASCENDING), MPFROMP(findbuf.achName)); ++i; } while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) ); DosFindClose(hDir); } WinShowWindow(hwndListA, TRUE); WinShowWindow(hwndList1, TRUE); while ( i ) { if ( i % 2 ) { WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE)); WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE)); } --i; } break; case WM_CONTROL : switch ( SHORT2FROMMP(mp1) ) { /* Process double click on a List Box */ case LN_SELECT : switch ( SHORT1FROMMP(mp1) ) { case 1024UL : /* WinAlarm(HWND_DESKTOP, WA_NOTE); */ break; case 1027UL : /* WinAlarm(HWND_DESKTOP, WA_ERROR); */ break; } break; } break; case WM_MEASUREITEM : GpiQueryFontMetrics(hPS = WinGetPS(hWnd), sizeof(FONTMETRICS), &fm); WinReleasePS(hPS); return(MRFROMLONG(fm.lMaxBaselineExt)); /* Draw a list box item */ case WM_DRAWITEM : if ( SHORT1FROMMP(mp1) == 1024 ) hwndListBox = hwndList1; else if ( SHORT1FROMMP(mp1) == 1026 ) hwndListBox = hwndListA; /* Point to Owner Item information */ poi = (POWNERITEM)mp2; GpiCreateLogColorTable(poi->hps, 0L, LCOLF_RGB, 0L, 0L, (PLONG)NULL); i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXTLENGTH, MPFROMLONG(poi->idItem), 0L)); i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXT, MPFROM2SHORT(poi->idItem, CCHMAXPATH), MPFROMP(szFile))); /* Check to see if item to be drawn or */ /* highlighted */ if ( poi->fsState != poi->fsStateOld ) { WinFillRect(poi->hps, &poi->rclItem, RGBCLR_DIALOGBACKGROUND); if ( poi->fsState ) WinDrawText(poi->hps, -1L, szFile, &poi->rclItem, RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER | DT_ERASERECT); /* Set item highlighting by inverting the items */ /* rectangle colour */ WinInvertRect(poi->hps, &poi->rclItem); if ( !poi->fsState ) WinDrawText(poi->hps, -1L, szFile, &poi->rclItem, RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER | DT_ERASERECT); poi->fsState = poi->fsStateOld = 0; } else { /* Item needs to be drawn, get item rectangle */ /* item position */ WinFillRect(poi->hps, &poi->rclItem, RGBCLR_DIALOGBACKGROUND); WinDrawText(poi->hps, -1L, szFile, &poi->rclItem, RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER | DT_ERASERECT); } return(MRFROMLONG(TRUE)); case WM_BUTTON1DBLCLK : i = 0; if ( !DosFindFirst("*.*", &hDir, FILE_NORMAL, (PVOID)&findbuf, sizeof(FILEFINDBUF3), &ulFileCnt, FIL_STANDARD) ) { do { ++i; } while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) ); DosFindClose(hDir); } while ( i ) { if ( i % 2 ) { WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE)); WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE)); } --i; } break; case WM_BUTTON2DOWN : for ( i = 0; i < 5; i++ ) WinSendMsg(hwndListx, LM_DELETEITEM, MPFROMSHORT(2), 0L); #if 0 WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(LIT_NONE), MPFROMLONG(TRUE)); i = LIT_FIRST; while ( (i = (INT)LONGFROMMR(WinSendMsg(hwndList1, LM_QUERYSELECTION, MPFROMLONG(i), 0L))) != LIT_NONE ) WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i), MPFROMLONG(FALSE)); #endif break; /* Erase background */ case WM_ERASEBACKGROUND : WinQueryWindowRect(hWnd, &rcl); WinFillRect((HPS)mp1, &rcl, SYSCLR_DIALOGBACKGROUND); break; /* Paint the main client window */ case WM_PAINT : WinSetPointer(HWND_DESKTOP, hptrWait); WinFillRect(hPS = WinBeginPaint(hWnd, (HPS)NULL, &rcl), &rcl, SYSCLR_DIALOGBACKGROUND); WinEndPaint(hPS); WinSetPointer(HWND_DESKTOP, hptrArrow); break; /* Close Down */ case WM_CLOSE : WinPostMsg(hWnd, WM_QUIT, 0L, 0L); break; case WM_DESTROY : WinDestroyPointer(hptrArrow); WinDestroyPointer(hptrWait); break; /* Default message processing */ default: return(WinDefWindowProc(hWnd, msg, mp1, mp2)); } return(0L); }
VOID FAR PMfrThread (VOID) { int sub_rc; habThread = WinInitialize(0); WinGetLastError(habThread); /* get the memory DC */ cp.hdcMemory = DevOpenDC (habThread, OD_MEMORY, "*", 0L, NULL, NULL) ; /* this says that we don't have a PS yet; not one to destroy */ cp.hpsMemory = (HPS) NULL; /* let each sub-driver have a crack at it now */ PrintDriverInit(); CalcDriverInit(); /* Initialization here is done. Post main thread that we are going to work */ WinPostMsg(cp.hwnd, WM_THRD_POST, MPFROM2SHORT(SUB_INIT_DONE, 0), MPFROMP(NULL) ); for (;;) { /* wait for something to do */ DosSemWait (&cp.ulSemTrigger, SEM_INDEFINITE_WAIT) ; /* take an early exit for Shutdown */ if (cp.sSubAction == SUB_ACT_TERM) break; /* posted out of wait. do something */ switch(cp.sSubAction) { case SUB_ACT_CALC: sub_rc = CalcDriver(); break; case SUB_ACT_PRINT: sub_rc = PrintDriver(); break; case SUB_ACT_SAVE: sub_rc = SaveDriver(); break; case SUB_ACT_LOAD: sub_rc = LoadDriver(); break; default: sub_rc = 0x9999; /* let the main task figure it out */ break; } /* test here for shutdown also */ if (cp.sSubAction == SUB_ACT_TERM) break; /* not shutdown. */ /* indicate ready for the next cycle */ DosSemSet (&cp.ulSemTrigger) ; WinPostMsg (cp.hwnd, WM_THRD_POST, MPFROM2SHORT(sub_rc, 0) , MPFROMP(NULL) ) ; } /* shutdown has been triggered. release resources obtained by us. NOTE: Serialize using DosEnterCritSec so that the main thread is dormant until we get everything cleaned up and go away. The main thread will be re-dispatched following our final DosExit. */ DosEnterCritSec(); if (cp.hpsMemory != (HPS) 0) { /* protection from a failed WM_CREATE or IDM_GO */ GpiSetBitmap(cp.hpsMemory, (HBITMAP) NULL); GpiDestroyPS(cp.hpsMemory); GpiDeleteBitmap (cp.hbmMemory); } cp.hpsMemory = (HPS) 0; if ( cp.pixels != NULL) hfree(cp.pixels); cp.pixels = NULL; if (cp.hdcMemory != (HDC) 0) DevCloseDC (cp.hdcMemory); cp.hdcMemory = (HDC) 0; /* say good-bye to PM */ WinTerminate(habThread); /* flag we done */ DosSemClear ((HSEM) &cp.ulSemSubEnded); /* and go away */ DosExit(EXIT_THREAD, 0); }
MRESULT EXPENTRY wpCD(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { switch (msg) { case WM_INITDLG: { ULONG rc, i; HFILE CDDevice; ULONG action; ULONG len; struct { USHORT CountCD; USHORT FirstCD; } CDInfo; FIELDINFO *firstFieldInfo, *posFieldInfo, *splitFieldInfo; FIELDINFOINSERT fieldInfoInsert; CNRINFO cnrInfo; cnrInfo.cb = sizeof(cnrInfo); firstFieldInfo = posFieldInfo = allocaFieldInfo(hwnd, CT_TRACK, NUM_FIELDS); posFieldInfo->flData = CFA_BITMAPORICON | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Icon"; posFieldInfo->offStruct = FIELDOFFSET(RECORDCORE,hptrIcon); fieldInfo[0] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Filename"; posFieldInfo->offStruct = FIELDOFFSET(RECORDCORE,pszIcon); fieldInfo[1] = posFieldInfo; cnrInfo.pFieldInfoLast = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Track #"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,track); fieldInfo[2] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR | CFA_FIREADONLY; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Type"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,typepointer); fieldInfo[3] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR | CFA_FIREADONLY; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Time"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,timepointer); fieldInfo[4] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Size"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,size); fieldInfo[5] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "MP3 Size"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,mp3size); fieldInfo[6] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Title"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,titleptr); fieldInfo[7] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Artist"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,artistptr); fieldInfo[8] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Album"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,albumptr); fieldInfo[9] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Year"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,yearptr); fieldInfo[10] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Genre"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,genreptr); fieldInfo[11] = posFieldInfo; posFieldInfo = posFieldInfo->pNextFieldInfo; posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; posFieldInfo->flTitle = CFA_CENTER; posFieldInfo->pTitleData = "Comment"; posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,commentptr); fieldInfo[12] = posFieldInfo; fieldInfoInsert.cb = sizeof(fieldInfoInsert); fieldInfoInsert.pFieldInfoOrder = (FIELDINFO *) CMA_FIRST; fieldInfoInsert.fInvalidateFieldInfo = TRUE; fieldInfoInsert.cFieldInfoInsert = NUM_FIELDS; insertFieldInfo(hwnd, CT_TRACK, firstFieldInfo, &fieldInfoInsert); cnrInfo.xVertSplitbar = 100; cnrInfo.flWindowAttr = CV_DETAIL | CA_DETAILSVIEWTITLES; WinSendDlgItemMsg(hwnd,CT_TRACK,CM_SETCNRINFO, MPFROMP(&cnrInfo), MPFROMLONG(CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR | CMA_FLWINDOWATTR)); loadConfig(CFGFILE, &grabbers, &countGrabbers); for(i = 0; i < countGrabbers; i++) insertItemText(hwnd,CB_GRABBER,LIT_END,grabbers[i].id); selectItem(hwnd,CB_GRABBER,0); setText(hwnd, EF_TITLE, "Title"); /* wohw, this is too powerful, need cooling */ len = sizeof(CDInfo); if(!DosOpen("\\DEV\\CD-ROM2$", &CDDevice, &action, 0, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL)) { if(!DosDevIOCtl(CDDevice, 0x82, 0x60, NULL, 0, NULL, &CDInfo, len, &len)) { for(i = 0; i < CDInfo.CountCD; i++) { char driveLetter[3] = { (char) ('A' + CDInfo.FirstCD + i), ':', 0}; insertItemText(hwnd,CB_DRIVE,LIT_END,driveLetter); } } DosClose(CDDevice); } selectItem(hwnd,CB_DRIVE,0); wpCT = WinSubclassWindow(WinWindowFromID(hwnd,CT_TRACK),wpCTTrack); dataIco = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, ICO_DATA); trackIco = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, ICO_TRACK); loadIni(hwnd); return 0; } case WM_COMMAND: return processCommand(hwnd,mp1,mp2); case WM_CONTROL: return processControl(hwnd,mp1,mp2); case WM_ADJUSTFRAMEPOS: { SWP *pos = (SWP*) PVOIDFROMMP(mp1); static int bitRateCheck = 0; if(pos->fl & SWP_SIZE) { SWP ctpos; WinQueryWindowPos(WinWindowFromID(hwnd, CT_TRACK), &ctpos); WinSetWindowPos (WinWindowFromID(hwnd, CT_TRACK), 0, 0, ctpos.y, pos->cx, pos->cy - ctpos.y, SWP_SIZE | SWP_SHOW | SWP_MOVE); } if((pos->fl & SWP_SHOW) && bitRateChanged != bitRateCheck) { bitRateCheck = bitRateChanged; refreshFieldInfo(hwnd, CT_TRACK); } break; } case WM_MENUEND: removeSourceEmphasis(HWNDFROMMP(mp2),&sourceEmphasisInfo); return 0; case WM_CLOSE: { WinDestroyPointer(dataIco); WinDestroyPointer(trackIco); free(grabbers); saveIni(hwnd); /* delete all current records */ CDTRACKRECORD *record = (CDTRACKRECORD *) enumRecords(hwnd, CT_TRACK, NULL, CMA_FIRST); while(record && record != (CDTRACKRECORD *) -1) { free(record->record.pszIcon); record = (CDTRACKRECORD *) enumRecords(hwnd, CT_TRACK, (RECORDCORE *) record, CMA_NEXT); } removeRecords(hwnd, CT_TRACK, NULL, 0); removeFieldInfo(hwnd,CT_TRACK, NULL, 0); return 0; } case WM_CHAR: if(SHORT2FROMMP(mp2) == VK_ESC) return 0; else break; /* back from worker thread */ case DLGCD_REFRESH: dlgcd_refresh2(mp1,mp2); return 0; case CDDB_FUZZYMATCH: { CDDBQUERY_DATA *matches = (CDDBQUERY_DATA *) mp1, *chosen = (CDDBQUERY_DATA *) mp2; FUZZYMATCHCREATEPARAMS data = {matches,chosen}; WinDlgBox(HWND_DESKTOP, hwnd, wpMatch, NULLHANDLE, DLG_MATCH, &data); return 0; } } return WinDefDlgProc( hwnd, msg, mp1, mp2 ); }
BOOL XDragItem :: RenderPrepare( const XWindow * target, const USHORT operation, const USHORT reply, const char * mechanism, const char * container, ULONG& support) { if(trans == NULL) { trans = DrgAllocDragtransfer(1); trans->cb = sizeof(trans); trans->hwndClient = target->GetHandle(); trans->pditem = item; } else { DrgDeleteStrHandle( trans->hstrSelectedRMF ); DrgDeleteStrHandle( trans->hstrRenderToName ); } trans->hstrSelectedRMF = DrgAddStrHandle( (char*) mechanism); trans->hstrRenderToName = DrgAddStrHandle( (char*) container ); trans->usOperation = operation; trans->fsReply = reply; BOOL result = (BOOL) DrgSendTransferMsg( trans->pditem->hwndItem, DM_RENDERPREPARE, MPFROMP(trans), 0); support = trans->fsReply; return result; }
static MRESULT processCommand(HWND hwnd,MPARAM mp1,MPARAM mp2) { switch(SHORT1FROMMP(mp1)) { case IDM_ICONVIEW: { CNRINFO cnrInfo; cnrInfo.cb = sizeof(cnrInfo); WinSendDlgItemMsg(hwnd,CT_TRACK,CM_QUERYCNRINFO, MPFROMP(&cnrInfo),MPFROMLONG(sizeof(cnrInfo))); cnrInfo.flWindowAttr |= CV_ICON; cnrInfo.flWindowAttr &= ~CV_NAME & ~CV_DETAIL & ~CV_TREE; WinSendDlgItemMsg(hwnd,CT_TRACK,CM_SETCNRINFO, MPFROMP(&cnrInfo),MPFROMLONG(CMA_FLWINDOWATTR)); return 0; } case IDM_NAMEVIEW: { CNRINFO cnrInfo; cnrInfo.cb = sizeof(cnrInfo); WinSendDlgItemMsg(hwnd,CT_TRACK,CM_QUERYCNRINFO, MPFROMP(&cnrInfo),MPFROMLONG(sizeof(cnrInfo))); cnrInfo.flWindowAttr |= CV_NAME | CV_FLOW; cnrInfo.flWindowAttr &= ~CV_ICON & ~CV_DETAIL & ~CV_TREE; WinSendDlgItemMsg(hwnd,CT_TRACK,CM_SETCNRINFO, MPFROMP(&cnrInfo),MPFROMLONG(CMA_FLWINDOWATTR)); return 0; } case IDM_DETAILVIEW: { CNRINFO cnrInfo; cnrInfo.cb = sizeof(cnrInfo); WinSendDlgItemMsg(hwnd,CT_TRACK,CM_QUERYCNRINFO, MPFROMP(&cnrInfo),MPFROMLONG(sizeof(cnrInfo))); cnrInfo.flWindowAttr |= CV_DETAIL | CA_DETAILSVIEWTITLES; cnrInfo.flWindowAttr &= ~CV_ICON & ~CV_NAME & ~CV_TREE; WinSendDlgItemMsg(hwnd,CT_TRACK,CM_SETCNRINFO, MPFROMP(&cnrInfo),MPFROMLONG(CMA_FLWINDOWATTR)); return 0; } case IDM_MINIICONS: { CNRINFO cnrInfo; miniIcons = !miniIcons; cnrInfo.cb = sizeof(cnrInfo); WinSendDlgItemMsg(hwnd,CT_TRACK,CM_QUERYCNRINFO, MPFROMP(&cnrInfo),MPFROMLONG(sizeof(cnrInfo))); cnrInfo.flWindowAttr = (miniIcons) ? (cnrInfo.flWindowAttr | CV_MINI) : (cnrInfo.flWindowAttr & ~CV_MINI); WinSendDlgItemMsg(hwnd,CT_TRACK,CM_SETCNRINFO, MPFROMP(&cnrInfo),MPFROMLONG(CMA_FLWINDOWATTR)); return 0; } case IDM_SELECTALL: selectAllRecords(hwnd, CT_TRACK, TRUE); return 0; case IDM_DESELECTALL: selectAllRecords(hwnd, CT_TRACK, FALSE); return 0; case PB_CDPLAY: sourceEmphasisInfo.sourceRecord = searchRecords(hwnd, CT_TRACK, (RECORDCORE *) CMA_FIRST, CRA_CURSORED); case IDM_PLAY: { CDTRACKRECORD *record; char buffer[512], drive[4]; CD_drive cdDrive; record = (CDTRACKRECORD *) sourceEmphasisInfo.sourceRecord; if(record) { getText(WinWindowFromID(hwnd, CB_DRIVE), CBID_EDIT, buffer, sizeof(buffer)); drive[0] = buffer[0]; drive[1] = ':'; drive[2] = 0; if(cdDrive.open(drive)) { cdDrive.stop(); cdDrive.readCDInfo(); cdDrive.play(record->track); cdDrive.close(); } } return 0; } case PB_CDSTOP: case IDM_STOP: { char buffer[512], drive[4]; CD_drive cdDrive; getText(WinWindowFromID(hwnd, CB_DRIVE), CBID_EDIT, buffer, sizeof(buffer)); drive[0] = buffer[0]; drive[1] = ':'; drive[2] = 0; if(cdDrive.open(drive)) { cdDrive.stop(); cdDrive.close(); } return 0; } case PB_REFRESH: case IDM_REFRESH: WinPostMsg(workerhwnd,DLGCD_REFRESH,(void *) hwnd, NULL); return 0; } return 0; }
PMINIRECORDCORE AddName(char *_Name, char *_Host, char *_Port) { char aTextValue[255]; PNAMEENTRY pRecord; RECORDINSERT RecordInsert; if (CheckYes(gLastNameFirst)) CvtLastFirst(_Name, aTextValue); else strcpy(aTextValue, _Name); /* Add a container record to end of the Container */ /* IMPORTANT!!! we allocate 32 extra bytes for the pszIcon string */ /* We must allocate more than that if we have any extra PSZ members */ /* as columns */ /* Two extra columns */ pRecord=(PVOID)WinSendDlgItemMsg(sHwnd, sID, CM_ALLOCRECORD, MPFROMLONG(sizeof(*pRecord)-sizeof(MINIRECORDCORE)+32), /* Bytes of additional data */ MPFROMLONG(1)); /* Number of records */ pRecord->Record.cb=sizeof(MINIRECORDCORE); pRecord->Record.flRecordAttr=0; pRecord->Record.hptrIcon=0; pRecord->Record.pszIcon = (PVOID)GetSubMem(g1Meg, strlen(aTextValue)+1); if (pRecord->Record.pszIcon) strcpy(pRecord->Record.pszIcon, aTextValue); pRecord->pszHost = (PSZ)GetSubMem(g1Meg, strlen(_Host)+1); if (pRecord->pszHost) strcpy(pRecord->pszHost, _Host); pRecord->pszPort = (PSZ)GetSubMem(g1Meg, strlen(_Port)+1); if (pRecord->pszPort) strcpy(pRecord->pszPort, _Port); /* IMPORTANT!!! initiaize other members here if they exist */ /* add the item to the container */ RecordInsert.cb=sizeof(RECORDINSERT); RecordInsert.pRecordOrder=(PRECORDCORE)CMA_END;/* add to the end */ RecordInsert.pRecordParent=(PRECORDCORE)0; /* not a child record */ RecordInsert.zOrder=CMA_TOP; RecordInsert.cRecordsInsert=1; RecordInsert.fInvalidateRecord=TRUE; /* repaint the record */ WinSendDlgItemMsg(sHwnd, sID, CM_INSERTRECORD, MPFROMP(pRecord), MPFROMP(&RecordInsert)); // WinSendDlgItemMsg(hwndDlg, NAMES_CONTAINER, // CM_SETRECORDEMPHASIS, // MPFROMP(pRecord), /* pointer to reference record */ // MPFROM2SHORT(TRUE, CRA_SELECTED)); return((PMINIRECORDCORE)pRecord); }
BOOL OSpinBtn::setArray(PSZ array, ULONG num) { return((BOOL)WinSendMsg (hwnd, SPBM_SETARRAY, MPFROMP (array), MPFROMLONG (num))); }
void fill_submenu (HWND h, struct _item *M) { int ni, i; HWND hwndMenu; char *p; MENUITEM mi; // count submenus ni = 0; while (M[ni].type != ITEM_TYPE_END) ni++; // fill every submenu for (i=0; i<ni; i++) { switch (M[i].type) { case ITEM_TYPE_ACTION: case ITEM_TYPE_SWITCH: mi.iPosition = MIT_END; mi.afStyle = MIS_TEXT; mi.afAttribute = 0; mi.hwndSubMenu = 0; mi.hItem = 0; mi.id = M[i].body.action; p = str_strdup1 (M[i].text, 64); if (M[i].hotkey != 0) str_insert (p, '~', M[i].hkpos); if (M[i].keydesc[0] != '\0') { strcat (p, "\t"); strcat (p, M[i].keydesc); } WinSendMsg (h, MM_INSERTITEM, MPFROMP (&mi), p); free (p); break; case ITEM_TYPE_SUBMENU: hwndMenu = WinCreateMenu (HWND_OBJECT, NULL); WinSetWindowUShort (hwndMenu, QWS_ID, i); M[i].submenu_id = i; fill_submenu (hwndMenu, M[i].body.submenu); mi.iPosition = MIT_END; mi.afStyle = MIS_TEXT | MIS_SUBMENU; mi.afAttribute = 0; mi.hwndSubMenu = hwndMenu; mi.id = i; p = str_strdup1 (M[i].text, 64); if (M[i].hotkey != 0) str_insert (p, '~', M[i].hkpos); if (M[i].keydesc[0] != '\0') { strcat (p, "\t"); strcat (p, M[i].keydesc); } WinSendMsg (h, MM_INSERTITEM, MPFROMP (&mi), p); free (p); break; case ITEM_TYPE_SEP: mi.iPosition = MIT_END; mi.afStyle = MIS_SEPARATOR; mi.afAttribute = 0; mi.hwndSubMenu = 0; mi.hItem = 0; mi.id = 0; WinSendMsg (h, MM_INSERTITEM, MPFROMP (&mi), NULL); break; } } }
//============================================================================= // Dialog procedure //============================================================================= MRESULT EXPENTRY DlgMenu (HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2) { unsigned int i, j, k, num, slider, masklen, subnetbit, hostbit; unsigned int numsubnet, numhost, numtotal; unsigned char InField[4], OutScale[3], class[2] = "\0", OutMsg[48]; unsigned char currnet[4], netstart[4], netstop[4], broadcast[4]; static char ErrAddr[] = "Wrong IP address"; static char ErrMask[] = "Wrong network mask"; switch (msg) { //----------------------------------------------------------------------------- // Handle the initialization of the dialog //----------------------------------------------------------------------------- case WM_INITDLG: { //----------------------------------------------------------------------------- // Set icon //----------------------------------------------------------------------------- HPOINTER hptr = (HPOINTER)WinLoadPointer(HWND_DESKTOP, NULLHANDLE, 1); WinSendMsg(hwndDlg, WM_SETICON, (MPARAM) hptr, 0l); for ( i=0; i<4; i++ ) WinSendDlgItemMsg(hwndDlg, EF_A1+i, EM_SETTEXTLIMIT, (MPARAM)3, 0); WinSendDlgItemMsg(hwndDlg, SBH, SLM_SETTICKSIZE, MPFROM2SHORT(SMA_SETALLTICKS, 3), NULL); for ( i=0; i<=32; i+=8 ) { itoa(i, OutScale, 10); WinSendDlgItemMsg(hwndDlg, SBH, SLM_SETSCALETEXT, MPFROMLONG(i), MPFROMP(OutScale)); } break; } //----------------------------------------------------------------------------- // Handle WM_COMMAND //----------------------------------------------------------------------------- case WM_COMMAND: { switch(SHORT1FROMMP(mp1)) { //----------------------------------------------------------------------------- // Close the dialog //----------------------------------------------------------------------------- case PB_EXIT: { WinSendMsg(hwndDlg, WM_CLOSE, 0L, 0L); break; } //----------------------------------------------------------------------------- // Calculate //----------------------------------------------------------------------------- case PB_CALCULATE: { WinSetDlgItemText(hwndDlg, LT_NET, ""); WinSetDlgItemText(hwndDlg, TXT_MB, ""); WinSetDlgItemText(hwndDlg, TXT_M, ""); WinSetDlgItemText(hwndDlg, TXT_SB, ""); WinSetDlgItemText(hwndDlg, TXT_HB, ""); WinSetDlgItemText(hwndDlg, TXT_NS, ""); WinSetDlgItemText(hwndDlg, TXT_NH, ""); WinSetDlgItemText(hwndDlg, TXT_T, ""); WinSetDlgItemText(hwndDlg, TXT_CN, ""); WinSetDlgItemText(hwndDlg, TXT_CB, ""); WinSetDlgItemText(hwndDlg, TXT_CHR, ""); for ( i=0; i<4; i++ ) { //----------------------------------------------------------------------------- // Разберем поля IP-адреса //----------------------------------------------------------------------------- if ( (num=WinQueryDlgItemTextLength(hwndDlg, EF_A1+i)) == 0 ) { SendErrMsg(hwndDlg, ErrAddr); return (0); } WinQueryDlgItemText(hwndDlg, EF_A1+i, sizeof(InField), InField); for ( j=0; j<num; j++) if ( isdigit(InField[j]) == 0 ) { SendErrMsg(hwndDlg, ErrAddr); return (0); } if ( (num=atoi(InField)) > 255 ) { SendErrMsg(hwndDlg, ErrAddr); return (0); } addr[i] = num; } //----------------------------------------------------------------------------- // Разберем адрес IP //----------------------------------------------------------------------------- memset(network, 0, sizeof(network)); if ( (addr[0] & '\x80') == '\x00' ) { class[0] = 'A'; i = 1; } else if ( (addr[0] & '\xc0') == '\x80' ) { class[0] = 'B'; i = 2; } else if ( (addr[0] & '\xe0') == '\xc0' ) { class[0] = 'C'; i = 3; } else { SendErrMsg(hwndDlg, ErrAddr); return (0); } masklen = 8 * i; for ( j=0; j<i; j++ ) network[j] = addr[j]; sprintf(OutMsg, "Class %s network %d.%d.%d.%d", class, network[0], network[1], network[2], network[3]); WinSetDlgItemText(hwndDlg, LT_NET, OutMsg); //----------------------------------------------------------------------------- // Разберем поля маски //----------------------------------------------------------------------------- slider = (ULONG)WinSendDlgItemMsg(hwndDlg, SBH, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), NULL); if ( (slider<masklen) || (slider==(masklen+1)) || (slider>=31) ) { SendErrMsg(hwndDlg, ErrMask); return (0); } sprintf(OutMsg, "%d", slider); WinSetDlgItemText(hwndDlg, TXT_MB, OutMsg); memset(mask, 0, sizeof(mask)); for ( i=0, k=0; i<4; i++) for ( j=0; (j<8)&&(k<slider); j++, k++ ) mask[i] |= ('\x80'>>j); sprintf(OutMsg, "%d.%d.%d.%d", mask[0], mask[1], mask[2], mask[3]); WinSetDlgItemText(hwndDlg, TXT_M, OutMsg); subnetbit = slider-masklen; sprintf(OutMsg, "%d", subnetbit); WinSetDlgItemText(hwndDlg, TXT_SB, OutMsg); hostbit = 32-masklen-subnetbit; sprintf(OutMsg, "%d", hostbit); WinSetDlgItemText(hwndDlg, TXT_HB, OutMsg); if ( subnetbit != 0 ) numsubnet = (1L<<subnetbit)-2; else numsubnet = 0; sprintf(OutMsg, "%d", numsubnet); WinSetDlgItemText(hwndDlg, TXT_NS, OutMsg); numhost = (1L<<hostbit)-2; sprintf(OutMsg, "%d", numhost); WinSetDlgItemText(hwndDlg, TXT_NH, OutMsg); if ( subnetbit != 0 ) numtotal = numsubnet*numhost; else numtotal = numhost; sprintf(OutMsg, "%d", numtotal); WinSetDlgItemText(hwndDlg, TXT_T, OutMsg); for (i=0; i<4; i++) currnet[i] = addr[i] & mask[i]; sprintf(OutMsg, "%d.%d.%d.%d", currnet[0], currnet[1], currnet[2], currnet[3]); WinSetDlgItemText(hwndDlg, TXT_CN, OutMsg); for (i=0; i<4; i++) broadcast[i] = currnet[i] | (~mask[i]); sprintf(OutMsg, "%d.%d.%d.%d", broadcast[0], broadcast[1], broadcast[2], broadcast[3]); WinSetDlgItemText(hwndDlg, TXT_CB, OutMsg); for (i=0; i<4; i++) { netstart[i] = currnet[i]; netstop[i] = broadcast[i]; } netstart[3]++; netstop[3]-=1; sprintf(OutMsg, "%d.%d.%d.%d-%d.%d.%d.%d", netstart[0], netstart[1], netstart[2], netstart[3], netstop[0], netstop[1], netstop[2], netstop[3]); WinSetDlgItemText(hwndDlg, TXT_CHR, OutMsg); return (0); } //----------------------------------------------------------------------------- // Расскажем о себе //----------------------------------------------------------------------------- case PB_ABOUT: { WinDlgBox( HWND_DESKTOP, hwndDlg, WinDefDlgProc, NULLHANDLE, 200, 0 ); return (0); } }
ULONG OListBox::queryItemText(OString& Buffer, const ULONG itemIndex) { PSZ tmp = new CHAR[2*CCHMAXPATH]; ULONG ul; ul = (ULONG) WinSendMsg(hwnd, LM_QUERYITEMTEXT, MPFROM2SHORT(itemIndex, 2*CCHMAXPATH), MPFROMP(tmp)); Buffer << tmp; delete[] tmp; return(ul); }
void PutMsg( USHORT unSrc, ULONG msg, MPARAM mp1, MPARAM mp2) { char buf[100]; /* Message buffer */ switch( unSrc ) { case 0: strcpy( buf, "message to client window: " ); break; case 1: strcpy( buf, "message to listbox: " ); break; default: strcpy( buf, "general: " ); strcat( buf, (char *)msg ); } switch( msg ) { case DM_DROP: strcat( buf, "DM_DROP" ); break; case DM_DRAGOVER: strcat( buf, "DM_DRAGOVER" ); break; case DM_DRAGLEAVE: strcat( buf, "DM_DRAGLEAVE" ); break; case DM_DROPHELP: strcat( buf, "DM_DROPHELP" ); break; case DM_ENDCONVERSATION: strcat( buf, "DM_ENDCONVERSATION" ); break; case DM_PRINT: strcat( buf, "DM_PRINT" ); break; case DM_RENDER: strcat( buf, "DM_RENDER" ); break; case DM_RENDERCOMPLETE: strcat( buf, "DM_RENDERCOMPLETE" ); break; case DM_RENDERPREPARE: strcat( buf, "DM_RENDERPREPARE" ); break; case DM_DRAGFILECOMPLETE: strcat( buf, "DM_DRAGFILECOMPLETE" ); break; case DM_EMPHASIZETARGET: strcat( buf, "DM_EMPHASIZETARGET" ); break; case DM_DRAGERROR: strcat( buf, "DM_DRAGERROR" ); break; case DM_FILERENDERED: strcat( buf, "DM_FILERENDERED" ); break; case DM_RENDERFILE: strcat( buf, "DM_RENDERFILE" ); break; case DM_DRAGOVERNOTIFY: strcat( buf, "DM_DRAGOVERNOTIFY" ); break; case DM_PRINTOBJECT: strcat( buf, "DM_PRINTOBJECT" ); break; case DM_DISCARDOBJECT: strcat( buf, "DM_DISCARDOBJECT" ); break; } WinSendMsg( hListBox, LM_INSERTITEM, (MPARAM)LIT_END, MPFROMP(buf)); return; }
MRESULT EXPENTRY stlrTitleBarProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { PSTLRFRAME p; /* ------------------------------------------------------------------- window creation : store the handle of the owner window, the initial titlebar size, convert the title substituting \r\n with 1 space, update the titlebar font ------------------------------------------------------------------- */ if (msg == WM_CREATE) { // if this is a global exception window, if the window ID is not // FID_TITLEBAR or if the owner window is not a frame, go to the // default system titlebar procedure if (!pd.ppib || (((PCREATESTRUCT)mp2)->id != FID_TITLEBAR) || !_isFrameWindow(((PCREATESTRUCT)mp2)->hwndOwner)) goto defaultTitlebarProcedure; // get the frame data p = (PSTLRFRAME)WinQueryWindowPtr(((PCREATESTRUCT)mp2)->hwndOwner, g.cd.frame.cbData); // /*-*/ dbgPrintf5("*** pd.ppib:%08x, id: %04x, isOwnerFrame: %d, p: %08x\n", // pd.ppib, ((PCREATESTRUCT)mp2)->id, // _isFrameWindow(((PCREATESTRUCT)mp2)->hwndOwner), p); // if the frame window is a win32frame initialize the frame data now if (!p || ((p == FL_WIN32FRAME) && (NULL == (p = _initWin32Frame(((PCREATESTRUCT)mp2)->hwndOwner))))) goto defaultTitlebarProcedure; // memorizza handle frame window WinSetWindowPtr(hwnd, g.cd.tbar.cbData, p); p->hTBar = hwnd; if (((PCREATESTRUCT)mp2)->pszText) p->cchTxt = psznconvcpy(p->achTxt, ((PCREATESTRUCT)mp2)->pszText, 260); p->wrclTitle.x = ((PCREATESTRUCT)mp2)->x; p->wrclTitle.y = ((PCREATESTRUCT)mp2)->y; p->wrclTitle.cx = ((PCREATESTRUCT)mp2)->cx; p->wrclTitle.cy = ((PCREATESTRUCT)mp2)->cy; // cambia font secondo preferenze if (o.tb.on && !(o.gen.disabled || pd.we.tbar)) _setPPFont(hwnd, o.tb.achFont); /* ------------------------------------------------------------------- hiliting/unhiliting of the titlebar : store the handle of the owner window, the initial titlebar size, convert the title substituting \r\n with 1 space, update the titlebar font ------------------------------------------------------------------- */ } else if (msg == TBM_SETHILITE) { if (_getFrameData(hwnd, p)) { p->is.tbhilited = (BOOL)mp1; if (!o.gen.disabled && o.tb.on && !pd.we.tbar) { if (o.tb.ovrPP || (p->is.tbhilited && !p->is.tbactpp) || !(p->is.tbhilited || p->is.tbictpp)) { if (WinIsWindowShowing(hwnd)) { p->hps = WinGetPS(hwnd); DrawTitlebar(p); WinReleasePS(p->hps); } /* endif */ return (MRESULT)TRUE; // Š solo apparentemente ridondante, in realt… Š necessario quando // non Š ovrPP ed Š presente solo PP att. o inatt. } else if (!(p->is.tbactpp && p->is.tbictpp)) { repaintWindow(hwnd); } /* endif */ } /* endif */ } /* endif */ /* ------------------------------------------------------------------- titlebar font/color changed - if the font changed repaint the window - if any color changed reset the presparm presence flag ------------------------------------------------------------------- */ } else if (msg == WM_PRESPARAMCHANGED) { if (!pd.we.tbar && _getFrameData(hwnd, p)) { ULONG ul; switch ((LONG)mp1) { case PP_FONTNAMESIZE: p->cyfont = 0; if (o.gen.disabled) break; if (WinIsWindowShowing(hwnd)) repaintWindow(hwnd); return (MRESULT)FALSE; case PP_ACTIVETEXTBGNDCOLOR: case PP_ACTIVETEXTBGNDCOLORINDEX: case PP_ACTIVECOLOR: case PP_ACTIVECOLORINDEX: p->is.tbactpp = _getPPColor(hwnd, (ULONG)mp1, &ul) != 0; break; case PP_INACTIVETEXTBGNDCOLOR: case PP_INACTIVETEXTBGNDCOLORINDEX: case PP_INACTIVECOLOR: case PP_INACTIVECOLORINDEX: p->is.tbictpp = _getPPColor(hwnd, (ULONG)mp1, &ul) != 0; break; } /* endswitch */ } /* endif */ /* ------------------------------------------------------------------- the titlebar text changed. If this is a Win-OS/2 window set the window words to 0 so that the enhancements are skipped, otherwise store the new text. ------------------------------------------------------------------- */ } else if (msg == WM_SETWINDOWPARAMS) { if (!pd.we.tbar && _getFrameData(hwnd, p)) { // unsubclass winOS2 windows titlebars if (p->is.winos2) { _resetDefaultProc(hwnd); // WinSetWindowULong(hwnd, g.cd.tbar.cbData, 0); } else { if ((PWNDPARAMS)mp1 && (((PWNDPARAMS)mp1)->fsStatus & WPM_TEXT) && ((PWNDPARAMS)mp1)->pszText) { p->cchTxt = psznconvcpy(p->achTxt, ((PWNDPARAMS)mp1)->pszText, 260); p->cyfont = 0; } /* endif */ } /* endif */ } /* endif */ /* ------------------------------------------------------------------- titlebar size/position changed : store new size and position ------------------------------------------------------------------- */ } else if (msg == WM_WINDOWPOSCHANGED) { if ((((PSWP)mp1)->fl & (SWP_SIZE | SWP_MOVE)) && _getFrameData(hwnd, p)) { p->wrclTitle.x = ((PSWP)mp1)->x; p->wrclTitle.y = ((PSWP)mp1)->y; p->wrclTitle.cx = ((PSWP)mp1)->cx; p->wrclTitle.cy = ((PSWP)mp1)->cy; } /* endif */ // ************************************************************************** // these messages are processed only if Styler/2 is not disabled: } else if (!o.gen.disabled) { /* ------------------------------------------------------------------- check if this is the roll-the-window mouse event : ------------------------------------------------------------------- */ if ((msg == o.roll.moumsg) && (SHORT2FROMMP(mp2) == o.roll.moukbd)) { if (!pd.we.wroll && o.roll.mou && _getFrameData(hwnd, p) && !p->is.win32 && (o.roll.on || p->is.RLon)) { toggleRollCmd(p->hwnd, p); return (MRESULT)TRUE; } /* endif */ /* ------------------------------------------------------------------- check if this is the hide-titlebar mouse event : ------------------------------------------------------------------- */ } else if ((msg == o.tbh.moumsg) && (SHORT2FROMMP(mp2) == o.tbh.moukbd)) { if (!pd.we.tbarhide && o.tbh.mou && _getFrameData(hwnd, p) && !p->is.win32 // opzione titlehide attiva e non dialogo o disattivazione titlehide && ((o.tbh.on && !(p->is.dialog && o.tbh.noDlg)) || p->is.titleHide)) { toggleTitleBarHidingCmd(p->hwnd, p); return (MRESULT)TRUE; } /* endif */ /* ------------------------------------------------------------------- check if this is the change-Zorder mouse event : ------------------------------------------------------------------- */ } else if ((msg == o.sizpos.ZordMoumsg) && (SHORT2FROMMP(mp2) == o.sizpos.ZordMoukbd)) { if (!pd.we.sizemove && o.sizpos.Zmove && _getFrameData(hwnd, p)) { _stlrMsgPost(p->hwnd, STLR_ZORDACTIV, SW2_SFMOVETOBOTTOM); return (MRESULT)TRUE; } /* endif */ /* ------------------------------------------------------------------- check if this is the snap-to-screen-edge mouse event : ------------------------------------------------------------------- */ } else if ((msg == o.sizpos.snapMoumsg) && (SHORT2FROMMP(mp2) == o.sizpos.snapMoukbd)) { if (!pd.we.sizemove && o.sizpos.snap && _getFrameData(hwnd, p)) { // get the rectangle of the window and of its parent RECTL r, rParent; WinQueryWindowRect(p->hwnd, &r); WinQueryWindowRect(_winParent(p->hwnd), &rParent); // click on the left side of the titlebar if (MOUSEX(mp1) < (p->wrclTitle.cx / 3)) { r.xLeft = -p->ptBrd.x; // click on the right side of the titlebar } else if (MOUSEX(mp1) > (p->wrclTitle.cx * 2 / 3)) { r.xLeft = rParent.xRight - r.xRight + p->ptBrd.x; // click on the (horizontal) middle of the titlebar } else { r.xLeft = (rParent.xRight - r.xRight) / 2; } /* endif */ // click on the bottom of the titlebar if (MOUSEY(mp1) < (g.sys.cyTbar / 3)) { r.yBottom = -p->ptBrd.y; // click on the top of the titlebar } else if (MOUSEY(mp1) > (g.sys.cyTbar * 2 / 3)) { r.yBottom = rParent.yTop - r.yTop + p->ptBrd.y; // click on the (vertical) middle of the titlebar } else { r.yBottom = (rParent.yTop - r.yTop) / 2; } /* endif */ WinSetWindowPos(p->hwnd, 0, r.xLeft, r.yBottom, 0, 0, SWP_MOVE | SWP_NOADJUST); } /* endif */ /* ------------------------------------------------------------------- enhanced window painting ------------------------------------------------------------------- */ } else if (msg == WM_PAINT) { if (!pd.we.tbar && o.tb.on && _getFrameData(hwnd, p) && (o.tb.ovrPP || (p->is.tbhilited && !p->is.tbactpp) || !(p->is.tbhilited || p->is.tbictpp))) { p->hps = WinBeginPaint(hwnd, NULLHANDLE, NULL); DrawTitlebar(p); WinEndPaint(p->hps); return (MRESULT)FALSE; } /* endif */ /* ------------------------------------------------------------------- override the default window tracking : ------------------------------------------------------------------- */ } else if ((msg == WM_BUTTON1DOWN) || (msg == WM_BUTTON2DOWN)) { if (_getFrameData(hwnd, p)) { // override window motion by titlebar drag : // store the current mouse position (mp1) // the window motion will start only when the mouse will move g.tbdrag.mpPos = mp1; // if the window is not already moving store which mouse button // has to be released to stop the titlebar drag if (!g.tbdrag.hwnd) g.tbdrag.msg = ++msg; // store the handle of the titlebar (mouse motion events are not // processed when this is NULLHANDLE) g.tbdrag.hwnd = hwnd; // cattura i msg successivi del mouse WinSetCapture(HWND_DESKTOP, hwnd); return (MRESULT)TRUE; } /* endif */ /* ------------------------------------------------------------------- terminate window motion through titlebar drag events : ------------------------------------------------------------------- */ } else if ((msg == WM_BUTTON1UP) || (msg == WM_BUTTON2UP)) { if ((g.tbdrag.hwnd == hwnd) && (g.tbdrag.msg == msg) && _getFrameData(hwnd, p)) { HWND hwndParent; WinSetCapture(HWND_DESKTOP, NULLHANDLE); g.tbdrag.msg = 0; g.tbdrag.hwnd = NULLHANDLE; // if the Ctrl key is not pressed and the window is not yet active // end the window is a size-move feature exception or the event // is not related to the Z-order motion feature or the snap-to- // parent-edge feature activate the window bringing it to the top if (!(SHORT2FROMMP(mp2) & KC_CTRL) && (g.hwnd.active != p->hwnd) && (pd.we.sizemove || (!(o.sizpos.Zmove && (msg == (o.sizpos.ZordMoumsg - 0x3a1)) && (SHORT2FROMMP(mp2) == o.sizpos.ZordMoukbd)) && (!(o.sizpos.snap && (msg == (o.sizpos.snapMoumsg - 0x3a1)) && (SHORT2FROMMP(mp2) == o.sizpos.snapMoukbd)))))) WinSetWindowPos(p->hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER); } /* endif */ /* ------------------------------------------------------------------- open the system menu on the titlebar : ------------------------------------------------------------------- */ } else if (msg == WM_CONTEXTMENU) { if (!pd.we.tbar && o.tb.menu && _getFrameData(hwnd, p)) { // if this is the titlebar of a WPS folder simulate a context // menu event on the client window if (p->is.folder) { p->hClient = WinWindowFromID(p->hwnd, FID_CLIENT); WinPostMsg(p->hClient, WM_CONTEXTMENU, (MPARAM)0x7fff7fff, MPVOID); // otherwise get the handle of the system menu and bring it to // the top via WinPopupMenu() } else if (p->hSMenu) { POINTL ptl; WinQueryPointerPos(g.hwnd.desktop, &ptl); g.cd.menu.pfnwp(p->hSMenu, MM_QUERYITEM, (MPARAM)SC_SYSMENU, MPFROMP(&p->mi)); g.hwnd.sysMenu = p->mi.hwndSubMenu; WinPopupMenu(g.hwnd.desktop, p->hSMenu, g.hwnd.sysMenu, ptl.x, ptl.y, 0, PU_HCONSTRAIN | PU_VCONSTRAIN | PU_NONE | PU_KEYBOARD | PU_MOUSEBUTTON1); } /* endif */ } /* endif */ return (MRESULT)TRUE; /* ------------------------------------------------------------------- trap WM_MOUSEMOVE to implement various features : - do not move maximized windows ------------------------------------------------------------------- */ } else if (msg == WM_MOUSEMOVE) { // if mouse button 1 or 2 were pressed and then the mouse position // changed if ((g.tbdrag.hwnd == hwnd) && (g.tbdrag.mpPos != mp1) && _getFrameData(hwnd, p)) { WinSetCapture(HWND_DESKTOP, NULLHANDLE); g.tbdrag.hwnd = NULLHANDLE; g.tbdrag.msg = 0; // if this is a maximized window and the don't-move-max-window // feature is set ignore the event if (o.maxwin.nomove && p->is.max && !(pd.we.maxwin || p->is.shield || p->is.ovrdnomovemax)) return (MRESULT)TRUE; WinSendMsg(p->hwnd, WM_TRACKFRAME, (MPARAM)TF_MOVE, g.tbdrag.mpPos); // ??????????????????????????????? // this is needed because the next WM_BUTTONxUP is captured by // the WM_TRACKFRAME processing // if (!(SHORT2FROMMP(mp2) & KC_CTRL)) // WinSetWindowPos(p->hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER); return (MRESULT)TRUE; } else if (g.is.onctrl != OCTLTBAR) { g.is.onctrl = OCTLTBAR; // ??????????????? this should be redundant // _resetHideMouTimer(); } /* endif */ } /* endif */ // ------------------------------------------------------------------- } /* endif */ defaultTitlebarProcedure: return g.cd.tbar.pfnwp(hwnd, msg, mp1, mp2); }
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); } }
// ******************************************************************************* // FUNCTION: SystemMenu // // FUNCTION USE: Used to remove unnecessary system menu menuitems // // DESCRIPTION: This routine differs slightly from the SetTheSysMenu window. // It is used to revamp the system menu for the purpose of the // special status window used by this application. // // PARAMETERS: HWND window handle of the window that has a system menu // // RETURNS: VOID // // INTERNALS: NONE // // HISTORY: // // ******************************************************************************* VOID SystemMenu(HWND hwnd) { HWND hwndSysMenu; HWND hwndFrame; MENUITEM menuitem; ULONG ulMenuID; SHORT sNumItems; SHORT sIndex = 0; // -------------------------------------------------------------------------- // Get the frame window handle by querying the client's parent // -------------------------------------------------------------------------- hwndFrame = WinQueryWindow(hwnd, QW_PARENT); // -------------------------------------------------------------------------- // Obtain the system menu window handle from the FID_SYSMENU identifier // and find out how many items exist in the menu. // -------------------------------------------------------------------------- hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU); WinSendMsg(hwndSysMenu, // Window Handle MM_QUERYITEM, // Message MPFROM2SHORT(SC_SYSMENU, FALSE), // Message Parameter 1 MPFROMP(&menuitem)); // Message Parameter 2 sNumItems = SHORT1FROMMR(WinSendMsg(menuitem.hwndSubMenu, // Window Handle MM_QUERYITEMCOUNT, // Message (MPARAM)NULL, // Message Parameter 1 (MPARAM)NULL)); // Message Parameter 2 while (sNumItems--) { ulMenuID = (ULONG) WinSendMsg(menuitem.hwndSubMenu, // Window Handle MM_ITEMIDFROMPOSITION, // Message MPFROM2SHORT(sIndex, TRUE), // Message Parameter 1 (MPARAM)NULL); // Message Parameter 2 switch (SHORT1FROMMP(ulMenuID)) { // -------------------------------------------------------------------------- // Keep these menuitems // -------------------------------------------------------------------------- case SC_RESTORE: case SC_MAXIMIZE: case SC_MINIMIZE: case SC_MOVE: case SC_CLOSE: sIndex++; break; // -------------------------------------------------------------------------- // Blast all other system menu menuitems // -------------------------------------------------------------------------- default: WinSendMsg(menuitem.hwndSubMenu, MM_DELETEITEM, MPFROM2SHORT(ulMenuID, TRUE), (MPARAM)NULL); } } return; }
static INT InsertContainerColumns (PINST pinst) { #define NEWFIELDOFFSET(s,m) (&(((s *)0)->m)) PFIELDINFO pfldinfo; PFIELDINFO pfldinfoFirst; FIELDINFOINSERT fiins; LONG iField = 0; static const FIELDINFO afldinfo[] = { {0, CFA_STRING | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT, CFA_LEFT | CFA_FITITLEREADONLY, "Call sign", (ULONG)(NEWFIELDOFFSET(APPCNRREC,pszCallsign)), 0, 0, 0}, {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT, CFA_LEFT | CFA_FITITLEREADONLY, "Heading", (ULONG)(NEWFIELDOFFSET(APPCNRREC,Heading)), 0, 0, 0}, {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT, CFA_LEFT | CFA_FITITLEREADONLY, "Assigned\nHeading", (ULONG)(NEWFIELDOFFSET(APPCNRREC,AssignedHeading)), 0, 0, 0}, {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT, CFA_LEFT | CFA_FITITLEREADONLY, "Altitude\n(Hundreds\nof Feet)", (ULONG)(NEWFIELDOFFSET(APPCNRREC,Altitude)), 0, 0, 0}, {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT, CFA_LEFT | CFA_FITITLEREADONLY, "Assigned\nAltitude\n(Hundreds\nof Feet)", (ULONG)(NEWFIELDOFFSET(APPCNRREC,AssignedAltitude)), 0, 0, 0}, {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT, CFA_LEFT | CFA_FITITLEREADONLY, "Speed\n(Tens of\nknots)", (ULONG)(NEWFIELDOFFSET(APPCNRREC,Speed)), 0, 0, 0}, {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT, CFA_LEFT | CFA_FITITLEREADONLY, "Assigned\nSpeed\n(Tens of\nknots", (ULONG)(NEWFIELDOFFSET(APPCNRREC,AssignedSpeed)), 0, 0, 0} }; static const INT cFields = sizeof afldinfo / sizeof afldinfo[0]; pfldinfo = pfldinfoFirst = (PFIELDINFO) WinSendMsg (pinst->hwndCnr, CM_ALLOCDETAILFIELDINFO, MPFROMLONG(cFields), NULL); for (iField = 0; iField < cFields; ++iField) { pfldinfo->cb = sizeof(FIELDINFO); pfldinfo->flData = afldinfo [iField].flData; pfldinfo->flTitle = afldinfo [iField].flTitle; pfldinfo->pTitleData = afldinfo [iField].pTitleData; pfldinfo->offStruct = afldinfo [iField].offStruct; pfldinfo = pfldinfo->pNextFieldInfo; } fiins.cb = sizeof fiins; fiins.pFieldInfoOrder = (PFIELDINFO)CMA_FIRST; fiins.cFieldInfoInsert = cFields; fiins.fInvalidateFieldInfo = TRUE; /* * INSERT DETAIL VIEW INFORMATION */ WinSendMsg (pinst->hwndCnr, CM_INSERTDETAILFIELDINFO, MPFROMP(pfldinfoFirst), MPFROMP(&fiins)); return 0; }
/*----------------------------------------------------------------------*/ MRESULT EXPENTRY DMLBSubclassListboxProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) /*----------------------------------------------------------------------*/ /* This window procedure is used to subclass a standard PM listbox */ /* control. This procedure will intercept certain mouse events on the */ /* listbox to implement direct-manipulation functions. */ /*----------------------------------------------------------------------*/ { SHORT Item; /* Listbox item number */ DMLBData *InstData; /* This instance-specific data (per listbox) */ /* The lisbox window pointer is to our instance data. */ InstData = WinQueryWindowPtr(hwnd, QWL_USER); switch (msg) { /* Since this is just a subclass setup after the listbox window */ /* is created, we never get a WM_CREATE message here. */ case WM_DESTROY: /* The listbox window is being destroyed. Cleanup any */ /* resources we have allocated in this subclass. */ if (InstData->DragMIcon != NULLHANDLE) { WinDestroyPointer(InstData->DragMIcon); WinDestroyPointer(InstData->DragCIcon); WinDestroyPointer(InstData->NorthIcon); WinDestroyPointer(InstData->SouthIcon); WinDestroyPointer(InstData->DragNoDrp); WinDestroyPointer(InstData->DeletIcon); InstData->DragMIcon = NULLHANDLE; } /* Cleanup other resources */ if (InstData->Dragging) { WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID); } /* Release instance data */ free(InstData); WinSetWindowPtr(hwnd, 0L, NULL); break; case WM_TIMER: /* We get timer messages during dragging to implement */ /* auto-scrolling of listbox when pointer is placed */ /* north or south of the listbox while dragging. */ if (!InstData->Dragging) /* Ignore if not dragging */ break; if (SHORT1FROMMP(mp1)==DRAG_TIMERID) { switch (InstData->PrevLocation) { // Last known location of the pointer case POINT_INSIDE: case POINT_OUTSIDE: /* Do nothing */ break; case POINT_NORTH: /* Scroll up one item */ Item = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYTOPINDEX, 0L, 0L); if ((Item != LIT_NONE) && (Item != 0)) WinPostMsg(InstData->TargetHwnd, LM_SETTOPINDEX, MPFROMSHORT(Item-1), 0L); break; case POINT_SOUTH: /* Scroll down one item */ Item = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYTOPINDEX, 0L, 0L); if (Item != LIT_NONE) WinPostMsg(InstData->TargetHwnd, LM_SETTOPINDEX, MPFROMSHORT(Item+1), 0L); break; } /* switch on PrevLocation */ return 0; } break; case WM_CONTEXTMENU: { SHORT CursorIndx, Max; /* User requested context menu... notify our owner. */ /* First find out what item the pointer is over. */ Max = (SHORT)WinSendMsg( hwnd, LM_QUERYITEMCOUNT, 0L, 0L ); CursorIndx = DMLBLocateListboxItem(hwnd, hwnd, SHORT2FROMMP(mp1), LLI_UNDER); if ((Max == 0) || (CursorIndx+1 > Max)) CursorIndx = LIT_NONE; /* Tell our owner about it */ return WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_CONTEXT), MPFROMSHORT(CursorIndx)); } case WM_MOUSEMOVE: /* Monitor the position of the mouse relative to the listbox */ /* so we can set the pointer icon correctly and note the */ /* position for use during WM_TIMER processing. */ if (!InstData->Dragging) /* Ignore if not dragging */ break; DMLBCheckTargetLocation(hwnd, InstData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)); /* Set pointer icon appropriate for location */ if (InstData->DragMIcon == NULLHANDLE) { // Load all the pointers (one time only) InstData->DragMIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGMOVE); InstData->DragCIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGCOPY); InstData->DragNoDrp= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGNONE); InstData->NorthIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGNORTH); InstData->SouthIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGSOUTH); InstData->DeletIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGDEL); } switch (InstData->PrevLocation) { case POINT_INSIDE: switch (InstData->TargetDropMode) { case DROPMODE_MOVE: WinSetPointer(HWND_DESKTOP, InstData->DragMIcon); // Use MOVE pointer break; case DROPMODE_COPY: WinSetPointer(HWND_DESKTOP, InstData->DragCIcon); // Use COPY pointer break; case DROPMODE_DELETE: WinSetPointer(HWND_DESKTOP, InstData->DeletIcon); // Use DELETE pointer break; } break; case POINT_OUTSIDE: WinSetPointer(HWND_DESKTOP, InstData->DragNoDrp); // No-drop pointer break; case POINT_NORTH: WinSetPointer(HWND_DESKTOP, InstData->NorthIcon); // Scroll-up pointer break; case POINT_SOUTH: WinSetPointer(HWND_DESKTOP, InstData->SouthIcon); // Scroll-down poineter break; } return (MRESULT)TRUE; /* Note we processed the message */ case WM_BEGINDRAG: { SHORT Max; SHORT i, CursorIndx, hit; /* User started dragging with the pointer on our window */ Max = (SHORT)WinSendMsg( hwnd, LM_QUERYITEMCOUNT, 0L, 0L ); /* If we are currently dragging, cancel it (should not happen) */ if ( InstData->Dragging ) { InstData->Dragging = FALSE; WinSetCapture( HWND_DESKTOP, NULLHANDLE ); return (MRESULT)FALSE; } /* Get index of item under the mouse pointer and check */ /* for reasonable numeric bounds. */ CursorIndx = DMLBLocateListboxItem(hwnd, hwnd, SHORT2FROMMP(mp1), LLI_UNDER); if ((Max == 0) || (CursorIndx+1 > Max)) { DosBeep( 440L, 50L ); // Don't allow drag if not on a listbox item return (MRESULT)FALSE; } /* Since we currently support dragging only a single item, */ /* de-select all items and just select the one under the */ /* pointer. To support multiple-drag we would probably */ /* need to notify the owner so they could set the selection*/ /* status of all items to be dragged (which may or may not */ /* include the item under the pointer). */ WinSendMsg(hwnd, LM_SELECTITEM, MPFROMSHORT(LIT_NONE), MPVOID); WinSendMsg(hwnd, LM_SELECTITEM, MPFROMSHORT(CursorIndx), MPFROMSHORT(TRUE)); /* Note we are now dragging and capture the pointer. */ InstData->Dragging = TRUE; WinSetCapture( HWND_DESKTOP, hwnd ); InstData->PrevLocation = POINT_INSIDE; WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID, WinQuerySysValue(HWND_DESKTOP, SV_SCROLLRATE)); return (MRESULT)TRUE; break; } case WM_ENDDRAG: { SHORT DropIndx, CurrIndx; SHORT SourceMax, TargetMax; /* Num of items in source/target listbox */ char *CopyText; /* Text to be copied/moved */ USHORT CopyTextLen; /* Length of text */ void *CopyHand; /* Handle of item to be copied/moved */ BOOL SameList = FALSE; /* Source and target are same listbox */ if (!InstData->Dragging) /* Ignore if we are not dragging */ return (MRESULT)FALSE; /* Clear dragging indicators and release pointer */ InstData->Dragging = FALSE; WinSetCapture( HWND_DESKTOP, NULLHANDLE ); WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID); /* See if what is under the pointer will accept the drop */ DMLBCheckTargetLocation(hwnd, InstData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)); if (InstData->PrevLocation != POINT_INSIDE) return (MRESULT)TRUE; /* Ignore drop outside a good listbox */ if (hwnd == InstData->TargetHwnd) // Source and target are same listbox SameList = TRUE; SourceMax = (SHORT)WinSendMsg(hwnd, LM_QUERYITEMCOUNT, 0L, 0L ) -1; TargetMax = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYITEMCOUNT, 0L, 0L ) -1; /* Get drop point and original selected point */ DropIndx = DMLBLocateListboxItem(InstData->TargetHwnd, hwnd, SHORT2FROMMP(mp1), LLI_INSERTPOINT); CurrIndx = (SHORT)WinSendMsg(hwnd, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), 0L); /* Prevent move onto same item as source, in same listbox */ /* being careful of DropIndx > SourceMax when drop after last item. */ if ((InstData->TargetDropMode==DROPMODE_MOVE) && (SameList) && ((min(DropIndx,SourceMax) == CurrIndx) || (DropIndx == CurrIndx+1))) { DosBeep( 700L, 50L ); /* Don't drop before or after original */ return (MRESULT)TRUE; } /* Make a copy of original to insert */ CopyTextLen = (SHORT)WinSendMsg(hwnd,LM_QUERYITEMTEXTLENGTH,MPFROMSHORT(CurrIndx), 0L) + 1; CopyText = malloc(CopyTextLen); WinSendMsg(hwnd, LM_QUERYITEMTEXT, MPFROM2SHORT(CurrIndx, CopyTextLen), MPFROMP(CopyText)); CopyHand = WinSendMsg(hwnd, LM_QUERYITEMHANDLE, MPFROMSHORT(CurrIndx), 0L); /* Insert before insertion point, or at end of list */ if (DropIndx > TargetMax) DropIndx = LIT_END; /* Disable update during insert/delete for smoother visual and */ /* prevent ownerdraw from occuring before new handles are set. */ WinEnableWindowUpdate(hwnd, FALSE); WinEnableWindowUpdate(InstData->TargetHwnd, FALSE); /* Insert into target list */ if (InstData->TargetDropMode != DROPMODE_DELETE) { DropIndx = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_INSERTITEM, MPFROMSHORT(DropIndx), MPFROMP(CopyText)); WinSendMsg(InstData->TargetHwnd, LM_SETITEMHANDLE, MPFROMSHORT(DropIndx), MPFROMP(CopyHand)); } free(CopyText); /* Tell owner of originating listbox what we are doing. We must notify */ /* the owner before we delete items because they may keep dynamic data */ /* in the item handles that has to be freed. The item in question is */ /* the currently selected item in the listbox. */ switch (InstData->TargetDropMode) { case DROPMODE_MOVE: if (!SameList) WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_DELETE_MOVE), MPFROMHWND(InstData->TargetHwnd)); break; case DROPMODE_DELETE: WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_DELETE), MPFROMHWND(InstData->TargetHwnd)); break; } /* If this is a move, delete original. If it is in the same */ /* listbox as target, get new index since it may have */ /* changed due to inserted copy. */ if ((InstData->TargetDropMode == DROPMODE_MOVE) || (InstData->TargetDropMode == DROPMODE_DELETE)) { CurrIndx = (SHORT)WinSendMsg(hwnd, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), 0L); WinSendMsg(hwnd, LM_DELETEITEM, MPFROMSHORT(CurrIndx), 0L); } /* Select the newly inserted item. If the old copy was */ /* above it in the same list, then the item number has changed by 1 */ if ((DropIndx > CurrIndx) && (SameList) && (InstData->TargetDropMode==DROPMODE_MOVE)) DropIndx--; if (InstData->TargetDropMode != DROPMODE_DELETE) { WinSendMsg(InstData->TargetHwnd, LM_SELECTITEM, MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE)); WinSendMsg(InstData->TargetHwnd, LM_SELECTITEM, MPFROMSHORT(DropIndx), MPFROMSHORT(TRUE)); } WinEnableWindowUpdate(hwnd, TRUE); WinEnableWindowUpdate(InstData->TargetHwnd, TRUE); /* Notify target of inserted items if necessary */ switch (InstData->TargetDropMode) { case DROPMODE_MOVE: if (SameList) WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_REORDERED), MPFROMHWND(hwnd)); else WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_INSERT_MOVE), MPFROMHWND(hwnd)); break; case DROPMODE_COPY: WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_INSERT_COPY), MPFROMHWND(hwnd)); break; } return (MRESULT)TRUE; } } /* Call previous window procedure to process this message */ return ( (*(InstData->OldProcAddr)) ( hwnd, msg, mp1, mp2 ) ); }
static INT InsertContainerRecords (PINST pinst) { PAPPCNRREC pacrRoot; // Ptr to root of list of records PAPPCNRREC pacrTraverse; // Ptr to traverse list of records RECORDINSERT recins; // Record insertion information HPOINTER hptrIcon; // Handle of jet icon RECTL rclCnr; // Container dimensions LONG iRecord = 0; // Record index static const PSZ apszCallSignPrefixes [] = { "AA", "DA", "UA", "TW" }; static const INT cPrefixes = sizeof apszCallSignPrefixes / sizeof apszCallSignPrefixes[0]; CHAR szBuf [30]; /* * SET UP RECORD INSERT STRUCTURE */ memset (&recins, 0, sizeof recins); recins.cb = sizeof recins; recins.pRecordOrder = (PRECORDCORE) CMA_END; recins.zOrder = CMA_TOP; recins.cRecordsInsert = 5; recins.fInvalidateRecord = TRUE; /* * ALLOCATE CONTAINER ITEM LINKED LIST */ pacrRoot = (PAPPCNRREC) WinSendMsg ( pinst->hwndCnr, CM_ALLOCRECORD, MPFROMLONG(sizeof(APPCNRREC) - sizeof(MINIRECORDCORE)), MPFROMLONG(recins.cRecordsInsert)); /* * SET UP USER RECORD LINKED LIST */ hptrIcon = WinLoadPointer (HWND_DESKTOP, 0, IDICON_JET); WinQueryWindowRect (pinst->hwndCnr, &rclCnr); srand (clock()); for (iRecord = 0, pacrTraverse = pacrRoot; iRecord < recins.cRecordsInsert; ++iRecord, pacrTraverse = (PAPPCNRREC) pacrTraverse->recc.preccNextRecord) { pacrTraverse->cnrrtyp = CNRRT_AIRCRAFT; pacrTraverse->iRecord = iRecord; pacrTraverse->Altitude = pacrTraverse->AssignedAltitude = rand() % 50 + 50; pacrTraverse->Heading = pacrTraverse->AssignedHeading = rand() % 360 + 1; pacrTraverse->Speed = pacrTraverse->AssignedSpeed = rand() % 20 + 10; sprintf (szBuf, "%s%ld", apszCallSignPrefixes [rand() % cPrefixes], rand() % 1000); pacrTraverse->pszCallsign = strdup (szBuf); SetRecordText (pacrTraverse); pacrTraverse->recc.hptrIcon = hptrIcon; pacrTraverse->recc.ptlIcon.x = rclCnr.xRight / 10 * (rand() % 9 + 1); pacrTraverse->recc.ptlIcon.y = rclCnr.yTop / 10 * (rand() % 9 + 1); } /* * INSERT ALL CONTAINER ITEMS */ WinSendMsg (pinst->hwndCnr, CM_INSERTRECORD, MPFROMP(pacrRoot), MPFROMP(&recins)); /* * INSERT CHILD RECORDS FOR TREE VIEW */ InsertCrewRecords (pinst->hwndCnr, pacrRoot); /* * DESELECT FIRST AIRPLANE, WHICH BECOMES SELECTED AUTOMATICALLY */ WinSendMsg (pinst->hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pacrRoot), MPFROM2SHORT(FALSE, CRA_SELECTED)); return 0; }
static void AdjustControls(int NBPwidth, int NBPheight) { SWP swpTemp; int xsize, ysize; RECTL rectl; POINTL pointl; int buttonheight; ULONG CXDLGFRAME = WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME); ULONG CYDLGFRAME = WinQuerySysValue(HWND_DESKTOP, SV_CYDLGFRAME); // Query button height in pixels if (WinQueryWindowPos(WinWindowFromID(hwndConfigDlg, PB_DEFAULT), &swpTemp)) buttonheight = swpTemp.cy; else buttonheight = 0; // Set the size and position of Notebook // The size is interesting. We should know how much additional space this notebook requires. // For this, we calculate how big is a notebook for a known client size (e.g., 0x0) rectl.xLeft = 0; rectl.xRight = 0; rectl.yBottom = 0; rectl.yTop = 0; WinSendMsg(hwndConfigNB, BKM_CALCPAGERECT, MPFROMP(&rectl), MPFROMSHORT(FALSE)); // Ok, this must be added to client size in order to be able to display the given client dialog: NBPwidth += rectl.xRight; NBPheight += rectl.yTop; // Now check how much shift is inside the window: // (client/notebook shift) pointl.x = 0; pointl.y = 0; WinMapWindowPoints(hwndInterfaceNBP, hwndConfigNB, &pointl, 1); // Add this too: NBPwidth += pointl.x; NBPheight += pointl.y; // Notebook position is above the buttons, which is some pixels above the bottom of window: swpTemp.x = CXDLGFRAME+2; swpTemp.y = CYDLGFRAME + buttonheight + 5; // Notebook size is just calculated: swpTemp.cx = NBPwidth; swpTemp.cy = NBPheight; WinSetWindowPos(hwndConfigNB, HWND_TOP, swpTemp.x, swpTemp.y, swpTemp.cx, swpTemp.cy, SWP_MOVE | SWP_SIZE); // Ok, the notebook is resized. Now resize the dialog window to be just // as big as it's needed for the notebook: xsize = swpTemp.cx + CXDLGFRAME*2 + 2*2; ysize = swpTemp.cy + CYDLGFRAME*2 + buttonheight + 5 + WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR) + 5; WinSetWindowPos(hwndConfigDlg, HWND_TOP, 0, 0, xsize, ysize, SWP_SIZE); // Set the position of buttons // Undo Button WinQueryWindowPos(WinWindowFromID(hwndConfigDlg, PB_UNDO), &swpTemp); swpTemp.y = CYDLGFRAME+2; swpTemp.x = (xsize/6)*1-swpTemp.cx/2; WinSetWindowPos(WinWindowFromID(hwndConfigDlg, PB_UNDO), HWND_TOP, swpTemp.x, swpTemp.y, swpTemp.cx, swpTemp.cy, SWP_MOVE); // Default Button WinQueryWindowPos(WinWindowFromID(hwndConfigDlg, PB_DEFAULT), &swpTemp); swpTemp.y = CYDLGFRAME+2; swpTemp.x = (xsize/6)*3-swpTemp.cx/2; WinSetWindowPos(WinWindowFromID(hwndConfigDlg, PB_DEFAULT), HWND_TOP, swpTemp.x, swpTemp.y, swpTemp.cx, swpTemp.cy, SWP_MOVE); // Help Button WinQueryWindowPos(WinWindowFromID(hwndConfigDlg, PB_HELP), &swpTemp); swpTemp.y = CYDLGFRAME+2; swpTemp.x = (xsize/6)*5-swpTemp.cx/2; WinSetWindowPos(WinWindowFromID(hwndConfigDlg, PB_HELP), HWND_TOP, swpTemp.x, swpTemp.y, swpTemp.cx, swpTemp.cy, SWP_MOVE); // That's all! }
static INT InsertCrewRecords ( HWND hwndCnr, PAPPCNRREC pacrRoot // Ptr to root of list of records ) { PAPPCNRREC pacrTraverse; // Ptr to traverse list of records PAPPCNRREC pacrCrew; // Ptr to child crew record RECORDINSERT recins; // Record insertion information HPOINTER hptrIconCrew; // Crew icon INT iCrewRecord; /* * LOAD ICONS */ hptrIconCrew = WinLoadPointer (HWND_DESKTOP, 0, IDICON_CREW); /* * SET UP RECORD INSERT STRUCTURE */ memset (&recins, 0, sizeof recins); recins.cb = sizeof recins; recins.pRecordOrder = (PRECORDCORE) CMA_END; recins.zOrder = CMA_TOP; recins.cRecordsInsert = 3; recins.fInvalidateRecord = TRUE; /* * LOOP THROUGH ALL MAIN RECORDS */ for (pacrTraverse = pacrRoot; pacrTraverse; pacrTraverse = (PAPPCNRREC) pacrTraverse->recc.preccNextRecord) { PAPPCNRREC pacrCrewTraverse; // Ptr to traverse crew records /* * ALLOCATE CREW CHILD RECORDS */ pacrCrew = (PAPPCNRREC) WinSendMsg ( hwndCnr, CM_ALLOCRECORD, MPFROMLONG(sizeof(APPCNRREC) - sizeof(MINIRECORDCORE)), MPFROMLONG(recins.cRecordsInsert)); /* * SET PARENT RECORD IN RECORDINSERT STRUCTURE */ recins.pRecordParent = (PRECORDCORE) pacrTraverse; /* * LOOP THROUGH ALL CREW CHILD RECORDS */ for (iCrewRecord = 0, pacrCrewTraverse = pacrCrew; pacrCrewTraverse; iCrewRecord++, pacrCrewTraverse = (PAPPCNRREC) pacrCrewTraverse->recc.preccNextRecord) { static const PSZ apszCrewPositions [] = { "Captain", "First Officer", "Head Flight Attendant" }; CHAR szTitle [100]; PSZ pszMadeUpName; /* * SET ICON AND TEXT OF CREW RECORD */ pacrCrewTraverse->cnrrtyp = CNRRT_CREWMEMBER; pacrCrewTraverse->recc.hptrIcon = hptrIconCrew; pszMadeUpName = MakeUpPersonName (); sprintf (szTitle, "%s\n%s", pszMadeUpName, apszCrewPositions [iCrewRecord]); free (pszMadeUpName); pacrCrewTraverse->recc.pszIcon = strdup (szTitle); } /* * INSERT ALL CREW RECORDS FOR THIS MAIN RECORD */ WinSendMsg (hwndCnr, CM_INSERTRECORD, MPFROMP(pacrCrew), MPFROMP(&recins)); } return 0; }
MRESULT EXPENTRY NewFrameProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 ) { PFNWP pfnwpOldFrameProc ; /* ------- get original frame procedure --------- */ pfnwpOldFrameProc = (PFNWP) WinQueryWindowULong( hwnd, QWL_USER ); switch (msg) { case WM_QUERYFRAMECTLCOUNT : { USHORT usItemCount ; /* ---- get count of original frame controls --- */ usItemCount = SHORT1FROMMR( pfnwpOldFrameProc( hwnd, msg, mp1, mp2 )); /* ------- add 1 for new toolbar control ------ */ return ( (MRESULT) ++usItemCount ); } case WM_FORMATFRAME : { PSWP pSWP ; // pointer to array of frame ctl SWPs USHORT usItemCount ; // count of original frame controls USHORT usNewMenuIndex ; // index of new menu SWP USHORT usToolBarIndex ; // index of Tool Bar menu SWP USHORT usClientIndex ; // index of client window SWP USHORT usVertScrollIndex ; // index of vertical scrollbar SWP HWND hwndVertScroll ; // hwnd of vertical scrollbar /* ------- get a pointer to the SWP array ---------- */ pSWP = PVOIDFROMMP( mp1 ); /* ---- run regular processing for original controls --- */ /* * Note that the original frame proc will setup all * the SWP sturctures for the standard frame window * controls starting at the beginning of the array. * A count of how many SWP structures were initialized * is returned. * All SWP structures for new controls that are to be * added ( in our case, 1 ) will be uninitialized and * at the end of the array. The start of the uninitialied * SWP structure start at an index equal to the returned * count. */ usItemCount = SHORT1FROMMR( pfnwpOldFrameProc( hwnd, msg, mp1, mp2 )); /* ------------- locate SWP for 1st menu ---------- */ /* * We will use the settings of the 1st menu to help initialize * the SWP for the second menu. We look for the proper SWP * by scanning the array for the matching hwnd. */ for ( usToolBarIndex = 0; usToolBarIndex < usItemCount; usToolBarIndex++) { if (pSWP[usToolBarIndex].hwnd == hwndToolBar){ break; } } // end of for( usToolBarIndex... /* ------------- locate SWP for client window ---------- */ /* * We will need to adjust the vertical height of the client * window to make room for the second menu. We look for the * proper SWP by scanning the array for a matching hwnd. */ for ( usClientIndex = 0; usClientIndex < usItemCount; usClientIndex++){ if (pSWP[usClientIndex].hwnd == hwndClient ){ break; } } // end of for ( usClientIndex... /* --- locate SWP for vert scroll (if exists) --- */ /* * First we will check if this window has a vert. scroll bar. * We will need to adjust the vertical height of the scroll * bar to make room for the second menu. We look for the * proper SWP by scanning the array for a matching hwnd. */ if ( ( hwndVertScroll = WinWindowFromID( hwnd, FID_VERTSCROLL)) != NULLHANDLE ){ for ( usVertScrollIndex = 0; usVertScrollIndex < usItemCount; usVertScrollIndex++){ if (pSWP[usVertScrollIndex].hwnd == hwndVertScroll ){ break; } } // end of for ( usClientIndex... } // end of if (( hwndVertScroll... /* ------ the new SWP starts after standard control SWPs ----- */ usNewMenuIndex = usItemCount ; /* ---- get size values for 2nd menu bar -------- */ pSWP[ usNewMenuIndex ].fl = SWP_SIZE; pSWP[ usNewMenuIndex ].cx = pSWP[usToolBarIndex].cx ; // set some pSWP[ usNewMenuIndex ].cy = pSWP[usToolBarIndex].cy ; // defaults pSWP[ usNewMenuIndex ].hwndInsertBehind = HWND_TOP ; pSWP[ usNewMenuIndex ].hwnd = hwndMenuBar ; /* -- get the menu code to make the actual size adjustments -- */ WinSendMsg( hwndMenuBar, WM_ADJUSTWINDOWPOS, MPFROMP( pSWP+usNewMenuIndex ), (MPARAM) 0L ); /* ------ position menu directly below other menu ------- */ pSWP[usNewMenuIndex].x = pSWP[usToolBarIndex].x ; pSWP[usNewMenuIndex].y = pSWP[usToolBarIndex].y - pSWP[usNewMenuIndex].cy ; pSWP[usNewMenuIndex].fl = pSWP[usToolBarIndex].fl ; /* -------- adjust client window size for 2nd menu ------- */ pSWP[usClientIndex].cy -= pSWP[usNewMenuIndex].cy ; /* -------- adjust vertical scroll size for 2nd menu ----- */ if ( hwndVertScroll != NULLHANDLE ){ pSWP[usVertScrollIndex].cy -= pSWP[usNewMenuIndex].cy ; } /* --- return total count of controls ( +1 for 2nd menu ) --- */ return( MRFROMSHORT( ++usItemCount ) ); } break; default: return( pfnwpOldFrameProc(hwnd,msg,mp1,mp2) ); } /* end of switch () */ return( FALSE ); } /* end of NewFrameProc */
MRESULT EXPENTRY fnwpSelectPortDlg(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2) { int iIndex; int iItemSelected; BOOL bItemSelected; int iCOMindex; int iTempIndex; int iFirstItem; BYTE *pByte; ULONG *pulPtr; switch (msg) { case WM_INITDLG: CenterDlgBox(hwnd); if ((ulPortCount = EnumeratePorts(achBuffer,4096)) != 0) { pulPtr = (PULONG)achBuffer; bItemSelected = FALSE; for (iIndex = 0; iIndex < ulPortCount; iIndex++) { stPorts[iIndex].pszPortName = (char *)*(pulPtr++); stPorts[iIndex].pszPortDesc = (char *)*(pulPtr++); WinSendDlgItemMsg(hwnd,PS_NAME_LIST,LM_INSERTITEM,MPFROMSHORT(LIT_END),MPFROMP(stPorts[iIndex].pszPortName)); if (strcmp(szPortName,stPorts[iIndex].pszPortName) == 0) { bItemSelected = TRUE; WinSendDlgItemMsg(hwnd,PS_NAME_LIST,LM_SELECTITEM,MPFROMSHORT(iIndex),MPFROMSHORT(TRUE)); } } if (!bItemSelected) WinSendDlgItemMsg(hwnd,PS_NAME_LIST,LM_SELECTITEM,MPFROMSHORT(0),MPFROMSHORT(TRUE)); } else WinDismissDlg(hwnd,FALSE); break; case WM_COMMAND: switch(SHORT1FROMMP(mp1)) { case DID_OK: iItemSelected = (SHORT)WinSendDlgItemMsg(hwnd,PS_NAME_LIST,LM_QUERYSELECTION,0L,0L); WinSendDlgItemMsg(hwnd,PS_NAME_LIST,LM_QUERYITEMTEXT,MPFROM2SHORT(iItemSelected,9),MPFROMP(szPortName)); strcpy(szPortDesc,stPorts[iItemSelected].pszPortDesc); sprintf(szMessage,"Port %s Selected",szPortName); PrintString(szMessage,1); MenuItemEnable(hwndFrame,IDM_PROCESS,TRUE); WinDismissDlg(hwnd,TRUE); break; case DID_CANCEL: WinDismissDlg(hwnd,FALSE); break; default: return WinDefDlgProc(hwnd,msg,mp1,mp2); } break; default: return(WinDefDlgProc(hwnd,msg,mp1,mp2)); } return(FALSE); }
void Container::noEmphasis(UserData *it) { WinSendMsg(cont,CM_SETRECORDEMPHASIS,MPFROMP((RECORDCORE*)it),MPFROM2SHORT(FALSE,CRA_SELECTED|CRA_INUSE)); }
BOOL OSpinBtn::getLimits(LONG *upper, LONG *lower) { return((BOOL)WinSendMsg(hwnd,SPBM_QUERYLIMITS, MPFROMP(upper),MPFROMP(lower))); }