Sign in to follow this  
hkBattousai

Are XBUTTON1 and XBUTTON2 not defined?

Recommended Posts

MSDN says :
Quote:
MSLLHOOKSTRUCT Structure Syntax typedef struct { POINT pt; DWORD mouseData; DWORD flags; DWORD time; ULONG_PTR dwExtraInfo; } MSLLHOOKSTRUCT, *PMSLLHOOKSTRUCT; Members pt ... mouseData If the message is WM_MOUSEWHEEL, the high-order word of this member is the wheel delta. The low-order word is reserved. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120. If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP, or WM_NCXBUTTONDBLCLK, the high-order word specifies which X button was pressed or released, and the low-order word is reserved. This value can be one or more of the following values. Otherwise, mouseData is not used. XBUTTON1 The first X button was pressed or released. XBUTTON2 The second X button was pressed or released. ... flags time dwExtraInfo Declared in Winuser.h, include Windows.h
There is nothing defined for XBUTTON1 or XBUTTON2. But, VK_XBUTTON1, VK_XBUTTON2, MK_XBUTTON1 and MK_XBUTTON2 are all defined in winuser.h though. Yet they don't work for the same purpose.

Share this post


Link to post
Share on other sites
In the most recent version of the Platform SDK (and this should be the case for any Platform SDK from Win2K on up) XBUTTON1 and XBUTTON2 are both defined. To use them you must first #define _WIN32_WINNT 0x0500 before including windows.h.

Share this post


Link to post
Share on other sites
I already have
#define _WIN32_IE	0x0601
#define _WIN32_WINNT 0x0501
on the top of my code.
Isn't that enough? The problem must be something else I believe.

I'm using DevCPP. Once I experienced that WM_INPUT message wasn't defined in the headers of DevCPP, but was defined in VS 2005. I defined it by hand in my project. Is it again something like that?

Share this post


Link to post
Share on other sites
You say its "at the top", by that do you mean before #include "windows.h" ? If not, that is your problem, unless your DevCPP is using a really old Windows SDK.

Share this post


Link to post
Share on other sites
Like this :
#define _WIN32_IE	0x0601
#define _WIN32_WINNT 0x0501
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <commctrl.h>
using namespace std;
#include "ErrorHandling.h"
#include "UsefulFunctions.h"
#include "WindowClasses.h"
#include "DiskFile.h"
#include "TrayIcon.h"
#include "Key Index.h"
HINSTANCE hInstance;
MSG Msg;
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
void ConstructGUIControls(int nFunster);
void ConvertVKey(USHORT VKey, CHAR * szInput);
void CheckParameter(char * szParam);
//... (code goes on like this)

Share this post


Link to post
Share on other sites

Here is the code from WinUser.h (which is included from windows.h):

#if(_WIN32_WINNT >= 0x0500)
#define VK_XBUTTON1 0x05 /* NOT contiguous with L & RBUTTON */
#define VK_XBUTTON2 0x06 /* NOT contiguous with L & RBUTTON */
#endif /* _WIN32_WINNT >= 0x0500 */


Now, if you're using DevCpp, make sure you have a recent Platform SDK installed. Do a "grep XBUTTON" in your psdk/include directory to make sure those lines are in there.

Share this post


Link to post
Share on other sites
Search MSDN for all three (VK_XBUTTON1, MK_XBUTTON1, and XBUTTON1). It documents them all.

Two of them are used for mouse buttons, but they mean slightly different things. One has nothing to do with mouse buttons but is used for special keyboard keys instead.

All three constants are also defined in winuser.h.

Share this post


Link to post
Share on other sites
hplus0603 has quoted the wrong part of the file. VK_XBUTTON1, MK_XBUTTON1, and XBUTTON1 are not the same. VK_XBUTTON1 is a virtual key constant. MK_XBUTTON1 is used is the low-order word of the wParam that comes from various WM_XBUTTON* messages, XBUTTON1 is used in the high-order word of the wParam of the same various WM_XBUTTON* messages as well as in low-level hooks.

Your problem is that the Platform SDK that comes with Dev-C++ is either older or not in sync with the official Microsoft Platform SDK. I do not know if you can download a gcc port of the SDK or if you can use MS's official copy, you'll need to find that out.

Alternatively, you can use Visual C++ Express when designing Windows applications.

Share this post


Link to post
Share on other sites
C:\Prog\wxDevCPP\include\winuser.h --> 134kb
C:\Prog\Visual Studio\VC\PlatformSDK\Include\WinUser.h --> 288kb

The problem is solved, XBUTTONn is not defined in DevCPP's header files.
Visual Studio is indeed superior to Dev-C++, but it requires the target PC to have Framework installed on it. That is the reason I stopped using VS. But using Dev-C++, I time to time encounter this kind of difficulties.

Share this post


Link to post
Share on other sites
Visual C++ does not require the .Net framework unless you are writing code in C++/CLI. All it requires is a small runtime distributable file, and you can eliminate the need for that using static linking the same as with Dev-C++ and the MinGW compiler. In any case, it's very rare to actually need to ship the redist files, because virtually all up-to-date XP and Vista installations already have the necessary libraries accessible.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this