-1

In order to prevent the WM_LBUTTONUP event from being flooded with code, I decided to make a class method that contains the code which initially triggered on WM_LBUTTONUP.

Example:

 case WM_LBUTTONUP:
 {//Code that used to trigger on WM_LBUTTONUP below:
  x=4;
  y=2;
  SendMessage(hWnd, CUSTOM_WMMESSAGE, NULL, NULL);
}//The above SendMessage() call works

Method Definition:

void Dog::bark(HWND hindow, INT wm_message)
{//All code that used to trigger on WM_LBUTTON up was moved to this method
 x=4;
 y=2;
 SendMessage(hwindow, wm_message, NULL, NULL);
}

Afterward:

case WM_LBUTTONUP:
{Object.bark();}
//When SendMessage was called this way (inside of a method definition)
//it did not work!

Problem:

SendMessage() worked on WM_LBUTTONUP when it was not used inside of a class method. However, once I called SendMessage() from a class method on WM_LBUTTONUP, the message was not sent (which means, SendMessage() did not, or does not work when called from a class method).

Please Note:

The method definition is not in the same file as WM_LBUTTON up (and I would like to keep it that way, to prevent main.cpp from being filled with too much code :) )

Edit

The file name which contains the class' definition is called Dog.hpp I included Dog.hpp inside of main.cpp. I have successfully created other class methods (inside of dog.hpp) which worked, so I know there's nothing wrong with the class or the header file code. The only problem is, that when the SendMessage() function is called inside of dog.hpp, as apposed to being called in main.cpp, it does not work.

4

1 に答える 1

0

Object.bark()渡していない入力パラメータが必要です。代わりにこれを行う必要があります:

case WM_LBUTTONUP:
{
    Object.bark(hWnd, CUSTOM_WMMESSAGE);
    break; // <-- this is missing in your original code as well!
}
于 2012-11-22T00:35:56.523 に答える