[2] | 1 | /*
|
---|
| 2 | *
|
---|
| 3 | * Main Source file for class CWProgFolder
|
---|
| 4 | *
|
---|
| 5 | * (C) Chris Wohlgenuth 1999-2004
|
---|
| 6 | *
|
---|
| 7 | * This class is intended for programmers and provides functions for some
|
---|
| 8 | * common tasks like:
|
---|
| 9 | * - Adding dialogs as frame controls to WPS folders
|
---|
| 10 | * - Showing 'About'-dialogs
|
---|
| 11 | * - Checking of object pointers
|
---|
| 12 | * - ...
|
---|
| 13 | *
|
---|
| 14 | * Use IBM VAC++ V3.08 and Gnu-make 3.74.1 to compile
|
---|
| 15 | *
|
---|
| 16 | */
|
---|
| 17 |
|
---|
| 18 | /*
|
---|
| 19 | * This program is free software; you can redistribute it and/or modify
|
---|
| 20 | * it under the terms of the GNU General Public License as published by
|
---|
| 21 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
| 22 | * any later version.
|
---|
| 23 | *
|
---|
| 24 | * This program is distributed in the hope that it will be useful,
|
---|
| 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 27 | * GNU General Public License for more details.
|
---|
| 28 | *
|
---|
| 29 | * You should have received a copy of the GNU General Public License
|
---|
| 30 | * along with this program; see the file COPYING. If not, write to
|
---|
| 31 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 32 | */
|
---|
| 33 | #define INCL_DOSQUEUES
|
---|
| 34 | #define INCL_PM
|
---|
| 35 | #include "progfolder.h"
|
---|
| 36 | #include "progfolder.hh"
|
---|
| 37 | #include "menufolder.hh"
|
---|
| 38 | #include <stdlib.h>
|
---|
| 39 | #include <stdio.h>
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | #define DEFAULT_DIALOG_FONT "9.WarpSans"
|
---|
| 43 |
|
---|
| 44 | typedef ULONG SOMLINK somTP_CWMenuFolder_mfInsertMenuItems(CWMenuFolder *somSelf,
|
---|
| 45 | HWND hwndMenu,
|
---|
| 46 | ULONG iPosition,
|
---|
| 47 | ULONG ulLastMenuId);
|
---|
| 48 | typedef somTP_CWMenuFolder_mfInsertMenuItems *somTD_CWMenuFolder_mfInsertMenuItems;
|
---|
| 49 |
|
---|
| 50 | typedef BOOL SOMLINK somTP_CWMenuFolder_mfCheckMenuItems(CWMenuFolder *somSelf,
|
---|
| 51 | WPObject* wpObject,
|
---|
| 52 | ULONG ulMenuId);
|
---|
| 53 | typedef somTP_CWMenuFolder_mfCheckMenuItems *somTD_CWMenuFolder_mfCheckMenuItems;
|
---|
| 54 |
|
---|
| 55 | MRESULT EXPENTRY folderFrameProcedure(HWND hwnd,ULONG msg, MPARAM mp1,MPARAM mp2);
|
---|
| 56 | HWND createStoreWindow(HWND hwndCLF);
|
---|
| 57 | HWND createLeechFrame(HWND hwndCLF);
|
---|
| 58 | BOOL cwRegisterSeparatorWindowClass(void);
|
---|
| 59 |
|
---|
| 60 | HPOINTER hptrHand=NULLHANDLE;
|
---|
| 61 |
|
---|
| 62 | /****************************************************
|
---|
| 63 | * *
|
---|
| 64 | * This function returns the running OS version: *
|
---|
| 65 | * *
|
---|
| 66 | * 30: Warp 3, 40 Warp 4 etc. *
|
---|
| 67 | * *
|
---|
| 68 | ****************************************************/
|
---|
| 69 | static ULONG cwQueryOSRelease()
|
---|
| 70 | {
|
---|
| 71 | static ULONG ulVersionMinor=0;
|
---|
| 72 |
|
---|
| 73 | if(!ulVersionMinor)
|
---|
| 74 | if(DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_MINOR, &ulVersionMinor, sizeof(ulVersionMinor)))
|
---|
| 75 | ulVersionMinor=30;/* Default Warp 3 */
|
---|
| 76 |
|
---|
| 77 | return ulVersionMinor;
|
---|
| 78 |
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | /**************************************************************/
|
---|
| 82 | /* */
|
---|
| 83 | /* This function returns the module handle of our class-dll */
|
---|
| 84 | /* */
|
---|
| 85 | /**************************************************************/
|
---|
| 86 | HMODULE queryModuleHandle(void)
|
---|
| 87 | {
|
---|
| 88 | static HMODULE hmod=0;
|
---|
| 89 |
|
---|
| 90 | if(!hmod) {
|
---|
| 91 | PSZ pathname=SOMClassMgrObject //Query Pathname of class file
|
---|
| 92 | ->somLocateClassFile(somIdFromString("CWProgFolder"),1,2);
|
---|
| 93 | DosQueryModuleHandle(pathname,&hmod); //Query module handle
|
---|
| 94 | }
|
---|
| 95 | return hmod;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | /****************************************************
|
---|
| 99 | * *
|
---|
| 100 | * This funktion inserts a separator into menu *
|
---|
| 101 | * <hwndMenu> and submenu <hwndSubMenu> at *
|
---|
| 102 | * position <iPosition> *
|
---|
| 103 | * *
|
---|
| 104 | ****************************************************/
|
---|
| 105 | MRESULT cwInsertMenuSeparator(int iPosition, HWND hwndMenu, HWND hwndSubMenu)
|
---|
| 106 | {
|
---|
| 107 | MENUITEM mi;
|
---|
| 108 |
|
---|
| 109 | /* Fill the MENUITEM structure */
|
---|
| 110 | mi.iPosition=iPosition;
|
---|
| 111 | mi.afStyle=MIS_SEPARATOR;
|
---|
| 112 | if(hwndSubMenu)
|
---|
| 113 | mi.afStyle|=MIS_SUBMENU;
|
---|
| 114 | mi.id=0;
|
---|
| 115 | mi.afAttribute=NULL;
|
---|
| 116 | mi.hwndSubMenu=hwndSubMenu;
|
---|
| 117 | mi.hItem=NULL;
|
---|
| 118 |
|
---|
| 119 | return WinSendMsg(hwndMenu,MM_INSERTITEM,(MPARAM)&mi,
|
---|
| 120 | (MPARAM)NULL);
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | /**************************************************************/
|
---|
| 124 | /* */
|
---|
| 125 | /* Overriden function: wpclsQueryStyle() */
|
---|
| 126 | /* */
|
---|
| 127 | /* This class doesn't need a template. */
|
---|
| 128 | /* */
|
---|
| 129 | /**************************************************************/
|
---|
| 130 | ULONG M_CWProgFolder::wpclsQueryStyle()
|
---|
| 131 | {
|
---|
| 132 | somId mySomId;
|
---|
| 133 | ULONG rc;
|
---|
| 134 |
|
---|
| 135 | if((mySomId=somIdFromString("wpclsQueryStyle"))!=NULLHANDLE) {
|
---|
| 136 | rc=((somTD_M_WPObject_wpclsQueryStyle)
|
---|
| 137 | somParentNumResolve(__ClassObject->somGetPClsMtabs(),
|
---|
| 138 | 1,
|
---|
| 139 | __ClassObject->
|
---|
| 140 | somGetMethodToken(mySomId))
|
---|
| 141 | )(this)/*|CLSSTYLE_DONTTEMPLATE*/|CLSSTYLE_NEVERTEMPLATE;
|
---|
| 142 | SOMFree(mySomId);
|
---|
| 143 | }
|
---|
| 144 | else
|
---|
| 145 | rc=M_WPFolder::wpclsQueryStyle()/*|CLSSTYLE_DONTTEMPLATE*/|CLSSTYLE_NEVERTEMPLATE;
|
---|
| 146 |
|
---|
| 147 | return rc;
|
---|
| 148 |
|
---|
| 149 | #if 0
|
---|
| 150 | return ((somTD_M_WPObject_wpclsQueryStyle)
|
---|
| 151 | somParentNumResolve(__ClassObject->somGetPClsMtabs(),
|
---|
| 152 | 1,
|
---|
| 153 | __ClassObject->
|
---|
| 154 | somGetMethodToken(somIdFromString
|
---|
| 155 | ("wpclsQueryStyle")))
|
---|
| 156 | )(this)|CLSSTYLE_DONTTEMPLATE/*|CLSSTYLE_NEVERTEMPLATE*/;
|
---|
| 157 | #endif
|
---|
| 158 |
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | /**************************************************************/
|
---|
| 162 | /* */
|
---|
| 163 | /* Overriden function: wpclsQueryTitle() */
|
---|
| 164 | /* */
|
---|
| 165 | /* Returns our class name */
|
---|
| 166 | /* */
|
---|
| 167 | /**************************************************************/
|
---|
| 168 | PSZ M_CWProgFolder::wpclsQueryTitle()
|
---|
| 169 | {
|
---|
| 170 | return "Support-Folder";
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 |
|
---|
| 174 | void M_CWProgFolder::wpclsInitData()
|
---|
| 175 | {
|
---|
| 176 | somId mySomId;
|
---|
| 177 |
|
---|
| 178 | /* call parent */
|
---|
| 179 | if((mySomId=somIdFromString("wpclsInitData"))!=NULLHANDLE) {
|
---|
| 180 | ((somTD_M_WPObject_wpclsInitData)
|
---|
| 181 | somParentNumResolve(__ClassObject->somGetPClsMtabs(),
|
---|
| 182 | 1,
|
---|
| 183 | __ClassObject->
|
---|
| 184 | somGetMethodToken(mySomId))
|
---|
| 185 | )(this);
|
---|
| 186 | SOMFree(mySomId);
|
---|
| 187 | }
|
---|
| 188 | else
|
---|
| 189 | M_WPFolder::wpclsInitData();
|
---|
| 190 |
|
---|
| 191 | /* Register the separator window class */
|
---|
| 192 | cwRegisterSeparatorWindowClass();
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | /* This Funktion is called when the close button of the */
|
---|
| 196 | /* frame is pressed or if the user chooses 'close' from */
|
---|
| 197 | /* the menu. Apparently the wpClose() method isn't */
|
---|
| 198 | /* called when choosing close. */
|
---|
| 199 | BOOL CWProgFolder::cwClose(HWND hwndFrame)
|
---|
| 200 | {
|
---|
| 201 | return TRUE;
|
---|
| 202 | }
|
---|
| 203 |
|
---|
| 204 | /**************************************************************/
|
---|
| 205 | /* */
|
---|
| 206 | /* Overriden function: wpOpen() */
|
---|
| 207 | /* */
|
---|
| 208 | /* This function subclasses the folder frame window and */
|
---|
| 209 | /* prepares it for the addition of frame controls. */
|
---|
| 210 | /* */
|
---|
| 211 | /**************************************************************/
|
---|
| 212 | HWND CWProgFolder::wpOpen(HWND hwndCnr,ULONG ulView,ULONG ulParam)
|
---|
| 213 | {
|
---|
| 214 | HWND hwnd;
|
---|
| 215 | HWND hwndStore;
|
---|
| 216 | PFNWP orgFrameProc;
|
---|
| 217 | char * memPtr;
|
---|
| 218 | somId mySomId;
|
---|
| 219 |
|
---|
| 220 | if((mySomId=somIdFromString("wpOpen"))!=NULLHANDLE) {
|
---|
| 221 | hwnd=((somTD_WPObject_wpOpen)
|
---|
| 222 | somParentNumResolve(__ClassObject->somGetPClsMtabs(),
|
---|
| 223 | 1,
|
---|
| 224 | __ClassObject->
|
---|
| 225 | somGetMethodToken(mySomId))
|
---|
| 226 | )(this,hwndCnr, ulView, ulParam);
|
---|
| 227 | SOMFree(mySomId);
|
---|
| 228 | }
|
---|
| 229 | else
|
---|
| 230 | hwnd=WPFolder::wpOpen(hwndCnr, ulView, ulParam);
|
---|
| 231 |
|
---|
| 232 | #if 0
|
---|
| 233 | // hwnd=WPFolder::wpOpen(hwndCnr, ulView, ulParam);/* Call parent to build folder window */
|
---|
| 234 | hwnd=((somTD_WPObject_wpOpen)
|
---|
| 235 | somParentNumResolve(__ClassObject->somGetPClsMtabs(),
|
---|
| 236 | 1,
|
---|
| 237 | __ClassObject->
|
---|
| 238 | somGetMethodToken(somIdFromString
|
---|
| 239 | ("wpOpen")))
|
---|
| 240 | )(this,hwndCnr, ulView, ulParam);
|
---|
| 241 | #endif
|
---|
| 242 |
|
---|
| 243 | if(ulView==OPEN_SETTINGS)
|
---|
| 244 | /* We only build frame controls for folder frame windows */
|
---|
| 245 | return hwnd;
|
---|
| 246 | if(WinWindowFromID(hwnd,ID_FOLDERSTOREWINDOW))
|
---|
| 247 | return hwnd;/* Already subclassed */
|
---|
| 248 |
|
---|
| 249 | hwndStore=createStoreWindow(hwnd);/* This holds our object pointer */
|
---|
| 250 | if(hwndStore){
|
---|
| 251 | /* Save 'this' ptr. */
|
---|
| 252 | WinSetWindowPtr(hwndStore,0,this);
|
---|
| 253 | /* Subclass the folder frame window */
|
---|
| 254 | orgFrameProc=WinSubclassWindow(hwnd,&folderFrameProcedure);
|
---|
| 255 | /* Save the old window procedure in our store window */
|
---|
| 256 | WinSetWindowPtr(hwndStore,QWP_ORGFRAMEPROC,orgFrameProc);
|
---|
| 257 | /* Save a ptr. to private control data */
|
---|
| 258 | memPtr=(char*)malloc(sizeof(FRAMECTRLDATA));
|
---|
| 259 | if(memPtr)
|
---|
| 260 | memset(memPtr,0,sizeof(FRAMECTRLDATA));
|
---|
| 261 | WinSetWindowPtr(hwndStore,QWP_FCTRLDATA,memPtr);
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | return hwnd;
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | /**************************************************************/
|
---|
| 268 | /* */
|
---|
| 269 | /* This member function returns the count of additional frame */
|
---|
| 270 | /* controls we have added to the frame. This fuction is */
|
---|
| 271 | /* called from the frame window procedure */
|
---|
| 272 | /* */
|
---|
| 273 | /**************************************************************/
|
---|
| 274 | ULONG CWProgFolder::cwNumAdditionalFrameControls(HWND hwndFolder)
|
---|
| 275 | {
|
---|
| 276 | ULONG rc;
|
---|
| 277 | FRAMECTRLDATA * fctrlData;
|
---|
| 278 |
|
---|
| 279 | fctrlData=(FRAMECTRLDATA*)WinQueryWindowPtr(WinWindowFromID(hwndFolder, ID_FOLDERSTOREWINDOW),QWP_FCTRLDATA);
|
---|
| 280 | if(!fctrlData) return 0;
|
---|
| 281 |
|
---|
| 282 | rc=0;
|
---|
| 283 |
|
---|
| 284 | if(fctrlData->bLeft)rc++;
|
---|
| 285 | if(fctrlData->bRight)rc++;
|
---|
| 286 | if(fctrlData->bTop)rc++;
|
---|
| 287 | if(fctrlData->bBottom)rc++;
|
---|
| 288 |
|
---|
| 289 | return rc;
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | /**************************************************************/
|
---|
| 293 | /* */
|
---|
| 294 | /* This function adjusts the size and position of the client. */
|
---|
| 295 | /* It is called from the frame window procedure */
|
---|
| 296 | /* */
|
---|
| 297 | /**************************************************************/
|
---|
| 298 | BOOL CWProgFolder::cwCalculateClient(HWND hwndFolder, PRECTL pRectl, BOOL which)
|
---|
| 299 | {
|
---|
| 300 | FRAMECTRLDATA * fctrlData;
|
---|
| 301 |
|
---|
| 302 | // which:
|
---|
| 303 | // TRUE: Frame rectangle provided, calculate client
|
---|
| 304 | // FALSE: Client area rectangle provided, calculate frame
|
---|
| 305 |
|
---|
| 306 | /* Get our control data */
|
---|
| 307 | fctrlData=(FRAMECTRLDATA*)WinQueryWindowPtr(WinWindowFromID(hwndFolder, ID_FOLDERSTOREWINDOW),QWP_FCTRLDATA);
|
---|
| 308 | if(!fctrlData) return FALSE;
|
---|
| 309 |
|
---|
| 310 |
|
---|
| 311 | if (SHORT1FROMMP(which))
|
---|
| 312 | // TRUE: Frame rectangle provided, calculate client
|
---|
| 313 | // FALSE: Client area rectangle provided, calculate frame
|
---|
| 314 | {
|
---|
| 315 | // TRUE: calculate the rectl of the client;
|
---|
| 316 | // call default window procedure to subtract child frame
|
---|
| 317 | // controls from the rectangle's height
|
---|
| 318 | LONG lClientHeight;
|
---|
| 319 | LONG lNewControls;
|
---|
| 320 |
|
---|
| 321 | lNewControls=0;
|
---|
| 322 | if(fctrlData->bTop)
|
---|
| 323 | lNewControls=fctrlData->sizelTopFrame.cy;
|
---|
| 324 | if(fctrlData->bBottom)
|
---|
| 325 | lNewControls+=fctrlData->sizelBottomFrame.cy;
|
---|
| 326 |
|
---|
| 327 | lClientHeight = pRectl->yTop - pRectl->yBottom;
|
---|
| 328 | if ( lNewControls > lClientHeight )
|
---|
| 329 | {
|
---|
| 330 | if(fctrlData->bBottom || fctrlData->bTop)
|
---|
| 331 | // extension is taller than client, so set client height to 0
|
---|
| 332 | pRectl->yTop = pRectl->yBottom;
|
---|
| 333 | }
|
---|
| 334 | else
|
---|
| 335 | {
|
---|
| 336 | // set the origin of the client and shrink it based upon the
|
---|
| 337 | // frame control's height
|
---|
| 338 | if(fctrlData->bBottom) {
|
---|
| 339 | pRectl->yBottom +=fctrlData->sizelBottomFrame.cy;
|
---|
| 340 | //pRectl->yTop -= fctrlData->sizelBottomFrame.cy;
|
---|
| 341 | }
|
---|
| 342 | if(fctrlData->bTop) {
|
---|
| 343 | pRectl->yTop -=fctrlData->sizelTopFrame.cy;
|
---|
| 344 | //pRectl->yBottom +=fctrlData->sizelTopFrame.cy;
|
---|
| 345 | }
|
---|
| 346 | }
|
---|
| 347 |
|
---|
| 348 | lNewControls=0;
|
---|
| 349 | if(fctrlData->bLeft)
|
---|
| 350 | lNewControls=fctrlData->sizelLeftFrame.cx;
|
---|
| 351 | if(fctrlData->bRight)
|
---|
| 352 | lNewControls+=fctrlData->sizelRightFrame.cx;
|
---|
| 353 |
|
---|
| 354 | lClientHeight = pRectl->xRight - pRectl->xLeft;
|
---|
| 355 | if ( lNewControls > lClientHeight )
|
---|
| 356 | {
|
---|
| 357 | if(fctrlData->bRight || fctrlData->bLeft)
|
---|
| 358 | // extension is taller than client, so set client height to 0
|
---|
| 359 | pRectl->xRight = pRectl->xLeft;
|
---|
| 360 | }
|
---|
| 361 | else
|
---|
| 362 | {
|
---|
| 363 | if(fctrlData->bLeft)
|
---|
| 364 | pRectl->xLeft+=fctrlData->sizelLeftFrame.cx;
|
---|
| 365 | if(fctrlData->bRight)
|
---|
| 366 | pRectl->xRight-=fctrlData->sizelRightFrame.cx;
|
---|
| 367 | }
|
---|
| 368 | }
|
---|
| 369 | else
|
---|
| 370 | {
|
---|
| 371 | // FALSE: calculate the rectl of the frame;
|
---|
| 372 | // call default window procedure to subtract child frame
|
---|
| 373 | // controls from the rectangle's height;
|
---|
| 374 | // set the origin of the frame and increase it based upon the
|
---|
| 375 | // static text control's height
|
---|
| 376 |
|
---|
| 377 | return TRUE;
|
---|
| 378 |
|
---|
| 379 | if(fctrlData->bBottom) {
|
---|
| 380 | pRectl->yBottom +=fctrlData->sizelBottomFrame.cy;
|
---|
| 381 | // pRectl->yTop -= fctrlData->sizelBottomFrame.cy;
|
---|
| 382 | }
|
---|
| 383 | if(fctrlData->bTop)
|
---|
| 384 | pRectl->yTop -=fctrlData->sizelTopFrame.cy;
|
---|
| 385 |
|
---|
| 386 | if(fctrlData->bLeft) {
|
---|
| 387 | pRectl->xLeft +=fctrlData->sizelLeftFrame.cx;
|
---|
| 388 | // pRectl->yRight -= fctrlData->sizelLeftFrame.cx;
|
---|
| 389 | }
|
---|
| 390 | if(fctrlData->bRight)
|
---|
| 391 | pRectl->xRight -=fctrlData->sizelRightFrame.cx;
|
---|
| 392 |
|
---|
| 393 | }
|
---|
| 394 |
|
---|
| 395 |
|
---|
| 396 | return TRUE;/* Everything's ok */
|
---|
| 397 | }
|
---|
| 398 |
|
---|
| 399 |
|
---|
| 400 |
|
---|
| 401 | /**************************************************************/
|
---|
| 402 | /* */
|
---|
| 403 |
|
---|
| 404 | /* */
|
---|
| 405 | /**************************************************************/
|
---|
| 406 | ULONG CWProgFolder::cwFormatFrame(HWND hwndFolder, USHORT countSWP,PSWP pswp)
|
---|
| 407 | {
|
---|
| 408 | /* countSWP: number of standard framecontrols
|
---|
| 409 | pswp: Array of SWP describing the framecontrols.
|
---|
| 410 | Since we added the number of our controls to the
|
---|
| 411 | standard controls in the framecontrol there is
|
---|
| 412 | space for the new controls.
|
---|
| 413 | */
|
---|
| 414 | ULONG rc;
|
---|
| 415 | PSWP pswpClient=0, pswpFrameCtl=0;
|
---|
| 416 | int iCount;
|
---|
| 417 | FRAMECTRLDATA * fctrlData;
|
---|
| 418 | int a;
|
---|
| 419 | CNRINFO CnrInfo;
|
---|
| 420 | HWND hwndClient;
|
---|
| 421 |
|
---|
| 422 | /* The data of our framecontrols is stored in a structure.
|
---|
| 423 | Get a pointer from the window words of the invisible child. */
|
---|
| 424 | fctrlData=(FRAMECTRLDATA*)WinQueryWindowPtr(WinWindowFromID(hwndFolder, ID_FOLDERSTOREWINDOW),QWP_FCTRLDATA);
|
---|
| 425 | if(!fctrlData) return 0;
|
---|
| 426 |
|
---|
| 427 | iCount=0;
|
---|
| 428 | rc=0;
|
---|
| 429 |
|
---|
| 430 | for (a = 0; a < countSWP; a++)
|
---|
| 431 | {
|
---|
| 432 | /* Find the client window */
|
---|
| 433 | if ( WinQueryWindowUShort( pswp[a].hwnd, QWS_ID ) == 0x8008 ) // FID_CLIENT )
|
---|
| 434 | {
|
---|
| 435 | pswpClient=&pswp[a];
|
---|
| 436 |
|
---|
| 437 | /* Framecontrol at the top */
|
---|
| 438 | if(fctrlData->bTop){
|
---|
| 439 | pswpFrameCtl=&pswp[countSWP+iCount++];/* First free position */
|
---|
| 440 |
|
---|
| 441 | /* Adjust client and insert the new control into the array of SWPs */
|
---|
| 442 |
|
---|
| 443 | /* Decrease the height of the client to have place for the new control */
|
---|
| 444 | pswp[a].cy -= fctrlData->sizelTopFrame.cy;
|
---|
| 445 |
|
---|
| 446 | /* Insert the HWND of the new control into the structure */
|
---|
| 447 | pswpFrameCtl->hwnd=fctrlData->hwndCtlTop;
|
---|
| 448 | /* The x-position is the same as that of the client */
|
---|
| 449 | pswpFrameCtl->x = pswpClient->x;
|
---|
| 450 | /* The control is placed above the client */
|
---|
| 451 | pswpFrameCtl->y = pswpClient->y + pswpClient->cy;
|
---|
| 452 | /* The control is as wide as the client */
|
---|
| 453 | pswpFrameCtl->cx = pswpClient->cx;
|
---|
| 454 | /* Insert the height of the control */
|
---|
| 455 | pswpFrameCtl->cy = fctrlData->sizelTopFrame.cy;
|
---|
| 456 | /* Place the control on top of all windows */
|
---|
| 457 | pswpFrameCtl->hwndInsertBehind = HWND_BOTTOM;
|
---|
| 458 | /* Insert necessary flags */
|
---|
| 459 | pswpFrameCtl->fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER | SWP_SHOW;
|
---|
| 460 |
|
---|
| 461 | /* Adjust position if flags are set. It's possible to place
|
---|
| 462 | the control above the controls on the left and right or let these controls
|
---|
| 463 | cover the full height of the folder. */
|
---|
| 464 | if(fctrlData->bLeft){
|
---|
| 465 | /* There is a frame control on the left side */
|
---|
| 466 | if(!(fctrlData->ulFlagsLeft & FCTL_POSBELOW)) {
|
---|
| 467 | pswpFrameCtl->x += fctrlData->sizelLeftFrame.cx;
|
---|
| 468 | pswpFrameCtl->cx -= fctrlData->sizelLeftFrame.cx;
|
---|
| 469 | }
|
---|
| 470 | }
|
---|
| 471 | /* framecontrol on the right side */
|
---|
| 472 | if(!(fctrlData->ulFlagsRight & FCTL_POSBELOW) && fctrlData->bRight)
|
---|
| 473 | pswpFrameCtl->cx -= fctrlData->sizelRightFrame.cx;
|
---|
| 474 |
|
---|
| 475 | if(!fctrlData->bCnrAdjusted) {
|
---|
| 476 | hwndClient=pswpClient->hwnd;
|
---|
| 477 | if(WinSendMsg(hwndClient,CM_QUERYCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(sizeof(CnrInfo)))){
|
---|
| 478 | if(fctrlData->bBottom)
|
---|
| 479 | CnrInfo.ptlOrigin.y-=fctrlData->sizelBottomFrame.cy;
|
---|
| 480 | if(fctrlData->bTop)
|
---|
| 481 | CnrInfo.ptlOrigin.y-=fctrlData->sizelTopFrame.cy;
|
---|
| 482 | //CnrInfo.ptlOrigin.y+=0;
|
---|
| 483 | WinSendMsg(hwndClient,CM_SETCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(CMA_PTLORIGIN));
|
---|
| 484 | }
|
---|
| 485 | fctrlData->bCnrAdjusted=TRUE;
|
---|
| 486 | }
|
---|
| 487 | /* One new control added */
|
---|
| 488 | rc++;
|
---|
| 489 | }/* end of if(fctrlData->bTop) */
|
---|
| 490 |
|
---|
| 491 |
|
---|
| 492 | /* Left frame control */
|
---|
| 493 | if(fctrlData->bLeft){
|
---|
| 494 | pswpFrameCtl=&pswp[countSWP+iCount++];/* First free position */
|
---|
| 495 |
|
---|
| 496 | pswpClient->cx -= fctrlData->sizelLeftFrame.cx;/* Size client */
|
---|
| 497 | pswpFrameCtl->hwnd=fctrlData->hwndCtlLeft;
|
---|
| 498 |
|
---|
| 499 | pswpFrameCtl->x =pswpClient->x;
|
---|
| 500 | pswpClient->x += fctrlData->sizelLeftFrame.cx;/* Size client */
|
---|
| 501 | pswpFrameCtl->y =pswpClient->y;
|
---|
| 502 |
|
---|
| 503 | pswpFrameCtl->cx = fctrlData->sizelLeftFrame.cx;
|
---|
| 504 | pswpFrameCtl->cy =pswpClient->cy;
|
---|
| 505 |
|
---|
| 506 | pswpFrameCtl->hwndInsertBehind = HWND_BOTTOM;
|
---|
| 507 | pswpFrameCtl->fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER | SWP_SHOW;
|
---|
| 508 |
|
---|
| 509 | /* Position this frame control above bottom ctrl if requested */
|
---|
| 510 | if((fctrlData->ulFlagsLeft & FCTL_POSABOVE) && fctrlData->bBottom){
|
---|
| 511 | pswpFrameCtl->y +=fctrlData->sizelBottomFrame.cy;
|
---|
| 512 | pswpFrameCtl->cy -=fctrlData->sizelBottomFrame.cy;
|
---|
| 513 | }
|
---|
| 514 | /* Position this frame control below top ctrl if requested */
|
---|
| 515 | if(!(fctrlData->ulFlagsLeft & FCTL_POSBELOW) && fctrlData->bTop){
|
---|
| 516 | pswpFrameCtl->cy +=fctrlData->sizelTopFrame.cy;
|
---|
| 517 | }
|
---|
| 518 | rc++;
|
---|
| 519 | }/* end of if(fctrlData->bLeft) */
|
---|
| 520 |
|
---|
| 521 | /* Bottom frame control */
|
---|
| 522 | if(fctrlData->bBottom){
|
---|
| 523 | pswpFrameCtl=&pswp[countSWP+iCount++];/* First free position */
|
---|
| 524 |
|
---|
| 525 | pswpClient->cy -= fctrlData->sizelBottomFrame.cy;
|
---|
| 526 | pswpFrameCtl->hwnd=fctrlData->hwndCtlBottom;
|
---|
| 527 |
|
---|
| 528 | pswpFrameCtl->x = pswpClient->x;
|
---|
| 529 | pswpFrameCtl->y = pswpClient->y;
|
---|
| 530 | pswpClient->y += fctrlData->sizelBottomFrame.cy;
|
---|
| 531 |
|
---|
| 532 | pswpFrameCtl->cx = pswpClient->cx;
|
---|
| 533 | pswpFrameCtl->cy = fctrlData->sizelBottomFrame.cy;
|
---|
| 534 |
|
---|
| 535 | pswpFrameCtl->hwndInsertBehind = HWND_BOTTOM;
|
---|
| 536 | pswpFrameCtl->fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER | SWP_SHOW;
|
---|
| 537 |
|
---|
| 538 | /* Adjust position if flags are set */
|
---|
| 539 | if(fctrlData->bLeft){
|
---|
| 540 | if((fctrlData->ulFlagsLeft & FCTL_POSABOVE)) {
|
---|
| 541 | pswpFrameCtl->cx +=fctrlData->sizelLeftFrame.cx;
|
---|
| 542 | pswpFrameCtl->x -= fctrlData->sizelLeftFrame.cx;
|
---|
| 543 | }
|
---|
| 544 | }
|
---|
| 545 | if(!(fctrlData->ulFlagsRight & FCTL_POSABOVE)&& fctrlData->bRight) {
|
---|
| 546 | pswpFrameCtl->cx -= fctrlData->sizelRightFrame.cx;
|
---|
| 547 | }
|
---|
| 548 | /* Adjust container view so items do not scroll out of view */
|
---|
| 549 | /* hwndClient=pswpClient->hwnd;
|
---|
| 550 | if(WinSendMsg(hwndClient,CM_QUERYCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(sizeof(CnrInfo)))){
|
---|
| 551 | CnrInfo.ptlOrigin.y-=pswpFrameCtl->cy;
|
---|
| 552 | WinSendMsg(hwndClient,CM_SETCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(CMA_PTLORIGIN));
|
---|
| 553 | };*/
|
---|
| 554 |
|
---|
| 555 | if(!fctrlData->bCnrAdjusted) {
|
---|
| 556 | hwndClient=pswpClient->hwnd;
|
---|
| 557 | if(WinSendMsg(hwndClient,CM_QUERYCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(sizeof(CnrInfo)))){
|
---|
| 558 | if(fctrlData->bBottom)
|
---|
| 559 | CnrInfo.ptlOrigin.y-=fctrlData->sizelBottomFrame.cy;
|
---|
| 560 | if(fctrlData->bTop)
|
---|
| 561 | CnrInfo.ptlOrigin.y-=fctrlData->sizelTopFrame.cy;
|
---|
| 562 | //CnrInfo.ptlOrigin.y+=0;
|
---|
| 563 | WinSendMsg(hwndClient,CM_SETCNRINFO,MPFROMP(&CnrInfo),MPFROMSHORT(CMA_PTLORIGIN));
|
---|
| 564 | }
|
---|
| 565 | fctrlData->bCnrAdjusted=TRUE;
|
---|
| 566 | }
|
---|
| 567 |
|
---|
| 568 | rc++;
|
---|
| 569 | }/* end of if(fctrlData->bBottom) */
|
---|
| 570 |
|
---|
| 571 | /* Right frame control */
|
---|
| 572 | if(fctrlData->bRight){
|
---|
| 573 | pswpFrameCtl=&pswp[countSWP+iCount++];/* First free position */
|
---|
| 574 |
|
---|
| 575 | pswpClient->cx -= fctrlData->sizelRightFrame.cx;/* Size client */
|
---|
| 576 | pswpFrameCtl->hwnd=fctrlData->hwndCtlRight;
|
---|
| 577 |
|
---|
| 578 | pswpFrameCtl->x =pswpClient->x+pswpClient->cx;
|
---|
| 579 | pswpFrameCtl->y =pswpClient->y;
|
---|
| 580 |
|
---|
| 581 | pswpFrameCtl->cx = fctrlData->sizelRightFrame.cx;
|
---|
| 582 | pswpFrameCtl->cy =pswpClient->cy;
|
---|
| 583 |
|
---|
| 584 | pswpFrameCtl->hwndInsertBehind = HWND_BOTTOM;
|
---|
| 585 | pswpFrameCtl->fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER | SWP_SHOW;
|
---|
| 586 |
|
---|
| 587 | /* Position this frame control above bottom ctrl only if requested */
|
---|
| 588 | if(!(fctrlData->ulFlagsRight & FCTL_POSABOVE) && fctrlData->bBottom){
|
---|
| 589 | pswpFrameCtl->y -=fctrlData->sizelBottomFrame.cy;
|
---|
| 590 | pswpFrameCtl->cy +=fctrlData->sizelBottomFrame.cy;
|
---|
| 591 | }
|
---|
| 592 | /* Position this frame control below top ctrl only if requested */
|
---|
| 593 | if(!(fctrlData->ulFlagsRight & FCTL_POSBELOW) && fctrlData->bTop){
|
---|
| 594 | pswpFrameCtl->cy +=fctrlData->sizelTopFrame.cy;
|
---|
| 595 | }
|
---|
| 596 | rc++;
|
---|
| 597 | }/* end of if(fctrlData->bRight) */
|
---|
| 598 |
|
---|
| 599 |
|
---|
| 600 | }
|
---|
| 601 | }
|
---|
| 602 | return rc;/* Return additional controls */
|
---|
| 603 | }
|
---|
| 604 |
|
---|
| 605 |
|
---|
| 606 | /**************************************************************/
|
---|
| 607 | /* */
|
---|
| 608 | /* This function adds a frame control at the specified */
|
---|
| 609 | /* position. */
|
---|
| 610 | /* */
|
---|
| 611 | /**************************************************************/
|
---|
| 612 | BOOL CWProgFolder::cwAddFrameCtl(HWND hwndFolder, HWND hwndNewCtl,SIZEL sizel, ULONG ulPos, ULONG ulFlags)
|
---|
| 613 | {
|
---|
| 614 | FRAMECTRLDATA * fctrlData;
|
---|
| 615 |
|
---|
| 616 | /* Get the framecontrol datastructure from the invisible control window */
|
---|
| 617 | fctrlData=(FRAMECTRLDATA*)WinQueryWindowPtr(WinWindowFromID(hwndFolder, ID_FOLDERSTOREWINDOW),QWP_FCTRLDATA);
|
---|
| 618 | if(!fctrlData) return FALSE;
|
---|
| 619 |
|
---|
| 620 | /* Fill in the values into the structure */
|
---|
| 621 | /* This is the dialog at the left */
|
---|
| 622 | if(ulPos & FCTL_LEFT) {
|
---|
| 623 | /* The HWND of the dialog used as a framcontrol */
|
---|
| 624 | fctrlData->hwndCtlLeft=hwndNewCtl;
|
---|
| 625 | /* The size of the dialog. Actually only sizel.cx is used
|
---|
| 626 | since this is a dialog at the left which always has
|
---|
| 627 | got the height of the client. */
|
---|
| 628 | fctrlData->sizelLeftFrame=sizel;
|
---|
| 629 | /* A flag which determines the positioning of the dialog.
|
---|
| 630 | If there is a dialog at the top you may tell the folder
|
---|
| 631 | to move it sizel.cx pixel to the right to allow the
|
---|
| 632 | control at the left to cover the full height of the folder.
|
---|
| 633 | The same is with the control at the bottom. This gives
|
---|
| 634 | you the ability to finetune the appearance of the
|
---|
| 635 | folder. Just try the flags FCTL_POSBELOW, FCTL_POSABOVE as
|
---|
| 636 | defined in progfolder.h in conjunction with framecontrols
|
---|
| 637 | at different positions of the folder.
|
---|
| 638 | */
|
---|
| 639 | fctrlData->ulFlagsLeft=ulFlags;
|
---|
| 640 | /* Tell the frame procedure that there's a framecontrol
|
---|
| 641 | at the left. */
|
---|
| 642 | fctrlData->bLeft=TRUE;
|
---|
| 643 | if(!fctrlData->hwndCtlLeft)
|
---|
| 644 | /* If this method is called with hwndNewCtl=NULL the framecontrol
|
---|
| 645 | is disabled. */
|
---|
| 646 | fctrlData->bLeft=FALSE;
|
---|
| 647 | }
|
---|
| 648 | /* This is the dialog at the right */
|
---|
| 649 | if(ulPos & FCTL_RIGHT){
|
---|
| 650 | fctrlData->hwndCtlRight=hwndNewCtl;
|
---|
| 651 | fctrlData->sizelRightFrame=sizel;
|
---|
| 652 | fctrlData->ulFlagsRight=ulFlags;
|
---|
| 653 | fctrlData->bRight=TRUE;
|
---|
| 654 | if(!fctrlData->hwndCtlRight)
|
---|
| 655 | fctrlData->bRight=FALSE;
|
---|
| 656 | }
|
---|
| 657 | if(ulPos & FCTL_TOP){
|
---|
| 658 | fctrlData->hwndCtlTop=hwndNewCtl;
|
---|
| 659 | fctrlData->sizelTopFrame=sizel;
|
---|
| 660 | fctrlData->bTop=TRUE;
|
---|
| 661 | if(!fctrlData->hwndCtlTop)
|
---|
| 662 | fctrlData->bTop=FALSE;
|
---|
| 663 | }
|
---|
| 664 | if(ulPos & FCTL_BOTTOM){
|
---|
| 665 | fctrlData->hwndCtlBottom=hwndNewCtl;
|
---|
| 666 | fctrlData->sizelBottomFrame=sizel;
|
---|
| 667 | fctrlData->bBottom=TRUE;
|
---|
| 668 | if(!fctrlData->hwndCtlBottom)
|
---|
| 669 | fctrlData->bBottom=FALSE;
|
---|
| 670 | }
|
---|
| 671 | return TRUE;
|
---|
| 672 | }
|
---|
| 673 |
|
---|
| 674 |
|
---|
| 675 | /**************************************************************/
|
---|
| 676 | /* */
|
---|
| 677 | /* This function returns information about the specified */
|
---|
| 678 | /* private frame control. */
|
---|
| 679 | /* */
|
---|
| 680 | /**************************************************************/
|
---|
| 681 | HWND CWProgFolder::cwQueryFrameCtl(HWND hwndFolder, SIZEL* sizel, ULONG ulPos, ULONG * ulFlags)
|
---|
| 682 | {
|
---|
| 683 | FRAMECTRLDATA * fctrlData;
|
---|
| 684 |
|
---|
| 685 | fctrlData=(FRAMECTRLDATA*)WinQueryWindowPtr(WinWindowFromID(hwndFolder, ID_FOLDERSTOREWINDOW),QWP_FCTRLDATA);
|
---|
| 686 | if(!fctrlData) return FALSE;
|
---|
| 687 |
|
---|
| 688 |
|
---|
| 689 | if(ulPos & FCTL_LEFT){
|
---|
| 690 | *sizel=fctrlData->sizelLeftFrame;
|
---|
| 691 | *ulFlags= fctrlData->ulFlagsLeft;
|
---|
| 692 | return fctrlData->hwndCtlLeft;
|
---|
| 693 | }
|
---|
| 694 | if(ulPos & FCTL_RIGHT){
|
---|
| 695 | *sizel=fctrlData->sizelRightFrame;
|
---|
| 696 | *ulFlags=fctrlData->ulFlagsRight;
|
---|
| 697 | return fctrlData->hwndCtlRight;
|
---|
| 698 | }
|
---|
| 699 | if(ulPos & FCTL_TOP){
|
---|
| 700 | *sizel=fctrlData->sizelTopFrame;
|
---|
| 701 | *ulFlags=0;
|
---|
| 702 | return fctrlData->hwndCtlTop;
|
---|
| 703 | }
|
---|
| 704 | if(ulPos & FCTL_BOTTOM){
|
---|
| 705 | *sizel=fctrlData->sizelBottomFrame;
|
---|
| 706 | *ulFlags=0;
|
---|
| 707 | return fctrlData->hwndCtlBottom;
|
---|
| 708 | }
|
---|
| 709 | return NULL;
|
---|
| 710 | }
|
---|
| 711 |
|
---|
| 712 | /**************************************************************/
|
---|
| 713 | /* */
|
---|
| 714 | /* This function requests an update of frame controls so */
|
---|
| 715 | /* added frame controls will become visible. */
|
---|
| 716 | /* You must call this function after calling cwAddFrameCtl(). */
|
---|
| 717 | /* */
|
---|
| 718 | /**************************************************************/
|
---|
| 719 | void CWProgFolder::cwUpdateFrame(HWND hwndFolder)
|
---|
| 720 | {
|
---|
| 721 |
|
---|
| 722 | WinSendMsg(hwndFolder,WM_UPDATEFRAME,0,0);
|
---|
| 723 |
|
---|
| 724 | }
|
---|
| 725 |
|
---|
| 726 | /**************************************************************/
|
---|
| 727 | /* */
|
---|
| 728 | /* This function returns the pointer to a file system object */
|
---|
| 729 | /* or NULL. */
|
---|
| 730 | /* It follows shadow objects and returns the object handle */
|
---|
| 731 | /* of the linked object if it's a file system object */
|
---|
| 732 | /* */
|
---|
| 733 | /**************************************************************/
|
---|
| 734 | WPObject* CWProgFolder::cwGetFileSystemObject(WPObject* wpObject)
|
---|
| 735 | {
|
---|
| 736 | if(!somIsObj(wpObject)) return NULL;//No object given
|
---|
| 737 |
|
---|
| 738 | /* Check if it's a shadow */
|
---|
| 739 | if(somResolveByName(wpObject,"wpQueryShadowedObject")){
|
---|
| 740 | /* Yes, it's a shadow. Query the linked object. */
|
---|
| 741 | wpObject=((WPShadow*)wpObject)->wpQueryShadowedObject(FALSE);
|
---|
| 742 | }
|
---|
| 743 |
|
---|
| 744 | if(!somIsObj(wpObject)) return NULL;//The link is broken
|
---|
| 745 |
|
---|
| 746 | /* Check if it's a file system object */
|
---|
| 747 | if(somResolveByName(wpObject, "wpQueryRealName")){
|
---|
| 748 | return wpObject;/* Yes */
|
---|
| 749 | }
|
---|
| 750 | else
|
---|
| 751 | return NULL;
|
---|
| 752 | }
|
---|
| 753 |
|
---|
| 754 | void paintURL(HPS hps, HWND hwnd, LONG lColor)
|
---|
| 755 | {
|
---|
| 756 | POINTL aptl[TXTBOX_COUNT];
|
---|
| 757 | POINTL ptl[2];
|
---|
| 758 | int iLen;
|
---|
| 759 | RECTL rectl;
|
---|
| 760 | char chrURL[500];
|
---|
| 761 | int a;
|
---|
| 762 | LONG lSaveY;
|
---|
| 763 | // SIZEF fxSize;
|
---|
| 764 |
|
---|
| 765 | WinQueryWindowText(hwnd, sizeof(chrURL),chrURL);
|
---|
| 766 | iLen=strlen(chrURL);
|
---|
| 767 | GpiQueryTextBox(hps, iLen, chrURL, TXTBOX_COUNT, aptl);
|
---|
| 768 | WinQueryWindowRect(hwnd, &rectl);
|
---|
| 769 | // WinDrawText(hps, -1L, chrURL, &rectl, CLR_BLUE, CLR_BACKGROUND, DT_LEFT|DT_UNDERSCORE);
|
---|
| 770 |
|
---|
| 771 | if(aptl[TXTBOX_TOPRIGHT].x-aptl[TXTBOX_TOPLEFT].x <= rectl.xRight-rectl.xLeft)
|
---|
| 772 | WinDrawText(hps, -1L, chrURL, &rectl, lColor, CLR_BACKGROUND, DT_CENTER|DT_UNDERSCORE);
|
---|
| 773 | else
|
---|
| 774 | {
|
---|
| 775 | /* Always draw the first 15 chars to speed up */
|
---|
| 776 | a=15;
|
---|
| 777 | ptl[0].x=0;
|
---|
| 778 | lSaveY=rectl.yTop-aptl[TXTBOX_TOPLEFT].y;
|
---|
| 779 | ptl[0].y=lSaveY;
|
---|
| 780 |
|
---|
| 781 | GpiSetColor(hps, lColor);
|
---|
| 782 | GpiCharStringPosAt(hps, ptl,NULLHANDLE, CHS_UNDERSCORE, a, chrURL, 0);
|
---|
| 783 | // GpiQueryCharBox(hps, &fxSize);
|
---|
| 784 |
|
---|
| 785 |
|
---|
| 786 | // GpiQueryCharStringPos(hps, 0, 1, &chrURL[a], 0,ptl);
|
---|
| 787 | while(a < iLen) {/* While chars in string */
|
---|
| 788 | /* Get draw position of next char */
|
---|
| 789 | GpiQueryCharStringPos(hps, 0, 1, &chrURL[a], 0, ptl);
|
---|
| 790 | if(ptl[1].x > rectl.xRight) {/* ptl[1] is position of next char */
|
---|
| 791 | /* Center the next line ?? */
|
---|
| 792 | GpiQueryTextBox(hps, strlen(&chrURL[a]), &chrURL[a], TXTBOX_COUNT, aptl);
|
---|
| 793 | if(aptl[TXTBOX_TOPRIGHT].x-aptl[TXTBOX_TOPLEFT].x <= rectl.xRight-rectl.xLeft)
|
---|
| 794 | /* Yes */
|
---|
| 795 | ptl[0].x=(rectl.xRight-rectl.xLeft-(aptl[TXTBOX_TOPRIGHT].x-aptl[TXTBOX_TOPLEFT].x))/2;
|
---|
| 796 | else
|
---|
| 797 | ptl[0].x=0; /* No */
|
---|
| 798 | lSaveY-=aptl[TXTBOX_TOPLEFT].y+2;
|
---|
| 799 | ptl[0].y=lSaveY;
|
---|
| 800 | GpiMove(hps, ptl);
|
---|
| 801 | }
|
---|
| 802 | /* Draw char */
|
---|
| 803 | GpiCharStringPos(hps,NULLHANDLE,CHS_UNDERSCORE,1,&chrURL[a],0);
|
---|
| 804 | a++;
|
---|
| 805 | // GpiQueryCharStringPos(hps, 0, 1, &chrURL[a], 0, ptl);
|
---|
| 806 | // a++;
|
---|
| 807 | };
|
---|
| 808 | }
|
---|
| 809 | }
|
---|
| 810 |
|
---|
| 811 | MRESULT EXPENTRY urlProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
|
---|
| 812 | {
|
---|
| 813 | PFNWP pfnwp;
|
---|
| 814 | char chrURL[500];
|
---|
| 815 | STARTDATA startData;
|
---|
| 816 | char chrLoadError[CCHMAXPATH];
|
---|
| 817 | ULONG ulSessionID;
|
---|
| 818 | PID pid;
|
---|
| 819 | ULONG attrValue[32];
|
---|
| 820 | APIRET rc;
|
---|
| 821 | HPS hps;
|
---|
| 822 | RECTL rectl;
|
---|
| 823 |
|
---|
| 824 | switch( msg )
|
---|
| 825 | {
|
---|
| 826 | case WM_BUTTON1DOWN:
|
---|
| 827 | hps=WinGetPS(hwnd);
|
---|
| 828 | paintURL(hps, hwnd, CLR_RED);
|
---|
| 829 | WinReleasePS(hps);
|
---|
| 830 | return (MRESULT) FALSE;
|
---|
| 831 | case WM_BUTTON1UP:
|
---|
| 832 | hps=WinGetPS(hwnd);
|
---|
| 833 | paintURL(hps, hwnd, CLR_BLUE);
|
---|
| 834 | WinReleasePS(hps);
|
---|
| 835 | return (MRESULT) FALSE;
|
---|
| 836 | case WM_BUTTON1CLICK:
|
---|
| 837 | WinQueryWindowText(hwnd,sizeof(chrURL),chrURL);
|
---|
| 838 | memset(&startData,0,sizeof(startData));
|
---|
| 839 | startData.Length=sizeof(startData);
|
---|
| 840 | startData.Related=SSF_RELATED_INDEPENDENT;
|
---|
| 841 | startData.FgBg=SSF_FGBG_FORE;
|
---|
| 842 | startData.TraceOpt=SSF_TRACEOPT_NONE;
|
---|
| 843 | startData.PgmTitle="";
|
---|
| 844 | startData.PgmName="netscape.exe";
|
---|
| 845 | startData.InheritOpt=SSF_INHERTOPT_SHELL;
|
---|
| 846 | startData.SessionType=SSF_TYPE_DEFAULT;
|
---|
| 847 | startData.PgmControl=SSF_CONTROL_VISIBLE;
|
---|
| 848 | startData.InitXPos=30;
|
---|
| 849 | startData.InitYPos=30;
|
---|
| 850 | startData.InitXSize=500;
|
---|
| 851 | startData.InitYSize=400;
|
---|
| 852 | startData.ObjectBuffer=chrLoadError;
|
---|
| 853 | startData.ObjectBuffLen=(ULONG)sizeof(chrLoadError);
|
---|
| 854 | startData.PgmInputs=chrURL;
|
---|
| 855 | rc=DosStartSession(&startData,&ulSessionID,&pid);
|
---|
| 856 | return (MRESULT) FALSE;
|
---|
| 857 | case WM_PAINT:
|
---|
| 858 | hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
|
---|
| 859 | paintURL(hps, hwnd, CLR_BLUE);
|
---|
| 860 | WinEndPaint(hps);
|
---|
| 861 | return (MRESULT) FALSE;
|
---|
| 862 | case WM_MOUSEMOVE:
|
---|
| 863 | if(hptrHand) {
|
---|
| 864 | WinSetPointer(HWND_DESKTOP,hptrHand);
|
---|
| 865 | }
|
---|
| 866 | return (MRESULT)FALSE;
|
---|
| 867 | default:
|
---|
| 868 | break;
|
---|
| 869 | }
|
---|
| 870 | pfnwp=(PFNWP)WinQueryWindowULong(hwnd,QWL_USER);
|
---|
| 871 | if(pfnwp)
|
---|
| 872 | return pfnwp( hwnd, msg, mp1, mp2 );
|
---|
| 873 |
|
---|
| 874 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
---|
| 875 | }
|
---|
| 876 |
|
---|
| 877 |
|
---|
| 878 | /**************************************************************/
|
---|
| 879 | /* */
|
---|
| 880 |
|
---|
| 881 | /* */
|
---|
| 882 | /**************************************************************/
|
---|
| 883 | MRESULT EXPENTRY aboutDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
|
---|
| 884 | {
|
---|
| 885 | HENUM hEnum;
|
---|
| 886 | HWND hwndNext;
|
---|
| 887 | char chrText[400];
|
---|
| 888 | ULONG ulStyle;
|
---|
| 889 | char text[50];
|
---|
| 890 | PFNWP pfnwp;
|
---|
| 891 | HMODULE hModule;
|
---|
| 892 | SWP swp;
|
---|
| 893 |
|
---|
| 894 | switch( msg )
|
---|
| 895 | {
|
---|
| 896 | case WM_INITDLG:
|
---|
| 897 | /* Find text controls with an URL */
|
---|
| 898 | hEnum=WinBeginEnumWindows(hwnd);
|
---|
| 899 | do {
|
---|
| 900 | hwndNext=WinGetNextWindow(hEnum);
|
---|
| 901 | if(hwndNext) {
|
---|
| 902 | WinQueryClassName(hwndNext,sizeof(chrText), chrText);
|
---|
| 903 | if(!strcmpi(chrText,"#5")) {
|
---|
| 904 | ulStyle=WinQueryWindowULong(hwndNext,QWL_STYLE);
|
---|
| 905 |
|
---|
| 906 | if((ulStyle & 0xf) == SS_TEXT) {
|
---|
| 907 | /* Static text control */
|
---|
| 908 | WinQueryWindowText(hwndNext,sizeof(chrText), chrText);
|
---|
| 909 | if(!strnicmp(chrText,"http:",5)){
|
---|
| 910 | if(!hptrHand) {
|
---|
| 911 | if(!DosQueryModuleHandle("PROGFLDR.DLL",&hModule))
|
---|
| 912 | hptrHand=WinLoadPointer(HWND_DESKTOP,hModule,IDPT_HAND);
|
---|
| 913 | }
|
---|
| 914 | pfnwp=WinSubclassWindow(hwndNext, urlProc);
|
---|
| 915 | WinSetWindowULong(hwndNext,QWL_USER,(ULONG)pfnwp);
|
---|
| 916 | }
|
---|
| 917 | }/* end of if((ulStyle & 0xf) == SS_TEXT) */
|
---|
| 918 | }
|
---|
| 919 | }
|
---|
| 920 | }while(hwndNext);
|
---|
| 921 | WinEndEnumWindows(hEnum);
|
---|
| 922 | /* Set dialog font to WarpSans for Warp 4 and above */
|
---|
| 923 | if(cwQueryOSRelease()>=40) {
|
---|
| 924 | WinSetPresParam(hwnd,
|
---|
| 925 | PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
|
---|
| 926 | DEFAULT_DIALOG_FONT );
|
---|
| 927 | }
|
---|
| 928 |
|
---|
| 929 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 930 |
|
---|
| 931 | WinSetWindowPos(hwnd,HWND_TOP,(WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)-swp.cx)/2, (WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN)-swp.cy)/2,
|
---|
| 932 | 0,0, SWP_MOVE|SWP_ZORDER|SWP_ACTIVATE|SWP_SHOW);
|
---|
| 933 | return (MRESULT) TRUE;
|
---|
| 934 | case WM_DESTROY:
|
---|
| 935 | break;
|
---|
| 936 | case WM_CLOSE:
|
---|
| 937 | break;
|
---|
| 938 | case WM_COMMAND:
|
---|
| 939 | {
|
---|
| 940 | switch( SHORT1FROMMP( mp1 ) )
|
---|
| 941 | {
|
---|
| 942 | default:
|
---|
| 943 | break;
|
---|
| 944 | }
|
---|
| 945 | }
|
---|
| 946 | break;
|
---|
| 947 | return (MRESULT) TRUE;
|
---|
| 948 | }
|
---|
| 949 | return( WinDefDlgProc( hwnd, msg, mp1, mp2 ) );
|
---|
| 950 | }
|
---|
| 951 |
|
---|
| 952 | /**************************************************************/
|
---|
| 953 | /* */
|
---|
| 954 | /* This method shows an about dialog. */
|
---|
| 955 | /* */
|
---|
| 956 | /**************************************************************/
|
---|
| 957 | ULONG CWProgFolder::cwShowAboutDlg(HMODULE hModule, ULONG idDialog)
|
---|
| 958 | {
|
---|
| 959 | HWND hwnd;
|
---|
| 960 |
|
---|
| 961 | /*
|
---|
| 962 | New: 01.05.2004, MAke sure the about dialog is modal to the folder.
|
---|
| 963 | */
|
---|
| 964 | hwnd=WinQueryActiveWindow(HWND_DESKTOP);
|
---|
| 965 |
|
---|
| 966 | return (WinDlgBox( HWND_DESKTOP, hwnd, aboutDlgProc, hModule,idDialog, 0));
|
---|
| 967 | }
|
---|
| 968 |
|
---|
| 969 | /**************************************************************/
|
---|
| 970 | /* */
|
---|
| 971 | /* This funktion returns the CD-Drives in the system */
|
---|
| 972 | /* */
|
---|
| 973 | /* iNumCD (output): # of CD-Drives */
|
---|
| 974 | /* cFirstDrive (output): first cd-Drive letter */
|
---|
| 975 | /* returns TRUE: We have cd-drives */
|
---|
| 976 | /* */
|
---|
| 977 | /**************************************************************/
|
---|
| 978 | BOOL CWProgFolder::cwQueryCDDrives(int *iNumCD, char * cFirstDrive)
|
---|
| 979 | {
|
---|
| 980 | HFILE hfDevice;
|
---|
| 981 | ULONG ulAction;
|
---|
| 982 | ULONG ulLen;
|
---|
| 983 | static char cFirst=0;
|
---|
| 984 | static int iNumCDLocal=0;
|
---|
| 985 | static BOOL haveCD=FALSE;
|
---|
| 986 | static BOOL done=FALSE;
|
---|
| 987 | struct
|
---|
| 988 | {
|
---|
| 989 | USHORT usCountCD;
|
---|
| 990 | USHORT usFirstCD;
|
---|
| 991 | } CDInfo;
|
---|
| 992 |
|
---|
| 993 | if(!done){
|
---|
| 994 | ulLen = sizeof(CDInfo);
|
---|
| 995 | if(!DosOpen("\\DEV\\CD-ROM2$", &hfDevice, &ulAction, 0,
|
---|
| 996 | FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
|
---|
| 997 | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL))
|
---|
| 998 | {
|
---|
| 999 | if(!DosDevIOCtl(hfDevice, 0x82, 0x60, NULL, 0, NULL, &CDInfo, ulLen, &ulLen))
|
---|
| 1000 | {
|
---|
| 1001 | if(CDInfo.usCountCD) {
|
---|
| 1002 | haveCD=TRUE;
|
---|
| 1003 | iNumCDLocal=CDInfo.usCountCD;
|
---|
| 1004 | cFirst='A'+ CDInfo.usFirstCD;
|
---|
| 1005 | }
|
---|
| 1006 | }
|
---|
| 1007 | DosClose(hfDevice);
|
---|
| 1008 | }
|
---|
| 1009 | done=TRUE;
|
---|
| 1010 | }
|
---|
| 1011 | *iNumCD=iNumCDLocal;
|
---|
| 1012 | *cFirstDrive=cFirst;
|
---|
| 1013 | return haveCD;
|
---|
| 1014 | }
|
---|
| 1015 |
|
---|
| 1016 |
|
---|
| 1017 | /* Use this method to insert user menu items into a menu when WPSWizard is installed */
|
---|
| 1018 | BOOL CWProgFolder::cwInsertUserMenuItems(HWND hwndMenu, char* chrMenuFolder, ULONG ulFirstId, BOOL bLeadingSeparator)
|
---|
| 1019 | {
|
---|
| 1020 | M_WPObject *m_wpObject;
|
---|
| 1021 | CWMenuFolder * wpFolder;
|
---|
| 1022 | HOBJECT hObject;
|
---|
| 1023 | somId id;
|
---|
| 1024 | somTD_CWMenuFolder_mfInsertMenuItems methodPtr;
|
---|
| 1025 | ULONG ulRc=ulFirstId;
|
---|
| 1026 |
|
---|
| 1027 | /* Insert the menu items from the user menu folder. WPS-Wizard must be installed for
|
---|
| 1028 | this. */
|
---|
| 1029 | if((hObject=WinQueryObject(chrMenuFolder))!=NULLHANDLE) {//is there a default menufolder?
|
---|
| 1030 | /* Yes */
|
---|
| 1031 | m_wpObject=(M_WPObject*)this->somGetClass();
|
---|
| 1032 | if(somIsObj(m_wpObject)) {
|
---|
| 1033 | /* We have it */
|
---|
| 1034 | /* Get method address */
|
---|
| 1035 | if((id=somIdFromString("mfInsertMenuItems"))!=NULLHANDLE) {
|
---|
| 1036 | wpFolder=(CWMenuFolder *)m_wpObject->wpclsQueryObject( hObject);
|
---|
| 1037 | if(somIsObj(wpFolder)) {
|
---|
| 1038 | methodPtr= (somTD_CWMenuFolder_mfInsertMenuItems) (wpFolder->somGetClass())->somFindSMethod(id);
|
---|
| 1039 | if(methodPtr) {
|
---|
| 1040 | SHORT sIndex;
|
---|
| 1041 |
|
---|
| 1042 | if(bLeadingSeparator)
|
---|
| 1043 | sIndex=SHORT1FROMMR(cwInsertMenuSeparator(MIT_END, hwndMenu, NULL));
|
---|
| 1044 | ulRc=methodPtr(wpFolder, hwndMenu , MIT_END, ulFirstId);
|
---|
| 1045 | #if 0
|
---|
| 1046 | if(ulRc==ulFirstId) {
|
---|
| 1047 | /* No item inserted, remove the separator */
|
---|
| 1048 | sIndex=SHORT1FROMMR(WinSendMsg(hwndMenu,MM_ITEMIDFROMPOSITION,MPFROMSHORT(sIndex),
|
---|
| 1049 | (MPARAM)NULL));
|
---|
| 1050 | if(sIndex!=MIT_ERROR)
|
---|
| 1051 | WinSendMsg(hwndMenu,MM_DELETEITEM,MPFROM2SHORT(sIndex, TRUE),
|
---|
| 1052 | (MPARAM)NULL);
|
---|
| 1053 |
|
---|
| 1054 | }
|
---|
| 1055 | #endif
|
---|
| 1056 | }
|
---|
| 1057 | /* ulCurrentID contains the last used menu id */
|
---|
| 1058 | wpFolder->wpUnlockObject();//Object is locked because of wpclsQueryHandle()
|
---|
| 1059 | }/* if(somIsObj(wpFolder)) */
|
---|
| 1060 | SOMFree(id);
|
---|
| 1061 | }/* somId */
|
---|
| 1062 | }/* end of if(somIsObj(m_wpObject)) */
|
---|
| 1063 | }/* USERMENU_FOLDER */
|
---|
| 1064 | return ulRc;
|
---|
| 1065 | }
|
---|
| 1066 |
|
---|
| 1067 | BOOL CWProgFolder::cwCheckUserMenuItems( char* chrMenuFolder, USHORT usItemId)
|
---|
| 1068 | {
|
---|
| 1069 | CWMenuFolder * wpFolder;
|
---|
| 1070 | HOBJECT hObject;
|
---|
| 1071 | somId id;
|
---|
| 1072 | somTD_CWMenuFolder_mfCheckMenuItems methodPtr;
|
---|
| 1073 | M_WPObject *m_wpObject;
|
---|
| 1074 | BOOL bHandled=FALSE;
|
---|
| 1075 |
|
---|
| 1076 | if((hObject=WinQueryObject(chrMenuFolder))!=NULLHANDLE) {//is there a default menufolder?
|
---|
| 1077 | /* Get class object */
|
---|
| 1078 | m_wpObject=(M_WPObject*)this->somGetClass();
|
---|
| 1079 | if(somIsObj(m_wpObject)) {
|
---|
| 1080 | /* We have it */
|
---|
| 1081 | if((id=somIdFromString("mfCheckMenuItems"))!=NULLHANDLE){
|
---|
| 1082 | wpFolder=(CWMenuFolder *)m_wpObject->wpclsQueryObject( hObject);
|
---|
| 1083 | if(somIsObj(wpFolder)) {
|
---|
| 1084 | methodPtr= (somTD_CWMenuFolder_mfCheckMenuItems) (wpFolder->somGetClass())->somFindSMethod(id);
|
---|
| 1085 | SOMFree(id);
|
---|
| 1086 | if(methodPtr) {
|
---|
| 1087 | /* Check for Items */
|
---|
| 1088 | bHandled=methodPtr(wpFolder, this, usItemId);
|
---|
| 1089 | }
|
---|
| 1090 | wpFolder->wpUnlockObject();//Object is locked because of wpclsQueryHandle()
|
---|
| 1091 | }
|
---|
| 1092 | }/* somId */
|
---|
| 1093 | }/* end of if(somIsObj(m_wpObject)) */
|
---|
| 1094 | }
|
---|
| 1095 | return bHandled;
|
---|
| 1096 | }
|
---|