DXGL r708 - Code Review
For
DXGL
(
recent comments
|
status changes
|
tags
|
authors
|
states
|
release notes
|
statistics
)
Jump to navigation
Jump to search
Repository:
DXGL
Revision:
<
r707
|
r708
|
r709
>
Date:
05:45, 30 May 2017
Author:
admin
Status:
new
Tags:
Comment:
Allow only one instance of the DXGL Config dialog.
Modified paths:
/dxglcfg/dxglcfg.c
(modified) (
history
)
/dxglcfg2/dxglcfg2.c
(modified) (
history
)
Diff
[
purge
]
Index: dxglcfg/dxglcfg.c
—
—
@@ -1688,6 +1688,8 @@
1689
1689
INITCOMMONCONTROLSEX icc;
1690
1690
HMODULE comctl32;
1691
1691
BOOL(WINAPI *iccex)(LPINITCOMMONCONTROLSEX lpInitCtrls);
1692
+ HANDLE hMutex;
1693
+ HWND hWnd;
1692
1694
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
1693
1695
GetVersionEx(&osver);
1694
1696
CoInitialize(NULL);
—
—
@@ -1722,7 +1724,18 @@
1723
1725
// Message for when transitioning to the new config UI
1724
1726
/*MessageBox(NULL, _T("This version of DXGL Config is deprecated and no longer supported. Some options may no longer work correctly."),
1725
1727
_T("Notice"), MB_OK | MB_ICONWARNING);*/
1728
+ hMutex = CreateMutex(NULL, TRUE, _T("DXGLConfigMutex"));
1729
+ if (GetLastError() == ERROR_ALREADY_EXISTS)
1730
+ {
1731
+ // Find DXGL Config window
1732
+ hWnd = FindWindow(NULL, _T("DXGL Config"));
1733
+ // Focus DXGL Config window
1734
+ if (hWnd) SetForegroundWindow(hWnd);
1735
+ return 0;
1736
+ }
1726
1737
DialogBox(hInstance,MAKEINTRESOURCE(IDD_DXGLCFG),0,(DLGPROC)DXGLCfgCallback);
1738
+ ReleaseMutex(hMutex);
1739
+ CloseHandle(hMutex);
1727
1740
#ifdef _DEBUG
1728
1741
_CrtDumpMemoryLeaks();
1729
1742
#endif
Index: dxglcfg2/dxglcfg2.c
—
—
@@ -1968,6 +1968,8 @@
1969
1969
INITCOMMONCONTROLSEX icc;
1970
1970
HMODULE comctl32;
1971
1971
BOOL(WINAPI *iccex)(LPINITCOMMONCONTROLSEX lpInitCtrls);
1972
+ HANDLE hMutex;
1973
+ HWND hWnd;
1972
1974
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
1973
1975
GetVersionEx(&osver);
1974
1976
CoInitialize(NULL);
—
—
@@ -1999,7 +2001,18 @@
2000
2002
GetModuleFileName(NULL,hlppath,MAX_PATH);
2001
2003
GetDirFromPath(hlppath);
2002
2004
_tcscat(hlppath,_T("\\dxgl.chm"));
2005
+ hMutex = CreateMutex(NULL, TRUE, _T("DXGLConfigMutex"));
2006
+ if (GetLastError() == ERROR_ALREADY_EXISTS)
2007
+ {
2008
+ // Find DXGL Config window
2009
+ hWnd = FindWindow(NULL, _T("DXGL Config (Experimental)"));
2010
+ // Focus DXGL Config window
2011
+ if (hWnd) SetForegroundWindow(hWnd);
2012
+ return 0;
2013
+ }
2003
2014
DialogBox(hInstance,MAKEINTRESOURCE(IDD_DXGLCFG),0,(DLGPROC)DXGLCfgCallback);
2015
+ ReleaseMutex(hMutex);
2016
+ CloseHandle(hMutex);
2004
2017
#ifdef _DEBUG
2005
2018
_CrtDumpMemoryLeaks();
2006
2019
#endif
Navigation menu
Personal tools
Log in
Namespaces
Special page
English
expanded
collapsed
Views
More
expanded
collapsed
Search
Navigation
Home
Main page
Recent changes
Random page
MediaWiki help
Introduction
Progress
Downloads
Source code
Build from source
AppDB
Bug reports
Forums
Tools
Special pages
Printable version