Crash after creating child button window inside custom control - c++

I have an MFC Application that show a simple dialog containing a custom control the custom create dynamic control windows. after the first child of the custom control is created the application crash after a stack overflow
this is the call stack after the crash
Amn80Lib1.dll!TPXBitButton::GetThisMessageMap() Line 1627 C++
Amn80Lib1.dll!TPXBitButton::GetMessageMap() Line 1627 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2181 C++
mfc100d.dll!CWnd::ReflectChildNotify(unsigned int uMsg, unsigned int wParam, long lParam, long * pResult) Line 3408 C++
> mfc100d.dll!CWnd::OnChildNotify(unsigned int uMsg, unsigned int wParam, long lParam, long * pResult) Line 3387 C++
mfc100d.dll!CButton::OnChildNotify(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 91 C++
mfc100d.dll!CWnd::SendChildNotifyLastMsg(long * pResult) Line 3327 C++
mfc100d.dll!CWnd::ReflectLastMsg(HWND__ * hWndChild, long * pResult) Line 3365 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3463 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
The maximum number of stack frames supported by Visual Studio has been exceeded.
The message that is sent always is 528 this is 0x210 = WM_PARENTNOTIFY
The wParam = 77594625, lParam = 3409408
I don't know what is the reason for that, and how to stop it, I searched the childs if any of them send any message to the parent, but there is no messages, the dialog is not shown , but it's window handle was created and the custom control also has got a handle and it's first child has got a handle then we are stuck with the crash and the other childs didn't got the chance to be created. I traced the execution and got that the crash happen after calling the create method of the child of the custom control inside the dialog.
The custom control is a database navigation control that contains buttons for the next, previous, new, edit to enter record number, this custom control is inherited from TControl which is inherited from CWnd. the buttons inside it are inheriting from TButton which inherits from CButton.
UPDATE
The problem was as the following:
when I registered the custom control window class I set the windowproc to the MFC windowProc , when the MFC proc didn't find any method to eat the message it called the default proc of the window which is the MFC windowPoc that caused an open recursion, I fixed that by setting the window proc to the default one like the following
WNDCLASS wndClass;
//fill the window class data
wndClass.lpfnWndProc = ::DefWindowProc;//AfxWndProc;//this fixed it
that fixed my problem

I updated the answer to contain the solution of that problem, but in response to #Michael Walz I added the solution to this answer
when I registered the custom control window class I set the windowproc to the MFC windowProc , when the MFC proc didn't find any method to eat the message it called the default proc of the window which is the MFC windowPoc that caused an open recursion, I fixed that by setting the window proc to the default one like the following
WNDCLASS wndClass;
//fill the window class data
wndClass.lpfnWndProc = ::DefWindowProc;//AfxWndProc;//this fixed it
that fixed my problem

Related

How to distinguish if a window is being activated by mouse click?

I'm currently hooking window activations with the following code:
extern "C" __declspec(dllexport) LRESULT CALLBACK CBTProc(
_In_ int nCode,
_In_ WPARAM wParam,
_In_ LPARAM lParam
)
{
if (nCode < 0) return CallNextHookEx(nullptr, nCode, wParam, lParam);
HWND hwnd = reinterpret_cast<HWND>(wParam);
switch (nCode)
{
case HCBT_ACTIVATE: // The system is about to activate a window.
{
return 0; // 0 - Allow 1 - Deny
}
}
return 0;
From the docs:
https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644977(v=vs.85)
lParam
Specifies a long pointer to a CBTACTIVATESTRUCT structure containing the handle to the active window and specifies whether the activation is changing because of a mouse click.
How I could interpret the value of lParam and distinguish it?
As the documentation says, for HCBT_ACTIVATE the lParam specifies a pointer to a CBTACTIVATESTRUCT, so simply typecast it accordingly, just like you are doing with the wParam, eg:
extern "C" __declspec(dllexport) LRESULT CALLBACK CBTProc(
_In_ int nCode,
_In_ WPARAM wParam,
_In_ LPARAM lParam
)
{
if (nCode < 0) return CallNextHookEx(nullptr, nCode, wParam, lParam);
switch (nCode)
{
case HCBT_ACTIVATE: // The system is about to activate a window.
{
HWND hwnd = reinterpret_cast<HWND>(wParam);
CBTACTIVATESTRUCT* cbt = reinterpret_cast<CBTACTIVATESTRUCT*>(lParam);
// use hwnd, cbt->fMouse, and cbt->hWndActive as needed...
return 0; // 0 - Allow 1 - Deny
}
}
return 0;
}

How do i extract dragged & dropped filenames from a DROPFILES struct

I have a window with no controls with WS_EX_ACCEPTFILES enabled and the event triggers successfully when dragging files from explorer. What I need to do is extract the files to a vector. From what I've read, the wParam is supposed to contain the location of the files within a DROPFILES struct but I don't know how to access them.
LRESULT CALLBACK StaticWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR
uIdSubclass, DWORD_PTR dwRefData)
{
if (uMsg == WM_DROPFILES)
{
// extract files here
vector<string> files;
}
return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}
I don't need to send them to any controls since my window is for an openGL application, I just need to retain them in a list, how can it be done?
Per the WM_DROPFILES documentation:
Parameters
hDrop
A handle to an internal structure describing the dropped files. Pass this handle to DragFinish, DragQueryFile, or DragQueryPoint() to retrieve information about the dropped files.
lParam
Must be zero.
Simply type-cast the wParam to HDROP and call the drag-drop functions as needed, eg:
LRESULT CALLBACK StaticWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
if (uMsg == WM_DROPFILES)
{
HDROP hDrop = reinterpret_cast<HDROP>(wParam);
// extract files here
vector<string> files;
char filename[MAX_PATH];
UINT count = DragQueryFileA(hDrop, -1, NULL, 0);
for(UINT i = 0; i < count; ++i)
{
if (DragQueryFileA(hDrop, i, filename, MAX_PATH))
files.push_back(filename);
}
DragFinish(hDrop);
return 0;
}
return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}
Alternatively:
LRESULT CALLBACK StaticWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
if (uMsg == WM_DROPFILES)
{
HDROP hDrop = reinterpret_cast<HDROP>(wParam);
// extract files here
vector<string> files;
string filename;
UINT count = DragQueryFileA(hDrop, -1, NULL, 0);
for(UINT i = 0; i < count; ++i)
{
UINT size = DragQueryFileA(hDrop, i, NULL, 0);
if (size > 0)
{
filename.resize(size);
DragQueryFileA(hDrop, i, &filename[0], size+1);
files.push_back(filename);
}
}
DragFinish(hDrop);
return 0;
}
return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}

