Changeset 25 for trunk/src/helpers/winh.c
- Timestamp:
- Jan 17, 2001, 6:34:55 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/winh.c
r23 r25 109 109 // insert or MIT_END 110 110 SHORT sItemId, // in: ID of new menu item 111 PSZ pszItemTitle, // in: title of new menu item111 const char *pcszItemTitle, // in: title of new menu item 112 112 SHORT afStyle, 113 113 // in: MIS_* style flags. … … 168 168 MM_INSERTITEM, 169 169 (MPARAM)&mi, 170 (MPARAM)p szItemTitle));170 (MPARAM)pcszItemTitle)); 171 171 return (src); 172 172 } … … 186 186 ULONG iPosition, // in: index where to add submenu or MIT_END 187 187 SHORT sMenuId, // in: menu ID of new submenu 188 PSZ pszSubmenuTitle, // in: title of new submenu188 const char *pcszSubmenuTitle, // in: title of new submenu 189 189 USHORT afMenuStyle, // in: MIS* style flags for submenu; 190 190 // MIS_SUBMENU will always be added 191 191 SHORT sItemId, // in: ID of first item to add to submenu; 192 192 // if 0, no first item is inserted 193 PSZ pszItemTitle, // in: title of this item193 const char *pcszItemTitle, // in: title of this item 194 194 // (if sItemID != 0) 195 195 USHORT afItemStyle, // in: style flags for this item, e.g. MIS_TEXT … … 216 216 mi.hwndSubMenu = hwndNewMenu; 217 217 mi.hItem = 0; 218 src = SHORT1FROMMR(WinSendMsg(hwndMenu, MM_INSERTITEM, (MPARAM)&mi, (MPARAM)p szSubmenuTitle));218 src = SHORT1FROMMR(WinSendMsg(hwndMenu, MM_INSERTITEM, (MPARAM)&mi, (MPARAM)pcszSubmenuTitle)); 219 219 if ( (src != MIT_MEMERROR) 220 220 && (src != MIT_ERROR) … … 237 237 MM_INSERTITEM, 238 238 (MPARAM)&mi, 239 (MPARAM)p szItemTitle);239 (MPARAM)pcszItemTitle); 240 240 } 241 241 } … … 1059 1059 * extension, and position, all in one shot. 1060 1060 * 1061 * This function usually gets called when the window is 1062 * created and later when the window is resized. 1063 * 1061 1064 * This simplifies the typical functionality of a scroll 1062 1065 * bar in a client window which is to be scrolled. I am … … 1068 1071 * 1069 1072 * -- "window": the actual window with scroll bars which displays 1070 * a subrectangle of the available data. 1073 * a subrectangle of the available data. With a typical PM 1074 * application, this will be your client window. 1075 * 1071 1076 * The width or height of this must be passed in ulWinPels. 1072 1077 * 1073 1078 * -- "viewport": the entire data to be displayed, of which the 1074 1079 * "window" can only display a subrectangle, if the viewport 1075 * is larger than the window. The width or height of this must be 1076 * passed in ulViewportPels. This can be smaller than ulWinPels (if the 1077 * window is larger than the data), the same or larger than ulWinPels 1080 * is larger than the window. 1081 * 1082 * The width or height of this must be passed in ulViewportPels. 1083 * This can be smaller than ulWinPels (if the window is larger 1084 * than the data) or the same or larger than ulWinPels 1078 1085 * (if the window is too small to show all the data). 1079 1086 * 1080 1087 * -- "window offset": the offset of the current window within 1081 * the viewport. For horizontal scroll bars, this is 1082 * the X coordinate, counting from the left of the window 1083 * (0 means leftmost). 1088 * the viewport. 1089 * 1090 * For horizontal scroll bars, this is the X coordinate, 1091 * counting from the left of the window (0 means leftmost). 1092 * 1084 1093 * For vertical scroll bars, this is counted from the _top_ 1085 1094 * of the viewport (0 means topmost, as opposed to OS/2 1086 * window coordinates!). 1087 * This is because for vertical scroll bars controls, higher 1088 * values move the thumb _down_. 1089 * 1090 * The scroll bar is disabled if the entire viewport is visible, 1095 * window coordinates!). This is because for vertical scroll 1096 * bars controls, higher values move the thumb _down_. Yes 1097 * indeed, this conflicts with PM's coordinate system. 1098 * 1099 * The window offset is therefore always positive. 1100 * 1101 * The scroll bar gets disabled if the entire viewport is visible, 1091 1102 * that is, if ulViewportPels <= ulWinPels. In that case 1092 1103 * FALSE is returned. If (fAutoHide == TRUE), the scroll … … 1099 1110 * bars, 0 means topmost (which is kinda sick with the OS/2 1100 1111 * coordinate system), for horizontal scroll bars, 0 means leftmost. 1101 * The maximum value of the scroll bar will be: 1112 * 1113 * The maximum value of the scroll bar will be 1114 * 1102 1115 + (ulViewportPels - ulWinPels) / usScrollUnitPels 1103 1116 * … … 1210 1223 * on values starting from zero. The maximum value 1211 1224 * of the scroll bar is: 1225 * 1212 1226 + ulViewportPels - (prcl2Scroll->yTop - prcl2Scroll->yBottom) 1213 1227 * … … 1224 1238 *@@changed V0.9.3 (2000-04-30) [umoeller]: changed prototype, fixed pels/unit confusion 1225 1239 *@@changed V0.9.3 (2000-05-08) [umoeller]: now handling scroll units automatically 1240 *@@changed V0.9.7 (2001-01-17) [umoeller]: changed PLONG to PULONG 1226 1241 */ 1227 1242 1228 1243 BOOL winhHandleScrollMsg(HWND hwnd2Scroll, // in: client window to scroll 1229 1244 HWND hwndScrollBar, // in: vertical or horizontal scroll bar window 1230 P LONG plCurPelsOfs,// in/out: current viewport offset;1245 PULONG pulCurPelsOfs, // in/out: current viewport offset; 1231 1246 // this is updated with the proper scroll units 1232 1247 PRECTL prcl2Scroll, // in: hwnd2Scroll rectangle to scroll … … 1243 1258 // see PMREF for details 1244 1259 { 1245 LONG lOldPelsOfs = *plCurPelsOfs;1260 ULONG ulOldPelsOfs = *pulCurPelsOfs; 1246 1261 USHORT usPosUnits = SHORT1FROMMP(mp2), // in scroll units 1247 1262 usCmd = SHORT2FROMMP(mp2); … … 1267 1282 { 1268 1283 case SB_LINEUP: 1269 // _Pmpf(("SB_LINEUP")); 1270 *plCurPelsOfs -= usLineStepPels; // * usScrollUnitPels); 1284 if (*pulCurPelsOfs > usLineStepPels) 1285 *pulCurPelsOfs -= usLineStepPels; // * usScrollUnitPels); 1286 else 1287 *pulCurPelsOfs = 0; 1271 1288 break; 1272 1289 1273 1290 case SB_LINEDOWN: 1274 // _Pmpf(("SB_LINEDOWN")); 1275 *plCurPelsOfs += usLineStepPels; // * usScrollUnitPels); 1291 *pulCurPelsOfs += usLineStepPels; // * usScrollUnitPels); 1276 1292 break; 1277 1293 1278 1294 case SB_PAGEUP: 1279 *plCurPelsOfs -= ulWinPels; // convert to units 1295 if (*pulCurPelsOfs > ulWinPels) 1296 *pulCurPelsOfs -= ulWinPels; // convert to units 1297 else 1298 *pulCurPelsOfs = 0; 1280 1299 break; 1281 1300 1282 1301 case SB_PAGEDOWN: 1283 *p lCurPelsOfs += ulWinPels; // convert to units1302 *pulCurPelsOfs += ulWinPels; // convert to units 1284 1303 break; 1285 1304 1286 1305 case SB_SLIDERTRACK: 1287 *p lCurPelsOfs = (usPosUnits * usScrollUnitPels);1306 *pulCurPelsOfs = (usPosUnits * usScrollUnitPels); 1288 1307 // _Pmpf((" SB_SLIDERTRACK: usUnits = %d", usPosUnits)); 1289 1308 break; 1290 1309 1291 1310 case SB_SLIDERPOSITION: 1292 *p lCurPelsOfs = (usPosUnits * usScrollUnitPels);1311 *pulCurPelsOfs = (usPosUnits * usScrollUnitPels); 1293 1312 break; 1294 1313 } … … 1304 1323 } */ 1305 1324 1306 if (*plCurPelsOfs < 0)1307 *plCurPelsOfs = 0; 1308 if (*p lCurPelsOfs > (lMaxAllowedUnitOfs * usScrollUnitPels))1325 /* if (*plCurPelsOfs < 0) 1326 *plCurPelsOfs = 0; */ // checked above 1327 if (*pulCurPelsOfs > (lMaxAllowedUnitOfs * usScrollUnitPels)) 1309 1328 { 1310 1329 // _Pmpf((" !!! limiting 2: %d to %d", *plCurUnitOfs, lMaxAllowedUnitOfs)); 1311 *p lCurPelsOfs = (lMaxAllowedUnitOfs * usScrollUnitPels);1312 } 1313 if ( (*p lCurPelsOfs !=lOldPelsOfs)1314 || (*p lCurPelsOfs == 0)1315 || (*p lCurPelsOfs == (lMaxAllowedUnitOfs * usScrollUnitPels))1330 *pulCurPelsOfs = (lMaxAllowedUnitOfs * usScrollUnitPels); 1331 } 1332 if ( (*pulCurPelsOfs != ulOldPelsOfs) 1333 || (*pulCurPelsOfs == 0) 1334 || (*pulCurPelsOfs == (lMaxAllowedUnitOfs * usScrollUnitPels)) 1316 1335 ) 1317 1336 { … … 1322 1341 WinSendMsg(hwndScrollBar, 1323 1342 SBM_SETPOS, 1324 (MPARAM)(*p lCurPelsOfs / usScrollUnitPels), // / usScrollUnit),1343 (MPARAM)(*pulCurPelsOfs / usScrollUnitPels), // / usScrollUnit), 1325 1344 0); 1326 1345 // scroll window rectangle: … … 1333 1352 WinScrollWindow(hwnd2Scroll, 1334 1353 0, 1335 (*p lCurPelsOfs -lOldPelsOfs) // scroll units changed1354 (*pulCurPelsOfs - ulOldPelsOfs) // scroll units changed 1336 1355 , // * usScrollUnitPels, // convert to pels 1337 1356 &rcl2Scroll, // rcl to scroll … … 1342 1361 else 1343 1362 WinScrollWindow(hwnd2Scroll, 1344 -( *plCurPelsOfs -lOldPelsOfs) // scroll units changed1363 -(LONG)(*pulCurPelsOfs - ulOldPelsOfs) // scroll units changed 1345 1364 , // * usScrollUnitPels, 1346 1365 0, … … 1555 1574 BOOL winhSaveWindowPos(HWND hwnd, // in: window to save 1556 1575 HINI hIni, // in: INI file (or HINI_USER/SYSTEM) 1557 PSZ pszApp, // in: INI application name1558 PSZ pszKey) // in: INI key name1576 const char *pcszApp, // in: INI application name 1577 const char *pcszKey) // in: INI key name 1559 1578 { 1560 1579 BOOL brc = FALSE; … … 1572 1591 } 1573 1592 1574 brc = PrfWriteProfileData(hIni, pszApp, pszKey, &swp, sizeof(swp));1593 brc = PrfWriteProfileData(hIni, (PSZ)pcszApp, (PSZ)pcszKey, &swp, sizeof(swp)); 1575 1594 } 1576 1595 return (brc); … … 1614 1633 BOOL winhRestoreWindowPos(HWND hwnd, // in: window to restore 1615 1634 HINI hIni, // in: INI file (or HINI_USER/SYSTEM) 1616 PSZ pszApp, // in: INI application name1617 PSZ pszKey, // in: INI key name1635 const char *pcszApp, // in: INI application name 1636 const char *pcszKey, // in: INI key name 1618 1637 ULONG fl) // in: "fl" parameter for WinSetWindowPos 1619 1638 { … … 1623 1642 ULONG fl2 = (fl & ~SWP_ZORDER); 1624 1643 1625 if (PrfQueryProfileData(hIni, pszApp, pszKey, &swp, &cbswp))1644 if (PrfQueryProfileData(hIni, (PSZ)pcszApp, (PSZ)pcszKey, &swp, &cbswp)) 1626 1645 { 1627 1646 ULONG ulScreenCX = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN); … … 2341 2360 */ 2342 2361 2343 HWND winhCreateHelp(HWND 2344 PSZ pszFileName, // in: help file name or NULL2362 HWND winhCreateHelp(HWND hwndFrame, // in: app's frame window handle; can be NULLHANDLE 2363 const char *pcszFileName, // in: help file name or NULL 2345 2364 HMODULE hmod, // in: module with help table or NULLHANDLE (current) 2346 2365 PHELPTABLE pHelpTable, // in: help table or resource ID 2347 PSZ pszWindowTitle) // in: help window title or NULL2366 const char *pcszWindowTitle) // in: help window title or NULL 2348 2367 { 2349 2368 PPIB ppib; … … 2354 2373 HWND hwndHelp; 2355 2374 2356 if ( (p szFileName == NULL)2375 if ( (pcszFileName == NULL) 2357 2376 // || (*pszFileName) 2358 2377 ) … … 2368 2387 strcat(szName, ".hlp"); 2369 2388 2370 p szFileName = szName;2389 pcszFileName = szName; 2371 2390 } 2372 2391 … … 2379 2398 hi.idAccelTable = 0; 2380 2399 hi.idActionBar = 0; 2381 hi.pszHelpWindowTitle = pszWindowTitle;2400 hi.pszHelpWindowTitle = (PSZ)pcszWindowTitle; 2382 2401 hi.fShowPanelId = CMIC_HIDE_PANEL_ID; 2383 hi.pszHelpLibraryName = pszFileName;2402 hi.pszHelpLibraryName = (PSZ)pcszFileName; 2384 2403 2385 2404 hwndHelp = WinCreateHelpInstance(WinQueryAnchorBlock(hwndFrame), … … 2783 2802 */ 2784 2803 2785 BOOL winhAnotherInstance( PSZ pszSemName, // in: semaphore ID2804 BOOL winhAnotherInstance(const char *pcszSemName, // in: semaphore ID 2786 2805 BOOL fSwitch) // in: if TRUE, switch to first instance if running 2787 2806 { 2788 2807 HMTX hmtx; 2789 2808 2790 if (DosCreateMutexSem( pszSemName,2809 if (DosCreateMutexSem((PSZ)pcszSemName, 2791 2810 &hmtx, 2792 2811 DC_SEM_SHARED, … … 2804 2823 { 2805 2824 // yes: query mutex creator 2806 if (DosOpenMutexSem( pszSemName,2825 if (DosOpenMutexSem((PSZ)pcszSemName, 2807 2826 &hmtx) 2808 2827 == NO_ERROR) … … 2966 2985 // -- WINH_FOD_INISAVEDIR: store FOD path to INI on OK 2967 2986 HINI hini, // in: INI file to load/store last path from (can be HINI_USER) 2968 PSZ pszApplication, // in: INI application to load/store last path from2969 PSZ pszKey) // in: INI key to load/store last path from2987 const char *pcszApplication, // in: INI application to load/store last path from 2988 const char *pcszKey) // in: INI key to load/store last path from 2970 2989 { 2971 2990 FILEDLG fd; … … 2986 3005 // overwrite with initial directory for FOD from OS2.INI 2987 3006 if (PrfQueryProfileString(hini, 2988 pszApplication,2989 pszKey,3007 (PSZ)pcszApplication, 3008 (PSZ)pcszKey, 2990 3009 "", // default string 2991 3010 fd.szFullFile, … … 3020 3039 { 3021 3040 PrfWriteProfileString(hini, 3022 pszApplication,3023 pszKey, // "XWPSound:LastDir"3041 (PSZ)pcszApplication, 3042 (PSZ)pcszKey, 3024 3043 pszDir); 3025 3044 free(pszDir); … … 3101 3120 3102 3121 BOOL winhReplaceWindowText(HWND hwnd, // in: window whose text is to be modified 3103 PSZ pszSearch, // in: search string (e.g. "%1")3104 PSZ pszReplaceWith) // in: replacement string for pszSearch3122 const char *pcszSearch, // in: search string (e.g. "%1") 3123 const char *pcszReplaceWith) // in: replacement string for pszSearch 3105 3124 { 3106 3125 BOOL brc = FALSE; … … 3109 3128 { 3110 3129 ULONG ulOfs = 0; 3111 if (strhFindReplace(&pszText, &ulOfs, p szSearch, pszReplaceWith) > 0)3130 if (strhFindReplace(&pszText, &ulOfs, pcszSearch, pcszReplaceWith) > 0) 3112 3131 { 3113 3132 WinSetWindowText(hwnd, pszText); … … 3197 3216 ULONG flFrameCreateFlags, // in: FCF_* flags 3198 3217 ULONG ulFrameStyle, // in: WS_* flags (e.g. WS_VISIBLE, WS_ANIMATE) 3199 PSZ pszFrameTitle,3218 const char *pcszFrameTitle, 3200 3219 ULONG ulResourcesID, // in: according to FCF_* flags 3201 PSZ pszClassClient,3220 const char *pcszClassClient, 3202 3221 ULONG flStyleClient, 3203 3222 ULONG ulID, // in: frame window ID … … 3217 3236 hwndFrame = WinCreateWindow(hwndFrameParent, 3218 3237 WC_FRAME, 3219 pszFrameTitle,3238 (PSZ)pcszFrameTitle, 3220 3239 ulFrameStyle, 3221 3240 0,0,0,0, // size and position = 0 … … 3229 3248 { 3230 3249 *phwndClient = WinCreateWindow(hwndFrame, // parent 3231 pszClassClient, // class3250 (PSZ)pcszClassClient, // class 3232 3251 NULL, // no title 3233 3252 flStyleClient, // style … … 3273 3292 } 3274 3293 return (hwndFrame); 3294 } 3295 3296 /* 3297 *@@ winhCreateObjectWindow: 3298 * creates an object window of the specified 3299 * window class, which you should have registered 3300 * before calling this. pvCreateParam will be 3301 * given to the window on WM_CREATE. 3302 * 3303 * Returns the HWND of the object window or 3304 * NULLHANDLE on errors. 3305 * 3306 *@@added V0.9.3 (2000-04-17) [umoeller] 3307 *@@changed V0.9.7 (2001-01-17) [umoeller]: made this a function from a macro 3308 */ 3309 3310 HWND winhCreateObjectWindow(const char *pcszWindowClass, // in: PM window class name 3311 PVOID pvCreateParam) // in: create param 3312 { 3313 return (WinCreateWindow(HWND_OBJECT, 3314 (PSZ)pcszWindowClass, 3315 (PSZ)"", 3316 0, 3317 0,0,0,0, 3318 0, 3319 HWND_BOTTOM, 3320 0, 3321 pvCreateParam, 3322 NULL)); 3275 3323 } 3276 3324 … … 3570 3618 * 3571 3619 * After this function returns, *prcl is modified like this: 3620 * 3572 3621 * -- yTop and yBottom contain the upper and lower boundaries 3573 3622 * which were needed to draw the text. This depends on … … 3597 3646 PRECTL prcl, // in/out: rectangle to use for drawing 3598 3647 // (modified) 3599 PSZ pszText, // in: text to draw (zero-terminated)3648 const char *pcszText, // in: text to draw (zero-terminated) 3600 3649 ULONG flCmd) // in: flags like in WinDrawText; I have 3601 3650 // only tested DT_TOP and DT_LEFT though. … … 3605 3654 // have prcl calculated without drawing. 3606 3655 { 3607 PSZ p = pszText;3656 PSZ p = (PSZ)pcszText; 3608 3657 LONG lDrawn = 1, 3609 3658 lTotalDrawn = 0, 3610 3659 lLineCount = 0, 3611 3660 lOrigYTop = prcl->yTop; 3612 ULONG ulTextLen = strlen(p szText),3661 ULONG ulTextLen = strlen(pcszText), 3613 3662 ulCharHeight, 3614 3663 flCmd2,
Note:
See TracChangeset
for help on using the changeset viewer.