{"id":135,"date":"2015-08-07T13:09:23","date_gmt":"2015-08-07T04:09:23","guid":{"rendered":"http:\/\/rageworx.iptime.org\/?p=135"},"modified":"2015-08-07T13:09:23","modified_gmt":"2015-08-07T04:09:23","slug":"in-case-of-failure-to-using-fl_xid","status":"publish","type":"post","link":"https:\/\/rageworx.info\/?p=135","title":{"rendered":"In case of failure to using fl_xid();"},"content":{"rendered":"<p>I did try apply DirectX input to using joystick for my HID emulation, but my testing program failure in SetCooperativeLevel() API on dinput. At the result of analyse, I found FLTK API fl_xid() returns wrong HWND value from debuger.<\/p>\n<p><a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-137\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection01-500x194.jpg\" alt=\"inspection01\" width=\"500\" height=\"194\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection01-500x194.jpg 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection01.jpg 558w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a> Just inspected real HWND(handle of window) value with\u00a0<a href=\"http:\/\/processhacker.sourceforge.net\/\" target=\"_blank\">Process Hacker<\/a>. It was something wrong in internal value of calling fl_xid(); like below image.<\/p>\n<p><a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-138\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection02-500x226.jpg\" alt=\"inspection02\" width=\"500\" height=\"226\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection02-500x226.jpg 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection02.jpg 556w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>To verify in presumption of fact, I did compare with my FLTK DX8 joystick example, and it has exactly right HWND value in calling fl_xid();. Difference is only multi window in one program. Is it a cause of wrong HWND?<\/p>\n<p><a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection03.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-136\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection03-500x330.jpg\" alt=\"inspection03\" width=\"500\" height=\"330\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection03-500x330.jpg 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2015\/08\/inspection03.jpg 507w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>Whatever is reason, I need change my code to getting HWND in source code.<\/p>\n<pre class=\"\">\u00a0\u00a0\u00a0 \/\/HWND hCurWin = fl_xid( winMain );\r\n\u00a0\u00a0\u00a0 HWND hCurWin = GetWinHandle( GetCurrentProcessId() );<\/pre>\n<p>It was just simple, and GetWinHandle() is following.<\/p>\n<pre class=\"\">HWND GetWinHandle(ULONG pid)\r\n{\r\n\u00a0\u00a0\u00a0 HWND hTmp = FindWindow( NULL, NULL );\r\n\r\n\u00a0\u00a0\u00a0 while( hTmp != NULL )\r\n\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if( GetParent(hTmp) == NULL )\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if( pid == ProcIDFromWnd( hTmp ) )\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return hTmp;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hTmp = GetWindow( hTmp, GW_HWNDNEXT );\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 return NULL;\r\n}<\/pre>\n<p>I don&#8217;t have time to know what&#8217;s wrong in fl_xid(), but it will be good solution to using DirectX devices in FLTK windows program.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I did try apply DirectX input to using joystick for my HID emulation, but my testing program failure in SetCooperativeLevel() API on dinput. At the result of analyse, I found FLTK API fl_xid() returns wrong HWND value from debuger. Just inspected real HWND(handle of window) value with\u00a0Process Hacker. It was&#8230; <a href=\"https:\/\/rageworx.info\/?p=135\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,3],"tags":[99,70,110,71,112,111,113,109,32],"class_list":["post-135","post","type-post","status-publish","format-standard","hentry","category-development","category-raphs","tag-directx","tag-error","tag-failure","tag-fltk","tag-handle","tag-hwnd","tag-setcooperativelevel","tag-win32","tag-windows"],"_links":{"self":[{"href":"https:\/\/rageworx.info\/index.php?rest_route=\/wp\/v2\/posts\/135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rageworx.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rageworx.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rageworx.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rageworx.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=135"}],"version-history":[{"count":0,"href":"https:\/\/rageworx.info\/index.php?rest_route=\/wp\/v2\/posts\/135\/revisions"}],"wp:attachment":[{"href":"https:\/\/rageworx.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rageworx.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rageworx.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}