Hide mainform only and keep it in taskbar - hide

I have a main form being the parent of x number of ToolWindows. I would like to hide the main form but keep it in the taskbar.
When I set the main form's Visible = false, it hides and keeps the ToolWindows visible, so far all good. But the icon in the taskbar disappears too.
I want to hide the main form, keep the ToolWindows visible AND keep the Taskbar icon so I can bring the main form back again.

By default, Application.MainFormOnTaskbr is set to true, which means the MainForm owns the Taskbar button. When a window is on the Taskbar, it is not possible to show/hide the window without affecting its Taskbar button accordingly. You have three choices:
Set Application.MainFormOnTaskbar to false, so the Application window owns the Taskbar button instead of the MainForm. Not advisible on Vista+, as ShowMainFormOnTaskbar was introduced to address UI issues in Vista onwards.
Create another window that has its own Taskbar button. You can use a similar technique that TApplication uses for its window.
Don't hide the MainForm, thus its Taskbar button will not hide. Move the MainForm offscreen, or resize it, so the user cannot see it but Windows still can.

Related

How to propagate the parent's click event in Pyside2 as if I have clicked the button directly while hovering over it?

How to propagate the parent's click event in Pyside2 as if I have clicked the button directly while hovering over it?
This is a very peculiar problem, and I haven't been able to find even a question like this.
A button is positioned on the main UI window. When clicked, it hides the parent window, and spawns another window at that position. I need it to work with a single click, for example, I want to press the button, and not release the mouse immediately, but hover over a certain part of the newly spawned window and then release it.
This works perfectly fine if I click the button directly , but the problem is I need to click the button from the main UI window.
I am doing it by sending "mousePressEvent" from the main UI window to the child widget's "mousePressEvent", like this:
def mousePressEvent(self, event): #parent mouse press event
#----
#----
self.FocusedButton.mousePressEvent(event) # child widget
When I activate the button from the mainUI window, the window is immediately hidden and the new window is spawned. However, since I haven't performed mouse release yet, I am stuck into the parent's mouse press event loop. The mouse doesn't invoke paint event and doesn't register mouseMoveEvent until I release the click because the mainUI window is hidden and mouse tracking doesn't work any more.
I have tried setting the flags of the window in every way, (QtCore.Qt.WA_TransparentForMouseEvents,True ) for example, but none of it worked.
The main UI window inherits from "QtWidgets.QWidget" and does not have the clicked method.

PyQt: How do you clear focus on startup?

When I start up my PyQt GUI, the focus immediately goes to the text box.
I want there to be no focus on any of the buttons at the start of the program, especially not the text box.
Is there a way to remove the focus entirely or at least move the focus to a button or something?
Thanks
clearFocus() seems to work after a certain amount of delay after the window is visible. I also used setFocus() on the QMainWindow and then the textedit field lost focus.
Create a button with dimensions 0 wide by 0 high.
Set it as the default button and also early in the tab order before the other controlls that except focus; but note that it will be triggered if the user presses ENTER in some edit controls.
Call self.ui.yourbutton.setFocus() if desired for example after restore from minimized

Caption bar not being repainted in MFC

Alright, I'm using VS2012 with MFC in Windows 8 and I'm having a problem.
Let's say I have a very simple dialog in my application. When I click on a different window (for example on the Taskbar), the caption bar color indicates that the dialog is still focused!
This problem happens in several cases. For example, when I use CFileDialog to select some files, after closing the dialog, caption bar color indicates that the dialog is still inactive while it's automatically focused after closing the open dialog!
Now let's say I have two dialogs in my application. Dialog A is my primary dialog and I use a button to show modal dialog B. In standard applications, if I click on dialog A, dialog B caption bar flashes. This doesn't happen in my application and I think it's because of a bug in MFC.
Any ideas how to fix this problem?

Keep taskbar icon, replace MFC dialog

I have a MFC dialog based application. User can change the language of the dialog, and I made this by closing existing dialog, and opening another with changed language. The problem is that the effect in the taskbar is that one icon is removed, and another identical is created in its place. If my application's icon is not the last icon in the task bar it will be perceived as it was moved to the end of taskbar icon set.
I want to retain icon's position in the taskbar, and rather to prevent icon flicker at all from happening. How do I do that?
The application must support OS'es from Windows XP to Windows 7.
EDIT: alternative question for which I would accept an answer is how to create an invisible window that is nevertheless shown in the taskbar, and how to forward relevant window messages from that window to my main window?
Make the dialog a child of another outer parent window. The parent can be a dialog or any other kind of window; all it will be providing is the title bar. If the user tries to resize it it will have to forward resizing commands to the dialog, but otherwise you shouldn't need to do much in the parent window.
Why not replace the dialog with a CFormView instead? That way there's a frame window that wraps around the dialog (which is embedded in a form view) and it's the frame window that owns the taskbar icon.
Create an SDI application that displays a CFormView. Display the dialog in the default language (or whatever langauge the user previously chose) on initialization. When the user chooses the 'change language' option, simply change the form view that's being displayed with a new one.
Bonus feature: with this design, the framework will take care of things like language-specific accelerators and menus for you with no effort on your part.
For more on how to do this, check out http://www.codeguru.com/cpp/w-d/doc_view/viewmanagement/article.php/c3341/Multiple-Views-Using-SDI.htm

wxPython on KDE 4.2: popping window on top of the screen and hiding back

I want my window to be invisible most of the time, but get to top of
the screen on hotkey and hide again if the user switches to another
application.
In my hotkey handler I use
self.Show()
self.Raise()
self.Iconize(False)
and in my activate message handler
self.Hide()
self.Iconize(True)
but the window pops up on top of the screen, but remains deactivated:
it's title bar colour is a inactive one, and it flashes in the taskbar
as a window requiring my attention and it doesn't get EVT_ACTIVATE. I
tried to add self.SetFocus, but no effect.
And if I use
self.Show()
self.SetFocus()
in hotkey handler and in my activate message handler
self.Hide()
and it works okay if I deactivate my window by clicking to another
window, but if I press Alt-Tab and then invoke my window with a hotkey
it doesn't appear on top of the screen but just flashes in the
taskbar. Also I made an ability to hide it by pressing a button on it,
and if I hide it this way, it also doesn't show correctly afterwards
as in the case with Alt-Tab
you have to use a window manager to activate windows. I'm using wmctrl for that purpose (cannot find the same func. through kwin's dbus for kde).

Resources