explicit window_handle type for win32

This commit is contained in:
David Rose 2009-11-18 19:36:45 +00:00
parent 21aad12650
commit d0d2ac4fa0
6 changed files with 21 additions and 9 deletions

View File

@ -195,6 +195,7 @@ P3DInstance(P3D_request_ready_func *func,
(_fparams.lookup_token_int("width") == 0 || (_fparams.lookup_token_int("width") == 0 ||
_fparams.lookup_token_int("height") == 0)) { _fparams.lookup_token_int("height") == 0)) {
P3D_window_handle dummy_handle; P3D_window_handle dummy_handle;
memset(&dummy_handle, 0, sizeof(dummy_handle));
P3DWindowParams wparams(P3D_WT_hidden, 0, 0, 0, 0, dummy_handle); P3DWindowParams wparams(P3D_WT_hidden, 0, 0, 0, 0, dummy_handle);
set_wparams(wparams); set_wparams(wparams);
} }

View File

@ -430,7 +430,9 @@ make_window() {
DWORD window_style = DWORD window_style =
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
HWND parent_hwnd = _wparams.get_parent_window()._hwnd; const P3D_window_handle &handle = _wparams.get_parent_window();
assert(handle._window_handle_type == P3D_WHT_win_hwnd);
HWND parent_hwnd = handle._handle._win_hwnd._hwnd;
_hwnd = _hwnd =
CreateWindow("panda3d_splash", "Panda3D", window_style, CreateWindow("panda3d_splash", "Panda3D", window_style,

View File

@ -78,7 +78,8 @@ make_xml(P3DInstance *inst) {
xwparams->SetAttribute("win_width", _win_width); xwparams->SetAttribute("win_width", _win_width);
xwparams->SetAttribute("win_height", _win_height); xwparams->SetAttribute("win_height", _win_height);
#ifdef _WIN32 #ifdef _WIN32
xwparams->SetAttribute("parent_hwnd", (int)_parent_window._hwnd); assert(_parent_window._window_handle_type == P3D_WHT_win_hwnd);
xwparams->SetAttribute("parent_hwnd", (int)_parent_window._handle._win_hwnd._hwnd);
#elif defined(__APPLE__) #elif defined(__APPLE__)
xwparams->SetAttribute("subprocess_window", inst->_shared_filename); xwparams->SetAttribute("subprocess_window", inst->_shared_filename);

View File

@ -493,7 +493,9 @@ int PPInstance::Start( const std::string& p3dFilename )
m_eventStop.ResetEvent(); m_eventStop.ResetEvent();
P3D_window_handle parent_window; P3D_window_handle parent_window;
parent_window._hwnd = m_parentCtrl.m_hWnd; memset(&parent_window, 0, sizeof(parent_window));
parent_window._window_handle_type = P3D_WHT_win_hwnd;
parent_window._handle._win_hwnd._hwnd = m_parentCtrl.m_hWnd;
RECT rect; RECT rect;
GetClientRect( m_parentCtrl.m_hWnd, &rect ); GetClientRect( m_parentCtrl.m_hWnd, &rect );

View File

@ -1301,7 +1301,8 @@ send_window() {
// (0, 0), since the window we were given is already placed in the // (0, 0), since the window we were given is already placed in the
// right spot. // right spot.
#ifdef _WIN32 #ifdef _WIN32
parent_window._hwnd = (HWND)(_window.window); parent_window._window_handle_type = P3D_WHT_win_hwnd;
parent_window._handle._win_hwnd._hwnd = (HWND)(_window.window);
x = 0; x = 0;
y = 0; y = 0;
@ -1327,11 +1328,11 @@ send_window() {
// We have a "windowless" plugin. Parent our window directly to // We have a "windowless" plugin. Parent our window directly to
// the browser window. // the browser window.
#ifdef _WIN32 #ifdef _WIN32
parent_window._hwnd = 0;
HWND hwnd; HWND hwnd;
if (browser->getvalue(_npp_instance, NPNVnetscapeWindow, if (browser->getvalue(_npp_instance, NPNVnetscapeWindow,
&hwnd) == NPERR_NO_ERROR) { &hwnd) == NPERR_NO_ERROR) {
parent_window._hwnd = hwnd; parent_window._window_handle_type = P3D_WHT_win_hwnd;
parent_window._handle._win_hwnd._hwnd = hwnd;
} }
#elif defined(__APPLE__) #elif defined(__APPLE__)

View File

@ -241,8 +241,11 @@ run_command_line(int argc, char *argv[]) {
// Center the child window(s) within the parent window. // Center the child window(s) within the parent window.
#ifdef _WIN32 #ifdef _WIN32
assert(_parent_window._window_handle_type == P3D_WHT_win_hwnd);
HWND parent_hwnd = _parent_window._handle._win_hwnd._hwnd;
RECT rect; RECT rect;
GetClientRect(_parent_window._hwnd, &rect); GetClientRect(parent_hwnd, &rect);
_win_x = (int)(rect.right * 0.1); _win_x = (int)(rect.right * 0.1);
_win_y = (int)(rect.bottom * 0.1); _win_y = (int)(rect.bottom * 0.1);
@ -937,7 +940,9 @@ make_parent_window() {
ShowWindow(toplevel_window, SW_SHOWNORMAL); ShowWindow(toplevel_window, SW_SHOWNORMAL);
_parent_window._hwnd = toplevel_window; memset(&_parent_window, 0, sizeof(_parent_window));
_parent_window._window_handle_type = P3D_WHT_win_hwnd;
_parent_window._handle._win_hwnd._hwnd = toplevel_window;
} }
#else #else