<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Writing custom popup controls</title><link>http://blogs.msdn.com/jfoscoding/archive/2005/09/18/471048.aspx</link><description>Orangy asks: Hello, thanks for nice articles. Could you please write one about creating combobox-style controls using WinForms? I mean control with a popup element, which is hidden when user clicks (or tabs, alt-tabs, win-button, hit global shortcut which</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Writing custom popup controls</title><link>http://blogs.msdn.com/jfoscoding/archive/2005/09/18/471048.aspx#471083</link><pubDate>Mon, 19 Sep 2005 08:48:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:471083</guid><dc:creator>orangy</dc:creator><description>Thanks for the fast response! Unfortunately, I can't switch to 2.0 yet, so I'm stuck with p/invoke. FakeMenu example works, but it involves modal loop, which is (&lt;a rel="nofollow" target="_new" href="http://weblogs.asp.net/oldnewthing/archive/2005/02/18/376080.aspx"&gt;http://weblogs.asp.net/oldnewthing/archive/2005/02/18/376080.aspx&lt;/a&gt;) not good without disabling parent window. &lt;br&gt;Things are getting much worse, when you have child controls, which are inside popup window. &lt;br&gt;When I asked about combo-like controls, I thought you can explain &amp;quot;what happens there and how does combobox work&amp;quot;. &lt;br&gt;May it is more suitable for Raymond's blog :)</description></item><item><title>re: Writing custom popup controls</title><link>http://blogs.msdn.com/jfoscoding/archive/2005/09/18/471048.aspx#471273</link><pubDate>Mon, 19 Sep 2005 18:06:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:471273</guid><dc:creator>jfoscoding</dc:creator><description>Ok, well here's all the grit I was hoping you wouldnt have to delve into:&lt;br&gt;&lt;br&gt;Yes the modal loop kindof stinks.  The only alternative I have is a message hook.  &lt;br&gt;The main reason he's pushing a modal loop there is to change who the keyboard message goes to.  You can achieve this through a WH_GETMESSAGE window hook instead.  If you want to eat a message altogether, you can just swap it out to be WM_NULL.&lt;br&gt;&lt;br&gt;Because your window wont take window activation, you'll want to look for places where someone has clicked outside your window in addition to changes in activation.  The best place is WM_NCLBUTTONDOWN and WM_LBUTTONDOWN.  You can use the IsChild or GetAncestor with GA_ROOT to determine if the m.Hwnd is not a child of your window.   &lt;br&gt;&lt;br&gt;If you happen to see a keyboard message - change the m.Hwnd to be your control.  This is how the combobox gets &amp;quot;focus&amp;quot; to it's listbox - it fakes it by re-routing keystrokes to it.&lt;br&gt;&lt;br&gt;Finally, you may want to consider playing around with the WM_MOUSEACTIVATE message.  You do not want your child window to take focus AT ALL or else the main window will turn light blue.  You can say MA_NOACTIVATE, which will prevent the mouse click from setting focus to your window.&lt;br&gt;&lt;br&gt;Writing a windows hook in managed code&lt;br&gt;&lt;a rel="nofollow" target="_new" href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;318804"&gt;http://support.microsoft.com/default.aspx?scid=kb;EN-US;318804&lt;/a&gt;&lt;br&gt;&lt;br&gt;About window hooks&lt;br&gt;&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/abouthooks.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/abouthooks.asp&lt;/a&gt;&lt;br&gt;&lt;br&gt;More than you want to know about mouse input&lt;br&gt;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/jfoscoding/archive/2005/07/28/444647.aspx"&gt;http://blogs.msdn.com/jfoscoding/archive/2005/07/28/444647.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;More than you want to know about keyboard input&lt;br&gt;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/jfoscoding/archive/2005/01/24/359334.aspx"&gt;http://blogs.msdn.com/jfoscoding/archive/2005/01/24/359334.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;</description></item><item><title>re: Writing custom popup controls</title><link>http://blogs.msdn.com/jfoscoding/archive/2005/09/18/471048.aspx#471637</link><pubDate>Tue, 20 Sep 2005 08:12:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:471637</guid><dc:creator>orangy</dc:creator><description>Thanks a lot. I've got some new information :) Actually, I did hooks in managed code, I decompiled all WinForms with Reflector and traced it all down, so I new most of the stuff when I was reading your articles about kbrd and mouse input. I even wrote my own AlternativeForms from scratch (including VS designer and visual styles support), though not finished it. But I still had the feeling that I missed something. It seems to be &amp;quot;fake focus&amp;quot; by rerouting kbrd messages. I will check with this and get back to you with information and/or code. Could be nice sample for others.</description></item><item><title>Building custom popup controls</title><link>http://blogs.msdn.com/jfoscoding/archive/2005/09/18/471048.aspx#870198</link><pubDate>Wed, 25 Oct 2006 00:05:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:870198</guid><dc:creator>Naren's Blog</dc:creator><description>&lt;p&gt;I heard more than few times question on how to build combobox like dropdown custom control where clicking&lt;/p&gt;
</description></item></channel></rss>