DXGL r566 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r565‎ | r566 | r567 >
Date:01:44, 16 November 2014
Author:admin
Status:new
Tags:
Comment:
Add tabs to new DXGLCFG dialog.
Fix a few code errors.
Modified paths:
  • /buildtool/buildtool.c (modified) (history)
  • /cfgmgr/cfgmgr.c (modified) (history)
  • /dxglcfg2/dxglcfg2.c (modified) (history)
  • /dxglcfg2/dxglcfg2.rc (modified) (history)
  • /dxgltest/dxgltest.cpp (modified) (history)

Diff [purge]

Index: buildtool/buildtool.c
@@ -230,7 +230,7 @@
231231 ZeroMemory(&startinfo,sizeof(STARTUPINFOA));
232232 startinfo.cb = sizeof(STARTUPINFOA);
233233 strcat(hhcpath," ");
234 - strcat(hhcpath,path);
 234+ strncat(hhcpath,path,MAX_PATH);
235235 if(CreateProcessA(NULL,hhcpath,NULL,NULL,FALSE,0,NULL,NULL,&startinfo,&process))
236236 {
237237 foundhhc = TRUE;
@@ -269,7 +269,7 @@
270270 ZeroMemory(&startinfo,sizeof(STARTUPINFOA));
271271 startinfo.cb = sizeof(STARTUPINFOA);
272272 strcat(nsispath," ");
273 - strcat(nsispath,path);
 273+ strncat(nsispath,path,MAX_PATH);
274274 if(CreateProcessA(NULL,nsispath,NULL,NULL,FALSE,0,NULL,NULL,&startinfo,&process))
275275 {
276276 foundnsis = TRUE;
Index: cfgmgr/cfgmgr.c
@@ -677,7 +677,7 @@
678678 HKEY hKey;
679679 TCHAR regkey[MAX_PATH + 24];
680680 _tcscpy(regkey,regkeybase);
681 - _tcscat(regkey,name);
 681+ _tcsncat(regkey, name, MAX_PATH);
682682 ZeroMemory(cfg,sizeof(DXGLCFG));
683683 cfg->DPIScale = 1;
684684 RegCreateKeyEx(HKEY_CURRENT_USER,regkey,0,NULL,0,KEY_ALL_ACCESS,NULL,&hKey,NULL);
@@ -697,7 +697,7 @@
698698 HKEY hKey;
699699 TCHAR regkey[MAX_PATH + 24];
700700 _tcscpy(regkey, regkeybase);
701 - _tcscat(regkey, name);
 701+ _tcsncat(regkey, name, MAX_PATH);
702702 RegCreateKeyEx(HKEY_CURRENT_USER, regkey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
703703 WriteSettings(hKey,cfg,mask,FALSE);
704704 RegCloseKey(hKey);
Index: dxglcfg2/dxglcfg2.c
@@ -75,6 +75,9 @@
7676 DWORD current_app;
7777 BOOL tristate;
7878 TCHAR strdefault[] = _T("(global default)");
 79+HWND hTab;
 80+HWND hTabs[5];
 81+int tabopen;
7982
8083 DWORD AddApp(LPCTSTR path, BOOL copyfile, BOOL admin)
8184 {
@@ -385,11 +388,11 @@
386389 if (ptr)
387390 {
388391 *ptr = 0;
389 - numerator = _ttof(buffer);
390 - denominator = _ttof(ptr + 1);
 392+ numerator = (float)_ttof(buffer);
 393+ denominator = (float)_ttof(ptr + 1);
391394 return numerator / denominator;
392395 }
393 - else return _ttof(buffer);
 396+ else return (float)_ttof(buffer);
394397 }
395398 }
396399 }
@@ -400,7 +403,61 @@
401404 if(str[0] == 0) mask[0] = 0;
402405 else mask[0] = 0xff;
403406 }
404 -
 407+LRESULT CALLBACK DisplayTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 408+{
 409+ switch (Msg)
 410+ {
 411+ case WM_INITDIALOG:
 412+ return TRUE;
 413+ default:
 414+ return FALSE;
 415+ }
 416+ return TRUE;
 417+}
 418+LRESULT CALLBACK Tab3DCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 419+{
 420+ switch (Msg)
 421+ {
 422+ case WM_INITDIALOG:
 423+ return TRUE;
 424+ default:
 425+ return FALSE;
 426+ }
 427+ return TRUE;
 428+}
 429+LRESULT CALLBACK EffectsTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 430+{
 431+ switch (Msg)
 432+ {
 433+ case WM_INITDIALOG:
 434+ return TRUE;
 435+ default:
 436+ return FALSE;
 437+ }
 438+ return TRUE;
 439+}
 440+LRESULT CALLBACK AdvancedTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 441+{
 442+ switch (Msg)
 443+ {
 444+ case WM_INITDIALOG:
 445+ return TRUE;
 446+ default:
 447+ return FALSE;
 448+ }
 449+ return TRUE;
 450+}
 451+LRESULT CALLBACK DebugTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 452+{
 453+ switch (Msg)
 454+ {
 455+ case WM_INITDIALOG:
 456+ return TRUE;
 457+ default:
 458+ return FALSE;
 459+ }
 460+ return TRUE;
 461+}
