home *** CD-ROM | disk | FTP | other *** search
- #include <windows.h>
- #include <string.h>
- #include "ids.h"
- #include "demo.h"
- #include "three_d.h"
-
- BOOL FAR PASCAL DemoDlgProc(HWND,WORD,WORD,LONG);
- BOOL FAR PASCAL AboutDlgProc(HWND,WORD,WORD,LONG);
- static void AdjustPosition(HWND);
-
- extern HANDLE hInst;
-
- /*
- ****************************************************************************
- DemoDlgProc()
- Handles all messages for the 3-D demo dialog box.
- ****************************************************************************
- */
-
- BOOL FAR PASCAL DemoDlgProc(HWND hDlg, WORD msg, WORD wParam, LONG lParam)
- {
- FARPROC lpprocAboutDlg;
-
- switch (msg)
- {
- case WM_INITDIALOG:
- AdjustPosition(hDlg);
- /* Fill listboxes and combo boxes with current directory listing */
- DlgDirList(hDlg,"*.*",IDD_9,NULL,0x0000);
- DlgDirListComboBox(hDlg,"*.*",IDD_12,NULL,0x0000);
- DlgDirListComboBox(hDlg,"*.*",IDD_13,NULL,0x0000);
- DlgDirListComboBox(hDlg,"*.*",IDD_14,NULL,0x0000);
- break;
-
- case WM_CTLCOLOR: /* Allow DLL to handle this one */
- return(Control3dColor(hDlg,wParam));
-
- case WM_PAINT:
- /* This posts a message to the DLL defined message WM_3DPAINT */
- /* It is very important to return FALSE here, to allow the dialog */
- /* handler to process the WM_PAINT message first */
- PostMessage(hDlg,WM_3DPAINT,0,0L);
- return (FALSE);
-
- case WM_3DPAINT:
- /* This code calls functions in the DLL to make the controls in the */
- /* dialog box 3-D */
-
- Draw3dFrame(hDlg,INSIDE_FRAME);
- Draw3dBorder(hDlg,IDD_1,RECESSED,1);
- Draw3dBorder(hDlg,IDD_2,RAISED,1);
-
- Draw3dBorder(hDlg,IDD_3,RECESSED,2);
- Draw3dBorder(hDlg,IDD_4,RAISED,2);
- Draw3dShadow(hDlg,IDD_5);
-
- Draw3dBorder(hDlg,IDD_6,RECESSED,3);
- Draw3dBorder(hDlg,IDD_7,RAISED,3);
- Draw3dShadow(hDlg,IDD_8);
-
- Draw3dBorder(hDlg,IDD_9,RECESSED,1);
- Draw3dBorder(hDlg,IDD_10,RAISED,1);
- Draw3dShadow(hDlg,IDD_11);
-
- Draw3dBorder(hDlg,IDD_12,RECESSED,2);
- Draw3dBorder(hDlg,IDD_13,RAISED,2);
- Draw3dShadow(hDlg,IDD_14);
-
- Draw3dBorder(hDlg,IDD_15,RECESSED,3);
- Draw3dBorder(hDlg,IDD_16,RAISED,3);
- Draw3dShadow(hDlg,IDD_17);
-
- Draw3dBorder(hDlg,IDOK,RECESSED,2);
- Draw3dBorder(hDlg,IDCANCEL,RAISED,2);
- Draw3dShadow(hDlg,IDD_ABOUT);
-
- break;
-
- case WM_COMMAND:
- switch(wParam)
- {
- case IDOK:
- case IDCANCEL:
- EndDialog(hDlg,TRUE);
- break;
-
- case IDD_ABOUT:
- lpprocAboutDlg = MakeProcInstance(AboutDlgProc,hInst);
- DialogBox(hInst,"AboutBox",hDlg,lpprocAboutDlg);
- FreeProcInstance(lpprocAboutDlg);
- break;
-
- default:
- return (FALSE);
- }
- break;
-
- default:
- return(FALSE);
- }
- return (TRUE);
- }
-
- BOOL FAR PASCAL AboutDlgProc(HWND hDlg, WORD msg, WORD wParam, LONG lParam)
- {
- PAINTSTRUCT ps;
-
- switch (msg)
- {
- case WM_INITDIALOG:
- AdjustPosition(hDlg);
- break;
-
- case WM_CTLCOLOR:
- return(Control3dColor(hDlg,wParam));
-
- case WM_PAINT:
- PostMessage(hDlg,WM_3DPAINT,0,0L);
- return (FALSE);
-
- case WM_3DPAINT:
- Draw3dFrame(hDlg,OUTSIDE_FRAME);
- Draw3dBorder(hDlg,IDD_ICON1,RAISED,2);
- Draw3dBorder(hDlg,IDD_HEADER,RECESSED,2);
- Draw3dBorder(hDlg,IDD_ICON2,RAISED,2);
- Draw3dShadow(hDlg,IDD_RECT);
- break;
-
- case WM_COMMAND:
- switch(wParam)
- {
- case IDOK:
- EndDialog(hDlg,TRUE);
- break;
-
- default:
- return (FALSE);
- }
- break;
-
- default:
- return(FALSE);
- }
- return (TRUE);
- }
-
- /*
- ****************************************************************************
- AdjustPosition()
- Adjusts the position of the passed window so that it is centered both
- horizontally and vertically in the client of the main window.
- ****************************************************************************
- */
-
- void AdjustPosition(hWindow)
- HWND hWindow;
- {
- RECT hRect;
- short xSize,ySize,xPos,yPos;
- short xScreen,yScreen;
-
- xScreen = GetSystemMetrics(SM_CXSCREEN); /* Width of screen */
- yScreen = GetSystemMetrics(SM_CYSCREEN); /* Height of screen */
-
- GetWindowRect(hWindow,&hRect); /* Get dialog screen coordinates */
-
- xSize = hRect.right - hRect.left; /* x size of dialog box */
- ySize = hRect.bottom - hRect.top; /* y size of dialog box */
- xPos = (xScreen - xSize) / 2; /* Calculate x position */
- yPos = (yScreen - ySize) / 2; /* Calculate y position */
-
- /* Center the window based on the screen dimensions */
- MoveWindow(hWindow,xPos,yPos,xSize,ySize,FALSE);
-
- return;
- }
-
-