/2014/03/19/Win32-API--Set-window-to-foreground/

{"item":{"status":"visible","url":"\/2014\/03\/19\/Win32-API--Set-window-to-foreground\/","trash":"","name":"Win32-API--Set-window-to-foreground","parent":"","title":"Win32 API: Set window to foreground","date":"2014-03-19 07:38:39","filepath":"posts\/20140319_Win32-API--Set-window-to-foreground.xml.json","type":"post","content":"<p><img style=\"margin-left: 10px; margin-right: 10px; float: left;\" src=\"http:\/\/www.8bitrobot.com\/media\/uploads\/2012\/01\/gear.png\" alt=\"\" width=\"60\" height=\"64\" \/>It can be tricky setting your window as the top z-order window. &nbsp;It's not just a simple call to SetForegroundWindow.<\/p>\n<div style=\"clear: both;\">&nbsp;<\/div>\n<p>Here's how to do it:<\/p>\n<pre style=\"padding-left: 30px;\">AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(), NULL),\n GetCurrentThreadId(), TRUE);\n\nBringWindowToTop(hwnd);\nSetForegroundWindow(hwnd);\nSetFocus(hwnd);\n\nAttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(),NULL),\n GetCurrentThreadId(),FALSE);<\/pre>\n<p>This solution is from Nish Sivakumar's <a href=\"http:\/\/www.codeproject.com\/Articles\/1724\/Some-handy-dialog-box-tricks-tips-and-workarounds\">code project article<\/a> and KevinSW's <a href=\"http:\/\/www.codeproject.com\/Articles\/1724\/Some-handy-dialog-box-tricks-tips-and-workarounds?msg=2737186#xx2737186xx\">comment<\/a>.<\/p>"}}
comments powered by Disqus
 

Lorem Ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

 
This page is best viewed with Firefox 3.5+, Chrome 5+, Safari 5+, Opera 10.6+, IE 9+
Copyright © 2014 8bitrobot.com