405462 LRESULT CALLBACK DXGLCfgCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
406463 {
407464 PIXELFORMATDESCRIPTOR pfd =
@@ -464,6 +521,8 @@
465522 LPTSTR regkey;
466523 BOOL failed;
467524 RECT r;
 525+ NMHDR *nm;
 526+ int newtab;
468527 TCITEM tab;
469528 drawitem = (DRAWITEMSTRUCT*)lParam;
470529 switch (Msg)
@@ -531,8 +590,20 @@
532591 SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 3, (LPARAM)&tab);
533592 tab.pszText = _T("Debug");
534593 SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 4, (LPARAM)&tab);
 594+ hTab = GetDlgItem(hWnd, IDC_TABS);
 595+ hTabs[0] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DISPLAY), hTab, DisplayTabCallback);
 596+ hTabs[1] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_3DGRAPHICS), hTab, Tab3DCallback);
 597+ hTabs[2] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_EFFECTS), hTab, EffectsTabCallback);
 598+ hTabs[3] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADVANCED), hTab, AdvancedTabCallback);
 599+ hTabs[4] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DEBUG), hTab, DebugTabCallback);
 600+ SendDlgItemMessage(hWnd, IDC_TABS, TCM_GETITEMRECT, 0, (LPARAM)&r);
 601+ SetWindowPos(hTabs[0], NULL, r.left, r.bottom + 3, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
 602+ ShowWindow(hTabs[1], SW_HIDE);
 603+ ShowWindow(hTabs[2], SW_HIDE);
 604+ ShowWindow(hTabs[3], SW_HIDE);
 605+ ShowWindow(hTabs[4], SW_HIDE);
 606+ tabopen = 0;
535607
536 -
537608 // Load global settings.
538609 /* // scaler
539610 _tcscpy(buffer,_T("Change desktop resolution"));
@@ -887,6 +958,20 @@
888959 break;
889960 }
890961 break;
 962+ case WM_NOTIFY:
 963+ nm = (LPNMHDR)lParam;
 964+ if (nm->code == TCN_SELCHANGE)
 965+ {
 966+ newtab = SendDlgItemMessage(hWnd, IDC_TABS, TCM_GETCURSEL, 0, 0);
 967+ if (newtab != tabopen)
 968+ {
 969+ ShowWindow(hTabs[tabopen], SW_HIDE);
 970+ tabopen = newtab;
 971+ SendDlgItemMessage(hWnd, IDC_TABS, TCM_GETITEMRECT, 0, (LPARAM)&r);
 972+ SetWindowPos(hTabs[tabopen], NULL, r.left, r.bottom + 3, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
 973+ }
 974+ }
 975+ break;
891976 case WM_DRAWITEM:
892977 switch(wParam)
893978 {
Index: dxglcfg2/dxglcfg2.rc
@@ -28,11 +28,11 @@
2929 // Dialog resources
3030 //
3131 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
32 -IDD_DISPLAY DIALOG 0, 0, 283, 176
33 -STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_POPUP | WS_SYSMENU
 32+IDD_DISPLAY DIALOG 0, 0, 283, 173
 33+STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
3434 FONT 8, "Ms Shell Dlg"
3535 {
36 - COMBOBOX IDC_VSYNC, 114, 92, 101, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
 36+ COMBOBOX IDC_VSYNC, 114, 92, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
3737 LTEXT "Vertical sync", IDC_STATIC, 114, 82, 41, 8, SS_LEFT, WS_EX_LEFT
3838 COMBOBOX IDC_EXTRAMODES, 114, 42, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
3939 LTEXT "Additional display modes", 0, 114, 32, 78, 8, SS_LEFT, WS_EX_LEFT
@@ -44,7 +44,7 @@
4545 COMBOBOX IDC_ASPECT, 7, 67, 102, 30, CBS_DROPDOWN | CBS_HASSTRINGS, WS_EX_LEFT
4646 COMBOBOX IDC_SCALE, 7, 42, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
4747 LTEXT "Scaling method", IDC_STATIC, 7, 32, 49, 8, SS_LEFT, WS_EX_LEFT
48 - COMBOBOX IDC_SORTMODES, 114, 67, 101, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
 48+ COMBOBOX IDC_SORTMODES, 114, 67, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
4949 LTEXT "Sort video modes", IDC_STATIC, 114, 57, 56, 8, SS_LEFT, WS_EX_LEFT
5050 COMBOBOX IDC_VIDMODE, 7, 17, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
5151 LTEXT "Video mode", IDC_STATIC, 7, 7, 38, 8, SS_LEFT, WS_EX_LEFT
@@ -54,25 +54,25 @@
5555
5656
5757 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
58 -IDD_3DGRAPHICS DIALOG 0, 0, 283, 176
59 -STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_POPUP | WS_SYSMENU
 58+IDD_3DGRAPHICS DIALOG 0, 0, 283, 173
 59+STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
6060 FONT 8, "Ms Shell Dlg"
6161 {
6262 LTEXT "Texture filter", IDC_STATIC, 7, 7, 43, 8, SS_LEFT, WS_EX_LEFT
6363 COMBOBOX IDC_TEXFILTER, 7, 17, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
6464 LTEXT "Anisotropic filtering", IDC_STATIC, 114, 7, 62, 8, SS_LEFT, WS_EX_LEFT
65 - COMBOBOX IDC_ANISO, 114, 17, 100, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
 65+ COMBOBOX IDC_ANISO, 114, 17, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
6666 LTEXT "Antialiasing (MSAA)", IDC_STATIC, 7, 32, 63, 8, SS_LEFT, WS_EX_LEFT
6767 COMBOBOX IDC_MSAA, 7, 42, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
6868 LTEXT "Renderer aspect ratio", IDC_STATIC, 114, 32, 71, 8, SS_LEFT, WS_EX_LEFT
69 - COMBOBOX IDC_ASPECT3D, 114, 42, 100, 14, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
 69+ COMBOBOX IDC_ASPECT3D, 114, 42, 102, 14, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
7070 }
7171
7272
7373
7474 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
75 -IDD_DEBUG DIALOG 0, 0, 283, 176
76 -STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_POPUP | WS_SYSMENU
 75+IDD_DEBUG DIALOG 0, 0, 283, 173
 76+STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
7777 FONT 8, "Ms Shell Dlg"
7878 {
7979 LISTBOX IDC_DEBUGLIST, 7, 7, 269, 162, WS_TABSTOP | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_OWNERDRAWFIXED | LBS_SORT | LBS_NOTIFY, WS_EX_LEFT
@@ -81,8 +81,8 @@
8282
8383
8484 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
85 -IDD_EFFECTS DIALOG 0, 0, 283, 176
86 -STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_POPUP | WS_SYSMENU
 85+IDD_EFFECTS DIALOG 0, 0, 283, 173
 86+STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
8787 FONT 8, "Ms Shell Dlg"
8888 {
8989 LTEXT "Y", IDC_CUSTOMSCALELABELY, 57, 72, 6, 8, WS_DISABLED | SS_LEFT, WS_EX_LEFT
@@ -118,15 +118,15 @@
119119
120120
121121 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
122 -IDD_ADVANCED DIALOG 0, 0, 283, 176
123 -STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_POPUP | WS_SYSMENU
 122+IDD_ADVANCED DIALOG 0, 0, 283, 173
 123+STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
124124 FONT 8, "Ms Shell Dlg"
125125 {
126126 PUSHBUTTON "Write INI file...", IDC_WRITEINI, 203, 155, 73, 14, 0, WS_EX_LEFT
127127 COMBOBOX IDC_TEXTUREFORMAT, 7, 17, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
128128 LTEXT "Texture format", IDC_STATIC, 7, 7, 50, 8, SS_LEFT, WS_EX_LEFT
129 - LTEXT "Texture access method", IDC_STATIC, 111, 7, 76, 8, SS_LEFT, WS_EX_LEFT
130 - COMBOBOX IDC_TEXUPLOAD, 111, 17, 100, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
 129+ LTEXT "Texture access method", IDC_STATIC, 114, 7, 76, 8, SS_LEFT, WS_EX_LEFT
 130+ COMBOBOX IDC_TEXUPLOAD, 114, 17, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
131131 }
132132
133133
Index: dxgltest/dxgltest.cpp
@@ -777,7 +777,6 @@
778778 }
779779 }
780780 break;
781 - break;
782781 default:
783782 return FALSE;
784783 }