Annotation of pmsdk/samples/opendlg/tool1.c, revision 1.1

1.1     ! root        1: /*
        !             2:     TOOL1.C -- More commonly used library routines
        !             3:     Created by Microsoft Corporation, 1989
        !             4: */
        !             5: 
        !             6: #include "tool.h"
        !             7: 
        !             8: /***************************************************************************\
        !             9: * Merges sz[idMes1] and szText1 and displays a message box using
        !            10: * the wStyle. Use caption title provided by szText2.
        !            11: * Returns the answer from the message box (MBID_OK, MBID_CANCEL).
        !            12: \***************************************************************************/
        !            13: 
        !            14: int CALLBACK AlertBox (hwnd, idMes, lpszText1, lpszText2, idHelp, wStyle)
        !            15: HWND  hwnd;
        !            16: int   idMes;
        !            17: PSZ  lpszText1;
        !            18: PSZ  lpszText2;
        !            19: USHORT idHelp;
        !            20: USHORT wStyle;
        !            21:     {
        !            22:     char szMessage [MAXMESSAGELENGTH];
        !            23: 
        !            24:     MergeStrings((PSZ)vrgsz[idMes], lpszText1, (PSZ)szMessage);
        !            25:     if (idHelp != NULL)
        !            26:         wStyle |= MB_HELP;
        !            27:     return (WinMessageBox (HWND_DESKTOP, hwnd, (PSZ)szMessage, lpszText2,
        !            28:                            idHelp, wStyle));
        !            29:     }
        !            30: 
        !            31: 
        !            32: /***************************************************************************\
        !            33: * Scan szSrc for merge spec. If found, insert string szMerge at that point.
        !            34: * Then append rest of szSrc NOTE! Merge spec guaranteed to be two chars.
        !            35: * returns TRUE if it does a merge, false otherwise.
        !            36: \***************************************************************************/
        !            37: 
        !            38: BOOL CALLBACK MergeStrings(lpszSrc, lpszMerge, lpszDst)
        !            39: PSZ   lpszSrc;
        !            40: PSZ   lpszMerge;
        !            41: PSZ   lpszDst;
        !            42:     {
        !            43:     /* Find merge spec if there is one. */
        !            44:     while (*(unsigned far *)lpszSrc != *(unsigned *)vrgsz[IDS_MERGE1])
        !            45:         {
        !            46:         *lpszDst++ = *lpszSrc;
        !            47:         /* If we reach end of string before merge spec, just return. */
        !            48:         if (!*lpszSrc++)
        !            49:             return FALSE;
        !            50:         }
        !            51: 
        !            52:     /* If merge spec found, insert sz2 there. (check for null merge string */
        !            53:     if (lpszMerge)
        !            54:         {
        !            55:         while (*lpszMerge)
        !            56:             *lpszDst++ = *lpszMerge++;
        !            57:         }
        !            58: 
        !            59:     /* Jump over merge spec */
        !            60:     lpszSrc++,lpszSrc++;
        !            61: 
        !            62:     /* Now append rest of Src String */
        !            63:     while (*lpszDst++ = *lpszSrc++);
        !            64:     return TRUE;
        !            65:     }
        !            66: 
        !            67: 
        !            68: 
        !            69: /****************************************************************************\
        !            70: * This function invokes either an Open or Save dialog box.
        !            71: *     (lpdlf->rgbAction == DLG_OPENDLG)  -->  invoke Open dlgBox
        !            72: *     (lpdlf->rgbAction == DLG_SAVEDLG)  -->  invoke Save dlbBox
        !            73: *
        !            74: * Unless DLG_NOSAVE is specified, the file is opened and left open.
        !            75: *
        !            76: * Return values are:
        !            77: *     TDF_INVALID - Library error (internal error),
        !            78: *     TDF_ERRMEM  - Out of memory error
        !            79: *     TDF_NOOPEN  - User hits cancel
        !            80: *   specific to DLG_OPEN:
        !            81: *     TDF_NEWOPEN - Created new file
        !            82: *     TDF_OLDOPEN - Opened existing file
        !            83: *   specific to DLG_SAVE:
        !            84: *     TDF_NEWSAVE - user wants to save to a new file
        !            85: *     TDF_OLDSAVE - user wants to save over existing file
        !            86: *   specific to DLG_NOSAVE:
        !            87: *     TDF_NEWSAVE - user wants to save to a new file
        !            88: *     TDF_OLDSAVE - user wants to save over existing file
        !            89: \****************************************************************************/
        !            90: 
        !            91: int CALLBACK DlgFile(hwnd, pdlf)
        !            92: HWND  hwnd;
        !            93: PDLF pdlf;
        !            94:     {
        !            95:     /* create dialog box */
        !            96:     if (pdlf->rgbAction & DLG_SAVEDLG)
        !            97:         return WinDlgBox(HWND_DESKTOP, hwnd, DlgSaveAsWndProc, vhModule,
        !            98:                          IDD_SAVEAS, (PSZ)pdlf);
        !            99:     else
        !           100:         return WinDlgBox(HWND_DESKTOP, hwnd, DlgOpenWndProc, vhModule,
        !           101:                          IDD_OPEN, (PSZ)pdlf);
        !           102:     }
        !           103: 
        !           104: /**************************************************************************\
        !           105: * This function initializes the DLF structure
        !           106: \**************************************************************************/
        !           107: void CALLBACK SetupDLF(PDLF pdlf, int iAction, PHFILE phFile,
        !           108:                       PSZ Extension, PSZ AppName, PSZ pszInTitle,
        !           109:                       PSZ pszInInstructions ) {
        !           110:     pdlf->pszExt = Extension;
        !           111:     pdlf->rgbFlags = ATTRDIRLIST;
        !           112:     pdlf->phFile = phFile;
        !           113:     pdlf->pszAppName = AppName;
        !           114:     pdlf->rgbAction = iAction;
        !           115:     pdlf->pszTitle = pszInTitle;
        !           116:     pdlf->pszInstructions = pszInInstructions;
        !           117: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.