more /Wp64 warning fixes: mostly use UINT_PTR instead of UINT and define our WX[WL]PARAM with __w64 if available to avoid hundreds of warnings when casting LPARAMs to pointers/handles

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52165 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-02-28 02:22:52 +00:00
parent 2d2b68baa3
commit dca0f65178
24 changed files with 341 additions and 347 deletions

View File

@@ -2778,6 +2778,17 @@ typedef void * WXRECTANGLEPTR;
# define WXFAR
#endif
// we can't rely on Windows _W64 being defined as windows.h may not be included
// so define our own equivalent: this should be used with types like WXLPARAM
// or WXWPARAM which are 64 bit under Win64 to avoid warnings each time we cast
// it to a pointer or a handle (which results in hundreds of warnings as Win32
// API often passes pointers in them)
#if wxCHECK_VISUALC_VERSION(7)
#define wxW64 __w64
#else
#define wxW64
#endif
/* Stand-ins for Windows types to avoid #including all of windows.h */
typedef void * WXHWND;
typedef void * WXHANDLE;
@@ -2814,13 +2825,13 @@ typedef void * WXLPCREATESTRUCT;
typedef WXHWND WXWidget;
#ifdef __WIN64__
typedef unsigned __int64 WXWPARAM;
typedef unsigned __int64 WXWPARAM;
typedef __int64 WXLPARAM;
typedef __int64 WXLRESULT;
#else
typedef unsigned int WXWPARAM;
typedef long WXLPARAM;
typedef long WXLRESULT;
typedef wxW64 unsigned int WXWPARAM;
typedef wxW64 long WXLPARAM;
typedef wxW64 long WXLRESULT;
#endif
#if defined(__GNUWIN32__) || defined(__WXMICROWIN__)

View File

@@ -57,7 +57,7 @@ public:
//
// notice that it also returns the id as an unsigned int, as required by
// Win32 API
unsigned GetMSWId() const;
WXWPARAM GetMSWId() const;
// mark item as belonging to the given radio group
void SetAsRadioGroupStart();

View File

@@ -901,9 +901,15 @@ inline bool wxStyleHasBorder(long style)
// functions mapping HWND to wxWindow
// ----------------------------------------------------------------------------
// this function simply checks whether the given hWnd corresponds to a wxWindow
// this function simply checks whether the given hwnd corresponds to a wxWindow
// and returns either that window if it does or NULL otherwise
extern WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd);
extern WXDLLEXPORT wxWindow* wxFindWinFromHandle(HWND hwnd);
// without STRICT WXHWND is the same as HWND anyhow
inline wxWindow* wxFindWinFromHandle(WXHWND hWnd)
{
return wxFindWinFromHandle(wx_static_cast(HWND, hWnd));
}
// find the window for HWND which is part of some wxWindow, i.e. unlike
// wxFindWinFromHandle() above it will also work for "sub controls" of a

View File

@@ -597,17 +597,4 @@ public:
~wxWindowCreationHook();
};
// ----------------------------------------------------------------------------
// global objects
// ----------------------------------------------------------------------------
// notice that this hash must be defined after wxWindow declaration as it
// needs to "see" its dtor and not just forward declaration
#include "wx/hash.h"
// pseudo-template HWND <-> wxWindow hash table
WX_DECLARE_HASH(wxWindowMSW, wxWindowList, wxWinHashTable);
extern wxWinHashTable *wxWinHandleHash;
#endif // _WX_WINDOW_H_

View File

@@ -79,6 +79,7 @@
// overwrite them if there is a chance that they're not defined
#if !defined(_MSC_VER) || (_MSC_VER < 1300)
#define UINT_PTR unsigned int
#define INT_PTR int
#define LONG_PTR long
#define ULONG_PTR unsigned long
#define DWORD_PTR unsigned long

View File

@@ -1033,7 +1033,7 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
::ShellExecuteEx(&sei);
const int nResult = (int) sei.hInstApp;
const INT_PTR nResult = (INT_PTR)sei.hInstApp;
// Firefox returns file not found for some reason, so make an exception
// for it

View File

@@ -355,8 +355,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
RegisterWindowClasses();
wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100);
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
wxSetKeyboardHook(true);
#endif
@@ -510,10 +508,10 @@ bool wxApp::UnregisterWindowClasses()
void wxApp::CleanUp()
{
// all objects pending for deletion must be deleted first, otherwise we
// would crash when they use wxWinHandleHash (and UnregisterWindowClasses()
// call wouldn't succeed as long as any windows still exist), so call the
// base class method first and only then do our clean up
// all objects pending for deletion must be deleted first, otherwise
// UnregisterWindowClasses() call wouldn't succeed (because windows
// using the classes being unregistered still exist), so call the base
// class method first and only then do our clean up
wxAppBase::CleanUp();
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
@@ -528,9 +526,6 @@ void wxApp::CleanUp()
// unregister the classes now
UnregisterWindowClasses();
delete wxWinHandleHash;
wxWinHandleHash = NULL;
#ifdef __WXWINCE__
free( wxCanvasClassName );
free( wxCanvasClassNameNR );

View File

@@ -176,7 +176,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id,
msStyle,
0, 0, 0, 0,
GetWinHwnd(parent),
(HMENU)m_windowId.GetValue(),
(HMENU)wxUIntToPtr(m_windowId.GetValue()),
wxGetInstance(),
NULL
);

View File

@@ -144,8 +144,8 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
label.wx_str(), // the window name
style, // the window style
x, y, w, h, // the window position and size
GetHwndOf(GetParent()), // parent
(HMENU)GetId(), // child id
GetHwndOf(GetParent()), // parent
(HMENU)wxUIntToPtr(GetId()), // child id
wxGetInstance(), // app instance
NULL // creation parameters
);

View File

