I need to create an application which do the following:
At the beginning we have notepad window open with a lot of text in it.
Our application must scroll through this file and take notepad window screenshot after each scroll action.
I've tried to achieve this using SBM_GETRANGE, SBM_GETRANGE, SBM_SETPOS but it does not work for me.
Please note that emulating keyboard events (e.g. PageDown, PageUp) is not an option for me because this application should also work with other applications which may not support keyboard shortcuts for manipulating scrolls.
Thanks.
Don't try to manipulate the scrollbar directly - instead SetFocus() to the text window, then send Page Down messages. If there are applications where you must manipulate the scrollbar, you should get its window handle and send the messages there.
Related
In any web browser and in the Windows file manager and in many other applications there is support for forward and backward navigation. This always (or at least most of the time) by default works with extra mouse buttons if your mouse has any.
I want to implement this in a C++ application I'm making based on WinAPI. However I wonder how one would do this? Are the mouse buttons captured "manually" in each application that has this forward/backward navigation or is there native support for it somewhere in WinAPI?
Manually capturing the buttons is probably always an option, but if there already is an existing functionality that handles this then it seems like that should be used instead. That's probably more reliable as well.
To sum up: I want my application to correctly handle/receive backward and forward clicks from a mouse that has such buttons.
The WM_APPCOMMAND message offers the APPCOMMAND_BROWSER_FORWARD ("Navigate forward") and APPCOMMAND_BROWSER_BACKWARD ("Navigate backward") navigation commands. You can handle them in your application, even if it's not a browser.
The documentation has information, how and when the WM_APPCOMMAND is generated:
DefWindowProc generates the WM_APPCOMMAND message when it processes the WM_XBUTTONUP or WM_NCXBUTTONUP message, or when the user types an application command key.
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 add custom controls to a console window? You can use GetConsoleWindow() to get the window's handle, and then add your own menu items or consume all its events. I can't find any examples of people adding extra controls though.
I am developing a small, high performance serial terminal app. It is a console application - RichTextBox is too slow and has issues that make it unsuitable for VT100 terminal emulation.
I want to add some little graphics to show the state of the serial control lines (RTS/CTS/DTR/RI etc.) and perhaps a capture on/off toggle button. Ideally I'd like to add them to the window title bar. Bitmaps are all that are required.
After lots of research I found that it isn't easy, or even possible really.
You can add controls to the window with CreateWindow(), but of course only in the client area which is taken up entirely by the console text box. However, you can at least create floating controls that way, which hover over the text to provide status info etc.
You can put controls in the window borders but only with some hacking on XP or a new API that was introduced with Vista. The problem with this API is that it requires you to draw your own program icon and title text, and the console window doesn't seem to cope with it very well.
You can't add your own menu items because the console window doesn't pass the messages.
In the end I used the function keys for everything and gave a status indication by changing the console window icon.
I am currently developing a user interface DLL that uses the WIN32 API. The DLL must work for numerous platforms, XP, WIN CE, etc. I have managed to incorporate docking, anchoring and so on but appear to have a problem regarding owner-drawn buttons. I can draw the button's correct state, focus, clicked, default. However, I cannot receive key notifications. I specifically want to perform a click operation on a button that currently has focus, should the user press enter.
Note that I am using a windows message loop rather than a dialog message loop. I use windows hooks to hook into the window creation and set the user data to 'point' to my control instance. If I test for WM_KEYDOWN in the main message loop I can get a handle to my button control instance and could forward the message to the relevant control. Unfortunately, I am dealing with a lot of legacy code and this may not be an ideal solution.
So, my question is what is the best way forward. Is subclassing the button control's window procedure a viable option or is there an easier way?
Many thanks in advance.
The comments above are correct. The button with focus should be getting the key messages. But buttons don't (by themselves) respond to Enter--they respond to Space. It sounds like what you're missing is the typical dialog keyboard navigation, like Tab key moving the focus and Enter activating the "default" button.
If you've got a typical Windows message pump, and you want the keyboard behavior normally associated with dialogs, then you need to use the IsDialogMessage API in your message loop. This means your window is essentially a "modeless dialog".
Looks like standard window proc subclassing should do the trick. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).aspx for details.
I want to create a button that is basically Windows' close button. How could I do this? I want to avoid drawing this myself because I want it to look like that version of Windows' close button. Firefox's tabs do something like this. Thanks
You can get at Windows XP+ theme specific UI elements via the DrawThemeBackground API.
Use WP_CLOSEBUTTON for the window X button (and one of CBS_NORMAL/HOT/PUSHED/DISABLED for its state) and you can draw one wherever you like.
The close buttons on the tabs in Firefox are part of its theme.
If you look in Program Files\Mozilla Firefox\chrome\ there's a zip file called classic.jar.
Inside this zip file is a png file skin\classic\global\icons\close.png.
This png file has the icons for the various states of the close buttons on the tabs:
from hg.mozilla.org