From 3ac9b07639e29ab837c4a18862b61d63a128cb4c Mon Sep 17 00:00:00 2001 From: luigi__ Date: Wed, 9 Sep 2009 18:11:51 +0000 Subject: [PATCH] Windows port: Add a constructor to CToolWindow. Also fix a bug that would cause the Adhoc interface to always be initialized even when SoftAP is selected. --- desmume/src/windows/CWindow.cpp | 25 ++++++++++++++++++------- desmume/src/windows/CWindow.h | 9 +++++++-- desmume/src/windows/main.cpp | 19 +++++++++++-------- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/desmume/src/windows/CWindow.cpp b/desmume/src/windows/CWindow.cpp index 7c5d48886..3a2b671d9 100644 --- a/desmume/src/windows/CWindow.cpp +++ b/desmume/src/windows/CWindow.cpp @@ -47,14 +47,9 @@ DWORD GetFontQuality() vector ReggedWndClasses; -bool RegWndClass(string name, WNDPROC wndProc, int extraSize) +bool RegWndClass(string name, WNDPROC wndProc, UINT style, int extraSize) { - return RegWndClass(name, wndProc, 0, NULL, extraSize); -} - -bool RegWndClass(string name, WNDPROC wndProc, HICON icon, int extraSize) -{ - return RegWndClass(name, wndProc, 0, icon, extraSize); + return RegWndClass(name, wndProc, style, NULL, extraSize); } bool RegWndClass(string name, WNDPROC wndProc, UINT style, HICON icon, int extraSize) @@ -107,6 +102,22 @@ void UnregWndClass(string name) // Base toolwindow class //----------------------------------------------------------------------------- +CToolWindow::CToolWindow(char* className, WNDPROC proc, char* title, int width, int height) + : hWnd(NULL) +{ + DWORD style = WS_CAPTION | WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; + RECT rc; + + rc.left = 0; + rc.right = width; + rc.top = 0; + rc.bottom = height; + AdjustWindowRect(&rc, style, FALSE); + + hWnd = CreateWindow(className, title, style, CW_USEDEFAULT, CW_USEDEFAULT, + rc.right - rc.left, rc.bottom - rc.top, HWND_DESKTOP, NULL, hAppInst, (LPVOID)this); +} + CToolWindow::CToolWindow(int ID, DLGPROC proc, char* title) : hWnd(NULL) { diff --git a/desmume/src/windows/CWindow.h b/desmume/src/windows/CWindow.h index 35b85c7a3..09445c4fc 100644 --- a/desmume/src/windows/CWindow.h +++ b/desmume/src/windows/CWindow.h @@ -47,8 +47,7 @@ DWORD GetFontQuality(); // Incase the class was already registered, the function // just does nothing and returns true. // Returns false if registration failed. -bool RegWndClass(string name, WNDPROC wndProc, int extraSize = 0); -bool RegWndClass(string name, WNDPROC wndProc, HICON icon, int extraSize = 0); +bool RegWndClass(string name, WNDPROC wndProc, UINT style, int extraSize = 0); bool RegWndClass(string name, WNDPROC wndProc, UINT style, HICON icon, int extraSize = 0); // UnregWndClass() @@ -65,6 +64,12 @@ class CToolWindow { public: // CToolWindow constructor #1 + // Creates a window using CreateWindow(). + // If the window creation failed for whatever reason, + // hWnd will be NULL. + CToolWindow(char* className, WNDPROC proc, char* title, int width, int height); + + // CToolWindow constructor #2 // Creates a window from a dialog template resource. // If the window creation failed for whatever reason, // hWnd will be NULL. diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 433254822..02127d246 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -2078,6 +2078,9 @@ int _main() } addonsChangePak(addon_type); + CommonSettings.wifi.mode = GetPrivateProfileInt("Wifi", "Mode", 0, IniName); + CommonSettings.wifi.infraBridgeAdapter = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName); + #ifdef GDB_STUB if ( cmdline.arm9_gdb_port != 0) { arm9_gdb_stub = createStub_gdb( cmdline.arm9_gdb_port, @@ -2176,9 +2179,6 @@ int _main() GetPrivateProfileString("Firmware", "FirmwareFile", "firmware.bin", CommonSettings.Firmware, 256, IniName); CommonSettings.BootFromFirmware = GetPrivateProfileBool("Firmware", "BootFromFirmware", FALSE, IniName); - CommonSettings.wifi.mode = GetPrivateProfileInt("Wifi", "Mode", 0, IniName); - CommonSettings.wifi.infraBridgeAdapter = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName); - video.currentfilter = GetPrivateProfileInt("Video", "Filter", video.NONE, IniName); FilterUpdate(MainWindow->getHWnd(),false); @@ -2964,9 +2964,7 @@ void RunConfig(CONFIGSCREEN which) } else { -#endif MessageBox(MainWindow->getHWnd(),"winpcap failed to initialize, and so wifi cannot be configured.","wifi system failure",0); -#ifdef EXPERIMENTAL_WIFI } #endif break; @@ -3863,13 +3861,18 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM return 0; case IDM_IOREG: ViewRegisters->open(); - //OpenToolWindow(IORegView); + //if (!RegWndClass("DeSmuME_IORegView", IORegView_Proc, CS_DBLCLKS, sizeof(CIORegView*))) + // return 0; + + //OpenToolWindow(new CIORegView()); return 0; case IDM_MEMORY: //if(!MemView_IsOpened(ARMCPU_ARM9)) MemView_DlgOpen(HWND_DESKTOP, "ARM9 memory", ARMCPU_ARM9); //if(!MemView_IsOpened(ARMCPU_ARM7)) MemView_DlgOpen(HWND_DESKTOP, "ARM7 memory", ARMCPU_ARM7); - if (RegWndClass("MemView_ViewBox", MemView_ViewBoxProc, sizeof(CMemView*))) - OpenToolWindow(new CMemView()); + if (!RegWndClass("MemView_ViewBox", MemView_ViewBoxProc, 0, sizeof(CMemView*))) + return 0; + + OpenToolWindow(new CMemView()); return 0; case IDM_SOUND_VIEW: if(!SoundView_IsOpened()) SoundView_DlgOpen(HWND_DESKTOP);