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
Related
I am writing small c++ application using QT creator and i have a problem, I want to get selecting text from any application, I am using to this QClipboard library (SIGNAL(selectionChanged())), but it doesn't work properly admittedly i am getting selected text, but only after I release a mouse button. I would like to get selected text in "real time" without mouse button up. Is there any simple way to do it?
first you need to add this header file: QClipboard
then...
connect(qApp->clipboard, SIGNAL(selectionChanged), this, SLOT(your_slot()));
void your_slot() {
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(qApp->clipboard->text());
}
http://doc.qt.io/qt-5/qclipboard.html#selectionChanged
It looks like that is only supported well on X11, like Linux.
If you are interested in tracking mouse selections in your program in realtime, you can look directly at the mouse events or keyboard events, or the Rich Text Processing framework (QTextCursor).
You could also send a copy call while the mouse is down on a timer, and then look at the dataChanged signal.
Hope that helps.
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.
Does anyone know if it is possible to change the icons on the MFC VSListBox Dialog Control?
Specifically I'm trying to change the folder icon to a '+' icon instead:
I haven't tried it myself, but CVSListBoxBase::AddButton() seems to be what you need.
CVSListBox derives from CVSListBoxBase, and when you call CVSListBoxBase::SetStandardButtons to set the buttons, it calls AddButton() for each button.
The documentation for CVSListBoxBase is unfinished, so you'll have to "play" with it, but you can read the code in afxvslistbox.cpp/.h
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.
In Linux after text selecting it copies to buffer, so than we could paste it by clicking middle button of the mouse. I think that there is a special buffer for this thing. I want to use it. How could i get data of selected text?
OS: Linux
Programming language: c++
Own libraries: Qt
Thanks.
Just a more accurate answer than Paul Dixon's that answers your needs:
QClipboard* clipboard = QApplication::clipboard();
QString selectedText = clipboard->text(QClipboard::Selection);
You need to distinguish between selection and clipboard. The QClipboard documentation has this in the Notes for X11 Users section:
The X11 Window System has the concept
of a separate selection and clipboard.
When text is selected, it is
immediately available as the global
mouse selection. The global mouse
selection may later be copied to the
clipboard. By convention, the middle
mouse button is used to paste the
global mouse selection.
With QClipboard::Mode you can select which type (clipboard or selection) you want to access. The important part is that you need to be aware about the difference between selection and clipboard.
If you're using Qt, have you read the fine manual page on QClipboard?
QClipboard *clipboard = QApplication::clipboard();
QString clipboardText = clipboard->text();
the system that actually handles the selection and pasting system is X11 Windows. When you e.g paint some text in your favorite editor, the application sends and X11 request which tells to the X11 server that you have an active selection. If you then click the middle mouse button somewhere, the X11 server queries the application which told the server about the selection for the actual contents. Then the contents are forwarded to the receiving application.
Libraries like Qt provide wrappers for this mechanism, but the underlying mechanism is X11.