@@ -99,7 +99,7 @@ private:
#ifndef __WXMICROWIN__
int CALLBACK wxFontEnumeratorProc(LPLOGFONT lplf, LPTEXTMETRIC lptm,
DWORD dwStyle, LONG lParam);
DWORD dwStyle, LPARAM lParam);
#endif
// ============================================================================
@@ -269,7 +269,7 @@ bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
#ifndef __WXMICROWIN__
int CALLBACK wxFontEnumeratorProc(LPLOGFONT lplf, LPTEXTMETRIC lptm,
DWORD WXUNUSED(dwStyle), LONG lParam)
DWORD WXUNUSED(dwStyle), LPARAM lParam)
{
// we used to process TrueType fonts only, but there doesn't seem to be any

View File

@@ -853,7 +853,7 @@ bool wxFrame::HandlePaint()
HDC hdc = ::BeginPaint(GetHwnd(), &ps);
// Erase background before painting or we get white background
MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L);
MSWDefWindowProc(WM_ICONERASEBKGND, (WXWPARAM)ps.hdc, 0L);
if ( hIcon )
{
@@ -1118,7 +1118,7 @@ WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPara
const wxIcon& icon = GetIcon();
HICON hIcon = icon.Ok() ? GetHiconOf(icon)
: (HICON)GetDefaultIcon();
rc = (long)hIcon;
rc = (WXLRESULT)hIcon;
processed = rc != 0;
}
break;

View File

@@ -98,13 +98,14 @@ bool wxWinHelpController::KeywordSearch(const wxString& k,
wxString str = GetValidFilename(m_helpFile);
return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_PARTIALKEY, (DWORD)k.wx_str()) != 0);
return WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_PARTIALKEY,
(ULONG_PTR)k.wx_str()) != 0;
}
// Can't close the help window explicitly in WinHelp
bool wxWinHelpController::Quit(void)
{
return (WinHelp(GetSuitableHWND(this), 0, HELP_QUIT, 0L) != 0);
return WinHelp(GetSuitableHWND(this), 0, HELP_QUIT, 0) != 0;
}
// Append extension if necessary.

View File

@@ -756,7 +756,7 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
wxWindowCreationHook hook(this);
m_hWnd = (WXHWND)::SendMessage(GetWinHwnd(parent->GetClientWindow()),
WM_MDICREATE, 0, (LONG)(LPSTR)&mcs);
WM_MDICREATE, 0, (LPARAM)&mcs);
if ( !m_hWnd )
{
@@ -1430,14 +1430,15 @@ static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu)
{
success = true;
::InsertMenu(hmenu, i, MF_BYPOSITION | MF_POPUP | MF_STRING,
(UINT)subMenu, _("&Window").wx_str());
(UINT_PTR)subMenu, _("&Window").wx_str());
break;
}
}
if ( !success )
{
::AppendMenu(hmenu, MF_POPUP, (UINT)subMenu, _("&Window").wx_str());
::AppendMenu(hmenu, MF_POPUP,
(UINT_PTR)subMenu, _("&Window").wx_str());
}
}

View File

@@ -387,14 +387,14 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
// id is the numeric id for normal menu items and HMENU for submenus as
// required by ::AppendMenu() API
UINT id;
UINT_PTR id;
wxMenu *submenu = pItem->GetSubMenu();
if ( submenu != NULL ) {
wxASSERT_MSG( submenu->GetHMenu(), wxT("invalid submenu") );
submenu->SetParent(this);
id = (UINT)submenu->GetHMenu();
id = (UINT_PTR)submenu->GetHMenu();
flags |= MF_POPUP;
}
@@ -980,7 +980,7 @@ WXHMENU wxMenuBar::Create()
for ( i = 0, it = m_menus.begin(); i < count; i++, it++ )
{
if ( !::AppendMenu((HMENU)m_hMenu, MF_POPUP | MF_STRING,
(UINT)(*it)->GetHMenu(),
(UINT_PTR)(*it)->GetHMenu(),
m_titles[i].wx_str()) )
{
wxLogLastError(wxT("AppendMenu"));
@@ -1052,7 +1052,7 @@ void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label)
int mswpos = MSWPositionForWxMenu(GetMenu(pos),pos);
UINT id;
UINT_PTR id;
UINT flagsOld = ::GetMenuState((HMENU)m_hMenu, mswpos, MF_BYPOSITION);
if ( flagsOld == 0xFFFFFFFF )
{
@@ -1065,7 +1065,7 @@ void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label)
{
// HIBYTE contains the number of items in the submenu in this case
flagsOld &= 0xff;
id = (UINT)::GetSubMenu((HMENU)m_hMenu, mswpos);
id = (UINT_PTR)::GetSubMenu((HMENU)m_hMenu, mswpos);
}
else
{
@@ -1080,7 +1080,7 @@ void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label)
info.fType = MFT_STRING;
info.cch = label.length();
info.dwTypeData = wx_const_cast(wxChar *, label.wx_str());
if ( !SetMenuItemInfo(GetHmenu(), id, TRUE, & info) )
if ( !SetMenuItemInfo(GetHmenu(), id, TRUE, &info) )
{
wxLogLastError(wxT("SetMenuItemInfo"));
}
@@ -1132,7 +1132,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
if ( !::InsertMenu(GetHmenu(), (UINT)mswpos,
MF_BYPOSITION | MF_POPUP | MF_STRING,
(UINT)GetHmenuOf(menu), title.wx_str()) )
(UINT_PTR)GetHmenuOf(menu), title.wx_str()) )
{
wxLogLastError(wxT("InsertMenu"));
}
@@ -1199,7 +1199,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
#else
if ( !::InsertMenu(GetHmenu(), mswpos,
MF_BYPOSITION | MF_POPUP | MF_STRING,
(UINT)GetHmenuOf(menu), title.wx_str()) )
(UINT_PTR)GetHmenuOf(menu), title.wx_str()) )
{
wxLogLastError(wxT("InsertMenu"));
}
@@ -1258,7 +1258,7 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
}
#else
if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING,
(UINT)submenu, title.wx_str()) )
(UINT_PTR)submenu, title.wx_str()) )
{
wxLogLastError(wxT("AppendMenu"));
}

View File

