compatibility to building as Winelib application

svn path=/trunk/; revision=5946
This commit is contained in:
Martin Fuchs 2003-08-30 20:48:21 +00:00
parent d88ab5ba6e
commit c2a5e8e44e
5 changed files with 40 additions and 19 deletions

View file

@ -31,3 +31,4 @@
27.08.2003 m. fuchs partly implemented control panel window 27.08.2003 m. fuchs partly implemented control panel window
28.08.2003 m. fuchs control panel window in cabinet view mode 28.08.2003 m. fuchs control panel window in cabinet view mode
29.09.2003 m. fuchs Now we handle start menu popups via StartMenuRoot::TrackStartmenu(). 29.09.2003 m. fuchs Now we handle start menu popups via StartMenuRoot::TrackStartmenu().
30.09.2003 m. fuchs compatibility to building as Winelib application

View file

@ -39,8 +39,6 @@
#include "startmenu.h" #include "startmenu.h"
BtnWindowClass StartMenu::s_wcStartMenu(CLASSNAME_STARTMENU);
StartMenu::StartMenu(HWND hwnd) StartMenu::StartMenu(HWND hwnd)
: super(hwnd) : super(hwnd)
{ {
@ -67,10 +65,19 @@ StartMenu::~StartMenu()
} }
// We need this wrapper function for s_wcStartMenu, it calls to the WIN32 API
// through static C++ initializers are not allowed for Winelib applications.
BtnWindowClass& StartMenu::GetWndClasss()
{
static BtnWindowClass s_wcStartMenu(CLASSNAME_STARTMENU);
return s_wcStartMenu;
}
/* /*
HWND StartMenu::Create(int x, int y, HWND hwndParent) HWND StartMenu::Create(int x, int y, HWND hwndParent)
{ {
return Window::Create(WINDOW_CREATOR(StartMenu), NULL, s_wcStartMenu, TITLE_STARTMENU, return Window::Create(WINDOW_CREATOR(StartMenu), NULL, GetWndClasss(), TITLE_STARTMENU,
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, x, y, STARTMENU_WIDTH_MIN, 4, hwndParent); WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, x, y, STARTMENU_WIDTH_MIN, 4, hwndParent);
} }
*/ */
@ -80,7 +87,7 @@ Window::CREATORFUNC StartMenu::s_def_creator = STARTMENU_CREATOR(StartMenu);
HWND StartMenu::Create(int x, int y, const StartMenuFolders& folders, HWND hwndParent, CREATORFUNC creator) HWND StartMenu::Create(int x, int y, const StartMenuFolders& folders, HWND hwndParent, CREATORFUNC creator)
{ {
//TODO: check, if coordinates x/y are visible on the screen //TODO: check, if coordinates x/y are visible on the screen
return Window::Create(creator, &folders, 0, s_wcStartMenu, NULL, return Window::Create(creator, &folders, 0, GetWndClasss(), NULL,
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, x, y, STARTMENU_WIDTH_MIN, 4/*start height*/, hwndParent); WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, x, y, STARTMENU_WIDTH_MIN, 4/*start height*/, hwndParent);
} }
@ -554,7 +561,7 @@ HWND StartMenuRoot::Create(HWND hwndDesktopBar)
{ {
WindowRect pos(hwndDesktopBar); WindowRect pos(hwndDesktopBar);
return Window::Create(WINDOW_CREATOR(StartMenuRoot), 0, s_wcStartMenu, TITLE_STARTMENU, return Window::Create(WINDOW_CREATOR(StartMenuRoot), 0, GetWndClasss(), TITLE_STARTMENU,
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, pos.left, pos.top-4, STARTMENU_WIDTH_MIN, 4, hwndDesktopBar); WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, pos.left, pos.top-4, STARTMENU_WIDTH_MIN, 4, hwndDesktopBar);
} }

View file

@ -143,7 +143,7 @@ protected:
int Command(int id, int code); int Command(int id, int code);
// window class // window class
static BtnWindowClass s_wcStartMenu; static BtnWindowClass& GetWndClasss();
// data members // data members
int _next_id; int _next_id;

View file

