How do i include <Winuser.h> (identifier "WM_TOUCH" is undefined, "DWORD" is ambiguous)

I am attempting to include <Winuser.h>, but i keep getting undefined compile time errors

Compile errors


Severity	Code	Description	Project	File	Line	Suppression State
Error	C2065	'WM_TOUCH': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	49	
Error	C2065	'TOUCHINPUT': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	51	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	51	
Error	C2061	syntax error: identifier 'TOUCHINPUT'	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	51	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	52	
Error	C2065	'HTOUCHINPUT': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	56	
Error	C2146	syntax error: missing ')' before identifier 'lParam'	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	56	
Error	C2143	syntax error: missing ';' before '{'	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	57	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	62	
Error	C2228	left of '.dwID' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	62	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	63	
Error	C2228	left of '.dwID' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	63	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	64	
Error	C2228	left of '.dwFlags' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	64	
Error	C2065	'TOUCHEVENTF_UP': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	64	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	66	
Error	C2228	left of '.dwID' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	66	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	67	
Error	C2228	left of '.x' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	67	
Error	C3861	'TOUCH_COORD_TO_PIXEL': identifier not found	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	67	
Error	C2228	left of '.y' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	67	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	69	
Error	C2228	left of '.dwFlags' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	69	
Error	C2065	'TOUCHEVENTF_MOVE': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	69	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	72	
Error	C2228	left of '.dwID' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	72	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	73	
Error	C2228	left of '.x' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	73	
Error	C3861	'TOUCH_COORD_TO_PIXEL': identifier not found	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	73	
Error	C2228	left of '.y' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	73	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	75	
Error	C2228	left of '.dwFlags' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	75	
Error	C2065	'TOUCHEVENTF_DOWN': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	75	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	78	
Error	C2228	left of '.dwID' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	78	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	79	
Error	C2228	left of '.x' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	79	
Error	C3861	'TOUCH_COORD_TO_PIXEL': identifier not found	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	79	
Error	C2228	left of '.y' must have class/struct/union	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	79	
Error	C2065	'HTOUCHINPUT': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	85	
Error	C2146	syntax error: missing ')' before identifier 'lParam'	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	85	
Error	C2065	'ti': undeclared identifier	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	86	
Error	C2541	'delete': cannot delete objects that are not pointers	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	86	
Error	C3861	'RegisterTouchWindow': identifier not found	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Source\SolarSystem\MyWindowsMessageHandler.cpp	90	
Error		Failed to produce item: C:\Users\Dave\Desktop\SolarSystem\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-SolarSystem.exp	SolarSystem	C:\Users\Dave\Desktop\SolarSystem\Intermediate\ProjectFiles\ERROR	1	
Error	MSB3075	The command ""C:\Program Files (x86)\Epic Games\4.12\Engine\Build\BatchFiles\Build.bat" SolarSystemEditor Win64 Development "C:\Users\Dave\Desktop\SolarSystem\SolarSystem.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.	SolarSystem	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets	37	


The code in question


// Fill out your copyright notice in the Description page of Project Settings.

#include "SolarSystem.h"
#include "MyWindowsMessageHandler.h"
#include "GenericApplication.h"
#include "AllowWindowsPlatformTypes.h"
#include "Windows/WindowsSystemIncludes.h"
#include <Winuser.h>
#include "HideWindowsPlatformTypes.h"

#define MAXPOINTS 32
static int32 idLookup[MAXPOINTS];


int32 GetContactIndex(int32 dwID) {
	for (int32 i = 0; i < MAXPOINTS; i++) {
		if (idLookup* == -1) {
			idLookup* = dwID;
			return i;
		}
		else {
			if (idLookup* == dwID) {
				return i;
			}
		}
	}
	// Out of contacts
	return -1;
}

void ReleaseContactIndex(int32 dwID) {
	for (int32 i = 0; i < MAXPOINTS; i++) {
		if (idLookup* == dwID) {
			idLookup* = -1;
		}
	}
}

