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

Generated on Fri Dec 23 05:20:39 2005 for Potentially Visible Sets by doxygen1.2.15