- Home /
Need help for my plugin to unity And multi-touch on PC!!
Do you know if I can access to windows HWND of Unity? Like when I call :
BOOL TOUCH_API InitInstance(HINSTANCE hInstance, int nCmdShow) {
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd) {
return FALSE;
}
and change RegisterTouchWindow to :
// register the window for touch instead of gestures
RegisterTouchWindow(hWnd, 0);
// the following code initializes the points
for (int i=0; i< MAXPOINTS; i++){
points[i][0] = -1;
points[i][1] = -1;
idLookup[i] = -1;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE; }
because the Dll works perfectly if I disable this part of script :
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
Answer by Bunny83 · Mar 25, 2011 at 07:20 PM
That sounds like a pure Windows API problem.... If you use a native code plugin in Unity it have no relation to Unity except that it's loaded into the same process. To find the window handle (only for standalone builds of course, won't work in the editor or web), you have to use the common windows API. Use one of these functions: Enumwindows, GetWindow, Findwindow or maybe EnumThreadWindows with either the window classname of unity (i'm too lazy to look it up for you) or the currentThreadID/currentProcessID. Inside the enum callback you can use GetWindowThreadProcessId or sotr out the riht window.
Answer by Jocelyn Gervais · Mar 28, 2011 at 03:48 AM
Thank you, it's very helpful!! I finally use the : HWND WINAPI GetForegroundWindow(void);
Have a good day!! :D
Your answer
Follow this Question
Related Questions
I try to Create a DLL for get WM_TOUCH windows message! 1 Answer
Input Injection 0 Answers
Multitouch on Windows 7? 7 Answers
multitouch on desktop possible 1 Answer
Windows Multitouch Fail 1 Answer