How to interact with CALLBACK WndProc in Unreal?

Hello,

I am currently working on a windows based project which is using windows messages such as WM_GESTURE, WM_TOUCH. Somehow I have to place my own code in

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

Callback function in order to analyze current user interrupts. But I couldn’t find any document about it.

For example:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

    switch (message)
    {
      // pass touch messages to the touch handler 
      case WM_TOUCH:
        OnTouch(hWnd, wParam, lParam);
        break;

Thank you for your help in advance.

This topic helped me to get through with the issue.

Hi,

I am not sure if this is already resolved completely but in order to enable the wm_touch and wm_gesture functionality there must be done some additional tasks:

  1. WINVER must be set to minimum win7. that means in UEBuildWindows.cs the line must be

    InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add(“WINVER=0x0601”);

Otherwise during the include of the winuser.h header the wm_touch and wm_gesture defines are not set.

  1. the BOOL WINAPI RegisterTouchWindow(__in HWND hWnd, __in ULONG ulFlags) function must be called

I edited WindowsWindows.cpp in method FWindowsWindows::Initialize in line 155 under

ReshapeWindow(X, Y, ClientWidth, ClientHeight);
  1. To use this thread How can i add window message? - Platform & Builds - Epic Developer Community Forums
    You have to define the WM_TOUCH flags etc yourself because somehow the include of WinUser.h doesn’t work…
    I simply used something like

    #ifndef WM_TOUCH

    #define WM_TOUCH 0x0240

    #endif