home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 25 / nopv25.iso / 040A / GREED.ZIP / VPC.FN@ / VPC.FNC (.txt)
Encoding:
OS/2 INI File  |  1996-12-15  |  33.1 KB  |  801 lines

  1. Graphic
  2. Load and paint resource bitmap
  3. /*---( Load and paint a resource bitmap )---*/ 
  4. HPS hps;
  5. HBITMAP hbm;
  6. hps=WinGetPS(hwndDlg);
  7. hbm=GpiLoadBitmap(hps, 0, 1, 0L, 0L);
  8. WinReleasePS(hps);
  9. /* Set graphic handle #1 MPICTURE Bitmap */
  10. WinSendDlgItemMsg( hwndDlg,
  11.                    MPICTURE, 
  12.                    SM_SETHANDLE,
  13.                    MPFROMLONG(hbm), 0);
  14. WinInvalidateRect(WinWindowFromID(hwndDlg, MPICTURE),0,TRUE);
  15. C Functions
  16. sprintf
  17. sprintf( aTextValue, "Selected item: %d", anIntegerValue );
  18. malloc
  19. /*---------------(Allocate memory)---------------*/
  20. pBuffer = (PBYTE)malloc( (size_t)anUnsignedValue );
  21. if ( pBuffer )
  22.   free(pBuffer );
  23. fopen
  24. FILE *readfile;
  25. if ((readfile = fopen( pMainFormInfo->szImportFile, "r" )))
  26. } else {
  27. } /* end if */
  28. _splitpath
  29. /*---------( Get Backup of Current File )--------*/
  30. CHAR *GetNewExtent( CHAR *pPath, CHAR *pFile, CHAR *pExt )
  31.     CHAR szDrive[_MAX_DRIVE]="",
  32.          szDir[_MAX_DIR]="",
  33.          szFName[_MAX_FNAME]="",
  34.          szExt[_MAX_EXT]="";
  35.     _splitpath( pFile, szDrive, szDir, szFName, szExt );
  36.     sprintf( pPath, "%s%s%s%s", szDrive, szDir, szFName, pExt );
  37.     return ( pPath );
  38. Container Methods
  39. Container Methods
  40. Remove all container records
  41. /*--------(Remove all Container recordss)--------*/
  42. WinSendDlgItemMsg( pMainFormInfo->hwndDlg,
  43.                    pMainFormInfo->ulCnrObject,
  44.                    CM_REMOVERECORD,
  45.                    NULL, /* array of reference records */
  46.                    MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE)); /* delete 1 record */
  47. Allocate container records
  48. /************************************************/
  49. /* Allocate (ulItems) records at once -         */
  50. /* CM_ALLOCRECORD returns them in a linked list */
  51. /************************************************/
  52. pRecord=(PVOID)WinSendDlgItemMsg(hwndDlg, 
  53.                                  ulCnrObject,
  54.                                  CM_ALLOCRECORD,
  55.                                  MPFROMLONG(sizeof(*pRecord)-sizeof(MINIRECORDCORE)+32), /* Bytes of additional data */
  56.                                  MPFROMLONG(ulItems));   /* Number of records */
  57. Add a container item
  58. /* Add a container record to end MCOTSO Container */
  59.   PMAIN_MCOTSO_REC pRecord; /* Pointer to cnr item. */
  60.   /* IMPORTANT!!!! Manually replace MAIN with the form name */
  61.   /* This pRecord typedef is contained in the .H for this form */
  62.   RECORDINSERT RecordInsert;
  63.   /* IMPORTANT!!! we allocate 32 extra bytes for the pszIcon string */
  64.   /* We must allocate more than that if we have any extra PSZ members */
  65.   /* as columns */
  66.   pRecord=(PVOID)WinSendDlgItemMsg(hwndDlg, MCOTSO,
  67.                   CM_ALLOCRECORD,
  68.                   MPFROMLONG(sizeof(*pRecord)-sizeof(MINIRECORDCORE)+32), /* Bytes of additional data */
  69.                   MPFROMLONG(1));                  /* Number of records        */
  70.   pRecord->Record.cb=sizeof(MINIRECORDCORE);
  71.   pRecord->Record.flRecordAttr=0;
  72.   pRecord->Record.hptrIcon=WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE);
  73.   pRecord->Record.pszIcon=(PBYTE)pRecord+sizeof(*pRecord);
  74.   strcpy(pRecord->Record.pszIcon,aTextValue);
  75.   /* IMPORTANT!!! initiaize other members here if they exist */
  76.   /* add the item to the container */
  77.   RecordInsert.cb=sizeof(RECORDINSERT);
  78.   RecordInsert.pRecordOrder=(PRECORDCORE)CMA_END;/* add to the end */
  79.   RecordInsert.pRecordParent=(PRECORDCORE)0;     /* not a child record */
  80.   RecordInsert.zOrder=CMA_TOP;
  81.   RecordInsert.cRecordsInsert=1;
  82.   RecordInsert.fInvalidateRecord=TRUE;           /* repaint the record */
  83.   WinSendDlgItemMsg(hwndDlg, MCOTSO,
  84.                     CM_INSERTRECORD,
  85.                     MPFROMP(pRecord),
  86.                     MPFROMP(&RecordInsert));
  87. My Components
  88. WAKuM Icon
  89. /*---------------(Set WAKuM Icon Name)---------------*/
  90. sprintf( pMainFormInfo->szWakumIco, "%s\\%s",
  91.          pMainFormInfo->szHomeDir, WAKUM_ICO );
  92. Set Graphic Handle
  93. /* Set graphic handle #1WAKUMICO Icon */
  94. SetWakumIco( pMainFormInfo->szWakumIco,
  95.              hwndDlg,
  96.              WAKUMICO );
  97. Insert Notebook Page
  98. VOID InsertNbkPage( HWND hNewFrame, HWND hwndDlg,
  99.                     ULONG ulForm, CHAR *pDescr );
  100. /*-------------------( NOTEBOOK )-------------------*/
  101. VOID InsertNbkPage( HWND hNewFrame, HWND hwndDlg, ULONG ulForm, CHAR *pDescr )
  102.   ULONG  ulPageId;        /* Page identifier */
  103.   /* Add page with major tab ulForm Notebook */
  104.   ulPageId = (ULONG) WinSendDlgItemMsg(hwndDlg, ulForm,
  105.                   BKM_INSERTPAGE ,
  106.                   MPFROMLONG(0),
  107.                   MPFROM2SHORT(BKA_MAJOR|BKA_STATUSTEXTON|BKA_AUTOPAGESIZE,
  108.                      BKA_LAST));
  109.   if (ulPageId) {
  110.     /* Associate window within page  */
  111.     WinSetOwner(hNewFrame, WinWindowFromID(hwndDlg, ulForm));
  112.     WinSetParent(hNewFrame, WinWindowFromID(hwndDlg, ulForm),FALSE);
  113.     WinSendDlgItemMsg(hwndDlg, ulForm,
  114.                   BKM_SETPAGEWINDOWHWND,
  115.                   MPFROMLONG(ulPageId),    /* Page ID */
  116.                   MPFROMHWND(hNewFrame));  /* Window within page */
  117.     /* Set tab text */
  118.     WinSendDlgItemMsg(hwndDlg, ulForm,
  119.                   BKM_SETTABTEXT,
  120.                   MPFROMLONG(ulPageId),    /* Page ID */
  121.                   MPFROMP(pDescr));        /* Text for tab */
  122.   }  
  123. Set MLE Selection
  124. /*-----(Set selection Multi-Line Entry Field)-----*/
  125. /* Set selection MMEVALUE Multi-Line Entry Field */
  126. WinSendDlgItemMsg(hwndDlg, MMEVALUE,
  127.                   MLM_SETSEL,
  128.                   MPFROMLONG(0),             /* IPT for new anchor */
  129.                   MPFROMLONG( (LONG)WinSendDlgItemMsg(hwndDlg, MMEVALUE,
  130.                               MLM_QUERYTEXTLENGTH ,
  131.                               0, 0) ));      /* IPT for new cursor */
  132. Read Profile into List Box
  133. #include "main.h"
  134. VOID jkLoadLBFromProfile( HWND  hwndDlg,
  135.                           ULONG ulLBObject,
  136.                           HINI  hiniFnc,
  137.                           PSZ   pszAppl );
  138. VOID jkLoadLBFromProfile( HWND  hwndDlg,
  139.                           ULONG ulLBObject,
  140.                           HINI  hiniFnc,
  141.                           PSZ   pszAppl )
  142.   ULONG anUnsignedValue=0;
  143.   PBYTE pBuffer;
  144.   /*---(Read string length from Profile)---*/
  145.   PrfQueryProfileSize( hiniFnc,
  146.                        pszAppl,
  147.                        NULL,
  148.                        &anUnsignedValue);
  149.   anUnsignedValue++;  /* final NULL character */
  150.   if(!DosAllocSharedMem( (PVOID)&pBuffer,
  151.                          NULL,
  152.                          anUnsignedValue,
  153.                          fALLOC|OBJ_GIVEABLE))
  154.     PrfQueryProfileData( hiniFnc,
  155.                          pszAppl,
  156.                          NULL, 
  157.                          (PVOID)pBuffer,
  158.                          &anUnsignedValue );
  159.     while ( strlen(pBuffer) > 0)
  160.     {
  161.       /* Add item sorted ascending MLBAPPL List Box */
  162.       WinSendDlgItemMsg( hwndDlg,
  163.                          ulLBObject,
  164.                          LM_INSERTITEM,
  165.                          MPFROMSHORT(LIT_SORTASCENDING),
  166.                          MPFROMP(pBuffer));  /* Text for new item */
  167.       pBuffer += strlen(pBuffer);
  168.       pBuffer++;
  169.     } /* end while */
  170.     DosFreeMem(pBuffer);
  171. Set WAKuM Icon
  172. VOID   SetWakumIco( CHAR *pWakumIco, HWND hwndDlg, ULONG ulObject );
  173. /*-----------------( Set Wakum Ico )----------------*/
  174. VOID SetWakumIco( CHAR *pWakumIco, HWND hwndDlg, ULONG ulObject )
  175.   HPOINTER hptr;
  176.   hptr=(HPOINTER)WinLoadFileIcon(pWakumIco, FALSE);
  177.   WinSendDlgItemMsg( hwndDlg,
  178.                      ulObject,
  179.                      SM_SETHANDLE,
  180.                      MPFROMLONG(hptr),   /* Icon handle */
  181.                      0 );
  182.   WinInvalidateRect(WinWindowFromID(hwndDlg, ulObject),0,TRUE);
  183. Call Insert Notebook Page
  184. HWND hNewFrame;
  185. /* Set major tab size for the Notebook page */
  186. WinSendDlgItemMsg( hwndDlg,
  187.                    /notebook_controls_id/,   /* set value */
  188.                    BKM_SETDIMENSIONS,
  189.                    MPFROM2SHORT(MAJOR_TAB_WITH,        /* Width =80 */
  190.                                 MAJOR_TAB_HIGHT),      /* Hight =25 */
  191.                    MPFROMLONG(BKA_MAJORTAB) );
  192. hNewFrame = OpenS7NBOPT(hwndDlg, 0);
  193. InsertNbkPage( hNewFrame, hwndDlg, /notebook_controls_id/, "Editor" );
  194. Data Convertion
  195. Integer to Character
  196. /*------(Integer to Character)------*/
  197. ltoa(anIntegerValue, aTextValue, 10);
  198. Character to Integer
  199. /*---(Character to Integer)---*/
  200. anIntegerValue=atol(aTextValue);
  201. Work with files
  202. Load system icon
  203. /*----------------(Load system icon)----------------*/
  204. anUnsignedValue=(ULONG)WinQuerySysPointer(HWND_DESKTOP,
  205.                                           SPTR_ARROW,
  206.                                           FALSE);
  207. Load file icon
  208. /*-------------------(Load file icon)-------------------*/
  209. anUnsignedValue=(ULONG)WinLoadFileIcon(aTextValue, FALSE);
  210. Load resource bitmap
  211. /*-------------(Load resource bitmap)--------------*/
  212. hBitmap=GpiLoadBitmap(hps, NULLHANDLE, BMP_ID, 0, 0);
  213. Load resource icon
  214. /*--------------(Load resource icon)---------------*/
  215. hptr=(LONG)WinLoadPointer(HWND_DESKTOP, 0 , ICON_ID);
  216. Load resource string
  217. /*----------(Load resource string)-----------*/
  218. WinLoadString(hwndFrame, NULLHANDLE, STRING_ID,
  219.               sizeof(aTextValue), aTextValue);
  220. Load system bitmap
  221. /*--------------(Load system bitmap)---------------*/
  222. anUnsignedValue=(ULONG)WinGetSysBitmap(HWND_DESKTOP,
  223.                                        SBMP_SYSMENU);
  224. Release bitmap
  225. /*---(Release bitmap)---*/
  226. GpiDeleteBitmap(hBitmap);
  227. Release pointer
  228. /*--(Release pointer)--*/
  229. WinDestroyPointer(hptr);
  230. File save
  231. /*-------------------(File save)--------------------*/
  232. FILEDLG FileDlg;
  233. char pszTitle[]="File Save As";
  234. char pszFullFile[]="*.*";
  235. HWND    hwndFileDlg;
  236. memset(&FileDlg, 0, sizeof(FILEDLG));
  237. FileDlg.cbSize=sizeof(FILEDLG);
  238. FileDlg.fl=FDS_HELPBUTTON | FDS_CENTER | FDS_SAVEAS_DIALOG;
  239. FileDlg.pszTitle=pszTitle;
  240. strcpy(FileDlg.szFullFile, pszFullFile);
  241. hwndFileDlg = WinFileDlg(HWND_DESKTOP, hwndFrame, &FileDlg);
  242. if ( FileDlg.lReturn != DID_CANCEL & hwndFileDlg != NULLHANDLE ) 
  243. File open
  244. /*-------------------(File open)--------------------*/
  245. FILEDLG FileDlg;
  246. char pszTitle[]="File Open";
  247. char pszFullFile[]="*";
  248. HWND    hwndFileDlg;
  249. memset(&FileDlg, 0, sizeof(FILEDLG));
  250. FileDlg.cbSize=sizeof(FILEDLG);
  251. FileDlg.fl=FDS_HELPBUTTON | FDS_CENTER | FDS_OPEN_DIALOG;
  252. FileDlg.pszTitle=pszTitle;
  253. strcpy(FileDlg.szFullFile, pszFullFile);
  254. hwndFileDlg = WinFileDlg(HWND_DESKTOP, hwndFrame, &FileDlg);
  255. if ( FileDlg.lReturn != DID_CANCEL & hwndFileDlg != NULLHANDLE ) 
  256. Window management
  257. Close window
  258. /*----------(Close Window)----------*/
  259. WinSendMsg(hwndFrame, WM_CLOSE, 0, 0);
  260. Get screen x size
  261. /*------------------(Get screen x size)------------------*/
  262. anIntegerValue=WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
  263. Get screen y size
  264. /*------------------(Get screen y size)------------------*/
  265. anIntegerValue=WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
  266. Get window size/position
  267. /*--(Get window size/position)--*/
  268. WinQueryWindowPos(hwndFrame, &swp);
  269. Hide window
  270. /*-------(Hide window)-------*/
  271. WinShowWindow(hwndFrame, FALSE);
  272. Set window size/position
  273. /*-------------------(Set window size/position)-------------------*/
  274. WinSetWindowPos(hwndFrame, 0, 10, 10, 400, 400, SWP_MOVE | SWP_SIZE);
  275. Set window title
  276. /*---------(Set window title)---------*/
  277. strcpy(aTextValue,"new title");
  278. WinSetWindowText(hwndFrame, aTextValue);
  279. Show window
  280. /*-------(Show window)-------*/
  281. WinShowWindow(hwndFrame, TRUE);
  282. Make window active
  283. /*----------(Make window active)----------*/
  284. WinSetActiveWindow(HWND_DESKTOP, hwndFrame);
  285. Maximize window
  286. /*--------------(Maximize window)--------------*/
  287. WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, 0, 0,
  288.                 SWP_ZORDER | SWP_MAXIMIZE);
  289. Minimize window
  290. /*--------------(Minimize window)--------------*/
  291. WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, 0, 0,
  292.                 SWP_ZORDER | SWP_MINIMIZE);
  293. Set window focus
  294. /*------(Set window's focus)------*/
  295. WinSetFocus(HWND_DESKTOP, hwndFrame);
  296. Message box
  297. Cancel
  298. /*---------------------( Cancel )-------------------*/
  299. /* ULONG ulResponse=0; */
  300. ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP, 
  301.                                 hwndFrame,
  302.                                 "Message",
  303.                                 "Title",
  304.                                 256,
  305.                                 MB_CANCEL | MB_INFORMATION | MB_MOVEABLE);
  306. Enter
  307. /*---------------------( Enter )--------------------*/
  308. /* ULONG ulResponse=0; */
  309. ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP, 
  310.                                 hwndFrame,
  311.                                 "Message",
  312.                                 "Title",
  313.                                 256,
  314.                                 MB_ENTER | MB_INFORMATION | MB_MOVEABLE);
  315. Plain
  316. /*-----------------(Plain message)------------------*/
  317. WinMessageBox(HWND_DESKTOP, 
  318.               hwndFrame,
  319.               "Message",
  320.               "Title", 
  321.               256,
  322.               MB_OK | MB_INFORMATION | MB_MOVEABLE);
  323. OK/Cancel
  324. /*--------------------(OK/Cancel)-------------------*/
  325. /* ULONG ulResponse=0; */
  326. ulResponse=(ULONG)WinMessageBox( HWND_DESKTOP, 
  327.                                  hwndFrame,
  328.                                  "Message",
  329.                                  "Title",
  330.                                  256,
  331.                                  MB_OKCANCEL | MB_INFORMATION | MB_MOVEABLE);
  332. if ( ulResponse == MBID_OK )
  333. } else {
  334. } /* end if */
  335. Abort/Retry/Ignore
  336. /*------------------(Ignore/Cancel)-----------------*/
  337. /* ULONG ulResponse=0; */
  338. ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP, 
  339.                                 hwndFrame,
  340.                                 "Message",
  341.                                 "Title",
  342.                                 256,
  343.                                 MB_ABORTRETRYIGNORE | MB_INFORMATION | MB_MOVEABLE);
  344. if ( ulResponse == MBID_ABORT )
  345. } else if ( ulResponse == MBID_RETRY ) {
  346. } else {
  347. } /* end if */
  348. Enter/Cancel
  349. /*-------------------(Enter/Cancel)-----------------*/
  350. /* ULONG ulResponse=0; */
  351. ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP, 
  352.                                 hwndFrame,
  353.                                 "Message",
  354.                                 "Title",
  355.                                 256,
  356.                                 MB_ENTERCANCEL | MB_INFORMATION | MB_MOVEABLE);
  357. if ( ulResponse == MBID_ENTER )
  358. } else {
  359. } /* end if */
  360. Retry/Cancel
  361. /*-------------------(Retry/Cancel)-----------------*/
  362. /* ULONG ulResponse=0; */
  363. ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP, 
  364.                                 hwndFrame,
  365.                                 "Message",
  366.                                 "Title",
  367.                                 256,
  368.                                 MB_RETRYCANCEL | MB_INFORMATION | MB_MOVEABLE);
  369. if ( ulResponse == MBID_RETRY )
  370. } else {
  371. } /* end if */
  372. Yes/No
  373. /*---------------------(Yes/No)---------------------*/
  374. /* ULONG ulResponse=0; */
  375. ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP, 
  376.                                 hwndFrame,
  377.                                 "Message",
  378.                                 "Title",
  379.                                 256,
  380.                                 MB_YESNO | MB_INFORMATION | MB_MOVEABLE);
  381. if ( ulResponse == MBID_YES )
  382. } else {
  383. } /* end if */
  384. Yes/No/Cancel
  385. /*------------------(Yes/No/Cancel)-----------------*/
  386. /* ULONG ulResponse=0; */
  387. ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP, 
  388.                                 hwndFrame,
  389.                                 "Message",
  390.                                 "Title",
  391.                                 256,
  392.                                 MB_YESNOCANCEL | MB_INFORMATION | MB_MOVEABLE);
  393. if ( ulResponse == MBID_YES )
  394. } else if ( ulResponse == MBID_NO ) {
  395. } else {
  396. } /* end if */
  397. Help index
  398. /*-----------------(Open Help index)----------------*/
  399. WinSendMsg(hwndFrame, WM_SYSCOMMAND, 
  400.            MPFROMSHORT(SC_HELPINDEX), 0);
  401. General help
  402. /*---------------(Open General help)----------------*/
  403. WinSendMsg(hwndFrame, WM_SYSCOMMAND,
  404.            MPFROMSHORT(SC_HELPEXTENDED), 0);
  405. Using help
  406. /*-----------------(Open Using help)----------------*/
  407. WinSendMsg(pMainFormInfo->hwndHelpInstance,
  408.            HM_DISPLAY_HELP, 0, 0);
  409. Miscellaneous
  410. /*----(Beep freq dur)----*/
  411. /* ULONG  freq; */
  412. /* ULONG  dur;  */
  413. /* APIRET ulRC  */
  414. freq = 1000  /* Hz       */
  415. dur  = 200   /* millisec */
  416. ulRC = DosBeep(freq, dur);
  417. Clipboard - Get text
  418. /*-------------(Get Clipboard text)------------*/
  419. WinOpenClipbrd(0);
  420. anIntegerValue = WinQueryClipbrdData(0, CF_TEXT);
  421. strcpy(aTextValue, (PBYTE)anIntegerValue);
  422. WinCloseClipbrd(0);
  423. Clipboard - Set bitmap
  424. /*----------(Set Clipboard bitmap)-----------*/
  425. WinOpenClipbrd(0);
  426. WinSetClipbrdData(0, (ULONG)hbm, CF_BITMAP, 0L);
  427. WinCloseClipbrd(0);
  428. Clipboard - Get bitmap
  429. /*------(Get Clipboard bitmap)-------*/
  430. WinOpenClipbrd(0);
  431. hbm=WinQueryClipbrdData(0, CF_BITMAP);
  432. WinCloseClipbrd(0);
  433. Timer - Start
  434. /*-------------------(Start timer)------------------*/
  435. /* duration in 1/1000 secs */
  436. WinStartTimer(0, hwndFrame, ID_FORMTIMER, anUnsignedValue);
  437. Timer - Stop
  438. /*-------------(Stop timer)------------*/
  439. WinStopTimer(0, hwndFrame, ID_FORMTIMER);
  440. Get Date/Time
  441. /*------------(Get Date/Time)-----------*/
  442.   DATETIME DateTime;
  443.   DosGetDateTime(&DateTime);
  444. Pop-up menu
  445. /*-------------(Pop-up menu)------------*/
  446.   HWND   hwndPopup;
  447.   POINTL ptlPoint;
  448.   WinQueryPointerPos(HWND_DESKTOP, &ptlPoint);
  449.   hwndPopup=WinLoadMenu(hwndFrame, 0, 256);
  450.   WinPopupMenu(HWND_DESKTOP,
  451.                hwndFrame,
  452.                hwndPopup,
  453.                ptlPoint.x, ptlPoint.y,
  454.                0,
  455.                PU_NONE | PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 |
  456.                PU_HCONSTRAIN | PU_VCONSTRAIN);
  457. Set changed fllag off
  458. /*-------------(Set changed flag off)------------*/
  459. anUnsignedValue = (ULONG)WinSendDlgItemMsg( hwndDlg,
  460.                        ulObjectID,
  461.                        MLM_SETCHANGED ,
  462.                        MPFROMLONG(FALSE), 0 );
  463. Clipboard - Set text
  464. /*------------(Set Clipboard text)-----------*/
  465.   PBYTE pByte=0;
  466.   WinOpenClipbrd(0);
  467.   WinEmptyClipbrd(0);
  468.   if(!DosAllocSharedMem((PVOID)&pByte, NULL, strlen(aTextValue), fALLOC|OBJ_GIVEABLE)){
  469.      strcpy(pByte, aTextValue);
  470.      WinSetClipbrdData(0, (ULONG)pByte, CF_TEXT, CFI_POINTER);
  471.   }/* end if */
  472.   WinCloseClipbrd(0);
  473. Clipboard - Copy to
  474. /*---------------(Copy to Clipboard)--------------*/
  475. /* Copy selected to clipboard */
  476. WinSendDlgItemMsg( hwndDlg,
  477.                    ulObjectID,
  478.                    MLM_COPY ,
  479.                    0, 0 );
  480. Clipboard - Paste from
  481. /*---------------(Paste from clipboard)--------------*/
  482. WinSendDlgItemMsg( hwndDlg,
  483.                    ulObjectID,
  484.                    MLM_PASTE ,
  485.                    0, 0 );
  486. Clipboard - Cut to
  487. /*---------------(Cut to clipboard)--------------*/
  488. WinSendDlgItemMsg( hwndDlg,
  489.                    ulObjectId,
  490.                    MLM_CUT ,
  491.                    0, 0 );
  492. Font dialog
  493. /*-------------(Font dialog)------------*/
  494. /* Event Clicked/selected - ~Font... S31PBFONT */
  495. /*-------------(Font dialog)------------*/
  496. HPS     hpsScreen;
  497. FONTDLG pfdFontdlg;
  498. HWND    hwndFontDlg;
  499. char    szFamilyname[255];
  500. CHAR    szMsg[255]="";
  501. strcpy( pS31COLORFormInfo->szLastFont, pS31COLORFormInfo->szCurrFont );
  502. memset(&pfdFontdlg, 0, sizeof(FONTDLG));
  503. hpsScreen = WinGetPS(hwndFrame);
  504. pfdFontdlg.cbSize = sizeof(FONTDLG);
  505. pfdFontdlg.hpsScreen = hpsScreen;
  506. /* szFamilyname[0] = '\0'; */
  507. strcpy( szFamilyname,
  508.         strchr( pS31COLORFormInfo->szCurrFont, '.' ) + 1 );
  509. pfdFontdlg.pszFamilyname  = szFamilyname;
  510. pfdFontdlg.usFamilyBufLen = sizeof(szFamilyname);
  511. pfdFontdlg.fxPointSize = MAKEFIXED(atol(pS31COLORFormInfo->szCurrFont), 0);
  512. pfdFontdlg.fl = FNTS_HELPBUTTON | FNTS_CENTER;
  513. pfdFontdlg.clrFore = CLR_BLACK;
  514. pfdFontdlg.clrBack = CLR_WHITE;
  515. hwndFontDlg = WinFontDlg(HWND_DESKTOP, hwndFrame, &pfdFontdlg);
  516. if ( hwndFontDlg && (pfdFontdlg.lReturn == DID_OK ))
  517.   sprintf( pS31COLORFormInfo->szCurrFont, "%d.%s",
  518.            pfdFontdlg.fxPointSize/65535,
  519.            pfdFontdlg.fAttrs.szFacename );
  520.   /* Set window font S3TXTF text field */
  521.   WinSetPresParam( WinWindowFromID( hwndDlg, S3TXTF ),
  522.                    PP_FONTNAMESIZE,
  523.                    strlen( pS31COLORFormInfo->szCurrFont ) + 1,
  524.                    pS31COLORFormInfo->szCurrFont );
  525.   /* Set item text S3TXTF text field */
  526.   WinSetDlgItemText( hwndDlg, S3TXTF, SAMPLE_TEXT );
  527.   /* Set item text S31EFFONT Entry Field */
  528.   WinSetDlgItemText( hwndDlg, S31EFFONT, pS31COLORFormInfo->szCurrFont );
  529.   /* Set window font Container Text */
  530.   WinSetPresParam( WinWindowFromID( pMainFormInfo->hwndDlg,
  531.                                     pMainFormInfo->ulCnrObject ),
  532.                                     PP_FONTNAMESIZE,
  533.                                     strlen(pS31COLORFormInfo->szCurrFont)+1,
  534.                                     pS31COLORFormInfo->szCurrFont );
  535. } /* end if */
  536. WinReleasePS(hpsScreen);
  537. Functions
  538. Set Application Icon
  539. VOID   SetApplIco( CHAR *pApplIco, HWND hwndDlg, ULONG ulObject );
  540. /*--------------(Set Application Icon)--------------*/
  541. VOID SetApplIco( CHAR *pApplIco, HWND hwndDlg, ULONG ulObject )
  542.   HPOINTER hptr;
  543.   hptr=(HPOINTER)WinLoadFileIcon(pApplIco, FALSE);
  544.   WinSendDlgItemMsg(hwndDlg, ulObject,
  545.                   SM_SETHANDLE,
  546.                   MPFROMLONG(hptr),   /* Icon handle */
  547.                   0);
  548.   WinInvalidateRect(WinWindowFromID(hwndDlg, ulObject),0,TRUE);
  549. Get Local Time String
  550. #include "time.h"
  551. #define  MAXSIZE     26
  552. CHAR *GetStrTime( CHAR *pZeit );
  553. /*---------------( Zeit als Kette )----------------*/
  554. CHAR *GetStrTime( CHAR *pZeit )
  555.   time_t  ttZeit;
  556.   struct tm *pstmZeit;
  557.   time( &ttZeit );
  558.   pstmZeit = localtime( (const time_t *) &ttZeit );
  559.   strftime( pZeit, MAXSIZE, "%d %b %Y / %H:%M:%S", pstmZeit );
  560.   return pZeit;
  561. Set MLE Selection
  562. CHAR *SetMLESelection( HWND hwndDlg, ULONG ulMEdit,
  563.                        PBYTE pAnchor, PBYTE pText, 
  564.                        LONG lTextLength );
  565. /*--------------------( MLE Selection for the found string)------------------*/
  566. CHAR *SetMLESelection( HWND hwndDlg, ULONG ulMEdit,
  567.                        PBYTE pAnchor, PBYTE pText, 
  568.                        LONG lTextLength )
  569.   ULONG ulSelBegin = 0;
  570.   ULONG ulSelEnd = 0;
  571.   ulSelBegin = (ULONG)(pText - pAnchor);
  572.   ulSelEnd   = ulSelBegin + (ULONG)lTextLength;
  573.   /* Set selection MMEEDIT Multi-Line Entry Field */
  574.   WinSendDlgItemMsg(hwndDlg,
  575.                     ulMEdit,
  576.                     MLM_SETSEL,
  577.                     MPFROMLONG(ulSelBegin),  /* IPT for new anchor */
  578.                     MPFROMLONG(ulSelEnd));   /* IPT for new cursor */
  579.   return (pText + lTextLength);
  580. Arguments
  581. GetPathName( pMainFormInfo->szHomeDir, argv[0] );
  582. if ( argc > 1) {
  583.   strcpy( pMainFormInfo->szFile, argv[1] );
  584.   if( ChangeDir(pMainFormInfo->szPath, pMainFormInfo->szFile) ) {
  585.     sprintf(pMainFormInfo->szFile, "%s\\%s",
  586.             pMainFormInfo->szHomeDir, STD_FILE_NAME );
  587.     strcpy(pMainFormInfo->szPath, pMainFormInfo->szHomeDir);
  588. } else {
  589.   strcpy( pMainFormInfo->szPath, pMainFormInfo->szHomeDir );
  590.   sprintf(pMainFormInfo->szFile, "%s\\%s",
  591.           pMainFormInfo->szHomeDir, STD_FILE_NAME );
  592. } /* end if */
  593. Get Path Name
  594. CHAR   *GetPathName( CHAR *pPath, CHAR *pFile );
  595. /*-----------------( Get Path Name )----------------*/
  596. CHAR *GetPathName( CHAR *pPath, CHAR *pFile )
  597.     CHAR szDrive[_MAX_DRIVE]="",
  598.          szDir[_MAX_DIR]="",
  599.          szFName[_MAX_FNAME]="",
  600.          szExt[_MAX_EXT]="";
  601.     _splitpath( pFile, szDrive, szDir, szFName, szExt );
  602.     szDir[strlen(szDir)-1] = 0;
  603.     sprintf( pPath, "%s%s", szDrive, szDir );
  604.     return ( pPath );
  605. Open File with Action
  606.   HWND hwndFileDlg;
  607.   FILEDLG FileDlg;
  608.   char pszTitle[]="GREED: Open file";
  609.   char pszFullFile[ CCHMAXPATH ];
  610.   sprintf( pszFullFile, "%s\\*", pMainFormInfo->szPath );
  611.   memset(&FileDlg, 0, sizeof(FILEDLG));
  612.   FileDlg.cbSize=sizeof(FILEDLG);
  613.   FileDlg.fl=FDS_HELPBUTTON | FDS_CENTER | FDS_OPEN_DIALOG;
  614.   FileDlg.pszTitle=pszTitle;
  615.   strcpy(FileDlg.szFullFile, pszFullFile);
  616.   hwndFileDlg = WinFileDlg(HWND_DESKTOP, hwndFrame, &FileDlg);
  617.   if ( FileDlg.lReturn != DID_CANCEL & hwndFileDlg != NULLHANDLE ) 
  618.     /*------( Open File Action )------*/
  619. Change Directory
  620. APIRET ChangeDir( CHAR *pPath, CHAR *pCurrFile );
  621. /*-----------------( ChangeDir )----------------*/
  622. APIRET ChangeDir( CHAR *pPath, CHAR *pCurrFile )
  623.     CHAR   szDrive[_MAX_DRIVE]="c:",
  624.            szDir[_MAX_DIR]="",
  625.            szFName[_MAX_FNAME]="",
  626.            szExt[_MAX_EXT]="";
  627.     APIRET ulRC = 0;
  628.     ULONG  ulDrive;
  629.     strupr( pCurrFile );
  630.     _splitpath( pCurrFile, szDrive, szDir, szFName, szExt );
  631.     ulDrive = (ULONG)(szDrive[0] - 'A' + 1 );
  632.     if ( !(ulRC=DosSetDefaultDisk( ulDrive )) ) {
  633.       sprintf( pPath, "%s%s", szDrive, szDir );
  634.       szDir[strlen(szDir)-1] = 0;
  635.       if (strlen(szDir))
  636.         ulRC = DosSetCurrentDir( szDir );
  637.     }
  638.     if ( !ulRC ) {
  639.       sprintf( pPath, "%s%s", szDrive, szDir );
  640.       if ( strlen( pPath ) == 3 )
  641.         pPath[strlen(pPath)-1] = 0;
  642.     }
  643.     return ( ulRC );
  644. C Constructs
  645. if - else
  646. if (  ) {
  647. } /* end if */
  648. else {
  649. }/* end else  */
  650. switch
  651. /* ULONG ulCondition */
  652. switch (ulCondition) {
  653.    case 1  : anUnsignedValue=1;
  654.              break;
  655.    case 2  : anUnsignedValue=2;
  656.              break;
  657.    default : anUnsignedValue=0;
  658.              break;
  659. } /* end switch */
  660. do while
  661. } while(anUnsignedValue<100);
  662. while
  663. while( condition )
  664. Profile
  665. Open Profile
  666. if ( (pMainFormInfo->hini = PrfOpenProfile(pMainFormInfo->hab,
  667.                                            EXTEC_INI)) == NULLHANDLE ) {
  668.   /*-------(Initialization-file create error)--------*/
  669.   WinMessageBox(HWND_DESKTOP, 
  670.                 hwndFrame,
  671.                 "Initialization-file create error. Execution finished.",
  672.                 "Extended Template Controller", 
  673.                 256,
  674.                 MB_OK | MB_INFORMATION | MB_MOVEABLE);
  675.   exit(1);
  676. } /* end if */
  677. Write String
  678. /*-------(Write string to Profile)-------*/
  679. PrfWriteProfileString( pMainFormInfo->hini,
  680.                        EXTEC_APPL,
  681.                        LAST_FNC,
  682.                        pMainFormInfo->szFncFile );
  683. Close Profile
  684. /*-----(Close the Profile file)-----*/
  685. PrfCloseProfile( pMainFormInfo->hini );
  686. Query Integer
  687. /*-----------(Read string from Profile)------------*/
  688. anUnsignedValue = (ULONG)PrfQueryProfileInt(hini,
  689.                                             APPL_NAME,
  690.                                             KEY_NAME,
  691.                                             lDefault);
  692. Write Data
  693. /*-------(Write string to Profile)-------*/
  694. PrfWriteProfileData( pMainFormInfo->hini,
  695.                      EXTEC_APPL,
  696.                      CNR_BCOLOR,
  697.                      anUnsignedValue,
  698.                      sizeof(ULONG) );
  699. Query Size
  700. /*---(Read string length from Profile)---*/
  701. PrfQueryProfileSize(pMainFormInfo->hiniFnc,
  702.                       pMainFormInfo->pmrcAppl,
  703.                       pMainFormInfo->pmrcKey,
  704.                       &anUnsignedValue);
  705. Query application names
  706. /*----------(Query all application names)----------*/
  707. PrfQueryProfileSize(pMainFormInfo->hiniFnc,
  708.                     NULL,
  709.                     NULL,
  710.                     &anUnsignedValue);
  711. anUnsignedValue++;  /* final NULL character */
  712. pPrfBuffer = (PBYTE)malloc( (size_t)anUnsignedValue );
  713. PrfQueryProfileData(pMainFormInfo->hiniFnc,
  714.                     NULL,
  715.                     NULL, 
  716.                     (PVOID)pPrfBuffer,
  717.                     &anUnsignedValue);
  718. Query String
  719. /*---(Read string from Profile)---*/
  720. PrfQueryProfileString( pMainFormInfo->hini,
  721.                        EXTEC_APPL,
  722.                        CODE_FILES,
  723.                        pszDefault,
  724.                        pBuffer,
  725.                        MAX_BUFER_LEN);
  726. Control Program functions
  727. DosAllocSharedMem
  728. if(!DosAllocSharedMem((PVOID)&pBuffer,
  729.                       NULL,
  730.                       ulBufLen,
  731.                       fALLOC|OBJ_GIVEABLE))
  732. if (pBuffer) DosFreeMem(pBuffer);
  733. DosFindFirst
  734. VOID jkSearchFiles( HWND hwndDlg,
  735.                     ULONG ulObject,
  736.                     PSZ pszFileSpec );
  737. /*----------(Search for specified files)----------*/
  738. VOID jkSearchFiles( HWND hwndDlg,
  739.                     ULONG ulObject,
  740.                     PSZ pszFileSpec )
  741.   HDIR         hdirFindHandle = HDIR_SYSTEM;
  742.   FILEFINDBUF3 FindBuffer     = {0};
  743.   ULONG        ulResultBufLen = sizeof(FILEFINDBUF3);
  744.   ULONG        ulFindCount    = 1;
  745.   APIRET       rc             = NO_ERROR;
  746.   rc = DosFindFirst( pszFileSpec,
  747.                      &hdirFindHandle,
  748.                      FILE_NORMAL,
  749.                      &FindBuffer,
  750.                      ulResultBufLen,
  751.                      &ulFindCount,
  752.                      FIL_STANDARD );
  753.   while (rc != ERROR_NO_MORE_FILES)
  754.     ulFindCount = 1;
  755.     rc = DosFindNext( hdirFindHandle,
  756.                       &findBuffer,
  757.                       ulResultBufLen,
  758.                       &ulFindCount );
  759.     if (rc = NO_ERROR || rc = ERROR_NO_MORE_FILES)
  760.     {
  761.       /* Add item sorted ascending 1013 List Box */
  762.       WinSendDlgItemMsg( hwndDlg,
  763.                          ulObject,
  764.                          LM_INSERTITEM,
  765.                          MPFROMSHORT(LIT_SORTASCENDING),
  766.                          MPFROMP(FindBuffer.achName) );  /* Text for new item */
  767.     }
  768. DosAllocMem
  769. if(!DosAllocMem( (PVOID)&pBuffer,
  770.                   ulBufLen,
  771.                   PAG_WRITE | PAG_COMMIT ))
  772. if (pBuffer) DosFreeMem(pBuffer);
  773. PM functions
  774. Get selected text MLE
  775. LONG  lStarSel=0, lEndSel=0;
  776. PBYTE pText;
  777. /* Get offset selection start MMEEDIT Multi-Line Entry Field */
  778. lStartSel=(LONG)WinSendDlgItemMsg( hwndDlg,
  779.                   MMEEDIT,
  780.                   MLM_QUERYSEL ,
  781.                   MPFROMLONG(MLFQS_MINSEL),
  782.                   0 );
  783. /* Get offset of selection end MMEEDIT Multi-Line Entry Field */
  784. lEndSel=(LONG)WinSendDlgItemMsg( hwndDlg,
  785.                   MMEEDIT,
  786.                   MLM_QUERYSEL ,
  787.                   MPFROMLONG(MLFQS_MAXSEL),
  788.                   0 );
  789. if ( lEndSel-lStartSel )
  790.   /*---------------(Allocate memory)---------------*/
  791.   pText = (PBYTE)malloc( (size_t)anUnsignedValue );
  792.   if ( pText )
  793.     /* The helper function MLEGetItemText (in MAIN.C) gets MLE text */
  794.     MLEGetItemText( hwndDlg,
  795.                     MMEEDIT,
  796.                     lStartSel,         /* Starting from the beginning */
  797.                     lEndSel-lStartSel, /* Until the end of the text   */
  798.                     &pText );          /* Ptr for text buffer area    */
  799.     free( pText );
  800. } (* end if */
  801.