• Advertisement

Archived

This topic is now archived and is closed to further replies.

PTC Question

This topic is 5866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, For anyone who has used PTC, is there anyway to get the window handle? I need it for DirectInput and since PTC takes care of the windows, I can''t find any way to get it. Thanks, tj963

Share this post


Link to post
Share on other sites
Advertisement
I''ve never used PTC but if you know the HINSTANCE for you application (e.g. given to you in your WinMain function) then you could use EnumWindows() and check each window''s HINSTANCE (get it by calling GetWindowLong(hWnd, GWL_HINSTANCE) from within you EnumWindowsProc function) and comparing the 2 - if they match then this window was created by your application.

Try something like this :

HWND g_hMyWindow = 0;

BOOL EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
HINSTANCE hWndInstance = GetWindowLong(hWnd, GWL_HINSTANCE);
if (hWndInstance == (HINSTANCE)lParam)
{
g_hMyWindow = hWnd;
return FALSE;
}
return TRUE;
}

void FindMyWindow(HINSTANCE hInstance)
{
EnumWindows(EnumWindowsProc, (LPARAM)hInstance);
}


HTH

Iain.

Share this post


Link to post
Share on other sites

  • Advertisement