Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

winfuncs.cpp

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include "shared.h"
00003 #include "resource.rh"
00004 #include "mmgr.h"
00005 
00006 extern int DialogInUse;
00007 extern float lightColor[3];
00008 extern HWND hWnd;
00009 extern HWND hWndStartDlg;
00010 extern char szText[BUFFER_SIZE];
00011 extern char Directory[MAX_PATH];
00012 extern char AppDirectory[MAX_PATH];  // This application's directory
00013 extern char HaloTypeName[MAX_PATH];         // filename and path to the tga images
00014 extern char FireTypeName[MAX_PATH];
00015 extern char SplineFileName[MAX_PATH];  // filename and path to the spline data
00016 
00017 HWND hWndOfDlg;
00018 OPENFILENAME ofn;
00019 char CurrentDirectory[MAX_PATH];
00020 
00021 // Initialization dialog process
00022 BOOL CALLBACK StartProc(HWND hwnd,UINT Message, WPARAM wParam, LPARAM /*lParam*/)
00023 {
00024     switch(Message)
00025     {
00026         case WM_INITDIALOG:
00027             hWndStartDlg = hwnd;
00028 
00029             SendDlgItemMessage(hwnd, IDC_DLG_TEXT1, EM_SETLIMITTEXT, (WPARAM)BUFFER_SIZE - 1, (LPARAM)0);
00030 
00031             sprintf(SplineFileName, "%s", AppDirectory);
00032             strcat(SplineFileName, "\\default.spn");
00033             SetDlgItemText(hWndStartDlg, IDC_DLG_TEXT1, SplineFileName);
00034         return TRUE;
00035 
00036         case WM_COMMAND:
00037             switch(LOWORD(wParam))
00038             {
00039                 case IDCANCEL:
00040                     EndDialog(hwnd, IDCANCEL);
00041                 return TRUE;
00042 
00043                 case IDOK:
00044                     if (GetDlgItemText(hwnd, IDC_DLG_TEXT1, szText, BUFFER_SIZE))
00045                         sprintf(SplineFileName, "%s", szText);
00046                     else
00047                         return FALSE;
00048                     EndDialog(hwnd, IDOK);
00049                 return TRUE;
00050 
00051                 case IDC_DLG_SETPATH1:
00052                     sprintf(szText, "%s", SplineFileName);
00053                     ZeroMemory(&ofn, sizeof(ofn));
00054                     ofn.lStructSize = sizeof(ofn);
00055                     ofn.hwndOwner = hWndStartDlg;
00056                     ofn.lpstrFilter = "Spline Files (*.spn)\0*.spn\0\0";
00057                     ofn.lpstrFile = szText;
00058                     ofn.nMaxFile = MAX_PATH;
00059                     ofn.lpstrInitialDir = AppDirectory;
00060                     ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
00061                     ofn.lpstrDefExt = "spn";
00062                     if(GetOpenFileName(&ofn))
00063                         SetDlgItemText(hWndStartDlg, IDC_DLG_TEXT1, szText);
00064                     sprintf(SplineFileName, "%s", szText);
00065                 return TRUE;
00066             }
00067         break;
00068     }
00069     return FALSE;
00070 }
00071 
00072 // Hook function for color common dialog window
00073 UINT APIENTRY ColorDialogHook(HWND hdlg, UINT msg, WPARAM, LPARAM)
00074 {
00075     switch (msg)
00076     {
00077         case WM_INITDIALOG:
00078         {
00079             if(DialogInUse == 1)  // Ambient
00080                 SetWindowText(hdlg, "Choose Ambient Color");
00081             if(DialogInUse == 2)  // Diffuse
00082                 SetWindowText(hdlg, "Choose Diffuse Color");
00083             if(DialogInUse == 3)  // Specular
00084                 SetWindowText(hdlg, "Choose Specular Color");
00085             return TRUE;
00086         }
00087 
00088         default:
00089             return FALSE;
00090     }
00091 }
00092 
00093 void GetLightColor()
00094 {
00095     COLORREF colors[16];
00096     COLORREF colorRGB = RGB(lightColor[0]*255, lightColor[1]*255, lightColor[2]*255);
00097     CHOOSECOLOR colorDialog;
00098     memset(&colorDialog,0,sizeof(colorDialog));
00099     memset(colors,255,sizeof(colors));
00100     colorDialog.lStructSize = sizeof(CHOOSECOLOR);
00101     colorDialog.hwndOwner = hWnd;
00102     colorDialog.rgbResult = colorRGB;
00103     colorDialog.lpCustColors = colors;
00104     colorDialog.Flags = CC_FULLOPEN | CC_RGBINIT | CC_ENABLEHOOK;
00105     colorDialog.lpfnHook = (LPCCHOOKPROC)ColorDialogHook;
00106     ChooseColor(&colorDialog);
00107     lightColor[0] = (float)GetRValue(colorDialog.rgbResult)/255;
00108     lightColor[1] = (float)GetGValue(colorDialog.rgbResult)/255;
00109     lightColor[2] = (float)GetBValue(colorDialog.rgbResult)/255;
00110 }

Generated on Fri Dec 23 05:15:48 2005 for Constructive Solid Geometry by doxygen1.2.15