MDI Document taskbar thumbnails with no decorations - windows

Is it possible to remove the close window decoration from an mdi document taskbar flyout window? That is, remove the red "x" to prevent the user from closing the document via the taskbar.

Try this in your window:
CMenu* pSysMenu = this->GetSystemMenu(FALSE);
pSysMenu->RemoveMenu(SC_CLOSE,MF_BYCOMMMAND);

Related

How do I prevent the menu bar from moving down when my popover is open?

I have an app with a popover that appears on a status bar item. The thing is, when you click on the icon while you're in a full screen app, then move the mouse away from the menu bar to click on something in the popup, the menu bar moves up, and so does the popup. It's annoying.
Anyone know of any way to solve this? I've tried attaching an invisible menu to the popup, but I can't get the menu to be invisible.
Screenshot for clarity, the annoying part is where I wave my mouse around:
The popover window is moving because its parent window is the status item window, and when the parent window moves, the child moves with it. (Before I investigated this, I didn't even know Cocoa had parent and child windows.) I solved the problem with this code immediately after showing the popover:
NSWindow *popoverWindow = self.popup.contentViewController.view.window;
[popoverWindow.parentWindow removeChildWindow:popoverWindow];
Now, the menu bar still moves up, but at least the popup stays in the same place.
Either use Carbon events or watch for things happening to the menu bar (window of type NSStatusBarWindow):
Notifications of type
NSWindowDidChangeOcclusionStateNotification
NSWindowDidMoveNotification
NSWindowWillCloseNotification
NSWindowDidCloseNotification
with an object of class NSStatusBarWindow should give you enough information about the menu bar showing or hiding to add proper handling.
Super-hacky approach:
Custom window with some super-high window level to make it appear over the menu bar, then add a transparent custom view to the new window that catches and handles/blocks mouse clicks according to your needs.
Or:
Get the window instance the popover is using to display and track/handle NSWindowWillMoveNotification / NSWindowDidMoveNotification.
I converted #tbodt's answer to Swift 4 and confirmed that is resolves this issue:
let popoverWindow = popup.contentViewController.view.window as? NSWindow
popoverWindow?.parent?.removeChildWindow(popoverWindow!)

"...or in a Close button in a child window."

MSDN - "WM_NCHITTEST" - "HTSYSMENU: In a window menu or in a Close button in a child window."
Can somebody give the example of a child window with Close button in HTSYSMENU area?
An MDI child window is the only thing I can think of.

Why do my buttons stay highlighted simultaneously?

You usually only have one button that looks like a "default button".
However, I made a child window and placed two buttons in it (with the child window as their parent). Then I put the child window inside a dialog and displayed it.
Suddenly, the buttons stay highlighted even when I click other buttons!
Why?
Your child window needs the WS_EX_CONTROLPARENT style, to allow the dialog to handle the notifications from its children.

NSPanel parent window floats on top of full-screened NSView

I have an NS panel that is the child of an NS Window; the panel is set to floating window level. The parent window has an NSView that is in full screen mode, so the NSPanel, is floating on top of the full screened NSView. Anytime I click the panel, it brings the parent window into floating mode as well, such that it renders on top of the movie. Is there any way for me to prevent this?
Whenever you enter fullscreen mode, why don't you just remove the panel as a child window? It should still be displayed and function, but then it won't bring the other window forward. Then when you exit fullscreen mode, add it back as a child window.

OSX Cocoa: How to check which window is in focus?

Hey all, I'm pretty new to Cocoa and XCode, so I'm sorry if this is a dumb question.
How would I go about checking which window is in focus?
Additionally how would I go about checking if a certain window is in focus, if this is not the same as the previous solution.
Thanks for the help.
There are actually two forms of “focus”:
The window that has the active appearance (colored/dark gray stoplight, black text in title bar, undimmed proxy icon, etc.) is the main window.
The window that receives key events is the key window.
Consider a document window with an Inspector panel. If the user is editing some text in a field in the Inspector, then the document window may be main, but the Inspector panel is key.
To get the key window or the main window, ask the shared NSApplication instance. And, as TechZen noted, you can ask a window both whether it is key and whether it is main.
You looking for 'keyWindow'. It's a property of both NSWindow and NSApplication. It's a bool in the former and a NSWindow instances in the latter.

Resources