Constraining other application's window sizes through Qt Application - c++

I'm looking for a way in Qt to constrain other application window's (some will not be Qt) so that when maximized don't overlap my Qt application. Essentially I want to create the Windows Taskbar. I'd like the applications edge to dock to the appropriate edge of my Qt Taskbar in the same way that applications dock to the Windows taskbar when they are maximized. I envision this taskbar to exist along the top edge of the screen, but would like to allow users to decide which edge it will live on.
I know it isn't hard to make a window that is always on top it's more the auto docking issue I'm having a hard time figuring out.
I'm right now only looking to accomplish this on Windows.
Thank for any help.

Detailed explanation on how to do it would be too long for an answer here, but MSDN documentation on SHAppBarMessage should get you started. Taskbar created like that can even be part of winows taskbar ;)

Related

QT: Using the mouse wheel when dragging from outside of application

I have a QT application with a TreeView in which items can be dragged into and around the TreeView. The Scroll wheel is able to scroll up and down the view when collapsed sufficiently to show the scroll bar in all cases except for when dragging in an item from the desktop.
Could anyone point me in the right directon? Or inform me on what questions I should be asking?
is the problem maybe related to the application not beeing in focus anymore? Keypresses (also mousewheel scroll) is usually send to the application which is activ/in focus.
I have done an private project which would react to keypresses on OS (windows) level to be able to control it while the user would play a computer game.
I don't have enough reputation to make a comment. Hope this might help you.

How to create a borderless window with titlebar in windows c++

I am trying to create a Direct3D app that is operating in windowed mode with a title bar and minimize/quit button. However, I'd really like to be able to axe the border around the window.
I am looking to do this because it looks pretty cheesy on dual monitors when the app is filling the primary monitor horizontally (with room to move the app vertically), but its window border overflows onto the secondary screen. I've tried a bunch of combinations of setwindowlong with GWL_STYLE and GWL_EXSTYLE, but can't seem to make headway unless I disable the title bar.
I've seen a bunch of apps that are borderless however they seem to emulate the title bar rather than using the built in one provided by Microsoft.
Thanks for any suggestions.
You can't remove the border and keep the titlebar AFAIK.
You can reimplement the titlebar by using WM_NCHITTEST but you still need to draw it yourself which would not be a bad idea if you want your D3D app to look its best.
Visual Studio, last time I checked, achieves its border with transparent layered windows standing behind the primary one. They are the shadows you see.

Widgets in window title Qt

Is in Qt something like GTK.headerbar or any other possibility to add wiget (button for example) in window title?
Thanks in advance.
Short answer is 'no', Qt doesn't implement any kind of window decorations (except QWS which is a different story).
In Linux the title bars (window decorations) are carried by Window Managers, like Metacity or Compiz. Windows and OSX use their own window decorations. Qt has almost no control over what happens on the window title bars.
Gnome3/GTK3 (and not Gnome2) allows you to use widgets in the title bar but it's not the case for many other Desktop Environments / Window Managers. Your options are:
Use the API provided by the window manager / OS
Pros: native look.
Cons: you need to maintain separate implementation for each OS / DE. Not all support doing such.
Hide window decorations and implement you own
Pros: code once, use everywhere. Google Chrome and Vivaldi do that, for example.
Cons: you need to implement window resize and move
Use an overlay widget on top of the system title bar that will always follow the window
Pros: pretty much straightforward to do but I don't recommend it.
Cons: the widget will always lag when moving the main window. Native look still has to be implemented. Take into account that user can switch the theme and the widget will look odd.

Needed: A popup window without a taskbar icon

I am designing a UI engine that needs to render into popup (WS_POPUP) windows. As these windows cannot be children of other windows, each instance is given its own taskbar icon.
I need a way to prevent the taskbar icons from appearing for certain windows that are created as "dialogs". I cannot use an OS-provided dialog because they all have frames (and I can't figure out how to render into them) or a tool-created custom dialog (which seem to require the CLR).
I am not an expert with the windows API and I feel that I have missed something obvious...
Also: Anything involving CLI/CLR is not an option.
EDIT:
The WS_EX_NOACTIVATE style can be used for this purpose as well, though the activation behavior would need to be emulated by the program.
If you set the WS_EX_TOOLWINDOW extended style for your window, it won't be shown in the task bar or Alt+Tab list. This does cause the window to be rendered slightly differently, however (thinking floating tool palette).

Qt Tray Icon Drag and Drop

Does anyone know if it is possible to use drag and drop with a tray icon using Qt?
I've been doing some research and here is what I have come up with:
A QSystemTrayIcon cannot explicitly handle a drag/drop event. However there is a workaround based on the Spifftastic tray icon location method.
You create a uniquely colored icon
and place it as the icon for a brief
moment and take a screenshot of it.
Given that you know the color
sequence for the icon, you can
search through the screenshot and
locate the particular icon's
location.
A transparent widget is positioned
over the icon and is used as the
drop target.
I have yet to work at a few of the finer details of the operation but that is the gist of it. All things considered it is a hacky way of things but given that there are no other ways to do this I think it is acceptable.
Fluffy App (written in C#) uses the Spifftastic method to locate the tray icon. I'm assuming the part about the transparent window is how they accomplish that but I have yet to decompile and examine their system.
Since QSystemTrayIcon is a QObject, not a QWidget, my guess is this is not possible. The system tray icon isn't really owned by Qt - it's passed on to the 'desktop', i.e whatever part of the Gnome/KDE/Windows/Mac is drawing the relevant area. At least on Mac, you'd be dropping on the menu-bar, which would be a very strange UI. For Gnome and KDE it's a FreeDesktop.org standard, but again I don't think its your process which actually does the drawing, and hence there's no way for Qt to get events such as drag and drop to you.