@@ -186,13 +186,13 @@ wxMenuItem::~wxMenuItem()
// ----
// return the id for calling Win32 API functions
unsigned wxMenuItem::GetMSWId() const
WXWPARAM wxMenuItem::GetMSWId() const
{
// we must use ids in unsigned short range with Windows functions, if we
// pass ids > USHRT_MAX to them they get very confused (e.g. start
// generating WM_COMMAND messages with negative high word of wParam), so
// use the cast to ensure the id is in range
return m_subMenu ? wx_reinterpret_cast(unsigned, m_subMenu->GetHMenu())
return m_subMenu ? wxPtrToUInt(m_subMenu->GetHMenu())
: wx_static_cast(unsigned short, GetId());
}

View File

@@ -338,7 +338,7 @@ bool wxPenRefData::Alloc()
{
case wxSTIPPLE:
lb.lbStyle = BS_PATTERN;
lb.lbHatch = (LONG)m_stipple.GetHBITMAP();
lb.lbHatch = wxPtrToUInt(m_stipple.GetHBITMAP());
break;
case wxBDIAGONAL_HATCH:

View File

@@ -122,19 +122,18 @@ IMPLEMENT_CLASS(wxWindowsPrintNativeData, wxPrintNativeDataBase)
wxWindowsPrintNativeData::wxWindowsPrintNativeData()
{
m_devMode = (void*) NULL;
m_devNames = (void*) NULL;
m_devMode = NULL;
m_devNames = NULL;
m_customWindowsPaperId = 0;
}
wxWindowsPrintNativeData::~wxWindowsPrintNativeData()
{
HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
if ( hDevMode )
GlobalFree(hDevMode);
HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
if ( hDevNames )
GlobalFree(hDevNames);
if ( m_devMode )
::GlobalFree(wx_static_cast(HGLOBAL, m_devMode));
if ( m_devNames )
::GlobalFree(wx_static_cast(HGLOBAL, m_devNames));
}
bool wxWindowsPrintNativeData::IsOk() const
@@ -144,205 +143,194 @@ bool wxWindowsPrintNativeData::IsOk() const
bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data )
{
HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
if (!hDevMode)
{
if ( !m_devMode )
return false;
GlobalPtrLock lockDevMode(m_devMode);
LPDEVMODE devMode = wx_static_cast(LPDEVMODE, lockDevMode.Get());
//// Orientation
if (devMode->dmFields & DM_ORIENTATION)
data.SetOrientation( devMode->dmOrientation );
//// Collation
if (devMode->dmFields & DM_COLLATE)
{
if (devMode->dmCollate == DMCOLLATE_TRUE)
data.SetCollate( true );
else
data.SetCollate( false );
}
//// Number of copies
if (devMode->dmFields & DM_COPIES)
data.SetNoCopies( devMode->dmCopies );
//// Bin
if (devMode->dmFields & DM_DEFAULTSOURCE) {
switch (devMode->dmDefaultSource) {
case DMBIN_ONLYONE : data.SetBin(wxPRINTBIN_ONLYONE ); break;
case DMBIN_LOWER : data.SetBin(wxPRINTBIN_LOWER ); break;
case DMBIN_MIDDLE : data.SetBin(wxPRINTBIN_MIDDLE ); break;
case DMBIN_MANUAL : data.SetBin(wxPRINTBIN_MANUAL ); break;
case DMBIN_ENVELOPE : data.SetBin(wxPRINTBIN_ENVELOPE ); break;
case DMBIN_ENVMANUAL : data.SetBin(wxPRINTBIN_ENVMANUAL ); break;
case DMBIN_AUTO : data.SetBin(wxPRINTBIN_AUTO ); break;
case DMBIN_TRACTOR : data.SetBin(wxPRINTBIN_TRACTOR ); break;
case DMBIN_SMALLFMT : data.SetBin(wxPRINTBIN_SMALLFMT ); break;
case DMBIN_LARGEFMT : data.SetBin(wxPRINTBIN_LARGEFMT ); break;
case DMBIN_LARGECAPACITY : data.SetBin(wxPRINTBIN_LARGECAPACITY ); break;
case DMBIN_CASSETTE : data.SetBin(wxPRINTBIN_CASSETTE ); break;
case DMBIN_FORMSOURCE : data.SetBin(wxPRINTBIN_FORMSOURCE ); break;
default:
if (devMode->dmDefaultSource>=DMBIN_USER) {
data.SetBin((wxPrintBin)((devMode->dmDefaultSource)-DMBIN_USER+(int)wxPRINTBIN_USER));
} else {
data.SetBin(wxPRINTBIN_DEFAULT);
}
break;
}
} else {
data.SetBin(wxPRINTBIN_DEFAULT);
}
if (devMode->dmFields & DM_MEDIATYPE)
{
wxASSERT( (int)devMode->dmMediaType != wxPRINTMEDIA_DEFAULT );
data.SetMedia(devMode->dmMediaType);
}
//// Printer name
if (devMode->dmDeviceName[0] != 0)
// This syntax fixes a crash when using VS 7.1
data.SetPrinterName( wxString(devMode->dmDeviceName, CCHDEVICENAME) );
//// Colour
if (devMode->dmFields & DM_COLOR)
{
if (devMode->dmColor == DMCOLOR_COLOR)
data.SetColour( true );
else
data.SetColour( false );
}
else
data.SetColour( true );
//// Paper size
// We don't know size of user defined paper and some buggy drivers
// set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
// dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
// code wouldn't set m_paperSize correctly.
bool foundPaperSize = false;
if ((devMode->dmFields & DM_PAPERSIZE) && (devMode->dmPaperSize < DMPAPER_USER))
{
LPDEVMODE devMode = (LPDEVMODE)GlobalLock(hDevMode);
//// Orientation
if (devMode->dmFields & DM_ORIENTATION)
data.SetOrientation( devMode->dmOrientation );
//// Collation
if (devMode->dmFields & DM_COLLATE)
if (wxThePrintPaperDatabase)
{
if (devMode->dmCollate == DMCOLLATE_TRUE)
data.SetCollate( true );
else
data.SetCollate( false );
}
//// Number of copies
if (devMode->dmFields & DM_COPIES)
data.SetNoCopies( devMode->dmCopies );
//// Bin
if (devMode->dmFields & DM_DEFAULTSOURCE) {
switch (devMode->dmDefaultSource) {
case DMBIN_ONLYONE : data.SetBin(wxPRINTBIN_ONLYONE ); break;
case DMBIN_LOWER : data.SetBin(wxPRINTBIN_LOWER ); break;
case DMBIN_MIDDLE : data.SetBin(wxPRINTBIN_MIDDLE ); break;
case DMBIN_MANUAL : data.SetBin(wxPRINTBIN_MANUAL ); break;
case DMBIN_ENVELOPE : data.SetBin(wxPRINTBIN_ENVELOPE ); break;
case DMBIN_ENVMANUAL : data.SetBin(wxPRINTBIN_ENVMANUAL ); break;
case DMBIN_AUTO : data.SetBin(wxPRINTBIN_AUTO ); break;
case DMBIN_TRACTOR : data.SetBin(wxPRINTBIN_TRACTOR ); break;
case DMBIN_SMALLFMT : data.SetBin(wxPRINTBIN_SMALLFMT ); break;
case DMBIN_LARGEFMT : data.SetBin(wxPRINTBIN_LARGEFMT ); break;
case DMBIN_LARGECAPACITY : data.SetBin(wxPRINTBIN_LARGECAPACITY ); break;
case DMBIN_CASSETTE : data.SetBin(wxPRINTBIN_CASSETTE ); break;
case DMBIN_FORMSOURCE : data.SetBin(wxPRINTBIN_FORMSOURCE ); break;
default:
if (devMode->dmDefaultSource>=DMBIN_USER) {
data.SetBin((wxPrintBin)((devMode->dmDefaultSource)-DMBIN_USER+(int)wxPRINTBIN_USER));
} else {
data.SetBin(wxPRINTBIN_DEFAULT);
}
break;
}
} else {
data.SetBin(wxPRINTBIN_DEFAULT);
}
if (devMode->dmFields & DM_MEDIATYPE)
{
wxASSERT( (int)devMode->dmMediaType != wxPRINTMEDIA_DEFAULT );
data.SetMedia(devMode->dmMediaType);
}
//// Printer name
if (devMode->dmDeviceName[0] != 0)
// This syntax fixes a crash when using VS 7.1
data.SetPrinterName( wxString(devMode->dmDeviceName, CCHDEVICENAME) );
//// Colour
if (devMode->dmFields & DM_COLOR)
{
if (devMode->dmColor == DMCOLOR_COLOR)
data.SetColour( true );
else
data.SetColour( false );
}
else
data.SetColour( true );
//// Paper size
// We don't know size of user defined paper and some buggy drivers
// set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
// dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
// code wouldn't set m_paperSize correctly.
bool foundPaperSize = false;
if ((devMode->dmFields & DM_PAPERSIZE) && (devMode->dmPaperSize < DMPAPER_USER))
{
if (wxThePrintPaperDatabase)
wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperTypeByPlatformId(devMode->dmPaperSize);
if (paper)
{
wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperTypeByPlatformId(devMode->dmPaperSize);
if (paper)
{
data.SetPaperId( paper->GetId() );
data.SetPaperSize( wxSize(paper->GetWidth() / 10,paper->GetHeight() / 10) );
m_customWindowsPaperId = 0;
foundPaperSize = true;
}
}
else
{
// Shouldn't really get here
wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
data.SetPaperId( wxPAPER_NONE );
data.SetPaperSize( wxSize(0,0) );
data.SetPaperId( paper->GetId() );
data.SetPaperSize( wxSize(paper->GetWidth() / 10,paper->GetHeight() / 10) );
m_customWindowsPaperId = 0;
GlobalUnlock(hDevMode);
return false;
foundPaperSize = true;
}
}
if (!foundPaperSize) {
if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH))
{
// DEVMODE is in tenths of a millimeter
data.SetPaperSize( wxSize(devMode->dmPaperWidth / 10, devMode->dmPaperLength / 10) );
data.SetPaperId( wxPAPER_NONE );
m_customWindowsPaperId = devMode->dmPaperSize;
}
else
{
// Often will reach this for non-standard paper sizes (sizes which
// wouldn't be in wxWidget's paper database). Setting
// m_customWindowsPaperId to devMode->dmPaperSize should be enough
// to get this paper size working.
data.SetPaperSize( wxSize(0,0) );
data.SetPaperId( wxPAPER_NONE );
m_customWindowsPaperId = devMode->dmPaperSize;
}
}
//// Duplex
if (devMode->dmFields & DM_DUPLEX)
else
{
switch (devMode->dmDuplex)
{
case DMDUP_HORIZONTAL: data.SetDuplex( wxDUPLEX_HORIZONTAL ); break;
case DMDUP_VERTICAL: data.SetDuplex( wxDUPLEX_VERTICAL ); break;
default:
case DMDUP_SIMPLEX: data.SetDuplex( wxDUPLEX_SIMPLEX ); break;
}
// Shouldn't really get here
wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
data.SetPaperId( wxPAPER_NONE );
data.SetPaperSize( wxSize(0,0) );
m_customWindowsPaperId = 0;
return false;
}
else
data.SetDuplex( wxDUPLEX_SIMPLEX );
//// Quality
if (devMode->dmFields & DM_PRINTQUALITY)
{
switch (devMode->dmPrintQuality)
{
case DMRES_MEDIUM: data.SetQuality( wxPRINT_QUALITY_MEDIUM ); break;
case DMRES_LOW: data.SetQuality( wxPRINT_QUALITY_LOW ); break;
case DMRES_DRAFT: data.SetQuality( wxPRINT_QUALITY_DRAFT ); break;
case DMRES_HIGH: data.SetQuality( wxPRINT_QUALITY_HIGH ); break;
default:
{
// TODO: if the printer fills in the resolution in DPI, how
// will the application know if it's high, low, draft etc.??
// wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
data.SetQuality( devMode->dmPrintQuality );
break;
}
}
}
else
data.SetQuality( wxPRINT_QUALITY_HIGH );
if (devMode->dmDriverExtra > 0)
data.SetPrivData( (char *)devMode+devMode->dmSize, devMode->dmDriverExtra );
else
data.SetPrivData( NULL, 0 );
GlobalUnlock(hDevMode);
}
if (hDevNames)
{
LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(hDevNames);
if (lpDevNames)
if (!foundPaperSize) {
if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH))
{
// TODO: Unicode-ification
// DEVMODE is in tenths of a millimeter
data.SetPaperSize( wxSize(devMode->dmPaperWidth / 10, devMode->dmPaperLength / 10) );
data.SetPaperId( wxPAPER_NONE );
m_customWindowsPaperId = devMode->dmPaperSize;
}
else
{
// Often will reach this for non-standard paper sizes (sizes which
// wouldn't be in wxWidget's paper database). Setting
// m_customWindowsPaperId to devMode->dmPaperSize should be enough
// to get this paper size working.
data.SetPaperSize( wxSize(0,0) );
data.SetPaperId( wxPAPER_NONE );
m_customWindowsPaperId = devMode->dmPaperSize;
}
}
// Get the port name
// port is obsolete in WIN32
// m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
//// Duplex
// Get the printer name
wxString printerName = (LPTSTR)lpDevNames + lpDevNames->wDeviceOffset;
if (devMode->dmFields & DM_DUPLEX)
{
switch (devMode->dmDuplex)
{
case DMDUP_HORIZONTAL: data.SetDuplex( wxDUPLEX_HORIZONTAL ); break;
case DMDUP_VERTICAL: data.SetDuplex( wxDUPLEX_VERTICAL ); break;
default:
case DMDUP_SIMPLEX: data.SetDuplex( wxDUPLEX_SIMPLEX ); break;
}
}
else
data.SetDuplex( wxDUPLEX_SIMPLEX );
// Not sure if we should check for this mismatch
//// Quality
if (devMode->dmFields & DM_PRINTQUALITY)
{
switch (devMode->dmPrintQuality)
{
case DMRES_MEDIUM: data.SetQuality( wxPRINT_QUALITY_MEDIUM ); break;
case DMRES_LOW: data.SetQuality( wxPRINT_QUALITY_LOW ); break;
case DMRES_DRAFT: data.SetQuality( wxPRINT_QUALITY_DRAFT ); break;
case DMRES_HIGH: data.SetQuality( wxPRINT_QUALITY_HIGH ); break;
default:
{
// TODO: if the printer fills in the resolution in DPI, how
// will the application know if it's high, low, draft etc.??
// wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
data.SetQuality( devMode->dmPrintQuality );
break;
}
}
}
else
data.SetQuality( wxPRINT_QUALITY_HIGH );
if (devMode->dmDriverExtra > 0)
data.SetPrivData( (char *)devMode+devMode->dmSize, devMode->dmDriverExtra );
else
data.SetPrivData( NULL, 0 );
if ( m_devNames )
{
GlobalPtrLock lockDevNames(m_devNames);
LPDEVNAMES lpDevNames = wx_static_cast(LPDEVNAMES, lockDevNames.Get());
// TODO: Unicode-ification
// Get the port name
// port is obsolete in WIN32
// m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
// Get the printer name
wxString printerName = (LPTSTR)lpDevNames + lpDevNames->wDeviceOffset;
// Not sure if we should check for this mismatch
// wxASSERT_MSG( (m_printerName.empty() || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
if (!printerName.empty())
data.SetPrinterName( printerName );
GlobalUnlock(hDevNames);
}
if (!printerName.empty())
data.SetPrinterName( printerName );
}
return true;
@@ -350,9 +338,8 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data )
bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
{
HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
if (!hDevMode)
HGLOBAL hDevMode = wx_static_cast(HGLOBAL, m_devMode);
if ( !m_devMode )
{
// Use PRINTDLG as a way of creating a DEVMODE object
PRINTDLG pd;
@@ -398,7 +385,7 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
else
{
hDevMode = pd.hDevMode;
m_devMode = (void*)(long) hDevMode;
m_devMode = hDevMode;
pd.hDevMode = NULL;
// We'll create a new DEVNAMEs structure below.
@@ -415,7 +402,8 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
if ( hDevMode )
{
LPDEVMODE devMode = (LPDEVMODE) GlobalLock(hDevMode);
GlobalPtrLock lockDevMode(hDevMode);
DEVMODE * const devMode = wx_static_cast(DEVMODE *, lockDevMode.Get());
//// Orientation
devMode->dmOrientation = (short)data.GetOrientation();
@@ -432,9 +420,9 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
wxString name = data.GetPrinterName();
if (!name.empty())
{
//int len = wxMin(31, m_printerName.Len());
wxStrncpy((wxChar*)devMode->dmDeviceName,name.c_str(),31);
devMode->dmDeviceName[31] = wxT('\0');
wxStrncpy(devMode->dmDeviceName, name.wx_str(),
WXSIZEOF(devMode->dmDeviceName) - 1);
devMode->dmDeviceName[WXSIZEOF(devMode->dmDeviceName) - 1] = wxT('\0');
}
//// Colour
@@ -559,16 +547,15 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
devMode->dmMediaType = data.GetMedia();
devMode->dmFields |= DM_MEDIATYPE;
}
GlobalUnlock(hDevMode);
}
if ( hDevNames )
if ( m_devNames )
{
GlobalFree(hDevNames);
::GlobalFree(wx_static_cast(HGLOBAL, m_devNames));
}
// TODO: I hope it's OK to pass some empty strings to DEVNAMES.
m_devNames = (void*) (long) wxCreateDevNames(wxEmptyString, data.GetPrinterName(), wxEmptyString);
m_devNames = wxCreateDevNames(wxEmptyString, data.GetPrinterName(), wxEmptyString);
return true;
}
@@ -700,14 +687,14 @@ bool wxWindowsPrintDialog::ConvertToNative( wxPrintDialogData &data )
if (pd->hDevNames)
GlobalFree(pd->hDevNames);
pd->hDevMode = (HGLOBAL)(DWORD) native_data->GetDevMode();
native_data->SetDevMode( (void*) NULL);
pd->hDevMode = wx_static_cast(HGLOBAL, native_data->GetDevMode());
native_data->SetDevMode(NULL);
// Shouldn't assert; we should be able to test Ok-ness at a higher level
//wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
pd->hDevNames = (HGLOBAL)(DWORD) native_data->GetDevNames();
native_data->SetDevNames( (void*) NULL);
pd->hDevNames = wx_static_cast(HGLOBAL, native_data->GetDevNames());
native_data->SetDevNames(NULL);
pd->hDC = (HDC) NULL;
@@ -772,10 +759,9 @@ bool wxWindowsPrintDialog::ConvertFromNative( wxPrintDialogData &data )
{
if (native_data->GetDevMode())
{
// Make sure we don't leak memory
GlobalFree( (HGLOBAL)(DWORD) native_data->GetDevMode() );
::GlobalFree(wx_static_cast(HGLOBAL, native_data->GetDevMode()));
}
native_data->SetDevMode( (void*)(long) pd->hDevMode );
native_data->SetDevMode(pd->hDevMode);
pd->hDevMode = NULL;
}
@@ -784,10 +770,9 @@ bool wxWindowsPrintDialog::ConvertFromNative( wxPrintDialogData &data )
{
if (native_data->GetDevNames())
{
// Make sure we don't leak memory
GlobalFree((HGLOBAL)(DWORD) native_data->GetDevNames());
::GlobalFree(wx_static_cast(HGLOBAL, native_data->GetDevNames()));
}
native_data->SetDevNames((void*)(long) pd->hDevNames);
native_data->SetDevNames(pd->hDevNames);
pd->hDevNames = NULL;
}

View File

@@ -183,7 +183,7 @@ bool wxRadioBox::Create(wxWindow *parent,
styleBtn,
0, 0, 0, 0, // will be set in SetSize()
GetHwndOf(parent),
(HMENU)subid.GetValue(),
(HMENU)wxUIntToPtr(subid.GetValue()),
wxGetInstance(),
NULL);
@@ -210,7 +210,8 @@ bool wxRadioBox::Create(wxWindow *parent,
wxEmptyString,
WS_GROUP | BS_AUTORADIOBUTTON | WS_CHILD,
0, 0, 0, 0, GetHwndOf(parent),
(HMENU)m_dummyId.GetValue(), wxGetInstance(), NULL);
(HMENU)wxUIntToPtr(m_dummyId.GetValue()),
wxGetInstance(), NULL);
m_radioButtons->SetFont(GetFont());