void  MyWindowsMessageHandler::InitVariable() {
	for (int32 i = 0; i < MAXPOINTS; i++) {
		idLookup* = -1;
	}
	isTouchInit = false;
}
bool  MyWindowsMessageHandler::ProcessMessage(HWND hwnd, uint32 msg, WPARAM wParam, LPARAM lParam, int32& OutResult) {
	if (msg == WM_TOUCH) {
		unsigned int numInputs = LOWORD(wParam); // Number of actual per-contact messages
		TOUCHINPUT* ti = new TOUCHINPUT[numInputs]; // Allocate the storage for the parameters of the per-contact messages
		if (ti == NULL) {
			return false;
		}

		if (GetTouchInputInfo((HTOUCHINPUT)lParam, numInputs, ti, sizeof(TOUCHINPUT)))
		{
			// For each contact, dispatch the message to the appropriate message
			// handler.
			for (unsigned int i = 0; i<numInputs; ++i)
			{
				int32 index = GetContactIndex(ti*.dwID);
				if (ti*.dwID != 0 && index < MAXPOINTS) {
					if ((ti*.dwFlags & TOUCHEVENTF_UP))
					{
						ReleaseContactIndex(ti*.dwID);
						TouchController->OnTouchUpHandler(TOUCH_COORD_TO_PIXEL(ti*.x), TOUCH_COORD_TO_PIXEL(ti*.y), index);
					}
					else if ((ti*.dwFlags & TOUCHEVENTF_MOVE))
					{
						//case photo detecter is TOUCHEVENTF_MOVE  and TOUCHEVENTF_UP combine so Release is this position,so case no photo detector is this position's ReleaseContactIndex comment out
						ReleaseContactIndex(ti*.dwID);
						TouchController->OnTouchMoveHandler(TOUCH_COORD_TO_PIXEL(ti*.x), TOUCH_COORD_TO_PIXEL(ti*.y), index);
					}
					else if ((ti*.dwFlags & TOUCHEVENTF_DOWN))
					{
						//case photo detecter is TOUCHEVENTF_MOVE  and TOUCHEVENTF_UP combine so Release is this position,so case no photo detector is this position's ReleaseContactIndex comment out  
						ReleaseContactIndex(ti*.dwID);
						TouchController->OnTouchDownHandler(TOUCH_COORD_TO_PIXEL(ti*.x), TOUCH_COORD_TO_PIXEL(ti*.y), index);
					}

				}
			}
		}
		CloseTouchInputHandle((HTOUCHINPUT)lParam);
		delete] ti;
		return false;
	}
	else if (!isTouchInit) {
		RegisterTouchWindow(hwnd, 0);
		isTouchInit = true;
	}
	LRESULT rez = DefWindowProc(hwnd, msg, wParam, lParam);
	return (rez != 0 ? true : false);
}



Here is the MyWindowsMessageHandler.h


// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GenericApplicationMessageHandler.h"
#include "WindowsApplication.h"
#include "WindowsWindow.h"
#include "AllowWindowsPlatformTypes.h"
#include "Ole2.h"
#include "OleIdl.h"
#include "ShObjIdl.h"
#include <Winuser.h>
#include "HideWindowsPlatformTypes.h"
#include "WindowsApplication.h"
#include "MyPlayerController.h"


class  SOLARSYSTEM_API MyWindowsMessageHandler :
	public IWindowsMessageHandler
{

public:
	void InitVariable();
	virtual bool ProcessMessage(HWND hwnd, uint32 msg, WPARAM wParam, LPARAM lParam, int32& OutResult) override;
	AMyPlayerController *TouchController;
	bool isTouchInit;
};


I am attempting to get windows 10 multi-touch.

It would be helpfull if you posted the error(s).

I don’t know how to set this up for UHT/UBT, But for standard VC++ projects there is a includes directory listing.
You probably want something like that.

HTH

It appears the compiler does not know where to look for the header file you are including. Generally undeclared idintifier errors that include data types of the header file indicate the file was not found. This can be a tricky thing to get used to doing. If you include what you are using to compile your code, I may be able to tell you exactly how to set your include directory, or add additional dependencies.

Hey thanks for the reply guys, I am using Visual Studio 2015, here is my source: https://dl.dropboxusercontent.com/u/46314146/MultiTouch.zip

Thanks for responding.

Could you add this to your header:



// Exclude rarely-used stuff from Windows headers
#define WIN32_LEAN_AND_MEAN

// Windows Header Files:
#include <windows.h>


This should solve all the undefined type errors, If not: Check to see that it is indeed being included in the compilation.

HTH

I need to detect windows events too.
I wonder where should i call ProcessMessage