Larry
2010-02-12 16:56:19 UTC
Hi,
I would like to create custom macro (and methods) in order to deal with
message sent from the menu, so far I have coded the following:
#define STRICT
#include <windows.h>
#include <windowsx.h>
#define IDM_BLOCK 800
// Declare Custom HANDLE MSG //
#define HANDLE_IDM_BLOCK(hwnd, wParam, lParam, fn) \
((fn)(hwnd), 0L)
#define FORWARD_IDM_BLOCK(hwnd, fn) \
(void)(fn)((hwnd), IDM_BLOCK, 0L, 0L)
///////////////////////////////
// Default
void Cls_OnDestroy(HWND hwnd);
void Cls_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
BOOL Cls_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct);
// Custom
void Cls_OnMenuBlock(HWND hwnd);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
__try
{
switch (message)
{
HANDLE_MSG (hWnd, WM_CREATE, Cls_OnCreate);
HANDLE_MSG (hWnd, WM_COMMAND, Cls_OnCommand);
HANDLE_MSG (hWnd, WM_DESTROY, Cls_OnDestroy);
}
}
__except(EXCEPTION_EXECUTE_HANDLER) {}
return DefWindowProc(hWnd, message, wParam, lParam);
}
void Cls_OnCommand(HWND hWnd, int id, HWND hwndCtl, UINT codeNotify)
{
__try
{
switch (id)
{
HANDLE_MSG (hWnd, IDM_BLOCK, Cls_OnMenuBlock);
}
}
__except(EXCEPTION_EXECUTE_HANDLER) {}
}
void Cls_OnMenuBlock(HWND hwnd)
{
}
Now, when I run the code I get this error: error C2562: 'Cls_OnCommand' :
'void' function returning a value
I don't see that function returns any value as opposite to the error fired
by the compiler...
what am I doing wrong? I just need functions like this: Cls_OnMenuBlock(HWND
hwnd); to take along only the HWND
thanks
I would like to create custom macro (and methods) in order to deal with
message sent from the menu, so far I have coded the following:
#define STRICT
#include <windows.h>
#include <windowsx.h>
#define IDM_BLOCK 800
// Declare Custom HANDLE MSG //
#define HANDLE_IDM_BLOCK(hwnd, wParam, lParam, fn) \
((fn)(hwnd), 0L)
#define FORWARD_IDM_BLOCK(hwnd, fn) \
(void)(fn)((hwnd), IDM_BLOCK, 0L, 0L)
///////////////////////////////
// Default
void Cls_OnDestroy(HWND hwnd);
void Cls_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
BOOL Cls_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct);
// Custom
void Cls_OnMenuBlock(HWND hwnd);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
__try
{
switch (message)
{
HANDLE_MSG (hWnd, WM_CREATE, Cls_OnCreate);
HANDLE_MSG (hWnd, WM_COMMAND, Cls_OnCommand);
HANDLE_MSG (hWnd, WM_DESTROY, Cls_OnDestroy);
}
}
__except(EXCEPTION_EXECUTE_HANDLER) {}
return DefWindowProc(hWnd, message, wParam, lParam);
}
void Cls_OnCommand(HWND hWnd, int id, HWND hwndCtl, UINT codeNotify)
{
__try
{
switch (id)
{
HANDLE_MSG (hWnd, IDM_BLOCK, Cls_OnMenuBlock);
}
}
__except(EXCEPTION_EXECUTE_HANDLER) {}
}
void Cls_OnMenuBlock(HWND hwnd)
{
}
Now, when I run the code I get this error: error C2562: 'Cls_OnCommand' :
'void' function returning a value
I don't see that function returns any value as opposite to the error fired
by the compiler...
what am I doing wrong? I just need functions like this: Cls_OnMenuBlock(HWND
hwnd); to take along only the HWND
thanks