View File

@@ -217,7 +217,7 @@ wxSlider::Create(wxWindow *parent,
WS_CHILD | WS_VISIBLE | SS_CENTER,
0, 0, 0, 0,
hwndParent,
(HMENU)lblid.GetValue(),
(HMENU)wxUIntToPtr(lblid.GetValue()),
wxGetInstance(),
NULL
);

View File

@@ -106,7 +106,7 @@ bool wxStatusBar95::Create(wxWindow *parent,
wstyle,
0, 0, 0, 0,
GetHwndOf(parent),
(HMENU)m_windowId.GetValue(),
(HMENU)wxUIntToPtr(m_windowId.GetValue()),
wxGetInstance(),
NULL
);

View File

@@ -805,8 +805,8 @@ bool wxToolBar::Realize()
TBREPLACEBITMAP replaceBitmap;
replaceBitmap.hInstOld = NULL;
replaceBitmap.hInstNew = NULL;
replaceBitmap.nIDOld = (UINT) oldToolBarBitmap;
replaceBitmap.nIDNew = (UINT) hBitmap;
replaceBitmap.nIDOld = (UINT_PTR)oldToolBarBitmap;
replaceBitmap.nIDNew = (UINT_PTR)hBitmap;
replaceBitmap.nButtons = nButtons;
if ( !::SendMessage(GetHwnd(), TB_REPLACEBITMAP,
0, (LPARAM) &replaceBitmap) )
@@ -835,7 +835,7 @@ bool wxToolBar::Realize()
{
TBADDBITMAP addBitmap;
addBitmap.hInst = 0;
addBitmap.nID = (UINT) hBitmap;
addBitmap.nID = (UINT_PTR)hBitmap;
if ( ::SendMessage(GetHwnd(), TB_ADDBITMAP,
(WPARAM) nButtons, (LPARAM)&addBitmap) == -1 )
{
@@ -915,7 +915,7 @@ bool wxToolBar::Realize()
{
const wxString& label = tool->GetLabel();
if ( !label.empty() )
button.iString = (int)label.wx_str();
button.iString = (INT_PTR)label.wx_str();
}
button.idCommand = tool->GetId();

View File

@@ -105,7 +105,7 @@ public:
uFlags |= TTF_TRANSPARENT;
}
uId = (UINT)hwndOwner;
uId = (UINT_PTR)hwndOwner;
}
};
@@ -374,9 +374,12 @@ void wxToolTip::Add(WXHWND hWnd)
}
// only set a new width if it is bigger than the current setting
if (max > SendTooltipMessage(GetToolTipCtrl(), TTM_GETMAXTIPWIDTH, 0))
if ( max > SendTooltipMessage(GetToolTipCtrl(),
TTM_GETMAXTIPWIDTH, 0) )
{
SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH,
(void *)max);
wxUIntToPtr(max));
}
}
else
#endif // comctl32.dll >= 4.70

