Class Window is the base class for several C++ window wrapper classes. More...
#include <window.h>
Classes | |
struct | StaticWindowData |
structure for managing critical sections as static class information in struct Window More... | |
Public Types | |
typedef map< HWND, Window * > | WindowMap |
typedef Window *(* | CREATORFUNC )(HWND) |
typedef Window *(* | CREATORFUNC_INFO )(HWND, const void *) |
Public Member Functions | |
Window (HWND hwnd) | |
virtual | ~Window () |
LRESULT | SendParent (UINT nmsg, WPARAM wparam=0, LPARAM lparam=0) |
LRESULT | PostParent (UINT nmsg, WPARAM wparam=0, LPARAM lparam=0) |
Static Public Member Functions | |
static HWND | Create (CREATORFUNC creator, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0) |
static HWND | Create (CREATORFUNC_INFO creator, const void *info, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0) |
static Window * | create_mdi_child (const ChildWndInfo &info, const MDICREATESTRUCT &mcs, CREATORFUNC_INFO creator) |
static LRESULT CALLBACK | WindowWndProc (HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) |
static INT_PTR CALLBACK | DialogProc (HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) |
static Window * | get_window (HWND hwnd) |
get window controller from window handle | |
template<typename CLASS > | |
static CLASS * | get_window (HWND hwnd) |
static void | register_pretranslate (HWND hwnd) |
static void | unregister_pretranslate (HWND hwnd) |
static BOOL | pretranslate_msg (LPMSG pmsg) |
static void | register_dialog (HWND hwnd) |
static void | unregister_dialog (HWND hwnd) |
static BOOL | dispatch_dialog_msg (LPMSG pmsg) |
static int | MessageLoop () |
static void | CancelModes () |
Protected Member Functions | |
virtual LRESULT | Init (LPCREATESTRUCT pcs) |
virtual LRESULT | WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam) |
virtual int | Command (int id, int code) |
virtual int | Notify (int id, NMHDR *pnmh) |
Static Protected Member Functions | |
static Window * | create_controller (HWND hwnd) |
create controller for a new window | |
static StaticWindowData & | GetStaticWindowData () |
static LRESULT CALLBACK | MDICBTHookProc (int code, WPARAM wparam, LPARAM lparam) |
static LRESULT CALLBACK | PropSheetCBTHookProc (int code, WPARAM wparam, LPARAM lparam) |
Static Protected Attributes | |
static WindowMap | s_wnd_map |
static const void * | s_new_info = NULL |
static CREATORFUNC | s_window_creator = NULL |
static HHOOK | s_hcbtHook = 0 |
static WindowSet | s_pretranslate_windows |
static WindowSet | s_dialogs |
Class Window is the base class for several C++ window wrapper classes.
Window objects are allocated from the heap. They are automatically freed when the window gets destroyed.
Definition at line 58 of file window.h.
typedef Window*(* Window::CREATORFUNC)(HWND) |
typedef Window*(* Window::CREATORFUNC_INFO)(HWND, const void *) |
Window::Window | ( | HWND | hwnd ) |
Definition at line 74 of file window.cpp.
References WindowHandle::_hwnd, GetStaticWindowData(), and s_wnd_map.
: WindowHandle(hwnd) { Lock lock(GetStaticWindowData()._map_crit_sect); // protect access to s_wnd_map s_wnd_map[_hwnd] = this; }
Window::~Window | ( | ) | [virtual] |
Definition at line 82 of file window.cpp.
References WindowHandle::_hwnd, GetStaticWindowData(), and s_wnd_map.
{ Lock lock(GetStaticWindowData()._map_crit_sect); // protect access to s_wnd_map s_wnd_map.erase(_hwnd); }
void Window::CancelModes | ( | ) | [static] |
Reimplemented in NotifyArea.
Definition at line 298 of file window.cpp.
{ PostMessage(HWND_BROADCAST, WM_CANCELMODE, 0, 0); }
int Window::Command | ( | int | id, |
int | code | ||
) | [protected, virtual] |
Reimplemented in DesktopShellView, FindProgramDlg, DesktopSettingsDlg, TaskbarSettingsDlg, StartmenuSettingsDlg, MdiSdiDlg, FileChildWindow, MainFrameBase, MDIMainFrame, SDIMainFrame, DesktopBar, QuickLaunchBar, StartMenu, StartMenuHandler, FavoritesMenu, TaskBar, NotifyArea, TrayNotifyDlg, SubclassedWindow, Dialog, and PropSheetPageDlg.
Definition at line 288 of file window.cpp.
Referenced by TaskBar::Command(), StartMenu::Command(), DialogProc(), and WindowWndProc().
{ return 1; // no command handler found }
HWND Window::Create | ( | CREATORFUNC_INFO | creator, |
const void * | info, | ||
DWORD | dwExStyle, | ||
LPCTSTR | lpClassName, | ||
LPCTSTR | lpWindowName, | ||
DWORD | dwStyle, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
HWND | hwndParent = 0 , |
||
HMENU | hMenu = 0 |
||
) | [static] |
Definition at line 105 of file window.cpp.
References ExplorerGlobals::_hInstance, g_Globals, GetStaticWindowData(), s_new_info, and s_window_creator.
{ Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info s_window_creator = (CREATORFUNC) creator; s_new_info = info; return CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, w, h, hwndParent, hMenu, g_Globals._hInstance, 0/*lpParam*/); }
HWND Window::Create | ( | CREATORFUNC | creator, |
DWORD | dwExStyle, | ||
LPCTSTR | lpClassName, | ||
LPCTSTR | lpWindowName, | ||
DWORD | dwStyle, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
HWND | hwndParent = 0 , |
||
HMENU | hMenu = 0 |
||
) | [static] |
Definition at line 90 of file window.cpp.
References ExplorerGlobals::_hInstance, g_Globals, GetStaticWindowData(), s_new_info, and s_window_creator.
Referenced by MDIShellBrowserChild::WndProc().
{ Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info s_window_creator = creator; s_new_info = NULL; return CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, w, h, hwndParent, hMenu, g_Globals._hInstance, 0/*lpParam*/); }
create controller for a new window
Definition at line 223 of file window.cpp.
References GetStaticWindowData(), s_new_info, and s_window_creator.
Referenced by DialogProc(), MDICBTHookProc(), PropSheetCBTHookProc(), and WindowWndProc().
{ if (s_window_creator) { // protect for recursion and create the window object only for the first window Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info const void* info = s_new_info; s_new_info = NULL; CREATORFUNC window_creator = s_window_creator; s_window_creator = NULL; if (info) return CREATORFUNC_INFO(window_creator)(hwnd, info); else return CREATORFUNC(window_creator)(hwnd); } return NULL; }
Window * Window::create_mdi_child | ( | const ChildWndInfo & | info, |
const MDICREATESTRUCT & | mcs, | ||
CREATORFUNC_INFO | creator | ||
) | [static] |
Definition at line 121 of file window.cpp.
References ChildWndInfo::_hmdiclient, WindowHandle::_hwnd, get_window(), GetStaticWindowData(), HWND, MDICBTHookProc(), s_hcbtHook, s_new_info, and s_window_creator.
Referenced by ChildWindow::create(), and FileChildWindow::create().
{ Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info s_window_creator = (CREATORFUNC) creator; s_new_info = &info; s_hcbtHook = SetWindowsHookEx(WH_CBT, MDICBTHookProc, 0, GetCurrentThreadId()); HWND hwnd = (HWND) SendMessage(info._hmdiclient, WM_MDICREATE, 0, (LPARAM)&mcs); // end hook in case it's not already done if (s_hcbtHook) UnhookWindowsHookEx(s_hcbtHook); Window* child = get_window(hwnd); s_new_info = NULL; if (child && (!hwnd || !child->_hwnd)) child = NULL; return child; }
INT_PTR CALLBACK Window::DialogProc | ( | HWND | hwnd, |
UINT | nmsg, | ||
WPARAM | wparam, | ||
LPARAM | lparam | ||
) | [static] |
Reimplemented in PropSheetPageDlg.
Definition at line 720 of file window.cpp.
References Command(), create_controller(), get_window(), Init(), NFR_CURRENT, Notify(), and WndProc().
Referenced by Dialog::DoModal().
{ Window* pThis = get_window(hwnd); if (pThis) { switch(nmsg) { case WM_COMMAND: pThis->Command(LOWORD(wparam), HIWORD(wparam)); return TRUE; // message has been processed case WM_NOTIFY: pThis->Notify(wparam, (NMHDR*)lparam); return TRUE; // message has been processed case WM_NOTIFYFORMAT: SetWindowLong(hwnd, DWLP_MSGRESULT, NFR_CURRENT); // set return value NFR_CURRENT return TRUE; // message has been processed case WM_NCDESTROY: delete pThis; return TRUE; // message has been processed default: return pThis->WndProc(nmsg, wparam, lparam); } } else if (nmsg == WM_INITDIALOG) { pThis = create_controller(hwnd); if (pThis) return pThis->Init(NULL); } return FALSE; // message has not been processed }
static BOOL Window::dispatch_dialog_msg | ( | LPMSG | pmsg ) | [static] |
Referenced by PropertySheetDialog::DoModal(), MessageLoop(), and StartMenuRoot::TrackStartmenu().
get window controller from window handle
Definition at line 206 of file window.cpp.
References GetStaticWindowData(), and s_wnd_map.
Referenced by create_mdi_child(), DialogProc(), MDICBTHookProc(), PropSheetCBTHookProc(), and WindowWndProc().
{ { Lock lock(GetStaticWindowData()._map_crit_sect); // protect access to s_wnd_map WindowMap::const_iterator found = s_wnd_map.find(hwnd); if (found!=s_wnd_map.end()) return found->second; } return NULL; }
static CLASS* Window::get_window | ( | HWND | hwnd ) | [inline, static] |
Definition at line 87 of file window.h.
References get_window().
Referenced by get_window().
{return static_cast<CLASS*>(get_window(hwnd));}
Window::StaticWindowData & Window::GetStaticWindowData | ( | ) | [static, protected] |
Definition at line 66 of file window.cpp.
Referenced by Create(), create_controller(), create_mdi_child(), Dialog::DoModal(), get_window(), Window(), and ~Window().
{ static StaticWindowData s_initialized_data; return s_initialized_data; }
LRESULT Window::Init | ( | LPCREATESTRUCT | pcs ) | [protected, virtual] |
Reimplemented in DesktopWindow, MDIShellBrowserChild, DesktopBar, StartMenu, StartMenuRoot, TaskBar, and NotifyArea.
Definition at line 244 of file window.cpp.
Referenced by PropSheetPageDlg::DialogProc(), DialogProc(), NotifyArea::Init(), TaskBar::Init(), StartMenu::Init(), MDIShellBrowserChild::Init(), DesktopBar::Init(), DesktopWindow::Init(), SubclassedWindow::SubclassedWndProc(), and WindowWndProc().
{
return 0;
}
LRESULT CALLBACK Window::MDICBTHookProc | ( | int | code, |
WPARAM | wparam, | ||
LPARAM | lparam | ||
) | [static, protected] |
Definition at line 145 of file window.cpp.
References create_controller(), get_window(), HWND, and s_hcbtHook.
Referenced by create_mdi_child().
{ if (code == HCBT_CREATEWND) { UnhookWindowsHookEx(s_hcbtHook); // use the hook only for the first created window s_hcbtHook = 0; HWND hwnd = (HWND)wparam; // create Window controller and associate it with the window handle Window* child = get_window(hwnd); if (!child) child = create_controller(hwnd); } return CallNextHookEx(s_hcbtHook, code, wparam, lparam); }
int Window::MessageLoop | ( | ) | [static] |
Definition at line 624 of file window.cpp.
References dispatch_dialog_msg(), HandleException(), and pretranslate_msg().
Referenced by explorer_main().
{ MSG msg; while(GetMessage(&msg, 0, 0, 0)) { try { if (pretranslate_msg(&msg)) continue; if (dispatch_dialog_msg(&msg)) continue; TranslateMessage(&msg); try { DispatchMessage(&msg); } catch(COMException& e) { HandleException(e, 0); } } catch(COMException& e) { HandleException(e, 0); } } return msg.wParam; }
int Window::Notify | ( | int | id, |
NMHDR * | pnmh | ||
) | [protected, virtual] |
Reimplemented in DesktopShellView, FindProgramDlg, DesktopSettingsDlg, TaskbarSettingsDlg, FileChildWindow, MainFrameBase, Pane, DesktopBar, QuickLaunchBar, TaskBar, NotifyArea, TrayNotifyDlg, ClockWindow, SubclassedWindow, ShellBrowserChildT< ChildWindow >, and ShellBrowserChildT< MainFrameBase >.
Definition at line 293 of file window.cpp.
Referenced by PropSheetPageDlg::DialogProc(), DialogProc(), TaskBar::Notify(), TaskbarSettingsDlg::Notify(), DesktopSettingsDlg::Notify(), and WindowWndProc().
{
return 0;
}
LRESULT Window::PostParent | ( | UINT | nmsg, |
WPARAM | wparam = 0 , |
||
LPARAM | lparam = 0 |
||
) |
Definition at line 662 of file window.cpp.
References WindowHandle::_hwnd, and HWND.
BOOL Window::pretranslate_msg | ( | LPMSG | pmsg ) | [static] |
Definition at line 592 of file window.cpp.
References PM_TRANSLATE_MSG, and s_pretranslate_windows.
Referenced by PropertySheetDialog::DoModal(), MessageLoop(), and StartMenuRoot::TrackStartmenu().
{ for(WindowSet::const_iterator it=Window::s_pretranslate_windows.begin(); it!=s_pretranslate_windows.end(); ++it) if (SendMessage(*it, PM_TRANSLATE_MSG, 0, (LPARAM)pmsg)) return TRUE; return FALSE; }
LRESULT CALLBACK Window::PropSheetCBTHookProc | ( | int | code, |
WPARAM | wparam, | ||
LPARAM | lparam | ||
) | [static, protected] |
Definition at line 188 of file window.cpp.
References create_controller(), get_window(), HWND, and s_hcbtHook.
{ if (code == HCBT_CREATEWND) { HWND hwnd = (HWND)wparam; // create Window controller and associate it with the window handle Window* child = get_window(hwnd); if (!child) child = create_controller(hwnd); } return CallNextHookEx(s_hcbtHook, code, wparam, lparam); }
void Window::register_dialog | ( | HWND | hwnd ) | [static] |
Definition at line 604 of file window.cpp.
References s_dialogs.
Referenced by Dialog::Dialog(), and DialogWindow::DialogWindow().
{ s_dialogs.insert(hwnd); }
void Window::register_pretranslate | ( | HWND | hwnd ) | [static] |
Definition at line 582 of file window.cpp.
References s_pretranslate_windows.
Referenced by FindProgramDlg::FindProgramDlg(), PreTranslateWindow::PreTranslateWindow(), and TrayNotifyDlg::TrayNotifyDlg().
{ s_pretranslate_windows.insert(hwnd); }
LRESULT Window::SendParent | ( | UINT | nmsg, |
WPARAM | wparam = 0 , |
||
LPARAM | lparam = 0 |
||
) |
Definition at line 652 of file window.cpp.
References WindowHandle::_hwnd, and HWND.
Referenced by StartMenu::CloseStartMenu(), NotifyArea::Command(), StartMenu::WndProc(), and StartMenu::~StartMenu().
{ HWND parent = GetParent(_hwnd); if (!parent) return 0; return SendMessage(parent, nmsg, wparam, lparam); }
void Window::unregister_dialog | ( | HWND | hwnd ) | [static] |
Definition at line 609 of file window.cpp.
References s_dialogs.
Referenced by Dialog::~Dialog(), and DialogWindow::~DialogWindow().
{ s_dialogs.erase(hwnd); }
void Window::unregister_pretranslate | ( | HWND | hwnd ) | [static] |
Definition at line 587 of file window.cpp.
References s_pretranslate_windows.
Referenced by FindProgramDlg::~FindProgramDlg(), PreTranslateWindow::~PreTranslateWindow(), and TrayNotifyDlg::~TrayNotifyDlg().
{ s_pretranslate_windows.erase(hwnd); }
LRESULT CALLBACK Window::WindowWndProc | ( | HWND | hwnd, |
UINT | nmsg, | ||
WPARAM | wparam, | ||
LPARAM | lparam | ||
) | [static] |
Definition at line 250 of file window.cpp.
References Command(), create_controller(), get_window(), Init(), NFR_CURRENT, Notify(), and WndProc().
{ Window* pThis = get_window(hwnd); if (!pThis) pThis = create_controller(hwnd); if (pThis) { switch(nmsg) { case WM_COMMAND: return pThis->Command(LOWORD(wparam), HIWORD(wparam)); case WM_NOTIFY: return pThis->Notify(wparam, (NMHDR*)lparam); case WM_NOTIFYFORMAT: return NFR_CURRENT; case WM_CREATE: return pThis->Init((LPCREATESTRUCT)lparam); case WM_NCDESTROY: delete pThis; return 0; default: return pThis->WndProc(nmsg, wparam, lparam); } } else return DefWindowProc(hwnd, nmsg, wparam, lparam); }
LRESULT Window::WndProc | ( | UINT | nmsg, |
WPARAM | wparam, | ||
LPARAM | lparam | ||
) | [protected, virtual] |
Reimplemented in ExplorerAboutDlg, BackgroundWindow, DesktopWindow, DesktopShellView, FindProgramDlg, FileChildWindow, MainFrameBase, MDIMainFrame, SDIMainFrame, Pane, MDIShellBrowserChild, WebChildWindow, DesktopBar, StartButton, QuickLaunchBar, StartMenuButton, StartMenu, StartMenuRoot, TaskBar, NotifyArea, TrayNotifyDlg, ClockWindow, SubclassedWindow, ChildWindow, Dialog, OwnerdrawnButton, FlatButton, ColorStatic, HyperlinkCtrl, EditController, ShellBrowserChildT< ChildWindow >, ShellBrowserChildT< MainFrameBase >, IPCtrlWindow< ChildWindow, SIfacePtr< IWebBrowser2 > >, ExtContextMenuHandlerT< ShellBrowserChildT< MainFrameBase > >, ExtContextMenuHandlerT< ChildWindow >, ExtContextMenuHandlerT< OwnerDrawParent< DialogWindow > >, ExtContextMenuHandlerT< SubclassedWindow >, ExtContextMenuHandlerT< ShellBrowserChildT< ChildWindow > >, ResizeController< Dialog >, CtlColorParent< OwnerDrawParent< Dialog > >, OwnerDrawParent< PropSheetPageDlg >, OwnerDrawParent< Window >, OwnerDrawParent< DialogWindow >, and OwnerDrawParent< Dialog >.
Definition at line 283 of file window.cpp.
References WindowHandle::_hwnd.
Referenced by DialogProc(), WindowWndProc(), ClockWindow::WndProc(), NotifyArea::WndProc(), TaskBar::WndProc(), MainFrameBase::WndProc(), and DesktopWindow::WndProc().
{ return DefWindowProc(_hwnd, nmsg, wparam, lparam); }
WindowSet Window::s_dialogs [static, protected] |
Definition at line 138 of file window.h.
Referenced by register_dialog(), and unregister_dialog().
HHOOK Window::s_hcbtHook = 0 [static, protected] |
Definition at line 133 of file window.h.
Referenced by create_mdi_child(), MDICBTHookProc(), and PropSheetCBTHookProc().
const void * Window::s_new_info = NULL [static, protected] |
Definition at line 119 of file window.h.
Referenced by Create(), create_controller(), create_mdi_child(), and Dialog::DoModal().
WindowSet Window::s_pretranslate_windows [static, protected] |
Definition at line 137 of file window.h.
Referenced by pretranslate_msg(), register_pretranslate(), and unregister_pretranslate().
Window::CREATORFUNC Window::s_window_creator = NULL [static, protected] |
Definition at line 120 of file window.h.
Referenced by Create(), create_controller(), create_mdi_child(), and Dialog::DoModal().
Window::WindowMap Window::s_wnd_map [static, protected] |
Definition at line 117 of file window.h.
Referenced by get_window(), Window(), and ~Window().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by |