From 23e8a773fa57f2f3605a1cd0e56d2ba4fc8c0331 Mon Sep 17 00:00:00 2001 From: "law%netscape.com" Date: Thu, 13 Aug 1998 06:34:31 +0000 Subject: [PATCH] Adding support for new 'desktop' preferences --- cmd/winfe/prefs/nsprefui/src/framedlg.cpp | 5 +++- cmd/winfe/prefs/nsprefui/src/framedlg.h | 6 ++++ cmd/winfe/prefs/nsprefui/src/prefui.cpp | 35 ++++++++++++++--------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/cmd/winfe/prefs/nsprefui/src/framedlg.cpp b/cmd/winfe/prefs/nsprefui/src/framedlg.cpp index 7630264000a7..548fa28bc58f 100644 --- a/cmd/winfe/prefs/nsprefui/src/framedlg.cpp +++ b/cmd/winfe/prefs/nsprefui/src/framedlg.cpp @@ -215,6 +215,8 @@ DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////// // CPropertyFrameDialog implementation +HWND CPropertyFrameDialog::m_hwndShowing = 0; + // Constructor CPropertyFrameDialog::CPropertyFrameDialog(HWND hwndOwner, int x, @@ -286,7 +288,7 @@ CPropertyFrameDialog::InitDialog(HWND hdlg) HWND hwnd; // Save away the window handle for the dialog - m_hdlg = hdlg; + m_hwndShowing = m_hdlg = hdlg; // Get the bold font we will be using. It's the same font as the // dialog box uses, except it's bold @@ -885,6 +887,7 @@ CPropertyFrameDialog::DoModal() // Cleanup if (m_pCurPage) m_pCurPage->m_pPage->SetObjects(0, NULL); + m_hwndShowing = 0; DestroyWindow(m_hdlg); return nResult; diff --git a/cmd/winfe/prefs/nsprefui/src/framedlg.h b/cmd/winfe/prefs/nsprefui/src/framedlg.h index a384554772f8..4d7457557cce 100644 --- a/cmd/winfe/prefs/nsprefui/src/framedlg.h +++ b/cmd/winfe/prefs/nsprefui/src/framedlg.h @@ -48,12 +48,18 @@ class CPropertyFrameDialog { // a chance to translate accelerators HRESULT TranslateAccelerator(LPMSG); + // Static functions to be used to ensure only one property frame is + // showing. + static BOOL IsShowing() { return m_hwndShowing != 0; } + static void BringToTop() { ::BringWindowToTop(m_hwndShowing); } + protected: int RunModalLoop(); private: HWND m_hdlg; HWND m_hwndOwner; + static HWND m_hwndShowing; int m_x, m_y; LPCSTR m_lpszCaption; ULONG m_nInitialCategory; diff --git a/cmd/winfe/prefs/nsprefui/src/prefui.cpp b/cmd/winfe/prefs/nsprefui/src/prefui.cpp index 79551d17d3df..02b3e24b5af3 100644 --- a/cmd/winfe/prefs/nsprefui/src/prefui.cpp +++ b/cmd/winfe/prefs/nsprefui/src/prefui.cpp @@ -330,20 +330,27 @@ NS_CreatePropertyFrame(HWND hwndOwner, if (nCategories == 0) return ResultFromScode(S_FALSE); - // Create the property frame dialog - CPropertyFrameDialog dialog(hwndOwner, x, y, lpszCaption, lpfnNetHelp); - - // Initialize the property frame dialog - hres = dialog.CreatePages(nCategories, lplpProviders, nInitial); - if (FAILED(hres)) { -#ifdef _DEBUG - OutputDebugString("CPropertyFrameDialog::CreatePages failed\n"); -#endif - return hres; - } - - // Display the property frame as a modal dialog - dialog.DoModal(); + // Catch cases where prefs already showing; we can get here if prefs are + // showing and user does "mozilla -prefs", for example. + if ( CPropertyFrameDialog::IsShowing() ) { + // Bring existing property frame dialog to top. + CPropertyFrameDialog::BringToTop(); + } else { + // Create the property frame dialog + CPropertyFrameDialog dialog(hwndOwner, x, y, lpszCaption, lpfnNetHelp); + + // Initialize the property frame dialog + hres = dialog.CreatePages(nCategories, lplpProviders, nInitial); + if (FAILED(hres)) { + #ifdef _DEBUG + OutputDebugString("CPropertyFrameDialog::CreatePages failed\n"); + #endif + return hres; + } + + // Display the property frame as a modal dialog + dialog.DoModal(); + } return NOERROR; }