home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / 32ADDRES.PAK / ADRCMDLG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  24.3 KB  |  674 lines

  1. // BDE32 3.x - (C) Copyright 1996 by Borland International
  2.  
  3. #include "address.h"
  4.  
  5. //======================================================================
  6. //  Name:   FileOpenHook()
  7. //
  8. //  Input:  hWnd, msg, wParam, lParam.
  9. //
  10. //  Return: TRUE -  The table was opened successfully.
  11. //          FALSE - The table failed to open.
  12. //
  13. //  Desc:   This routine will process all I/O for the dialog that will
  14. //          open the table for us.
  15. //======================================================================
  16. BOOL FAR CALLBACK _export
  17. FileHook (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  18. {
  19. #ifndef WIN32
  20.     DLGPROC     lpProc;
  21. #endif
  22.     PASSSTRUCT  *Passwd = NULL;
  23.     static      BOOL            bUpper;
  24.     static      phDBIDb         phDb;
  25.     static      UINT32          lNumAliases;
  26.     static      pDBDesc         pAliases = NULL;
  27.     static      UINT32          lSel = 0;
  28.     static      BOOL            bServer = FALSE;
  29.     static      pCS             pCs;
  30.     static      BOOL            bNew = FALSE;
  31.  
  32.     CHAR        szAlias[MAXALIAS];
  33.     CHAR        szFile[DBIMAXNAMELEN]={0};
  34.     DBIResult   rslt;
  35.     UINT16      iTableLen;
  36.     CHAR        szExt[5]={"\0"};
  37.     pCHAR       pszMsg = NULL;
  38.     pCHAR       pTemp;
  39.  
  40.     if(iMSGFileOK == message)
  41.     {
  42.         if(!bServer && bNew)
  43.         {
  44.             // Get the actual file name so that we can check if it
  45.             // exists.
  46.             GetFileTitle(((OPENFILENAME*)lParam)->lpstrFile, szFile,
  47.                          DBIMAXNAMELEN);
  48.             strlwr(szFile);
  49.             if(!ChkExt(szFile))
  50.             {
  51. #ifndef WIN32
  52.                 lpProc = (DLGPROC)MakeProcInstance((FARPROC) TypeDlg,
  53.                                                    hInst);
  54.  
  55.                 if(DialogBoxParam(hInst, "TypeDlg", hDlg, lpProc,
  56.                                    (LONG)(void far*)szExt)==IDOK)
  57. #else
  58.                 if(DialogBoxParam(hInst, "TypeDlg", hDlg, TypeDlg,
  59.                                    (LONG)(void far*)szExt)==IDOK)
  60. #endif
  61.                 {
  62.                     strcat(szFile, szExt);
  63.                     pTemp = ((OPENFILENAME*)lParam)->lpstrFile;
  64.                     pTemp[((OPENFILENAME*)lParam)->nFileOffset] = '\0';
  65.                     strcat(((OPENFILENAME*)lParam)->lpstrFile, szFile);
  66. #ifndef WIN32
  67.                     FreeProcInstance((FARPROC) lpProc);
  68. #endif
  69.                     return 0;
  70.                 }
  71.                 else
  72.                 {
  73. #ifndef WIN32
  74.                     FreeProcInstance((FARPROC) lpProc);
  75. #endif
  76.                     return 1;
  77.                 }
  78.             }
  79.             else
  80.             {
  81.                 return 0;
  82.             }
  83.         }
  84.     } 
  85.  
  86.     switch (message)
  87.     {
  88.         case WM_INITDIALOG:
  89.  
  90.             // Get the Database pointer.
  91.             pCs = (pCS)((OPENFILENAME*)lParam)->lCustData;
  92.             phDb = pCs->phDb;
  93.             if(pCs->uType == 1)
  94.             {
  95.                 bNew = TRUE;
  96.             }
  97.             else
  98.             {
  99.                 bNew = FALSE;
  100.             }
  101.  
  102.             PostMessage(hDlg, WM_SETUP, 0, 0L);
  103.             return TRUE;
  104.  
  105.         case WM_SETUP:
  106.             // Hide the Addressbook type group if this is an open dialog.
  107.             if(!bNew)
  108.             {
  109.                 ShowWindow(GetDlgItem(hDlg, IDC_PERGROUP), SW_HIDE);
  110.                 ShowWindow(GetDlgItem(hDlg, IDC_BUSINESS), SW_HIDE);
  111.                 ShowWindow(GetDlgItem(hDlg, IDC_PERSONAL), SW_HIDE);
  112.             }
  113.  
  114.             SetupDialog(hDlg, SW_SHOW);
  115.  
  116.             // Fill the Alias string with the aliases that are available to
  117.             // the client.
  118.             if(FillAliasStr(&pAliases, &lNumAliases)!=DBIERR_NONE)
  119.             {
  120.                 SendMessage(hDlg, WM_DESTROY, 0, 0L);
  121.             }
  122.  
  123.             // Fill the alias CB.
  124.             FillAliasCBBox(pAliases, lNumAliases, cmb1, hDlg);
  125.  
  126.             // Choose the IDC_BUSINESS addressbook type as the defualt type.
  127.             Button_SetCheck(GetDlgItem(hDlg, IDC_BUSINESS), 1);
  128.  
  129.             PostMessage(hDlg, WM_ALL, 0, 0L);
  130.             bServer = FALSE;
  131.             break;
  132.  
  133.         case WM_ALL:
  134.             SetWindowText(GetDlgItem(hDlg, edt1), "*.dbf;*.db");
  135.             PostMessage(hDlg, WM_COMMAND, IDOK, 0L);
  136.             break;
  137.  
  138.         case WM_DESTROY:
  139.             if(pAliases)
  140.             {
  141.                 free(pAliases);
  142.             }
  143.             if(Passwd)
  144.             {
  145.                 free(Passwd);
  146.             }
  147.             if(pszMsg)
  148.             {
  149.                 free(pszMsg);
  150.             }
  151.             break;
  152.  
  153.         case WM_COMMAND:
  154.             switch (GET_WM_COMMAND_ID(wParam,lParam))
  155.             {
  156.                 case IDC_BUSINESS:
  157.                     pCs->uType = 1;
  158.                     break;
  159.  
  160.                 case IDC_PERSONAL:
  161.                     pCs->uType = 2;
  162.                     break;
  163.  
  164.                 case IDOK:
  165.                     if(bServer)
  166.                     {
  167.                         bIsServer = TRUE;
  168.                         memset((pCHAR)szTblName, '\0', DBIMAXTBLNAMELEN);
  169.                         GetWindowText(GetDlgItem(hDlg, edt1), szFile, 149);
  170.  
  171.                         // Check if the table ends with a period.
  172.                         iTableLen = (UINT16)strlen((pCHAR)szFile);
  173.                         if(szFile[iTableLen - 1]=='.')
  174.                         {
  175.                             // If it does delete the period.
  176.                             szFile[iTableLen - 1] = '\0';
  177.                         }
  178.                         strcpy((pCHAR)szTblName, szFile);
  179.  
  180.                         // Check the file case type on the server and set
  181.                         // the table name accordingly.
  182.                         if(bUpper)
  183.                         {
  184.                             strupr((pCHAR)szTblName);
  185.                         }
  186.                         else
  187.                         {
  188.                             strlwr((pCHAR)szTblName);
  189.                         }
  190.                         
  191.                         // We set the name legal.txt into the edit control
  192.                         // so that the Common Dialog DLL will not say that
  193.                         // the table name is illegal.
  194.                         SetWindowText(GetDlgItem(hDlg, edt1), "legal.txt");
  195.  
  196.                         // Close the dialog with a TRUE return value.
  197.                         EndDialog(hDlg, TRUE);
  198.                         return FALSE;
  199.                     }
  200.                     else
  201.                     {
  202.                         bIsServer = FALSE;
  203.                         return FALSE;
  204.                     }
  205.  
  206.                 case cmb1:
  207.                     switch (GET_WM_COMMAND_CMD(wParam,lParam))
  208.                     {
  209.                         case CBN_SELCHANGE:
  210.                             lSel = ComboBox_GetCurSel(GetDlgItem(hDlg,
  211.                                                       CB_GETCURSEL));
  212.                             (void)ComboBox_GetLBText(GetDlgItem(hDlg,
  213.                                                      CB_GETLBTEXT),
  214.                                                      lSel, szAlias);
  215.  
  216.                             PostMessage(hDlg, WM_NEXTDLGCTL,
  217.                                         (WPARAM)GetDlgItem(hDlg, edt1),
  218.                                         (LPARAM)(BOOL) LOWORD(TRUE));
  219.  
  220.                             // See if the alias is standard or if it is the
  221.                             // NULL alias.
  222.                             if((strnicmp(szAlias, "NULL", 4)==0) ||
  223.                                 IsStandard(szAlias, pAliases, lNumAliases))
  224.                             {
  225.                                 SetupDialog(hDlg, SW_SHOW);
  226.  
  227.                                 // If bServer than close the Database
  228.                                 // that we opened up.
  229.                                 if(bServer)
  230.                                 {
  231.                                     CloseDb(phDb);
  232.                                     bServer = FALSE;
  233.                                     OpenDB(phDb, NULL, NULL, NULL);
  234.                                 }
  235.  
  236.                                 // Set the file extension to .db and .dbf
  237.                                 // then send OK to display all local files.
  238.                                 SetWindowText(GetDlgItem(hDlg, edt1),
  239.                                               "*.db;*.dbf");
  240.                                 PostMessage(hDlg, WM_COMMAND, IDOK, 0L);
  241.                             }
  242.                             // Otherwise this is a server alias.  Therefore,
  243.                             // we need to know if it is a server alias.
  244.                             else
  245.                             {
  246.                                 // This is a server alias - so display the
  247.                                 // password dialogbox.
  248.  
  249.                                 // Hide the right side of the dialog box.
  250.                                 SetupDialog(hDlg, SW_HIDE);
  251.                                 SetWindowText(GetDlgItem(hDlg, edt1), "");
  252.  
  253.                                 // Clear the file list box
  254.                                 SendMessage(GetDlgItem(hDlg, lst1),
  255.                                             LB_RESETCONTENT, 0, 0L);
  256.                                 if((Passwd = (PASSSTRUCT*) malloc
  257.                                     (sizeof(PASSSTRUCT))) == NULL)
  258.                                 {
  259.                                     return FALSE;
  260.                                 }
  261.  
  262.                                 // Copy in the alias and the physical
  263.                                 // Database name.
  264.                                 strcpy(Passwd->Alias, pAliases[(UINT16)
  265.                                                       lSel].szName);
  266.                                 strcpy(Passwd->Database, pAliases[
  267.                                                          (UINT16)lSel].
  268.                                                          szPhyName);
  269. #ifndef WIN32
  270.                                 lpProc = (DLGPROC)MakeProcInstance
  271.                                          ((FARPROC) PasswdDlg, hInst);
  272.                                 // Since we have get the password and
  273.                                 // pass in the alias and database names
  274.                                 // we need to pass in the Passwd
  275.                                 // structure.
  276.                                 if(DialogBoxParam(hInst, "PasswdDlg",
  277.                                    hDlg, lpProc, (LONG)(void far*)
  278.                                    Passwd)==IDOK)
  279. #else
  280.                                 if(DialogBoxParam(hInst, "PasswdDlg",
  281.                                    hDlg, PasswdDlg, (LONG)(void far*)
  282.                                    Passwd)==IDOK)
  283. #endif
  284.                                 {
  285.                                     if(*phDb!=NULL)
  286.                                     {
  287.                                         CloseDb(phDb);
  288.                                     }
  289.  
  290.                                     // Open the SQL Database.
  291.                                     rslt=OpenDB(phDb, pAliases
  292.                                              [(UINT16)lSel].szDbType,
  293.                                              (pCHAR)Passwd,
  294.                                              pAliases[(UINT16)lSel].
  295.                                              szName);
  296.  
  297.                                     // If there were no errors then
  298.                                     // get the list of available tables.
  299.                                     if(rslt == DBIERR_NONE)
  300.                                     {
  301.                                         bServer = TRUE;
  302.                                         HourGlassCursor(TRUE);
  303.  
  304.                                         // Fill the file listbox
  305.                                         bUpper = FillFileList(hDlg, lst1,
  306.                                                               *phDb);
  307.  
  308.                                         // Set the alias as the directory
  309.                                         // name in the file dialog box.
  310.                                         SetWindowText(GetDlgItem(hDlg,
  311.                                                    stc1), pAliases[(UINT16)
  312.                                                    lSel].szPhyName);
  313.  
  314.                                         PostMessage(hDlg, WM_NEXTDLGCTL,
  315.                                              (WPARAM)GetDlgItem(hDlg, edt1),
  316.                                              (LPARAM)(BOOL) LOWORD(TRUE));
  317.  
  318.                                         HourGlassCursor(FALSE);
  319.                                     }
  320.                                     else
  321.                                     {
  322.                                         // Get the full information on
  323.                                         // why the connection failed.
  324.                                         DisplayError(rslt,  &pszMsg);
  325.  
  326.                                         // Display the full error string.
  327.                                         MessageBox(hDlg, pszMsg,
  328.                                             "AddressBook Manager Error",
  329.                                             MB_OK|MB_ICONINFORMATION);
  330.  
  331.                                         // Free the error string.
  332.                                         free(pszMsg);
  333.                                     }
  334.                                 }
  335. #ifndef WIN32
  336.                                 FreeProcInstance((FARPROC) lpProc);
  337. #endif
  338.                                 free(Passwd);
  339.                                 break;
  340.                             }
  341.                         return TRUE;
  342.                     }
  343.                     return TRUE;
  344.             }
  345.             break;
  346.     }
  347.     return FALSE;
  348. }
  349.  
  350. //======================================================================
  351. //  Name:   PasswdDlg()
  352. //
  353. //  Input:  hWnd, msg, wParam, lParam.  In the lParam is a structure that
  354. //          holds the Alias, Database name, and Password string to fill.
  355. //
  356. //  Return: TRUE -  Password was entered.
  357. //          FALSE - Password was not entered..
  358. //
  359. //  Desc:   This routine will process all I/O for the Password dialog.
  360. //======================================================================
  361. BOOL FAR CALLBACK _export
  362. PasswdDlg (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  363. {
  364.     BOOL        bRet = FALSE;
  365.     static      PASSSTRUCT  *PassWord = NULL;
  366.  
  367.     // Done to clear the unused warning.
  368.     lParam = lParam;
  369.  
  370.     switch (msg)
  371.     {
  372.         case WM_INITDIALOG:
  373.             PassWord = (PASSSTRUCT*)lParam;
  374.             SetWindowText(GetDlgItem(hWnd, IDS_ALIAS), PassWord->Alias);
  375.             SetWindowText(GetDlgItem(hWnd, IDS_DATABASE),
  376.                           PassWord->Database);
  377.             PostMessage(hWnd,WM_NEXTDLGCTL,
  378.                         (WPARAM)GetDlgItem(hWnd,IDC_PASS),TRUE);
  379.             break;
  380.  
  381.         case WM_COMMAND:
  382.             switch (GET_WM_COMMAND_ID(wParam,lParam))
  383.             {
  384.                 case IDOK:
  385.                     GetDlgItemText(hWnd, IDC_PASS, PassWord->Password,
  386.                                    MAXPASSLEN -1);
  387.                     bRet = TRUE;
  388.                     EndDialog(hWnd, bRet);
  389.                     break;
  390.  
  391.                 case IDCANCEL:
  392.                     bRet = FALSE;
  393.                     EndDialog(hWnd, bRet);
  394.                     break;
  395.             }
  396.             break;
  397.     }
  398.     return bRet;
  399. }
  400.  
  401. //======================================================================
  402. //  Name:   TypeDlg()
  403. //
  404. //  Input:  hWnd, msg, wParam, lParam.  In the lParam is the extension
  405. //          string.
  406. //
  407. //  Return: TRUE -  Table type was chosen.
  408. //          FALSE - Table type was not chosen.
  409. //
  410. //  Desc:   This routine will process all I/O for the Table Type dialog.
  411. //======================================================================
  412. BOOL FAR CALLBACK _export
  413. TypeDlg (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  414. {
  415.     BOOL        bRet = FALSE;
  416.     static      pCHAR  pszExtension;
  417.     static      CHAR   szString[301] = {'\0'};
  418.  
  419.     // Done to clear the unused warning.
  420.     lParam = lParam;
  421.  
  422.     switch (msg)
  423.     {
  424.         case WM_INITDIALOG:
  425.             pszExtension = (pCHAR)lParam;
  426.             LoadString(hInst, IDS_TABLETYPE, szString, 300);
  427.             SetWindowText(GetDlgItem(hWnd, ID_TYPE_DESC), szString);
  428.  
  429.             // Choose the Paradox table type as the default.
  430.             Button_SetCheck(GetDlgItem(hWnd, IDC_PARADOX), 1);
  431.             break;
  432.  
  433.         case WM_COMMAND:
  434.             switch (GET_WM_COMMAND_ID(wParam,lParam))
  435.             {
  436.                 case IDOK:
  437.                     if (Button_GetCheck(GetDlgItem(hWnd, IDC_PARADOX)) == 1)
  438.                     {
  439.                         strcpy(pszExtension,".db\0");
  440.                     }
  441.                     else
  442.                     {
  443.                         strcpy(pszExtension, ".dbf\0");
  444.                     }
  445.                     bRet = TRUE;
  446.                     EndDialog(hWnd, bRet);
  447.                     break;
  448.  
  449.                 case IDCANCEL:
  450.                     bRet = FALSE;
  451.                     EndDialog(hWnd, bRet);
  452.                     break;
  453.             }
  454.             break;
  455.     }
  456.     return(bRet);
  457. }
  458.  
  459. //=========================================================================
  460. //  Function:   InitializeStruct()
  461. //
  462. //  Input:      Pointer to the common dialog structure (lpStruct), and a
  463. //              pointer to the CREATESTRUCT structure (pCS).
  464. //
  465. //  Returns:    None.
  466. //
  467. //  Desc:       This function is used to initialize the structure for the
  468. //              open/save file common dialog. This routine is called just
  469. //              before the common dialogs API is called.
  470. //=========================================================================
  471. void
  472. InitializeStruct (LPSTR lpStruct, pCS pCs)
  473. {
  474.     LPFOCHUNK   lpFOChunk;
  475.  
  476.     lpFOChunk = (LPFOCHUNK)lpStruct;
  477.  
  478.     // If this is an open table structure.
  479.     if(pCs->uType == 0)
  480.     {
  481.         strcpy(lpFOChunk->szTitle, "Open Table");
  482.     }
  483.     else
  484.     {
  485.         strcpy(lpFOChunk->szTitle, "New Table");
  486.     }
  487.  
  488.     *(lpFOChunk->szFile)             = 0;
  489.     *(lpFOChunk->szFileTitle)        = 0;
  490.     lpFOChunk->ofn.lStructSize       = sizeof(OPENFILENAME);
  491.     lpFOChunk->ofn.hwndOwner         = (HWND)hMainWnd;
  492.     lpFOChunk->ofn.hInstance         = hInst;
  493.     lpFOChunk->ofn.lpstrFilter       = NULL;
  494.     lpFOChunk->ofn.lpstrCustomFilter = (LPSTR)NULL;
  495.     lpFOChunk->ofn.nMaxCustFilter    = 0L;
  496.     lpFOChunk->ofn.nFilterIndex      = 1L;
  497.     lpFOChunk->ofn.lpstrFile         = lpFOChunk->szFile;
  498.     lpFOChunk->ofn.nMaxFile          = (DWORD)sizeof(lpFOChunk->szFile);
  499.     lpFOChunk->ofn.lpstrFileTitle    = lpFOChunk->szFileTitle;
  500.     lpFOChunk->ofn.nMaxFileTitle     = MAXFILETITLELEN;
  501.     lpFOChunk->ofn.lpstrInitialDir   = szTblDirectory;
  502.     lpFOChunk->ofn.lpstrTitle        = lpFOChunk->szTitle;
  503.     lpFOChunk->ofn.Flags             = OFN_HIDEREADONLY |
  504.                                        OFN_ENABLETEMPLATE |
  505.                                        OFN_ENABLEHOOK;
  506.     lpFOChunk->ofn.nFileOffset       = 0;
  507.     lpFOChunk->ofn.nFileExtension    = 0;
  508.     lpFOChunk->ofn.lpstrDefExt       = (LPSTR)NULL;
  509.     lpFOChunk->ofn.lCustData         = (LPARAM)pCs;
  510. #ifndef WIN32
  511.     lpFOChunk->ofn.lpfnHook          = (FARHOOK)lpfnFileHook;
  512. #else
  513.     lpFOChunk->ofn.lpfnHook          = (FARHOOK)FileHook;
  514. #endif
  515.     lpFOChunk->ofn.lpTemplateName    = (LPSTR)MAKEINTRESOURCE
  516.                                              (FILEOPENORD);
  517.     return;
  518. }
  519.  
  520. //=========================================================================
  521. //  Function:   ProcessCDError()
  522. //
  523. //  Input:      CommDlgError(UINT16), Pointer to the common dialog structure
  524. //              (lpStruct).
  525. //
  526. //  Returns:    None.
  527. //
  528. //  Desc:       This function reports an error that has occurred during the
  529. //              last call to a Common Dialog routine.
  530. //=========================================================================
  531. void
  532. ProcessCDError (UINT32 dwErrorCode)
  533. {
  534.    UINT16   iStringID;
  535.    CHAR     szBuffer[200];
  536.  
  537.     switch(dwErrorCode)
  538.     {
  539.         case CDERR_DIALOGFAILURE:   iStringID=IDS_DIALOGFAILURE;   break;
  540.         case CDERR_INITIALIZATION:  iStringID=IDS_INITIALIZATION;  break;
  541.         case CDERR_NOTEMPLATE:      iStringID=IDS_NOTEMPLATE;      break;
  542.         case CDERR_NOHINSTANCE:     iStringID=IDS_NOHINSTANCE;     break;
  543.         case CDERR_LOCKRESFAILURE:  iStringID=IDS_LOCKRESFAILURE;  break;
  544.         case CDERR_MEMALLOCFAILURE: iStringID=IDS_MEMALLOCFAILURE; break;
  545.         case CDERR_MEMLOCKFAILURE:  iStringID=IDS_MEMLOCKFAILURE;  break;
  546.  
  547.         case 0:   // User may have hit CANCEL or we got a *very* random
  548.                   // error
  549.  
  550.         default:
  551.             return;
  552.    }
  553.  
  554.     if (!LoadString(hInst, iStringID, szBuffer, sizeof(szBuffer)))
  555.     {
  556.         return;
  557.     }
  558.  
  559.     MessageBox(hMainWnd, szBuffer, "AddressBook Error", MB_OK);
  560.     return;
  561. }
  562.  
  563. //=========================================================================
  564. //  Function:   ChkExt()
  565. //
  566. //  Input:      Pointer to a string that contains the filename to check
  567. //              (pCHAR).
  568. //
  569. //  Returns:    TRUE:   If the file has an extension of .db or .dbf
  570. //              FALSE:  If the file has an extension of anything else.
  571. //
  572. //  Desc:       This function simply checks if the filename has a .db in it.
  573. //              It then checks if the next character is a 'f' (.dbf) or
  574. //              a '/0' (.db).  It then returns the result of its check.
  575. //=========================================================================
  576. BOOL
  577. ChkExt (pCHAR pszFileName)
  578. {
  579.     pCHAR   pName;
  580.     BOOL    bRet = FALSE;
  581.     UINT16  i;
  582.  
  583.     strlwr(pszFileName);
  584.     if((pName = strstr(pszFileName, ".db"))!=NULL)
  585.     {
  586.         if((pName[3]=='f') || (pName[3]=='\0'))
  587.         {
  588.             bRet = TRUE;
  589.         }
  590.     }
  591.  
  592.     if(!bRet)
  593.     {
  594.         i=0;
  595.         while (i<strlen(pszFileName) && pszFileName[i]!='.')
  596.         {
  597.             i++;
  598.         }
  599.         pszFileName[i]='\0';
  600.     }
  601.     return bRet;
  602. }
  603.  
  604. //=========================================================================
  605. //  Function:   IsStandard()
  606. //
  607. //  Input:      Pointer to a string that contains the Alias name(pCHAR),
  608. //              Pointer to the alias list (pDBDesc), and the number of
  609. //              aliases (UINT32).
  610. //
  611. //  Returns:    TRUE:   If the alias is a standard alias.
  612. //              FALSE:  If the alias is not a standard alias.
  613. //
  614. //  Desc:       This function simply checks if the alias is a standard
  615. //              alias.  This is done by comparing the alias name with the
  616. //              alias list that is passed in.
  617. //=========================================================================
  618. BOOL
  619. IsStandard (pCHAR pszAlias, pDBDesc pAliases, UINT32 lNumAliases)
  620. {
  621.     UINT32  i;
  622.     BOOL    bRet = FALSE;
  623.  
  624.     for (i=0;i<lNumAliases;i++)
  625.     {
  626.         if(strcmpi(pAliases[(UINT16)i].szName, pszAlias)==0)
  627.         {
  628.             if(strcmpi(pAliases[(UINT16)i].szDbType, szCFGDBSTANDARD)==0)
  629.             {
  630.                 bRet = TRUE;
  631.             }
  632.         }
  633.     }
  634.     return bRet;
  635. }
  636.  
  637. //=========================================================================
  638. //  Function:   SetupDialog()
  639. //
  640. //  Input:      Handle to the CommonDialogBox (HWND), Value to pass
  641. //              into the ShowWindow function like SW_HIDE (INT16).
  642. //
  643. //  Returns:    None.
  644. //
  645. //  Desc:       This function simply shows or hides the windows on the
  646. //              right side of the common dialog box.  This is done by
  647. //              passing the second parameter of this function into the
  648. //              ShowWindow function for each window we wish to affect.
  649. //=========================================================================
  650. void
  651. SetupDialog (HWND hDlg, INT16 iAction)
  652. {
  653.     BOOL bFlag = TRUE;
  654.  
  655.     if(IsWindowVisible(GetDlgItem(hDlg, stc1)))
  656.     {
  657.         if(iAction == SW_SHOW)
  658.         {
  659.             // This way we will not redisplay what is already visable.
  660.             bFlag = FALSE;
  661.         }
  662.     }
  663.  
  664.     if(bFlag)
  665.     {
  666.         ShowWindow(GetDlgItem(hDlg, stc1), iAction);
  667.         ShowWindow(GetDlgItem(hDlg, stc5), iAction);
  668.         ShowWindow(GetDlgItem(hDlg, stc4), iAction);
  669.         ShowWindow(GetDlgItem(hDlg, cmb2), iAction);
  670.         ShowWindow(GetDlgItem(hDlg, lst2), iAction);
  671.     }
  672. }
  673.  
  674.