logan1337 Posted August 17, 2007 Share Posted August 17, 2007 Hi, I'm a .NET developer and I was hoping you might be able to tell me how you managed to get the floating tool windows in Paint.NET to avoid stealing the focus of the main window when they are active. I would like to apply this same functionality to my program but it always seems that clicking a floating (TopMost) window always unfocuses my other, main window. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted August 17, 2007 Share Posted August 17, 2007 Check out the source code ... Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
logan1337 Posted August 17, 2007 Author Share Posted August 17, 2007 Ah, I didn't realize it was available. :oops: Quote Link to comment Share on other sites More sharing options...
logan1337 Posted August 19, 2007 Author Share Posted August 19, 2007 I took a look, but the answer wasn't readily apparent... does anyone happen to know off-hand? The best I could come up with was calling mainwindow.Focus() on Click or ResizeEnd event, but that does nothing really to allow both windows to be focused, which is what I really want. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted August 22, 2007 Share Posted August 22, 2007 Look at the properties that PdnBaseForm introduces. It isn't a focus issue. It's a rendering trick. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
jsonchiu Posted August 22, 2007 Share Posted August 22, 2007 Couldn't you just set myForm.Opacity? Quote Some links: | Personal Website | Alien Attack | Try out my plugins: | Antialias | Diagonal Lines | Link to comment Share on other sites More sharing options...
logan1337 Posted August 22, 2007 Author Share Posted August 22, 2007 I don't believe that has anything to do with focus. A form can still be 50% opaque and focused, or 50% and not focused. The behavior that I want is just that of the floating tool windows in Paint.NET, such as the color palette for example, and that is: a) both appear focused (their title bars are of "foreground" color) clicks can occur directly on either window with no visual change c) window ordering does not change (because they are floating) and also ideally d) no Activated/Deactivated events are fired unless an external window is activated. For example, tool tips only appear on focused windows. I would like tool tips to be able to appear for both the main window and the floating window in my application. I will investigate the PdnBaseForm class at some point, though I am busy with other things at the moment. Quote Link to comment Share on other sites More sharing options...
logan1337 Posted August 22, 2007 Author Share Posted August 22, 2007 You'll notice in Paint.NET, that tool tips can occur on both the tool palette and the main form, even though both are technically separate windows. This is essentially what I want to figure out. Perhaps windows are focused on MouseEnter, though with the help of a "rendering trick", there is no change in their appearance. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted August 22, 2007 Share Posted August 22, 2007 I think the property is called ForceActiveTitlebar or something. And yes, there is some smart, albeit hacky, focus stealing and relinquishing. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
logan1337 Posted August 24, 2007 Author Share Posted August 24, 2007 Aha, my idea of focusing on MouseEnter and unfocusing on MouseLeave seems to work quite well! I discovered the Win32 functions GetForegroundWindow and SetForegroundWindow which proved immensely helpful in these regards. Now to investigate ForceActiveTitlebar to avoid the visual changes... Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted August 24, 2007 Share Posted August 24, 2007 I discovered the Win32 functions GetForegroundWindow and SetForegroundWindow which proved immensely helpful in these regards. Or you could just use Form.ActiveForm and Form.Activate(). Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.