home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / m / ms3dctl.zip / SAMPLE3D.C < prev    next >
C/C++ Source or Header  |  1993-02-10  |  3KB  |  130 lines

  1. //**************************************************************************
  2. //
  3. // Sample3D - Shows the use of CTL3D.DLL
  4. //
  5. // Yes it is really this easy.
  6. //
  7. //
  8. //**************************************************************************
  9.  
  10. #include <windows.h>
  11. #include <windowsx.h>
  12. #include <commdlg.h>
  13. #include "ctl3d.h"
  14.  
  15. extern const HINSTANCE _hInstance ;
  16. HWND hwndApp;
  17.  
  18. char szFilterSpec [128] =                       // file type filters
  19.              "Text Files (*.TXT)\0*.TXT\0All Files (*.*)\0*.*\0";
  20.  
  21. char szFileName[120];
  22.  
  23. BOOL FAR PASCAL OpenHook(HWND hwnd, int wm, int wParam, long lParam)
  24. {
  25.     switch (wm) {
  26.     case WM_INITDIALOG:
  27.             // We must call this to subclass the directory listbox even
  28.             // if the app calls Ctl3dAutoSubclass (commdlg bug)
  29.             // Ctl3dSubclassDlg(hwnd, CTL3D_ALL);
  30.         break;
  31.     }
  32.     return FALSE;
  33. }
  34.  
  35.  
  36. void FileOpen(HWND hwndOwner)
  37. {
  38.     OPENFILENAME ofn;
  39.  
  40.     /* fill in non-variant fields of OPENFILENAME struct. */
  41.     ofn.lStructSize       = sizeof(OPENFILENAME);
  42.     ofn.hwndOwner     = hwndOwner;
  43.     ofn.lpstrFilter   = szFilterSpec;
  44.     ofn.lpstrCustomFilter = NULL;
  45.     ofn.nMaxCustFilter    = 0;
  46.     ofn.nFilterIndex      = 1;
  47.     ofn.lpstrFile         = szFileName;
  48.     ofn.nMaxFile      = 120;
  49.     ofn.lpstrInitialDir   = NULL;
  50.     ofn.lpstrFileTitle    = NULL;
  51.     ofn.nMaxFileTitle     = 120;
  52.     ofn.lpstrTitle        = "3D Look";
  53.     ofn.lpstrDefExt       = "TXT";
  54.     ofn.Flags = OFN_HIDEREADONLY | OFN_ENABLEHOOK;
  55.          ofn.lpfnHook = MakeProcInstance(OpenHook, _hInstance);
  56.     ofn.lCustData = 0;
  57.     ofn.lpTemplateName = 0;
  58.  
  59.     GetOpenFileName ((LPOPENFILENAME)&ofn);
  60.     FreeProcInstance(ofn.lpfnHook);
  61. }
  62.  
  63.  
  64. //
  65. // Dialog Procedure
  66. //
  67. BOOL FAR PASCAL DialogProc(HWND hdlg, UINT wm, WPARAM wParam, LPARAM lParam)
  68. {
  69.     switch(wm) {
  70.         case WM_SYSCOLORCHANGE:
  71.            Ctl3dColorChange();
  72.            break;
  73.                                         
  74.         //
  75.         // Remove the comments from the next block of code to
  76.         // stop the dialog border form being drawn with 3D effects
  77.         //                                
  78.         // case WM_DLGBORDER:
  79.         //      *(int FAR *)lParam = CTL3D_NOBORDER;
  80.         //   return TRUE;
  81.            
  82.         //
  83.         // Remove the comments from the next block of code to
  84.         // stop subclassing the controls on this dialog
  85.         //                                
  86.         // case WM_DLGSUBCLASS:
  87.         //   *(int FAR *)lParam = CTL3D_NOSUBCLASS;
  88.         ///   return TRUE;
  89.  
  90.         case WM_COMMAND:
  91.             if (wParam == IDOK) {
  92.                 EndDialog(hdlg, TRUE);
  93.             }
  94.             else if (wParam == 130 ) {
  95.                 MessageBox(hdlg, "This is a sample Message Box","3D Look", MB_OK);
  96.             }
  97.             else if (wParam == 131 ) {
  98.                 FileOpen(hdlg);
  99.             }
  100.             break;
  101.             
  102.         default:
  103.             return FALSE;
  104.  
  105.     }
  106.  
  107.     return TRUE;
  108. }
  109.  
  110.  
  111.  
  112.  
  113. //
  114. // This sample uses main() instead of WinMain
  115. //
  116. void main( int argc, char *argv[], char **envp )
  117. {
  118.    FARPROC lpproc;
  119.  
  120.    Ctl3dRegister(_hInstance);
  121.    Ctl3dAutoSubclass(_hInstance);
  122.  
  123.    lpproc = MakeProcInstance((FARPROC) DialogProc, _hInstance);
  124.    DialogBox(_hInstance, MAKEINTRESOURCE(100), NULL, lpproc);
  125.    FreeProcInstance(lpproc);
  126.  
  127.    Ctl3dUnregister(_hInstance);
  128.    return;
  129. }
  130.