Jump to content

Floating tool windows


logan1337
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

B) 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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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().

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...