home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / gw / oddev.exe / DIALOGS.CPP next >
C/C++ Source or Header  |  1994-07-15  |  4KB  |  151 lines

  1. /* dialogs.c - Dialog procedures for ODMA sample DMS.
  2.  *
  3.  * COPYRIGHT (C) 1994
  4.  * SoftSolutions Technology Corporation
  5.  * Orem, Utah  USA
  6.  * All Rights Reserved
  7.  */
  8.  
  9. #include <windows.h>
  10. #include "odmasamp.h"
  11.  
  12.  
  13. BOOL CALLBACK _export SelectDocProc( HWND hwndDlg, UINT message, WPARAM wParam,
  14.     LPARAM lParam)
  15. {
  16.     static char FAR *DocId;
  17.     int i, count;
  18.     Document *pDoc;
  19.     char *lp;
  20.  
  21.     switch (message) {
  22.         case WM_INITDIALOG:
  23.             DocId = (char FAR *)lParam;
  24.             for( i = 0, count = 0; i < MAXDOCS; i++ ) {
  25.                 pDoc = DocList.GetDocumentByIndex( i );
  26.                 if (pDoc == NULL)
  27.                     continue;
  28.                 lp = pDoc->GetId();
  29.                 SendDlgItemMessage( hwndDlg, IDC_SELECT, LB_ADDSTRING, 0,
  30.                     (LPARAM)lp );
  31.                 count++;
  32.             }
  33.             if (count == 0) {
  34.                 // No documents in the DMS!
  35.                 EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE );
  36.             } else {
  37.                 // Select the first item in the list.
  38.                 SendDlgItemMessage( hwndDlg, IDC_SELECT, LB_SETCURSEL, 0, 0 );
  39.             }
  40.  
  41.             return TRUE;
  42.  
  43.         case WM_COMMAND:
  44.             switch (LOWORD(wParam)) {
  45.                 case IDOK:
  46.                     wsprintf( DocId, "::ODMA\\%s\\", (LPSTR) DMSID );
  47.                     i = (int) SendDlgItemMessage( hwndDlg, IDC_SELECT, LB_GETCURSEL,
  48.                         0, 0 );
  49.                     SendDlgItemMessage( hwndDlg, IDC_SELECT, LB_GETTEXT, i,
  50.                         (LPARAM)(DocId+strlen(DocId)) );
  51.  
  52.                     /* Fall through. */
  53.  
  54.                 case IDCANCEL:
  55.                 case IDAPPSELECT:
  56.                     EndDialog(hwndDlg, wParam);
  57.                     return TRUE;
  58.             }
  59.     }
  60.     return FALSE;
  61. }
  62.  
  63. BOOL CALLBACK _export SaveAsProc( HWND hwndDlg, UINT message, WPARAM wParam,
  64.     LPARAM lParam)
  65. {
  66.     static SaveAsData FAR *pSaveAsData;
  67.     char *lp;
  68.  
  69.     switch (message) {
  70.         case WM_INITDIALOG:
  71.             pSaveAsData = (SaveAsData FAR *)lParam;
  72.             SendDlgItemMessage( hwndDlg, ST_FORMAT, WM_SETTEXT, 0,
  73.                     (LPARAM)(pSaveAsData->Format) );
  74.             if (pSaveAsData->pcbCallBack == NULL)
  75.                 ShowWindow( GetDlgItem( hwndDlg, IDC_OPTIONS ), SW_HIDE );
  76.             return TRUE;
  77.  
  78.         case WM_COMMAND:
  79.             switch (LOWORD(wParam)) {
  80.                 case IDC_OPTIONS:
  81.                     lp = pSaveAsData->pcbCallBack( (DWORD)hwndDlg, pSaveAsData->Format,
  82.                         pSaveAsData->pInstanceData );
  83.                     strncpy( pSaveAsData->Format, lp, sizeof(pSaveAsData->Format) );
  84.                     pSaveAsData->Format[sizeof(pSaveAsData->Format)-1] = '\0';
  85.                     SendDlgItemMessage( hwndDlg, ST_FORMAT, WM_SETTEXT, 0,
  86.                         (LPARAM)(pSaveAsData->Format) );
  87.                     return TRUE;
  88.  
  89.                 case IDOK:
  90.                 case IDCOPY:
  91.                 case IDCANCEL:
  92.                     EndDialog(hwndDlg, wParam);
  93.                     return TRUE;
  94.             }
  95.     }
  96.     return FALSE;
  97. }
  98.  
  99. BOOL CALLBACK _export ProfileProc( HWND hwndDlg, UINT message, WPARAM wParam,
  100.     LPARAM lParam)
  101. {
  102.     static ProDlgData FAR *pDlgData;
  103.  
  104.     switch (message) {
  105.         case WM_INITDIALOG:
  106.             pDlgData = (ProDlgData FAR *)lParam;
  107.             SendDlgItemMessage( hwndDlg, ST_DOCID, WM_SETTEXT, 0,
  108.                 (LPARAM)(pDlgData->pDocument->GetId()) );
  109.             SendDlgItemMessage( hwndDlg, IDC_NAME, WM_SETTEXT, 0,
  110.                 (LPARAM)pDlgData->pDocument->Name );
  111.             SendDlgItemMessage( hwndDlg, IDC_AUTHOR, WM_SETTEXT, 0,
  112.                 (LPARAM)pDlgData->pDocument->Author );
  113.             SendDlgItemMessage( hwndDlg, IDC_TYPE, WM_SETTEXT, 0,
  114.                 (LPARAM)pDlgData->pDocument->DocType );
  115.             if (pDlgData->Mode & PROFILE_EDIT) {
  116.                 SendDlgItemMessage( hwndDlg, IDC_NAME, EM_SETREADONLY, 0, 0 );
  117.                 SendDlgItemMessage( hwndDlg, IDC_AUTHOR, EM_SETREADONLY, 0, 0 );
  118.                 SendDlgItemMessage( hwndDlg, IDC_TYPE, EM_SETREADONLY, 0, 0 );
  119.                 SetFocus( GetDlgItem( hwndDlg, IDC_NAME ) );
  120.             } else {
  121.                 SetFocus( GetDlgItem( hwndDlg, IDOK ) );
  122.                 ShowWindow( GetDlgItem( hwndDlg, IDCANCEL ), SW_HIDE );
  123.             }
  124.             return TRUE;
  125.  
  126.         case WM_COMMAND:
  127.             switch (LOWORD(wParam)) {
  128.                 case IDOK:
  129.                     if (pDlgData->Mode & PROFILE_EDIT) {
  130.                         SendDlgItemMessage( hwndDlg, IDC_NAME, WM_GETTEXT,
  131.                             sizeof(pDlgData->pDocument->Name),
  132.                             (LPARAM)pDlgData->pDocument->Name );
  133.                         SendDlgItemMessage( hwndDlg, IDC_AUTHOR, WM_GETTEXT,
  134.                             sizeof(pDlgData->pDocument->Author), (
  135.                             LPARAM)pDlgData->pDocument->Author );
  136.                         SendDlgItemMessage( hwndDlg, IDC_TYPE, WM_GETTEXT,
  137.                             sizeof(pDlgData->pDocument->DocType),
  138.                             (LPARAM)pDlgData->pDocument->DocType );
  139.                     }
  140.  
  141.                     // fall through to below
  142.  
  143.                 case IDCANCEL:
  144.                     EndDialog(hwndDlg, wParam);
  145.                     return TRUE;
  146.             }
  147.     }
  148.     return FALSE;
  149. }
  150.  
  151.