C
Christopher
Last time I posted about reinterpret cast I was told I could use a
static cast in that case. Well here I am again in the same situation.
I try to static cast and the compiler complains "static_cast cannot
convert from DisplayMode * to LPARAM"
What am I doing wrong?
I am making a call to a Windows function (although this question is
about casting):
INT_PTR DialogBoxParam(
HINSTANCE hInstance,
LPCTSTR lpTemplateName,
HWND hWndParent,
DLGPROC lpDialogFunc,
LPARAM dwInitParam
);
The documentation suggets that if I want to pass a data structure to
my dialog that I am creating, that I should pass a pointer to my data
structure as the 5th argument.
Ok, so that is exactly what I try do do:
DialogBoxParam(instance, MAKEINTRESOURCE(IDD_GRAPHICS_CONFG,m_hwnd,
DlgProc, static_cast<LPARAM>(&m_displayMode));
I realize there a a bunch of windows types in here, but we are only
concerned with the 5th argument.
I am passing the address of a member of my class which is of type
DisplayMode. DisplayMode is a class I created myself.
LPARAM when searching down the typdef tree resolves to a __w64,
whatever that is. The docs claim it to be a "word", I assume it is
just a 64 bit word which is equivalent to a 64bit integer value(i
think).
So, why does my static_cast fail and must I use reinterpret_cast here
instead?
The book I am using just does a C-style cast of course, which I was
under the impression is equivalent to a static cast. Is that
incorrect?
static cast in that case. Well here I am again in the same situation.
I try to static cast and the compiler complains "static_cast cannot
convert from DisplayMode * to LPARAM"
What am I doing wrong?
I am making a call to a Windows function (although this question is
about casting):
INT_PTR DialogBoxParam(
HINSTANCE hInstance,
LPCTSTR lpTemplateName,
HWND hWndParent,
DLGPROC lpDialogFunc,
LPARAM dwInitParam
);
The documentation suggets that if I want to pass a data structure to
my dialog that I am creating, that I should pass a pointer to my data
structure as the 5th argument.
Ok, so that is exactly what I try do do:
DialogBoxParam(instance, MAKEINTRESOURCE(IDD_GRAPHICS_CONFG,m_hwnd,
DlgProc, static_cast<LPARAM>(&m_displayMode));
I realize there a a bunch of windows types in here, but we are only
concerned with the 5th argument.
I am passing the address of a member of my class which is of type
DisplayMode. DisplayMode is a class I created myself.
LPARAM when searching down the typdef tree resolves to a __w64,
whatever that is. The docs claim it to be a "word", I assume it is
just a 64 bit word which is equivalent to a 64bit integer value(i
think).
So, why does my static_cast fail and must I use reinterpret_cast here
instead?
The book I am using just does a C-style cast of course, which I was
under the impression is equivalent to a static cast. Is that
incorrect?