I was trying the CMFCButton tooltips and found that if I call EnableFullText() the tooltips don't show.
Here's a little sample:
// In OnInitDialog()
c_MyBtn.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT;
c_MyBtn.SetMouseCursorHand();
c_MyBtn.EnableFullTextTooltip();
c_MyBtn.SetTooltip(_T("Some string"));
c_MyBtn.Invalidate();
So, does that function do something? The docs say it "Specifies whether to display the full text of a tooltip in a large tooltip window or a truncated version of the text in a small tooltip window", but the only thing I see is that tooltips don't show. I've tried long strings and strings with line breaks, but nothing.
Anyone knows the purpose of this function and how to use it?
I'm using Visual Studio 2008 SP1.
The wonderful thing about MFC is that Microsoft gives you the source. If there's ever a question, just look at the code.
Looking at EnableFullTextTooltip, all it does is set a couple of boolean flags. The important one is m_bDelayFullTextTooltipSet. This flag is checked in the OnDraw function. The tooltip text is set with SetTooltip: if the full button text fits on the button itself, it's called with NULL, otherwise it's called with the button text.
It appears the intent of this function is to have the tooltip display the text that should have been drawn on the button itself when the button is too small. If that's not what you want, avoid this function because it will override the tooltip that you have set.
Related
I have several Dialog in my program that tells the users various things, from errors, to confirmation.
The sample in the documentation tells me to use this to have an icon set depending on the dialog (warning, information, question mark...):
Gtk::MessageDialog dialog(*this, "This is a QUESTION MessageDialog",
false /* use_markup */, Gtk::MESSAGE_QUESTION,
Gtk::BUTTONS_OK_CANCEL);
However, I do not get any icon in the dialog, I am only able to change the icon in the top bar, using this :
Gtk::MessageDialog dialog(*this,~
"Please select something first.",
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK);
dialog.set_icon_name("dialog-error");
dialog.run();
I get no error, no warning, this compile and execute just fine, but the resulting message box doesn't have any icon in it. How can I get an icon to display properly INSIDE my dialog box ? I also tried the other MESSAGE_* available, without success.
According to the Gtk3 documentation one should use GtkDialog to create dialogs with images.
You may use set_image but it is deprecated since 3.12.
More concrete:
void Gtk::MessageDialog::set_image(Widget& image)
Sets the dialog’s image to image.
Since gtkmm 2.10:
Deprecated: 3.12: Use Gtk::Dialog to create dialogs with images
Deprecated:
Use Dialog to create dialogs with images.
Parameters
image The image.
Should be trivial . . . when editing via the VS resource editor.... the tools/objects list only shows 'static text' and the create an event handler wizard has all fields and [next] button dimmed (disabled).
I have a lovely About box -- it all works -- but instead of static text fields to display --
I want/need to display several lines (strings) of current runtime status info.....
I just do know Visual Studio well enough (I'm using 2008). . .
If any one has a simple example -- that really is all I need.
Thanks in advance.
best regards,
Kevin Waite
If you put a static text box in your dialog you can set its text to anything you want at runtime. First you need to get the window handle of the text box:
HWND hwndText = GetDlgItem(hwndDialog, IDC_MYTEXT);
Then you can set the new text into it:
SetWindowText(hwndText, L"Hi mom, this is my first text box!");
Static text isn't meant to change, so Windows doesn't always do the right thing when you change it. You need to tell it to erase and repaint so that the new text is properly displayed.
InvalidateRect(hwndText, NULL, true);
How about adding an empty static text, and just setting its Text property?
I just made an empty Windows Forms application in Visual Studio C++ Express, and dragged a "Label" control onto the form. In the forms Load function, the text can be set like this:
this->label1->Text = "Hello World";
The same method can be used if you want larger texts. Just use a multiline TextBox instead.
If you want to display multiple lines of text, you can use the EditBox control and set the multiline property to True.
To pass the data to the about dialog, you will need to have to pass those strings to the dialog when the dialog is created (before the call to DoModal); and have the string added to the editbox in the aboutbox OnInitDialog.
If you need the text to be updated live while the about dialog is open you will probably have to add a thread that will fetch the strings from somewhere and the UI will be updated with those new strings.
Good luck.
Code Used:
m_pButton->Create(L"ABC", WS_CHILD | WS_VISIBLE| BM_SETIMAGE,CRect(0,0,100,100),this,ID_BUTTON1);
m_pButton->SetIcon(::LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON1)));
//above Code show neither showing image nor showing text.
You might use CMFCButton if you are using VS 2008 SP1 or higher.
BM_SETIMAGE is not a button style, but a message which is sent to the window in order to set a bitmap.
What you probably want is the BS_BITMAP style. Unfortunately as far as I know, it is not possible to have both text and a bitmap on a standard button. But you should find plenty of working implementations of a custom button class on sites like codeguru or codeproject.
BS_ICON and BS_BITMAP must be both unset to enable icon and text on the same button.
See https://msdn.microsoft.com/en-us/library/bb761822(VS.85).aspx
WPF might be able to do this. But, changing GUI topkits might not be an option anyway.
You could override the DrawItem method in CButton. For details check out the following links:
CButton::DrawItem
Owner drawn button - step by step
How do I have a CEdit control display placeholder text when it's empty, similar to the behavior of NSTextFields in Cocoa?
Ages ago, I wrote a custom paint routine to do it, seemed to work fine.
Sometime after, they introduced SetCueBanner to CEdit, but I can remember it:
a) not working correctly
or -
b) not behaving the way I wanted
Perhaps it will work fine for you. If not, I can see if I can find my old code and post what I did in the custom paint routine.
EDIT
I just checked the Win32 docs, I think this is why I abandoned it:
You cannot set a cue banner on a multiline edit control
you could create a small window over the top of it that contains the placeholder text. Then when the user sets the keyboard focus to it hide the window and if the focus is removed and nothing is in the box then show it.
The SetCueBanner banner function is now working.
I'm trying to resize dynamically a CMFCPropertySheet to add a custom control at the bottom of each page.
As all Property Pages are not of the same height, I have a mechanism to increase the size if necessary.
For this, I have overridden the OnActivatePage method and by using SetWindowPos, I can resize the sheet, first, then the tab control, then the page and finally I can move the OK/Cancel/Help buttons.
It works fine with PropSheetLook_OutlookBar and PropSheetLook_Tabs styles but not with PropSheetLook_OneNoteTabs style. The page (or the tab) is not correctly resized (the lighter grey color of the page does not fill the sheet.
OneNote style OneNote http://www.freeimagehosting.net/uploads/th.ec91600664.jpg
Outlook style Outlook http://www.freeimagehosting.net/uploads/th.319b6938ab.jpg
Any idea? A MFC Feature Pack bug?
I found the problem. One needs to get a reference to the different tab control the OneNote version uses via GetTab() and resize it accordingly.
Just follow the instructions as seen in here.
Although the instructions are for CPropertySheet they work for the CMFCPropertySheet as well.
Some parts of the code is deprecated so you will need to make the following amendments.
Skip the XmnPropSheetCallback and DoModal implementations completely
In OnInitDialog just make a call to CPropertySheet::OnInitDialog(); and then call OnSize instead of doing everything presented in that code.