What are these windows? .. "M" and "Default IME" (from GetWindowText) - c++

Using EnumWindows and GetWindowText, I see many titles with "M' and "Default IME".
What is their primary function?.. It seems to be something quite fundamental.

I'm not sure about the "M" one, but the "Default IME" window is created by the default Input Method Editor (IME).
An IME allows the user to enter characters in a script that may involve a number of separate keystrokes, e.g. Chinese or Korean.
Different IMEs can be installed via the Region and Language dialogs in Control Panel.
Its not unusual for a number of hidden windows to exist on Windows, especially when there are COM components running (for example, a single threaded [STA] apartment uses a window message pump to serialize actions).

Related

GetKeyboardLayout() doesn't change when switching between ENG US and ENG INT

This is for an app running on Windows 10. I have two keyboard layouts loaded, ENG US and ENG INT
I am using GetKeyboardLayout(0) however I get the same result regardless of which layout I'm using.
How can I detect which of the two keyboard layouts are in use?
This maybe my mistake, if I make the call like
GetKeyboardLayout(GetWindowThreadProcessId(::GetForegroundWindow(), 0))
Then I get the correct result each time. Now I'm confused because I was under the impression that the keyboard layout was global on Windows 10.
Languages, Locales, and Keyboard Layouts:
Applications typically use locales to set the language in which input
and output is processed. Setting the locale for the keyboard, for
example, affects the character values generated by the keyboard.
Setting the locale for the display or printer affects the glyphs
displayed or printed. Applications set the locale for a keyboard by
loading and using keyboard layouts. They set the locale for a display
or printer by selecting a font that supports the specified locale.
Applications are generally not expected to manipulate input languages
directly. Instead, the user sets up language and layout combinations,
then switches among them.
Calls the ActivateKeyboardLayout function to activate the user's default layout for that language.
Calls the GetKeyboardLayout function to get layout.
Both are thread-based or process-based.
I guess what you might want to get is the input locale identifier for the system default input language, which is global.
SystemParametersInfo(SPI_GETDEFAULTINPUTLANG, 0, &hkl, 0);

Expanding A Console In Windows 10 OS

Background Information: I'm developing an Windows 10 app. Within my app, I'm working with nested consoles. I'm familiar with GetSystemMetrics() and using some of it's parameters to define my console physical appearance (i.e. SM_CXBORDER, SM_CXDLGFRAME, etc).
Snip: Nested Child Console
Problem: What parameter should I look into if I want my nested child consoles (i.e. child's child console) to be resizable? My current logic output a user cmd onto this console. Overtime, the outputs accumulate. For example, if a user inputs the cmd Time 10 times then he/she will need to start scrolling through the outputs to see any previous output. In the desired scenario, the user can input the cmd Time 10 times without having to scroll which can be done by extending the console vertically. As a user, I rather extend the console than scroll through the outputs. This is purely for better visibility and less congestion.
Attempt: I tried altering DLGFRAME, DLGWINFRAME, RESIZEFRAME, and SCROLL. However, I didn't have much success.
There is no layout engine in the classic Windows API that will make your window extend size automatically
"Fit window size to text" is a feature that is implemented only in more sophisticated GUI toolkits.
If you insist on using the classic Windows API for your GUI (kind of like using stone age tools) - the only option is to calculate how big your rendered text is going to be (either assume it is always one line or use DrawText with the DT_CALCRECT flag) and extend your main window and text control by that amount.
On the whole you would be far more wise to switch to a real GUI toolkit, than wrestle with WINAPI and reinvent extremely complex wheels
BTW don't call it a console - because console is a term used to refer to Windows console terminals that use a different API - your question is confusing with existing terminology

Trying to write a c++ console program to change a setting controlled by a windows checkbox

Is it possible to create a keyboard shortcut to switch between the monitor and portion selection of this wacom preferences window, via a c++ console program?
Sorry if this is poorly worded, I've had trouble trying to find the right words to search for ways to do it.
I think it should be possible, although a bit tedious. You should be able to use the Windows API, and try to EnumWindows/EnumDesktopWindows to identify the respective application Window, and its respective controls (which are also Windows).
You should identify the window title, and class ids, for the app window, and the checkbox button controls, then when you enumerate through all the desktop windows, you can identify the ones you are interested in.
Then you can use the SendMessage() API to send messages to the controls (Windows) of interest to manipulate them.
It's a bit tedious, but sounds possible.
An example of use here to get an idea:
http://www.cplusplus.com/forum/windows/25280/

Is it possible to embed a command prompt in a win32 app?

In linux and when installing packages etc. There are some installers that have a progress bar and a dos window which shows the files being extracted etc. How can i add this window to my C++ Win32 programs so that i can have it showing the tasks im doing? I cannot find any documentation on MSDN.
Question: How can i add a console window (if that's what its called, sure looks like one) in my program to show the details of the task at hand being done?
Here is a window with what i am asking.. (personal info so I erased the details. :]
You cannot embed a real console window inside another window (although a windowed process can have a separate console window). While it looks like a console window / command prompt, it is just a matter of appearances. What you want to do is create a sub-window/control with similar characteristics as a console window and then redirect the console output from the application(s) being run to append to that sub-window. For more information on how to do redirect the console output in Windows, see http://support.microsoft.com/kb/190351.
That "dos window" is a regular edit control: CreateWindow(ES_MULTILINE, EDIT, ...
However, it has the font set to a fixed-width one (Looks like courier). This is done by sending WM_SETFONT to the edit control.
#user995048 says "You cannot embed a real console window inside another window". But "cannot" is a strong word! I can run an entire virtualized computer in a window if I wish. :) So one can quite reasonably intuit that there are ways of doing what you say.
Sure, it is true that what you've seen are almost certainly cases of output redirection into a custom widget, designed to mimic the simple appearance of a terminal. However...if you want to embed one application's window inside another, there are things you can look into which might fit. Cooperative methods exist like GtkPlug, for instance:
http://developer.gnome.org/gtk/2.24/GtkPlug.html
To actually capture a not-designed-to-cooperate app's window and throw it in your app would be trickier. But possible, just as screen captures and virtual machines are possible. Probably best to avoid that sort of thing unless there's really a cause for it, though...
Try this
http://www.codeguru.com/cpp/misc/misc/article.php/c277/
link. I think the solution provided is what you need.
I tried it many years ago and it worked. I have not tried it in newer versions of windows though.

Getting input if the window is not active (Windows)

Short version:
How can I receive input messages in Windows with C++/C when the window is not active?
Background information:
I'm currently working on an Input System that should not depend on any window, so it can e.g. be used in the console as well.
My idea is to create an invisible window only receiving messages, which is possible using HWND_MESSAGE as hWndParent. It only receives input messages when it's active though, and I don't want this. It should always receive input (unless the application requests it no longer does so, e.g. because it lost focus).
I know this is possible somehow, many applications support global shortcuts (e.g. media players (playback control) or instant messengers (opening the contact list)), I just don't know how. Do you know?
Options:
RegisterHotKey if you need to register just one or a few hotkeys
SetWindowsHookEx with WH_KEYBOARD / WH_KEYBOARD_LL. Use when you need to filter many or all keyboard events. However, the hook code needs to be implemented in a DLL (which is loaded into other processes). You need separate 32 bit and 64 bit versions of the DLL
You need to setup windows keyboard input hook. Here is an example how to do it; it is even easier to do in C++