Destroying CListBox after LBN_KILLFOCUS leads to Exception

My goal is to destroy a CListBox-Object after it loses focus. I added the following code to the parent object:
BEGIN_MESSAGE_MAP(CChildView, CWnd)
ON_LBN_KILLFOCUS(IDC_LISTBOX, OnLBKillFocus)
END_MESSAGE_MAP()
void CChildView::OnLBKillFocus()
{
listBox->DestroyWindow();
}
I created the object like this:
listBox = new CListBox;
listBox->Create(WS_VISIBLE | WS_CHILD, CRect(10, 110, 100, 200), this, 1112);
But after the OnLBKillFocus function executed I get an exception in DefWindowProc. Apparently the already destroyed ListBox trys to process a WM_KILLFOCUS message and crashes, because the window handle is NULL.
Here is part of the stack trace:
mfc110ud.dll!CWnd::DefWindowProcW(unsigned int nMsg, unsigned int wParam, long lParam) Line 1141 C++
mfc110ud.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2138 C++
mfc110ud.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 290 C++
mfc110ud.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 453 C++
mfc110ud.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 304 C++
user32.dll!_InternalCallWinProc#20() Unknown
...
Does anybody have an idea what is the cause of this crash and how it can be avoided?
Decouple the action that should cause the destruction and destruction itself.
After you receive the WM_KILLFOCUS event, just use PostMessage with a private message (registered window message or WM_APP+n) and upon receive of this message destroy the window.

c++ MFC and handling windows Messages

What code is needed in the message map for Windows messages?
The code calling the function:
SendMessage(GRID_WM_UPDATECELL,(WPARAM)1,(LPARAM)&sDisp);
The function:
LRESULT CNJAGridCtrl::OnUpdateCell(WPARAM wParam, LPARAM lParam)
{
}
The message map line should be
ON_MESSAGE(GRID_WM_UPDATECELL, OnUpdateCell)
and the function signature should be
LRESULT CNJAGridCtrl::OnUpdateCell(WPARAM wParam, LPARAM lParam);

C++ Function pointer error

I am trying to make a source code to work
extern "C" {
typedef LRESULT (__stdcall *NRI_PM_CALLBACK)(WPARAM, LPARAM);
}
LRESULT OnPaymentManagerMessage(WPARAM wParam, LPARAM lParam)
{
int type = (wParam >> 4) & 0x0F;
int device = wParam & 0x0F;
//cstr.Format("** Msg **[ %d %d %d ]", type, device, lParam);
//handle message here
return lParam;
}
NRI_PM_CALLBACK callback = &OnPaymentManagerMessage; //error on this line
Error:a value of type "LRESULT (*)(WPARAM wParam, LPARAM lParam)" cannot be used to initialized an entity of type "NRI_PM_CALLBACK"
I am running this in Visual Studio Express 2012
Any ideas why ?
Thanks
Make OnPaymentManagerMessage() a __stdcall function:
LRESULT __stdcall OnPaymentManagerMessage(WPARAM wParam, LPARAM lParam)
/* ... */
__cdecl is the default for the compiler (though a compiler option can change that).