@ -57,27 +57,33 @@ IconWindowClass::IconWindowClass(LPCTSTR classname, UINT nid, UINT style, WNDPRO
} }
HHOOK Window::s_hcbtHook = 0; Window::WindowMap Window::s_wnd_map;
Window::CREATORFUNC Window::s_window_creator = NULL; Window::CREATORFUNC Window::s_window_creator = NULL;
const void* Window::s_new_info = NULL; const void* Window::s_new_info = NULL;
CritSect Window::s_create_crit_sect;
Window::WindowMap Window::s_wnd_map; HHOOK Window::s_hcbtHook = 0;
CritSect Window::s_map_crit_sect;
Window::StaticWindowData& Window::GetStaticWindowData()
{
static StaticWindowData s_initialized_data;
return s_initialized_data;
}
Window::Window(HWND hwnd) Window::Window(HWND hwnd)
: WindowHandle(hwnd) : WindowHandle(hwnd)
{ {
Lock lock(s_map_crit_sect); // protect access to s_wnd_map Lock lock(GetStaticWindowData()._map_crit_sect); // protect access to s_wnd_map
s_wnd_map[_hwnd] = this; s_wnd_map[_hwnd] = this;
} }
Window::~Window() Window::~Window()
{ {
Lock lock(s_map_crit_sect); // protect access to s_wnd_map Lock lock(GetStaticWindowData()._map_crit_sect); // protect access to s_wnd_map
s_wnd_map.erase(_hwnd); s_wnd_map.erase(_hwnd);
} }
@ -88,7 +94,7 @@ HWND Window::Create(CREATORFUNC creator, DWORD dwExStyle,
DWORD dwStyle, int x, int y, int w, int h, DWORD dwStyle, int x, int y, int w, int h,
HWND hwndParent, HMENU hMenu, LPVOID lpParam) HWND hwndParent, HMENU hMenu, LPVOID lpParam)
{ {
Lock lock(s_create_crit_sect); // protect access to s_window_creator and s_new_info Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info
s_window_creator = creator; s_window_creator = creator;
s_new_info = NULL; s_new_info = NULL;
@ -103,7 +109,7 @@ HWND Window::Create(CREATORFUNC creator, const void* info, DWORD dwExStyle,
DWORD dwStyle, int x, int y, int w, int h, DWORD dwStyle, int x, int y, int w, int h,
HWND hwndParent, HMENU hMenu, LPVOID lpParam) HWND hwndParent, HMENU hMenu, LPVOID lpParam)
{ {
Lock lock(s_create_crit_sect); // protect access to s_window_creator and s_new_info Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info
s_window_creator = creator; s_window_creator = creator;
s_new_info = info; s_new_info = info;
@ -118,7 +124,7 @@ static Window* s_new_child_wnd = NULL;
Window* Window::create_mdi_child(HWND hmdiclient, const MDICREATESTRUCT& mcs, CREATORFUNC creator, const void* info) Window* Window::create_mdi_child(HWND hmdiclient, const MDICREATESTRUCT& mcs, CREATORFUNC creator, const void* info)
{ {
Lock lock(s_create_crit_sect); // protect access to s_window_creator and s_new_info Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info
s_window_creator = creator; s_window_creator = creator;
s_new_info = info; s_new_info = info;
@ -160,7 +166,7 @@ LRESULT CALLBACK Window::CBTHookProc(int code, WPARAM wparam, LPARAM lparam)
Window* Window::get_window(HWND hwnd) Window* Window::get_window(HWND hwnd)
{ {
{ {
Lock lock(s_map_crit_sect); // protect access to s_wnd_map Lock lock(GetStaticWindowData()._map_crit_sect); // protect access to s_wnd_map
WindowMap::const_iterator found = s_wnd_map.find(hwnd); WindowMap::const_iterator found = s_wnd_map.find(hwnd);
@ -169,7 +175,7 @@ Window* Window::get_window(HWND hwnd)
} }
if (s_window_creator) { // protect for recursion if (s_window_creator) { // protect for recursion
Lock lock(s_create_crit_sect); // protect access to s_window_creator and s_new_info Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info
const void* info = s_new_info; const void* info = s_new_info;
s_new_info = NULL; s_new_info = NULL;

View file

@ -106,11 +106,18 @@ protected:
static WindowMap s_wnd_map; static WindowMap s_wnd_map;
static CritSect s_map_crit_sect;
static const void* s_new_info; static const void* s_new_info;
static CREATORFUNC s_window_creator; static CREATORFUNC s_window_creator;
static CritSect s_create_crit_sect;
struct StaticWindowData {
CritSect _map_crit_sect;
CritSect _create_crit_sect;
};
static StaticWindowData& GetStaticWindowData();
// MDI child creation // MDI child creation
static HHOOK s_hcbtHook; static HHOOK s_hcbtHook;