home *** CD-ROM | disk | FTP | other *** search
OS/2 INI File | 1996-12-15 | 33.1 KB | 801 lines |
- Graphic
- Load and paint resource bitmap
- /*---( Load and paint a resource bitmap )---*/
- HPS hps;
- HBITMAP hbm;
- hps=WinGetPS(hwndDlg);
- hbm=GpiLoadBitmap(hps, 0, 1, 0L, 0L);
- WinReleasePS(hps);
- /* Set graphic handle #1 MPICTURE Bitmap */
- WinSendDlgItemMsg( hwndDlg,
- MPICTURE,
- SM_SETHANDLE,
- MPFROMLONG(hbm), 0);
- WinInvalidateRect(WinWindowFromID(hwndDlg, MPICTURE),0,TRUE);
- C Functions
- sprintf
- sprintf( aTextValue, "Selected item: %d", anIntegerValue );
- malloc
- /*---------------(Allocate memory)---------------*/
- pBuffer = (PBYTE)malloc( (size_t)anUnsignedValue );
- if ( pBuffer )
- free(pBuffer );
- fopen
- FILE *readfile;
- if ((readfile = fopen( pMainFormInfo->szImportFile, "r" )))
- } else {
- } /* end if */
- _splitpath
- /*---------( Get Backup of Current File )--------*/
- CHAR *GetNewExtent( CHAR *pPath, CHAR *pFile, CHAR *pExt )
- CHAR szDrive[_MAX_DRIVE]="",
- szDir[_MAX_DIR]="",
- szFName[_MAX_FNAME]="",
- szExt[_MAX_EXT]="";
- _splitpath( pFile, szDrive, szDir, szFName, szExt );
- sprintf( pPath, "%s%s%s%s", szDrive, szDir, szFName, pExt );
- return ( pPath );
- Container Methods
- Container Methods
- Remove all container records
- /*--------(Remove all Container recordss)--------*/
- WinSendDlgItemMsg( pMainFormInfo->hwndDlg,
- pMainFormInfo->ulCnrObject,
- CM_REMOVERECORD,
- NULL, /* array of reference records */
- MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE)); /* delete 1 record */
- Allocate container records
- /************************************************/
- /* Allocate (ulItems) records at once - */
- /* CM_ALLOCRECORD returns them in a linked list */
- /************************************************/
- pRecord=(PVOID)WinSendDlgItemMsg(hwndDlg,
- ulCnrObject,
- CM_ALLOCRECORD,
- MPFROMLONG(sizeof(*pRecord)-sizeof(MINIRECORDCORE)+32), /* Bytes of additional data */
- MPFROMLONG(ulItems)); /* Number of records */
- Add a container item
- /* Add a container record to end MCOTSO Container */
- PMAIN_MCOTSO_REC pRecord; /* Pointer to cnr item. */
- /* IMPORTANT!!!! Manually replace MAIN with the form name */
- /* This pRecord typedef is contained in the .H for this form */
- RECORDINSERT RecordInsert;
- /* IMPORTANT!!! we allocate 32 extra bytes for the pszIcon string */
- /* We must allocate more than that if we have any extra PSZ members */
- /* as columns */
- pRecord=(PVOID)WinSendDlgItemMsg(hwndDlg, MCOTSO,
- CM_ALLOCRECORD,
- MPFROMLONG(sizeof(*pRecord)-sizeof(MINIRECORDCORE)+32), /* Bytes of additional data */
- MPFROMLONG(1)); /* Number of records */
- pRecord->Record.cb=sizeof(MINIRECORDCORE);
- pRecord->Record.flRecordAttr=0;
- pRecord->Record.hptrIcon=WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE);
- pRecord->Record.pszIcon=(PBYTE)pRecord+sizeof(*pRecord);
- strcpy(pRecord->Record.pszIcon,aTextValue);
- /* IMPORTANT!!! initiaize other members here if they exist */
- /* add the item to the container */
- RecordInsert.cb=sizeof(RECORDINSERT);
- RecordInsert.pRecordOrder=(PRECORDCORE)CMA_END;/* add to the end */
- RecordInsert.pRecordParent=(PRECORDCORE)0; /* not a child record */
- RecordInsert.zOrder=CMA_TOP;
- RecordInsert.cRecordsInsert=1;
- RecordInsert.fInvalidateRecord=TRUE; /* repaint the record */
- WinSendDlgItemMsg(hwndDlg, MCOTSO,
- CM_INSERTRECORD,
- MPFROMP(pRecord),
- MPFROMP(&RecordInsert));
- My Components
- WAKuM Icon
- /*---------------(Set WAKuM Icon Name)---------------*/
- sprintf( pMainFormInfo->szWakumIco, "%s\\%s",
- pMainFormInfo->szHomeDir, WAKUM_ICO );
- Set Graphic Handle
- /* Set graphic handle #1WAKUMICO Icon */
- SetWakumIco( pMainFormInfo->szWakumIco,
- hwndDlg,
- WAKUMICO );
- Insert Notebook Page
- VOID InsertNbkPage( HWND hNewFrame, HWND hwndDlg,
- ULONG ulForm, CHAR *pDescr );
- /*-------------------( NOTEBOOK )-------------------*/
- VOID InsertNbkPage( HWND hNewFrame, HWND hwndDlg, ULONG ulForm, CHAR *pDescr )
- ULONG ulPageId; /* Page identifier */
- /* Add page with major tab ulForm Notebook */
- ulPageId = (ULONG) WinSendDlgItemMsg(hwndDlg, ulForm,
- BKM_INSERTPAGE ,
- MPFROMLONG(0),
- MPFROM2SHORT(BKA_MAJOR|BKA_STATUSTEXTON|BKA_AUTOPAGESIZE,
- BKA_LAST));
- if (ulPageId) {
- /* Associate window within page */
- WinSetOwner(hNewFrame, WinWindowFromID(hwndDlg, ulForm));
- WinSetParent(hNewFrame, WinWindowFromID(hwndDlg, ulForm),FALSE);
- WinSendDlgItemMsg(hwndDlg, ulForm,
- BKM_SETPAGEWINDOWHWND,
- MPFROMLONG(ulPageId), /* Page ID */
- MPFROMHWND(hNewFrame)); /* Window within page */
- /* Set tab text */
- WinSendDlgItemMsg(hwndDlg, ulForm,
- BKM_SETTABTEXT,
- MPFROMLONG(ulPageId), /* Page ID */
- MPFROMP(pDescr)); /* Text for tab */
- }
- Set MLE Selection
- /*-----(Set selection Multi-Line Entry Field)-----*/
- /* Set selection MMEVALUE Multi-Line Entry Field */
- WinSendDlgItemMsg(hwndDlg, MMEVALUE,
- MLM_SETSEL,
- MPFROMLONG(0), /* IPT for new anchor */
- MPFROMLONG( (LONG)WinSendDlgItemMsg(hwndDlg, MMEVALUE,
- MLM_QUERYTEXTLENGTH ,
- 0, 0) )); /* IPT for new cursor */
- Read Profile into List Box
- #include "main.h"
- VOID jkLoadLBFromProfile( HWND hwndDlg,
- ULONG ulLBObject,
- HINI hiniFnc,
- PSZ pszAppl );
- VOID jkLoadLBFromProfile( HWND hwndDlg,
- ULONG ulLBObject,
- HINI hiniFnc,
- PSZ pszAppl )
- ULONG anUnsignedValue=0;
- PBYTE pBuffer;
- /*---(Read string length from Profile)---*/
- PrfQueryProfileSize( hiniFnc,
- pszAppl,
- NULL,
- &anUnsignedValue);
- anUnsignedValue++; /* final NULL character */
- if(!DosAllocSharedMem( (PVOID)&pBuffer,
- NULL,
- anUnsignedValue,
- fALLOC|OBJ_GIVEABLE))
- PrfQueryProfileData( hiniFnc,
- pszAppl,
- NULL,
- (PVOID)pBuffer,
- &anUnsignedValue );
- while ( strlen(pBuffer) > 0)
- {
- /* Add item sorted ascending MLBAPPL List Box */
- WinSendDlgItemMsg( hwndDlg,
- ulLBObject,
- LM_INSERTITEM,
- MPFROMSHORT(LIT_SORTASCENDING),
- MPFROMP(pBuffer)); /* Text for new item */
- pBuffer += strlen(pBuffer);
- pBuffer++;
- } /* end while */
- DosFreeMem(pBuffer);
- Set WAKuM Icon
- VOID SetWakumIco( CHAR *pWakumIco, HWND hwndDlg, ULONG ulObject );
- /*-----------------( Set Wakum Ico )----------------*/
- VOID SetWakumIco( CHAR *pWakumIco, HWND hwndDlg, ULONG ulObject )
- HPOINTER hptr;
- hptr=(HPOINTER)WinLoadFileIcon(pWakumIco, FALSE);
- WinSendDlgItemMsg( hwndDlg,
- ulObject,
- SM_SETHANDLE,
- MPFROMLONG(hptr), /* Icon handle */
- 0 );
- WinInvalidateRect(WinWindowFromID(hwndDlg, ulObject),0,TRUE);
- Call Insert Notebook Page
- HWND hNewFrame;
- /* Set major tab size for the Notebook page */
- WinSendDlgItemMsg( hwndDlg,
- /notebook_controls_id/, /* set value */
- BKM_SETDIMENSIONS,
- MPFROM2SHORT(MAJOR_TAB_WITH, /* Width =80 */
- MAJOR_TAB_HIGHT), /* Hight =25 */
- MPFROMLONG(BKA_MAJORTAB) );
- hNewFrame = OpenS7NBOPT(hwndDlg, 0);
- InsertNbkPage( hNewFrame, hwndDlg, /notebook_controls_id/, "Editor" );
- Data Convertion
- Integer to Character
- /*------(Integer to Character)------*/
- ltoa(anIntegerValue, aTextValue, 10);
- Character to Integer
- /*---(Character to Integer)---*/
- anIntegerValue=atol(aTextValue);
- Work with files
- Load system icon
- /*----------------(Load system icon)----------------*/
- anUnsignedValue=(ULONG)WinQuerySysPointer(HWND_DESKTOP,
- SPTR_ARROW,
- FALSE);
- Load file icon
- /*-------------------(Load file icon)-------------------*/
- anUnsignedValue=(ULONG)WinLoadFileIcon(aTextValue, FALSE);
- Load resource bitmap
- /*-------------(Load resource bitmap)--------------*/
- hBitmap=GpiLoadBitmap(hps, NULLHANDLE, BMP_ID, 0, 0);
- Load resource icon
- /*--------------(Load resource icon)---------------*/
- hptr=(LONG)WinLoadPointer(HWND_DESKTOP, 0 , ICON_ID);
- Load resource string
- /*----------(Load resource string)-----------*/
- WinLoadString(hwndFrame, NULLHANDLE, STRING_ID,
- sizeof(aTextValue), aTextValue);
- Load system bitmap
- /*--------------(Load system bitmap)---------------*/
- anUnsignedValue=(ULONG)WinGetSysBitmap(HWND_DESKTOP,
- SBMP_SYSMENU);
- Release bitmap
- /*---(Release bitmap)---*/
- GpiDeleteBitmap(hBitmap);
- Release pointer
- /*--(Release pointer)--*/
- WinDestroyPointer(hptr);
- File save
- /*-------------------(File save)--------------------*/
- FILEDLG FileDlg;
- char pszTitle[]="File Save As";
- char pszFullFile[]="*.*";
- HWND hwndFileDlg;
- memset(&FileDlg, 0, sizeof(FILEDLG));
- FileDlg.cbSize=sizeof(FILEDLG);
- FileDlg.fl=FDS_HELPBUTTON | FDS_CENTER | FDS_SAVEAS_DIALOG;
- FileDlg.pszTitle=pszTitle;
- strcpy(FileDlg.szFullFile, pszFullFile);
- hwndFileDlg = WinFileDlg(HWND_DESKTOP, hwndFrame, &FileDlg);
- if ( FileDlg.lReturn != DID_CANCEL & hwndFileDlg != NULLHANDLE )
- File open
- /*-------------------(File open)--------------------*/
- FILEDLG FileDlg;
- char pszTitle[]="File Open";
- char pszFullFile[]="*";
- HWND hwndFileDlg;
- memset(&FileDlg, 0, sizeof(FILEDLG));
- FileDlg.cbSize=sizeof(FILEDLG);
- FileDlg.fl=FDS_HELPBUTTON | FDS_CENTER | FDS_OPEN_DIALOG;
- FileDlg.pszTitle=pszTitle;
- strcpy(FileDlg.szFullFile, pszFullFile);
- hwndFileDlg = WinFileDlg(HWND_DESKTOP, hwndFrame, &FileDlg);
- if ( FileDlg.lReturn != DID_CANCEL & hwndFileDlg != NULLHANDLE )
- Window management
- Close window
- /*----------(Close Window)----------*/
- WinSendMsg(hwndFrame, WM_CLOSE, 0, 0);
- Get screen x size
- /*------------------(Get screen x size)------------------*/
- anIntegerValue=WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
- Get screen y size
- /*------------------(Get screen y size)------------------*/
- anIntegerValue=WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
- Get window size/position
- /*--(Get window size/position)--*/
- WinQueryWindowPos(hwndFrame, &swp);
- Hide window
- /*-------(Hide window)-------*/
- WinShowWindow(hwndFrame, FALSE);
- Set window size/position
- /*-------------------(Set window size/position)-------------------*/
- WinSetWindowPos(hwndFrame, 0, 10, 10, 400, 400, SWP_MOVE | SWP_SIZE);
- Set window title
- /*---------(Set window title)---------*/
- strcpy(aTextValue,"new title");
- WinSetWindowText(hwndFrame, aTextValue);
- Show window
- /*-------(Show window)-------*/
- WinShowWindow(hwndFrame, TRUE);
- Make window active
- /*----------(Make window active)----------*/
- WinSetActiveWindow(HWND_DESKTOP, hwndFrame);
- Maximize window
- /*--------------(Maximize window)--------------*/
- WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, 0, 0,
- SWP_ZORDER | SWP_MAXIMIZE);
- Minimize window
- /*--------------(Minimize window)--------------*/
- WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, 0, 0,
- SWP_ZORDER | SWP_MINIMIZE);
- Set window focus
- /*------(Set window's focus)------*/
- WinSetFocus(HWND_DESKTOP, hwndFrame);
- Message box
- Cancel
- /*---------------------( Cancel )-------------------*/
- /* ULONG ulResponse=0; */
- ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- "Message",
- "Title",
- 256,
- MB_CANCEL | MB_INFORMATION | MB_MOVEABLE);
- Enter
- /*---------------------( Enter )--------------------*/
- /* ULONG ulResponse=0; */
- ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- "Message",
- "Title",
- 256,
- MB_ENTER | MB_INFORMATION | MB_MOVEABLE);
- Plain
- /*-----------------(Plain message)------------------*/
- WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- "Message",
- "Title",
- 256,
- MB_OK | MB_INFORMATION | MB_MOVEABLE);
- OK/Cancel
- /*--------------------(OK/Cancel)-------------------*/
- /* ULONG ulResponse=0; */
- ulResponse=(ULONG)WinMessageBox( HWND_DESKTOP,
- hwndFrame,
- "Message",
- "Title",
- 256,
- MB_OKCANCEL | MB_INFORMATION | MB_MOVEABLE);
- if ( ulResponse == MBID_OK )
- } else {
- } /* end if */
- Abort/Retry/Ignore
- /*------------------(Ignore/Cancel)-----------------*/
- /* ULONG ulResponse=0; */
- ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- "Message",
- "Title",
- 256,
- MB_ABORTRETRYIGNORE | MB_INFORMATION | MB_MOVEABLE);
- if ( ulResponse == MBID_ABORT )
- } else if ( ulResponse == MBID_RETRY ) {
- } else {
- } /* end if */
- Enter/Cancel
- /*-------------------(Enter/Cancel)-----------------*/
- /* ULONG ulResponse=0; */
- ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- "Message",
- "Title",
- 256,
- MB_ENTERCANCEL | MB_INFORMATION | MB_MOVEABLE);
- if ( ulResponse == MBID_ENTER )
- } else {
- } /* end if */
- Retry/Cancel
- /*-------------------(Retry/Cancel)-----------------*/
- /* ULONG ulResponse=0; */
- ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- "Message",
- "Title",
- 256,
- MB_RETRYCANCEL | MB_INFORMATION | MB_MOVEABLE);
- if ( ulResponse == MBID_RETRY )
- } else {
- } /* end if */
- Yes/No
- /*---------------------(Yes/No)---------------------*/
- /* ULONG ulResponse=0; */
- ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- "Message",
- "Title",
- 256,
- MB_YESNO | MB_INFORMATION | MB_MOVEABLE);
- if ( ulResponse == MBID_YES )
- } else {
- } /* end if */
- Yes/No/Cancel
- /*------------------(Yes/No/Cancel)-----------------*/
- /* ULONG ulResponse=0; */
- ulResponse=(ULONG)WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- "Message",
- "Title",
- 256,
- MB_YESNOCANCEL | MB_INFORMATION | MB_MOVEABLE);
- if ( ulResponse == MBID_YES )
- } else if ( ulResponse == MBID_NO ) {
- } else {
- } /* end if */
- Help index
- /*-----------------(Open Help index)----------------*/
- WinSendMsg(hwndFrame, WM_SYSCOMMAND,
- MPFROMSHORT(SC_HELPINDEX), 0);
- General help
- /*---------------(Open General help)----------------*/
- WinSendMsg(hwndFrame, WM_SYSCOMMAND,
- MPFROMSHORT(SC_HELPEXTENDED), 0);
- Using help
- /*-----------------(Open Using help)----------------*/
- WinSendMsg(pMainFormInfo->hwndHelpInstance,
- HM_DISPLAY_HELP, 0, 0);
- Miscellaneous
- /*----(Beep freq dur)----*/
- /* ULONG freq; */
- /* ULONG dur; */
- /* APIRET ulRC */
- freq = 1000 /* Hz */
- dur = 200 /* millisec */
- ulRC = DosBeep(freq, dur);
- Clipboard - Get text
- /*-------------(Get Clipboard text)------------*/
- WinOpenClipbrd(0);
- anIntegerValue = WinQueryClipbrdData(0, CF_TEXT);
- strcpy(aTextValue, (PBYTE)anIntegerValue);
- WinCloseClipbrd(0);
- Clipboard - Set bitmap
- /*----------(Set Clipboard bitmap)-----------*/
- WinOpenClipbrd(0);
- WinSetClipbrdData(0, (ULONG)hbm, CF_BITMAP, 0L);
- WinCloseClipbrd(0);
- Clipboard - Get bitmap
- /*------(Get Clipboard bitmap)-------*/
- WinOpenClipbrd(0);
- hbm=WinQueryClipbrdData(0, CF_BITMAP);
- WinCloseClipbrd(0);
- Timer - Start
- /*-------------------(Start timer)------------------*/
- /* duration in 1/1000 secs */
- WinStartTimer(0, hwndFrame, ID_FORMTIMER, anUnsignedValue);
- Timer - Stop
- /*-------------(Stop timer)------------*/
- WinStopTimer(0, hwndFrame, ID_FORMTIMER);
- Get Date/Time
- /*------------(Get Date/Time)-----------*/
- DATETIME DateTime;
- DosGetDateTime(&DateTime);
- Pop-up menu
- /*-------------(Pop-up menu)------------*/
- HWND hwndPopup;
- POINTL ptlPoint;
- WinQueryPointerPos(HWND_DESKTOP, &ptlPoint);
- hwndPopup=WinLoadMenu(hwndFrame, 0, 256);
- WinPopupMenu(HWND_DESKTOP,
- hwndFrame,
- hwndPopup,
- ptlPoint.x, ptlPoint.y,
- 0,
- PU_NONE | PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 |
- PU_HCONSTRAIN | PU_VCONSTRAIN);
- Set changed fllag off
- /*-------------(Set changed flag off)------------*/
- anUnsignedValue = (ULONG)WinSendDlgItemMsg( hwndDlg,
- ulObjectID,
- MLM_SETCHANGED ,
- MPFROMLONG(FALSE), 0 );
- Clipboard - Set text
- /*------------(Set Clipboard text)-----------*/
- PBYTE pByte=0;
- WinOpenClipbrd(0);
- WinEmptyClipbrd(0);
- if(!DosAllocSharedMem((PVOID)&pByte, NULL, strlen(aTextValue), fALLOC|OBJ_GIVEABLE)){
- strcpy(pByte, aTextValue);
- WinSetClipbrdData(0, (ULONG)pByte, CF_TEXT, CFI_POINTER);
- }/* end if */
- WinCloseClipbrd(0);
- Clipboard - Copy to
- /*---------------(Copy to Clipboard)--------------*/
- /* Copy selected to clipboard */
- WinSendDlgItemMsg( hwndDlg,
- ulObjectID,
- MLM_COPY ,
- 0, 0 );
- Clipboard - Paste from
- /*---------------(Paste from clipboard)--------------*/
- WinSendDlgItemMsg( hwndDlg,
- ulObjectID,
- MLM_PASTE ,
- 0, 0 );
- Clipboard - Cut to
- /*---------------(Cut to clipboard)--------------*/
- WinSendDlgItemMsg( hwndDlg,
- ulObjectId,
- MLM_CUT ,
- 0, 0 );
- Font dialog
- /*-------------(Font dialog)------------*/
- /* Event Clicked/selected - ~Font... S31PBFONT */
- /*-------------(Font dialog)------------*/
- HPS hpsScreen;
- FONTDLG pfdFontdlg;
- HWND hwndFontDlg;
- char szFamilyname[255];
- CHAR szMsg[255]="";
- strcpy( pS31COLORFormInfo->szLastFont, pS31COLORFormInfo->szCurrFont );
- memset(&pfdFontdlg, 0, sizeof(FONTDLG));
- hpsScreen = WinGetPS(hwndFrame);
- pfdFontdlg.cbSize = sizeof(FONTDLG);
- pfdFontdlg.hpsScreen = hpsScreen;
- /* szFamilyname[0] = '\0'; */
- strcpy( szFamilyname,
- strchr( pS31COLORFormInfo->szCurrFont, '.' ) + 1 );
- pfdFontdlg.pszFamilyname = szFamilyname;
- pfdFontdlg.usFamilyBufLen = sizeof(szFamilyname);
- pfdFontdlg.fxPointSize = MAKEFIXED(atol(pS31COLORFormInfo->szCurrFont), 0);
- pfdFontdlg.fl = FNTS_HELPBUTTON | FNTS_CENTER;
- pfdFontdlg.clrFore = CLR_BLACK;
- pfdFontdlg.clrBack = CLR_WHITE;
- hwndFontDlg = WinFontDlg(HWND_DESKTOP, hwndFrame, &pfdFontdlg);
- if ( hwndFontDlg && (pfdFontdlg.lReturn == DID_OK ))
- sprintf( pS31COLORFormInfo->szCurrFont, "%d.%s",
- pfdFontdlg.fxPointSize/65535,
- pfdFontdlg.fAttrs.szFacename );
- /* Set window font S3TXTF text field */
- WinSetPresParam( WinWindowFromID( hwndDlg, S3TXTF ),
- PP_FONTNAMESIZE,
- strlen( pS31COLORFormInfo->szCurrFont ) + 1,
- pS31COLORFormInfo->szCurrFont );
- /* Set item text S3TXTF text field */
- WinSetDlgItemText( hwndDlg, S3TXTF, SAMPLE_TEXT );
- /* Set item text S31EFFONT Entry Field */
- WinSetDlgItemText( hwndDlg, S31EFFONT, pS31COLORFormInfo->szCurrFont );
- /* Set window font Container Text */
- WinSetPresParam( WinWindowFromID( pMainFormInfo->hwndDlg,
- pMainFormInfo->ulCnrObject ),
- PP_FONTNAMESIZE,
- strlen(pS31COLORFormInfo->szCurrFont)+1,
- pS31COLORFormInfo->szCurrFont );
- } /* end if */
- WinReleasePS(hpsScreen);
- Functions
- Set Application Icon
- VOID SetApplIco( CHAR *pApplIco, HWND hwndDlg, ULONG ulObject );
- /*--------------(Set Application Icon)--------------*/
- VOID SetApplIco( CHAR *pApplIco, HWND hwndDlg, ULONG ulObject )
- HPOINTER hptr;
- hptr=(HPOINTER)WinLoadFileIcon(pApplIco, FALSE);
- WinSendDlgItemMsg(hwndDlg, ulObject,
- SM_SETHANDLE,
- MPFROMLONG(hptr), /* Icon handle */
- 0);
- WinInvalidateRect(WinWindowFromID(hwndDlg, ulObject),0,TRUE);
- Get Local Time String
- #include "time.h"
- #define MAXSIZE 26
- CHAR *GetStrTime( CHAR *pZeit );
- /*---------------( Zeit als Kette )----------------*/
- CHAR *GetStrTime( CHAR *pZeit )
- time_t ttZeit;
- struct tm *pstmZeit;
- time( &ttZeit );
- pstmZeit = localtime( (const time_t *) &ttZeit );
- strftime( pZeit, MAXSIZE, "%d %b %Y / %H:%M:%S", pstmZeit );
- return pZeit;
- Set MLE Selection
- CHAR *SetMLESelection( HWND hwndDlg, ULONG ulMEdit,
- PBYTE pAnchor, PBYTE pText,
- LONG lTextLength );
- /*--------------------( MLE Selection for the found string)------------------*/
- CHAR *SetMLESelection( HWND hwndDlg, ULONG ulMEdit,
- PBYTE pAnchor, PBYTE pText,
- LONG lTextLength )
- ULONG ulSelBegin = 0;
- ULONG ulSelEnd = 0;
- ulSelBegin = (ULONG)(pText - pAnchor);
- ulSelEnd = ulSelBegin + (ULONG)lTextLength;
- /* Set selection MMEEDIT Multi-Line Entry Field */
- WinSendDlgItemMsg(hwndDlg,
- ulMEdit,
- MLM_SETSEL,
- MPFROMLONG(ulSelBegin), /* IPT for new anchor */
- MPFROMLONG(ulSelEnd)); /* IPT for new cursor */
- return (pText + lTextLength);
- Arguments
- GetPathName( pMainFormInfo->szHomeDir, argv[0] );
- if ( argc > 1) {
- strcpy( pMainFormInfo->szFile, argv[1] );
- if( ChangeDir(pMainFormInfo->szPath, pMainFormInfo->szFile) ) {
- sprintf(pMainFormInfo->szFile, "%s\\%s",
- pMainFormInfo->szHomeDir, STD_FILE_NAME );
- strcpy(pMainFormInfo->szPath, pMainFormInfo->szHomeDir);
- } else {
- strcpy( pMainFormInfo->szPath, pMainFormInfo->szHomeDir );
- sprintf(pMainFormInfo->szFile, "%s\\%s",
- pMainFormInfo->szHomeDir, STD_FILE_NAME );
- } /* end if */
- Get Path Name
- CHAR *GetPathName( CHAR *pPath, CHAR *pFile );
- /*-----------------( Get Path Name )----------------*/
- CHAR *GetPathName( CHAR *pPath, CHAR *pFile )
- CHAR szDrive[_MAX_DRIVE]="",
- szDir[_MAX_DIR]="",
- szFName[_MAX_FNAME]="",
- szExt[_MAX_EXT]="";
- _splitpath( pFile, szDrive, szDir, szFName, szExt );
- szDir[strlen(szDir)-1] = 0;
- sprintf( pPath, "%s%s", szDrive, szDir );
- return ( pPath );
- Open File with Action
- HWND hwndFileDlg;
- FILEDLG FileDlg;
- char pszTitle[]="GREED: Open file";
- char pszFullFile[ CCHMAXPATH ];
- sprintf( pszFullFile, "%s\\*", pMainFormInfo->szPath );
- memset(&FileDlg, 0, sizeof(FILEDLG));
- FileDlg.cbSize=sizeof(FILEDLG);
- FileDlg.fl=FDS_HELPBUTTON | FDS_CENTER | FDS_OPEN_DIALOG;
- FileDlg.pszTitle=pszTitle;
- strcpy(FileDlg.szFullFile, pszFullFile);
- hwndFileDlg = WinFileDlg(HWND_DESKTOP, hwndFrame, &FileDlg);
- if ( FileDlg.lReturn != DID_CANCEL & hwndFileDlg != NULLHANDLE )
- /*------( Open File Action )------*/
- Change Directory
- APIRET ChangeDir( CHAR *pPath, CHAR *pCurrFile );
- /*-----------------( ChangeDir )----------------*/
- APIRET ChangeDir( CHAR *pPath, CHAR *pCurrFile )
- CHAR szDrive[_MAX_DRIVE]="c:",
- szDir[_MAX_DIR]="",
- szFName[_MAX_FNAME]="",
- szExt[_MAX_EXT]="";
- APIRET ulRC = 0;
- ULONG ulDrive;
- strupr( pCurrFile );
- _splitpath( pCurrFile, szDrive, szDir, szFName, szExt );
- ulDrive = (ULONG)(szDrive[0] - 'A' + 1 );
- if ( !(ulRC=DosSetDefaultDisk( ulDrive )) ) {
- sprintf( pPath, "%s%s", szDrive, szDir );
- szDir[strlen(szDir)-1] = 0;
- if (strlen(szDir))
- ulRC = DosSetCurrentDir( szDir );
- }
- if ( !ulRC ) {
- sprintf( pPath, "%s%s", szDrive, szDir );
- if ( strlen( pPath ) == 3 )
- pPath[strlen(pPath)-1] = 0;
- }
- return ( ulRC );
- C Constructs
- if - else
- if ( ) {
- } /* end if */
- else {
- }/* end else */
- switch
- /* ULONG ulCondition */
- switch (ulCondition) {
- case 1 : anUnsignedValue=1;
- break;
- case 2 : anUnsignedValue=2;
- break;
- default : anUnsignedValue=0;
- break;
- } /* end switch */
- do while
- } while(anUnsignedValue<100);
- while
- while( condition )
- Profile
- Open Profile
- if ( (pMainFormInfo->hini = PrfOpenProfile(pMainFormInfo->hab,
- EXTEC_INI)) == NULLHANDLE ) {
- /*-------(Initialization-file create error)--------*/
- WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- "Initialization-file create error. Execution finished.",
- "Extended Template Controller",
- 256,
- MB_OK | MB_INFORMATION | MB_MOVEABLE);
- exit(1);
- } /* end if */
- Write String
- /*-------(Write string to Profile)-------*/
- PrfWriteProfileString( pMainFormInfo->hini,
- EXTEC_APPL,
- LAST_FNC,
- pMainFormInfo->szFncFile );
- Close Profile
- /*-----(Close the Profile file)-----*/
- PrfCloseProfile( pMainFormInfo->hini );
- Query Integer
- /*-----------(Read string from Profile)------------*/
- anUnsignedValue = (ULONG)PrfQueryProfileInt(hini,
- APPL_NAME,
- KEY_NAME,
- lDefault);
- Write Data
- /*-------(Write string to Profile)-------*/
- PrfWriteProfileData( pMainFormInfo->hini,
- EXTEC_APPL,
- CNR_BCOLOR,
- anUnsignedValue,
- sizeof(ULONG) );
- Query Size
- /*---(Read string length from Profile)---*/
- PrfQueryProfileSize(pMainFormInfo->hiniFnc,
- pMainFormInfo->pmrcAppl,
- pMainFormInfo->pmrcKey,
- &anUnsignedValue);
- Query application names
- /*----------(Query all application names)----------*/
- PrfQueryProfileSize(pMainFormInfo->hiniFnc,
- NULL,
- NULL,
- &anUnsignedValue);
- anUnsignedValue++; /* final NULL character */
- pPrfBuffer = (PBYTE)malloc( (size_t)anUnsignedValue );
- PrfQueryProfileData(pMainFormInfo->hiniFnc,
- NULL,
- NULL,
- (PVOID)pPrfBuffer,
- &anUnsignedValue);
- Query String
- /*---(Read string from Profile)---*/
- PrfQueryProfileString( pMainFormInfo->hini,
- EXTEC_APPL,
- CODE_FILES,
- pszDefault,
- pBuffer,
- MAX_BUFER_LEN);
- Control Program functions
- DosAllocSharedMem
- if(!DosAllocSharedMem((PVOID)&pBuffer,
- NULL,
- ulBufLen,
- fALLOC|OBJ_GIVEABLE))
- if (pBuffer) DosFreeMem(pBuffer);
- DosFindFirst
- VOID jkSearchFiles( HWND hwndDlg,
- ULONG ulObject,
- PSZ pszFileSpec );
- /*----------(Search for specified files)----------*/
- VOID jkSearchFiles( HWND hwndDlg,
- ULONG ulObject,
- PSZ pszFileSpec )
- HDIR hdirFindHandle = HDIR_SYSTEM;
- FILEFINDBUF3 FindBuffer = {0};
- ULONG ulResultBufLen = sizeof(FILEFINDBUF3);
- ULONG ulFindCount = 1;
- APIRET rc = NO_ERROR;
- rc = DosFindFirst( pszFileSpec,
- &hdirFindHandle,
- FILE_NORMAL,
- &FindBuffer,
- ulResultBufLen,
- &ulFindCount,
- FIL_STANDARD );
- while (rc != ERROR_NO_MORE_FILES)
- ulFindCount = 1;
- rc = DosFindNext( hdirFindHandle,
- &findBuffer,
- ulResultBufLen,
- &ulFindCount );
- if (rc = NO_ERROR || rc = ERROR_NO_MORE_FILES)
- {
- /* Add item sorted ascending 1013 List Box */
- WinSendDlgItemMsg( hwndDlg,
- ulObject,
- LM_INSERTITEM,
- MPFROMSHORT(LIT_SORTASCENDING),
- MPFROMP(FindBuffer.achName) ); /* Text for new item */
- }
- DosAllocMem
- if(!DosAllocMem( (PVOID)&pBuffer,
- ulBufLen,
- PAG_WRITE | PAG_COMMIT ))
- if (pBuffer) DosFreeMem(pBuffer);
- PM functions
- Get selected text MLE
- LONG lStarSel=0, lEndSel=0;
- PBYTE pText;
- /* Get offset selection start MMEEDIT Multi-Line Entry Field */
- lStartSel=(LONG)WinSendDlgItemMsg( hwndDlg,
- MMEEDIT,
- MLM_QUERYSEL ,
- MPFROMLONG(MLFQS_MINSEL),
- 0 );
- /* Get offset of selection end MMEEDIT Multi-Line Entry Field */
- lEndSel=(LONG)WinSendDlgItemMsg( hwndDlg,
- MMEEDIT,
- MLM_QUERYSEL ,
- MPFROMLONG(MLFQS_MAXSEL),
- 0 );
- if ( lEndSel-lStartSel )
- /*---------------(Allocate memory)---------------*/
- pText = (PBYTE)malloc( (size_t)anUnsignedValue );
- if ( pText )
- /* The helper function MLEGetItemText (in MAIN.C) gets MLE text */
- MLEGetItemText( hwndDlg,
- MMEEDIT,
- lStartSel, /* Starting from the beginning */
- lEndSel-lStartSel, /* Until the end of the text */
- &pText ); /* Ptr for text buffer area */
- free( pText );
- } (* end if */
-