How to set title/caption of Scintilla window - winapi

I have created a Scintilla window using CreateWindow() and want to set the title dynamically as different files are loaded into it. However, SetWindowText() is setting the content of the edit box rather than the caption. I also tried WM_SETTEXT to the same effect.
How do I set the title of the window instead?

Is the Scintilla window a top-level window with a caption? That is usually not the correct way to do things, you should create a custom container window with a caption and the Scintilla window should be a child window. This child window can take up the entire client area if required.
Using a control directly as a top-level window is not just problematic because of the caption text issue, there are also often notification messages from a control that you need to handle and these are sent to the controls parent window.

Related

Enable the disabled underlying window

Sometimes in the Windows OS, a program is able to open a new window which disables it's underlying window. Closing the newly opened window of course re-enables the first window. I want to enable the underlying window without closing the newly opened window with Autohotkey.
I made a gif which shows the situation perfectly:
https://imgur.com/a/EWt8OrF
I thought I might be able to pull this off with window styles and window extended styles, so here's what I tried:
^!e::
MouseGetPos,,, WindowUnderMouse
WinSet, Style, -0x8000000, ahk_id WindowUnderMouse
return
But it didn't work. I also did a lot of googling on this, but I didn't know what would be the proper keywords so I didn't find anything. Any idea how to accomplish this?
Some keywords for google:
How to make a modal window modeless
How to enable a disabled window
How to make a palette window
How to make a modal window a palette window
How to enable parent window
Child window disabling parent window
https://autohotkey.com/board/topic/49376-making-a-gui-dialog-modal/
https://autohotkey.com/docs/commands/Gui.htm

What type of Resource is a Popup Menu in Windows?

I've been researching popup menus (see https://msdn.microsoft.com/en-us/library/windows/desktop/ms647626(v=vs.85).aspx) and a bit confused at what they are behind the scenes.
They act partially like windows, but look like controls. For instance, they pop up above other elements, steal focus, and can go outside their parent container which makes me think they are a type of window. But they pass back an HMENU handle instead of a window handle, and they have no title bar, nor handles, nor show up in the task bar.
If they are a type of control, how can they go outside their parent window?
If they are a type of window, can I use window-specific functions on them? or if they are a control in a new window, is there a way to get a win handle to that new window?
Can I get the location of the popup menu for another application?
Found the answer:
trying to get a handle to a context menu in c++
Looks like a menu is a type of window, that is a child of the desktop window. You can get its window handle with EnumChildWindows on the desktop WinHandle and look for the class name of #32768.
There's more about these reserved system windows here:
About Window Classes | System Classes
A popup menu is a menu, not a window.
A menu merely uses a window for display. A new window is created each time the menu is displayed, and is destroyed afterward. By contrast, the same HMENU can be used to display the menu many times.

WinAPI changing parent of a ListView control

I'm developing an application with tab controls. After clicking on an icon in a tab, a popup window opens and the contents of the tab are moved to the popup window.
What I do is simple - change parent of each control within the tab to the popup window (using SetParent()). Everything works great except for listview controls (virtual listview).
After changing the parent, the listview no longer sends WM_NOTIFY notifications.
I've also tested it with non-virtual listview and the same happens.
I've searched all over google and came up with nothing, so any ideas would be appreciated.
UPDATE
After changing the parent, the listview keeps sending WM_NOTIFY notifications to its previous parent. Is this a bug in common controls?
A lot of the common controls cache their parents when they are created. There's nothing you can really do about this except to create them with the right parent in the first place.
One workaround is to register a dummy window class that does nothing more than host the common control in question, and forward messages back and forwards to it. Then you can reparent that window rather than the control itself.

Win32 GUI: resize a dialog

I have a basic Win32 dialog-based application. How do I make it resize?
If it was a window this would be possible by default (and it would fire WM_SIZE). I'm new to dialogs and I'm not able to figure out how to: 1. when mouse cursor hovers over the edge, it should change to IDC_SIZEWE or IDC_SIZENS, 2. just resize the dialog, I know how to position dialog's content.
You don't need to do the work yourself about moving the cursor to the edge, there is just a style you need to set in the .rc file or the dialog editor.
From the dialog editor: Set the border to Resizing to allow resizing of the dialog box.
From editing the .rc file directly: Append | WS_THICKFRAME to the line with STYLE
What window styles have you set on your dialog?
If you're using a framework such as MFC, you can repair a dialog that is no longer resizable by making sure the WS_THICKFRAME / WS_SIZEBOX or other suitable window style is set. In some development environments, this may also be set in the properties for the dialog if you are using something with runtime support.
If you created the window manually, specify one or the other in your call to CreateWindow / CreateWindowEx along with your other window styles. Some window styles, such as WS_OVERLAPPED also imply a resizable frame.
Window Styles # MSDN
CreateWindowEx # MSDN
Note - I tried doing this by calling ModifyStyle() on the window in the onInit(). However it does not work. You get the resize cursor, but no sizing happens.
This apparently has to be set in the RC file or maybe eralier in the window creation.

How do I host an application window as a child of a window belonging to another process?

I would like to host an application window from a process "A" into the main window of a process "B", just as if "A"'s window were a MDI child window. Is this possible in Windows? Or are there some tricks which would allow me to fake this?
By the way, I'd like to remove the title bar (or better yet, all the non-client stuff) of "A"'s window when it is embedded into "B"'s window. I suppose that this must be possible by tweaking the window styles or window classes, but I am by no means an expert in these Win32 intricacies.
It's possible to host the Window. Change A's parent HWND by calling the SetParent function against it. To change the window styles, you need to use the GetWindowLong/SetWindowLong pair to change the attributes that you want to muck with.
If this is a third-party application (ie, not yours), then you're probably in for a rough ride, particularly if the window does any theming or anything custom with its window (for example, changes to the drag area, etc).

Resources