View File

@@ -1233,7 +1233,7 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event)
{
// restore focus to the child which was last focused unless we already
// have it
wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd);
wxLogTrace(_T("focus"), _T("wxTLW %p activated."), m_hWnd);
wxWindow *winFocus = FindFocus();
if ( !winFocus || wxGetTopLevelParent(winFocus) != this )
@@ -1266,10 +1266,9 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event)
}
wxLogTrace(_T("focus"),
_T("wxTLW %08x deactivated, last focused: %08x."),
(int) m_hWnd,
(int) (m_winLastFocused ? GetHwndOf(m_winLastFocused)
: NULL));
_T("wxTLW %p deactivated, last focused: %p."),
m_hWnd,
m_winLastFocused ? GetHwndOf(m_winLastFocused) : NULL);
event.Skip();
}

View File

@@ -212,6 +212,13 @@ WX_DECLARE_HASH_MAP(int, wxWindow::MSWMessageHandler,
static MSWMessageHandlers gs_messageHandlers;
// hash containing all our windows, it uses HWND keys and wxWindow* values
WX_DECLARE_HASH_MAP(HWND, wxWindow *,
wxPointerHash, wxPointerEqual,
WindowHandles);
static WindowHandles gs_windowHandles;
// ---------------------------------------------------------------------------
// private functions
// ---------------------------------------------------------------------------
@@ -227,7 +234,6 @@ LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
void wxRemoveHandleAssociation(wxWindowMSW *win);
extern void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win);
wxWindow *wxFindWinFromHandle(WXHWND hWnd);
// get the text metrics for the current font
static TEXTMETRIC wxGetTextMetrics(const wxWindowMSW *win);
@@ -848,7 +854,7 @@ void wxWindowMSW::DoReleaseMouse()
/* static */ wxWindow *wxWindowBase::GetCapture()
{
HWND hwnd = ::GetCapture();
return hwnd ? wxFindWinFromHandle((WXHWND)hwnd) : (wxWindow *)NULL;
return hwnd ? wxFindWinFromHandle(hwnd) : NULL;
}
bool wxWindowMSW::SetFont(const wxFont& font)
@@ -2350,7 +2356,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
if ( (style & BS_OWNERDRAW) == BS_OWNERDRAW )
{
// emulate the button click
btn = wxFindWinFromHandle((WXHWND)msg->hwnd);
btn = wxFindWinFromHandle(msg->hwnd);
}
bProcess = false;
@@ -2641,11 +2647,11 @@ LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM w
// trace all messages - useful for the debugging
#ifdef __WXDEBUG__
wxLogTrace(wxTraceMessages,
wxT("Processing %s(hWnd=%08lx, wParam=%8lx, lParam=%8lx)"),
wxGetMessageName(message), (long)hWnd, (long)wParam, lParam);
wxT("Processing %s(hWnd=%p, wParam=%08lx, lParam=%08lx)"),
wxGetMessageName(message), hWnd, (long)wParam, lParam);
#endif // __WXDEBUG__
wxWindowMSW *wnd = wxFindWinFromHandle((WXHWND) hWnd);
wxWindowMSW *wnd = wxFindWinFromHandle(hWnd);
// when we get the first message for the HWND we just created, we associate
// it with wxWindow stored in gs_winBeingCreated
@@ -2781,11 +2787,11 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
break;
case WM_SETFOCUS:
processed = HandleSetFocus((WXHWND)(HWND)wParam);
processed = HandleSetFocus((WXHWND)wParam);
break;
case WM_KILLFOCUS:
processed = HandleKillFocus((WXHWND)(HWND)wParam);
processed = HandleKillFocus((WXHWND)wParam);
break;
case WM_PRINTCLIENT:
@@ -3007,23 +3013,15 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
// for these messages we must return true if process the message
#ifdef WM_DRAWITEM
case WM_DRAWITEM:
case WM_MEASUREITEM:
{
int idCtrl = (UINT)wParam;
if ( message == WM_DRAWITEM )
{
processed = MSWOnDrawItem(idCtrl,
(WXDRAWITEMSTRUCT *)lParam);
}
else
{
processed = MSWOnMeasureItem(idCtrl,
(WXMEASUREITEMSTRUCT *)lParam);
}
processed = MSWOnDrawItem(wParam, (WXDRAWITEMSTRUCT *)lParam);
if ( processed )
rc.result = TRUE;
break;
if ( processed )
rc.result = TRUE;
}
case WM_MEASUREITEM:
processed = MSWOnMeasureItem(wParam, (WXMEASUREITEMSTRUCT *)lParam);
if ( processed )
rc.result = TRUE;
break;
#endif // defined(WM_DRAWITEM)
@@ -3215,11 +3213,11 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
#endif
case WM_PALETTECHANGED:
processed = HandlePaletteChanged((WXHWND) (HWND) wParam);
processed = HandlePaletteChanged((WXHWND)wParam);
break;
case WM_CAPTURECHANGED:
processed = HandleCaptureChanged((WXHWND) (HWND) lParam);
processed = HandleCaptureChanged((WXHWND)lParam);
break;
case WM_SETTINGCHANGE:
@@ -3231,7 +3229,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
break;
case WM_ERASEBKGND:
processed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
processed = HandleEraseBkgnd((WXHDC)wParam);
if ( processed )
{
// we processed the message, i.e. erased the background
@@ -3246,7 +3244,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
#endif
case WM_INITDIALOG:
processed = HandleInitDialog((WXHWND)(HWND)wParam);
processed = HandleInitDialog((WXHWND)wParam);
if ( processed )
{
@@ -3270,7 +3268,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
#endif
case WM_SETCURSOR:
processed = HandleSetCursor((WXHWND)(HWND)wParam,
processed = HandleSetCursor((WXHWND)wParam,
LOWORD(lParam), // hit test
HIWORD(lParam)); // mouse msg
@@ -3355,9 +3353,10 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
// we could have got an event from our child, reflect it back
// to it if this is the case
wxWindowMSW *win = NULL;
if ( (WXHWND)wParam != m_hWnd )
WXHWND hWnd = (WXHWND)wParam;
if ( hWnd != m_hWnd )
{
win = FindItemByHWND((WXHWND)wParam);
win = FindItemByHWND(hWnd);
}
if ( !win )
@@ -3409,30 +3408,33 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
// now alter the client size making room for drawing a themed border
NCCALCSIZE_PARAMS *csparam = NULL;
RECT rect;
if (wParam)
RECT *rect;
if ( wParam )
{
csparam = (NCCALCSIZE_PARAMS*)lParam;
rect = csparam->rgrc[0];
csparam = (NCCALCSIZE_PARAMS *)lParam;
rect = &csparam->rgrc[0];
}
else
{
rect = *((RECT*)lParam);
rect = (RECT *)lParam;
}
wxUxThemeHandle hTheme((wxWindow *)this, L"EDIT");
RECT rcClient = { 0, 0, 0, 0 };
wxClientDC dc((wxWindow *)this);
wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
if (theme->GetThemeBackgroundContentRect(
hTheme, GetHdcOf(*impl), EP_EDITTEXT, ETS_NORMAL,
&rect, &rcClient) == S_OK)
if ( theme->GetThemeBackgroundContentRect
(
hTheme,
GetHdcOf(*impl),
EP_EDITTEXT,
ETS_NORMAL,
rect,
&rcClient) == S_OK )
{
InflateRect(&rcClient, -1, -1);
if (wParam)
csparam->rgrc[0] = rcClient;
else
*((RECT*)lParam) = rcClient;
*rect = rcClient;
rc.result = WVR_REDRAW;
}
}
@@ -3513,38 +3515,40 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
// wxWindow <-> HWND map
// ----------------------------------------------------------------------------
wxWinHashTable *wxWinHandleHash = NULL;
wxWindow *wxFindWinFromHandle(WXHWND hWnd)
wxWindow *wxFindWinFromHandle(HWND hwnd)
{
return (wxWindow*)wxWinHandleHash->Get((long)hWnd);
WindowHandles::const_iterator i = gs_windowHandles.find(hwnd);
return i == gs_windowHandles.end() ? NULL : i->second;
}
void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win)
void wxAssociateWinWithHandle(HWND hwnd, wxWindowMSW *win)
{
// adding NULL hWnd is (first) surely a result of an error and
// adding NULL hwnd is (first) surely a result of an error and
// (secondly) breaks menu command processing
wxCHECK_RET( hWnd != (HWND)NULL,
wxT("attempt to add a NULL hWnd to window list ignored") );
wxCHECK_RET( hwnd != (HWND)NULL,
wxT("attempt to add a NULL hwnd to window list ignored") );
wxWindow *oldWin = wxFindWinFromHandle((WXHWND) hWnd);
#ifdef __WXDEBUG__
if ( oldWin && (oldWin != win) )
WindowHandles::const_iterator i = gs_windowHandles.find(hwnd);
if ( i != gs_windowHandles.end() )
{
wxLogDebug(wxT("HWND %X already associated with another window (%s)"),
(int) hWnd, win->GetClassInfo()->GetClassName());
if ( i->second != win )
{
wxLogDebug(wxT("HWND %p already associated with another window (%s)"),
hwnd, win->GetClassInfo()->GetClassName());
}
//else: this actually happens currently because we associate the window
// with its HWND during creation (if we create it) and also when
// SubclassWin() is called later, this is ok
}
else
#endif // __WXDEBUG__
if (!oldWin)
{
wxWinHandleHash->Put((long)hWnd, (wxWindow *)win);
}
gs_windowHandles[hwnd] = win;
}
void wxRemoveHandleAssociation(wxWindowMSW *win)
{
wxWinHandleHash->Delete((long)win->GetHWND());
gs_windowHandles.erase(GetHwndOf(win));
}
// ----------------------------------------------------------------------------
@@ -3686,7 +3690,7 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass,
style,
x, y, w, h,
(HWND)MSWGetParent(),
(HMENU)controlId,
(HMENU)wxUIntToPtr(controlId),
wxGetInstance(),
NULL // no extra data
);
@@ -3716,7 +3720,7 @@ bool wxWindowMSW::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
#ifndef __WXMICROWIN__
LPNMHDR hdr = (LPNMHDR)lParam;
HWND hWnd = hdr->hwndFrom;
wxWindow *win = wxFindWinFromHandle((WXHWND)hWnd);
wxWindow *win = wxFindWinFromHandle(hWnd);
// if the control is one of our windows, let it handle the message itself
if ( win )
@@ -5183,7 +5187,7 @@ static wxWindowMSW *FindWindowForMouseEvent(wxWindowMSW *win, int *x, int *y)
::IsWindowVisible(hwndUnderMouse) &&
::IsWindowEnabled(hwndUnderMouse) )
{
wxWindow *winUnderMouse = wxFindWinFromHandle((WXHWND)hwndUnderMouse);
wxWindow *winUnderMouse = wxFindWinFromHandle(hwndUnderMouse);
if ( winUnderMouse )
{
// translate the mouse coords to the other window coords
@@ -6185,7 +6189,7 @@ wxWindow *wxGetActiveWindow()
HWND hWnd = GetActiveWindow();
if ( hWnd != 0 )
{
return wxFindWinFromHandle((WXHWND) hWnd);
return wxFindWinFromHandle(hWnd);
}
return NULL;
}
@@ -6200,7 +6204,7 @@ extern wxWindow *wxGetWindowFromHWND(WXHWND hWnd)
wxWindow *win = (wxWindow *)NULL;
if ( hwnd )
{
win = wxFindWinFromHandle((WXHWND)hwnd);
win = wxFindWinFromHandle(hwnd);
if ( !win )
{
#if wxUSE_RADIOBOX
@@ -6244,7 +6248,7 @@ extern wxWindow *wxGetWindowFromHWND(WXHWND hWnd)
#endif
hwnd = ::GetParent(hwnd);
win = wxFindWinFromHandle((WXHWND)hwnd);
win = wxFindWinFromHandle(hwnd);
}
return win;