Multi line tooltip with CStatusBar and always activated - mfc

I am using the CStatusBar control and here is an example of trying to set the tooltips:
m_StatusBar.CreateEx(this, SBT_TOOLTIPS);
m_StatusBar.SetIndicators(indicators_oclm, paneCount); //We create the status bar
m_StatusBar.SetPaneInfo(paneDate, ID_INDICATOR_DATE, SBPS_NORMAL, 200);
m_StatusBar.SetPaneInfo(paneProgressOrZoomFactor, ID_INDICATOR_ZOOM, SBPS_NORMAL, 200);
m_StatusBar.SetPaneInfo(panePageBreaks, ID_INDICATOR_PAGE_BREAK, SBPS_NORMAL, 200);
m_StatusBar.SetPaneInfo(paneSlipsPerPage, ID_INDICATOR_SLIPS_COUNT, SBPS_NORMAL, 10);
m_StatusBar.SetPaneInfo(paneForeignLanguageGroup, ID_INDICATOR_FOREIGN_LANGUAGE_GROUP, SBPS_NORMAL, 200);
m_StatusBar.GetStatusBarCtrl().SetTipText(paneSlipsPerPage, _T("Line 1\r\nLine2"));
When I display the tooltip:
As you can see, it has not shown two lines:
Line 1
Line 2
I have researched it (example here) but to no avail.
Update
Using slightly different code, sticking with just one line for the tip I now have:
You can see why I prefer multiline. In addition, I really want the pane text to read "Calendar to use" and the tip to have the information. But the tips only show if all the text is not visible. So I also need to make it always activated if possible.
Update
I still can't get multiline but I have come up with a workaround for some of it:
Get the width for "Calendars to Use"
Set the pane width to that value
Update the pane text as "Calendars to Use " (causes the tooltip notification)
Set the tip text
The icon on the cake is getting the multi line support
I tried:
static CToolTipCtrl* pToolTip = NULL;
CToolTipCtrl* ptt = AfxGetModuleState()->m_thread.GetDataNA()->m_pToolTip;
if (ptt != pToolTip) {
// new tooltip
ptt->SetMaxTipWidth(400);
pToolTip = ptt;
}
But the code never gets called.
Update
I have raised this as a feature request with Microsoft.

Related

How to add a separator to Gio::Menu

I'm writing an application using GTK3 and gtkmm. I'm adding a menu button to the header bar. So far, I got items to show up, but I can't add a separator.
Here's where I create the menu:
auto main_menu = Gio::Menu::create();
...and add some items:
main_menu->append("Export to WAV", "app.exportToWav");
main_menu->append("About", "app.about");
And here's what I get:
But I want to add a horizontal line between the two items. There seems to be no obvious way to do this with Gio::Menu, and I want that popover. I tried adding an item with "-" as its content, but that did nothing. Gtk::SeparatorMenuItem exists, but it doesn't seem to be compatible. Is this even doable with this kind of menu?
I've figured it out. Turns out, with Gio::Menu, you don't specify "separators," per se. Instead, you specify sections.
Essentially, what this means is creating multiple menus, and then grouping them all together in a single menu using the append_section(Gio::MenuModel) function.
Here's what I ended up doing:
// Create master menu
auto main_menu = Gio::Menu::create();
// Create menu sections
auto main_menu_section1 = Gio::Menu::create();
auto main_menu_section2 = Gio::Menu::create();
// Add item(s) to first section
main_menu_section1->append("Export to WAV", "app.exportToWav");
// Add item(s) to second section
main_menu_section2->append("About", "app.about");
// Append the new sections to the master menu
main_menu->append_section(main_menu_section1);
main_menu->append_section(main_menu_section2);
Then, each section is separated by a horizontal line:
It's faint, but it's there

Oracle Apex, line break in Gantt Chart Row Label

I'm very new to Oracle Apex and currently I want to use and customize Gantt charts. What I want to achieve it to show line breaks in the row-labels. Currently every newline character gets cut out and I am not sure where this happens and how I can prevent this.
The marked text contains newline characters. Don't be confused by the <br>, I just tests if this does the trick.
I just want to show more some information in the for each row. If there is another more elegant way, it would be very nice to give a tip.
Update:
I did some research and found a very nice example on a similar topic, in this case to create a custom tooltip https://youtu.be/2rZAIR_0tNg?t=2532.
I wanted to do the same thing for the row_axis label renderer, but nothing gets visualized.
The render function I use:
function custom_row_axis_label_renderer(data_context){
var row_axis_label_elem = document.createElement("g");
$("row_axis_label_elem").addClass("custom_row_axis_label");
row_axis_label_elem.innerHTML = '<text font-size="14px">Hello World</text>';
console.log(row_axis_label_elem);
return row_axis_label_elem;
}
The rendered element kind of exists, but it's get the size 0x0 from somewhere.
Am I missing something here?
Regards,
Nik
Meanwhile I found the solution on how to build a custom renderer. The main part I didn't new is that you NEED to pass x and y coordinates to have the new label to be rendered correctly. I found a proper example the the oracle forum, but unfortunately I can't find the link anymore to give credit to the original example.
Here is my code. It creates two text elements below each other to achieve a mocked line break and it adds a yellow icon. Of course you can use the data_context object to access the actual label. Add this part in the "Function and Global Variable Declaration
" part of your page:
custom_row_axis_label_renderer = function (data_context){
var row_axis_label_elem = document.createElementNS("http://www.w3.org/2000/svg", "g");
var upper_text = document.createElementNS("http://www.w3.org/2000/svg", "text");
var lower_text = document.createElementNS("http://www.w3.org/2000/svg", "text");
var icon_node = document.createElementNS("http://www.w3.org/2000/svg", "circle");
upper_text.textContent = "Hello";
upper_text.setAttribute("dominant-baseline","text-before-edge");
upper_text.setAttribute("class","oj-gantt-row-label");
upper_text.setAttribute("font-size","14px");
upper_text.setAttribute("text-anchor","end");
upper_text.setAttribute("x","220");
upper_text.setAttribute("y","5");
lower_text.textContent = "World";
lower_text.setAttribute("dominant-baseline","text-before-edge");
lower_text.setAttribute("class","oj-gantt-row-label");
lower_text.setAttribute("font-size","14px");
lower_text.setAttribute("text-anchor","end");
lower_text.setAttribute("x","220");
lower_text.setAttribute("y","25");
icon_node.setAttribute("cx","240");
icon_node.setAttribute("cy","25");
icon_node.setAttribute("r","8");
icon_node.setAttribute("class","u-color-7");
row_axis_label_elem.appendChild(upper_text);
row_axis_label_elem.appendChild(lower_text);
row_axis_label_elem.appendChild(icon_node);
return row_axis_label_elem;
}
Also you need to set the renderer of the row-axis-label. I also made the rows and task a little bit bigger to have enough space for two lines of text in the label. Add this in the "JavaScript Initialization Code" in the attriutes of you chart:
function( options ){
options.rowAxis.label = {renderer : custom_row_axis_label_renderer};
options.rowDefaults = {height : 60};
options.taskDefaults = {height: 40};
return options;
}

MFC MDI Designing user preferences dialog GUI layout functionality

In this instance I am not "stuck" but looking for some 'guidance' on how to perform a GUI layout mechanism that makes sense and easy to construct. I am using a TreeControl that visually "matches" Winamp's options/preferences dialog for all the settings and program options.
TO BE CLEAR: This is not something I've ever attempted and looking for user input to help me get across the finish line.
I have 6 items in the 'tree' (the 'parent') and 5 'subitems'. I have it fully constructed and I can get the data from whatever node is selected (which I'll post below images).
I am using a "do.Modal dialog" and, when I click on the tree node, I want the right side of the dialog to update to the needed controls for that node function. The execution of controls through "show" and "hide" to me seems pretty easy. The issue I have is the how to do the visual "static" controls in the resource editor when each "node paged" controls may or may not sit on top of each other visually during design time. During run time, when each node is selected on the nodes controls will be active but during design time, I may have controls sitting on top of each other and will be a logistical nightmare trying to sort out their positions etc.
How do I resolve that aspect of building it? I think of it as a select: 'node' show: 'option page controls' so I get the logic; I'm just wondering if I should have separate "popup" pages and call those … or deal with the controls directly. Does that makes sense?
I've done some searching on how to do this, but the examples are all over the place and I figured asking here makes the most sense. I'm sure there are multiple ways to do this, I'm just looking for the shortest path and easiest to maintain and possibly expand on the options in the future.
The examples of the dialog and the source code I'm using:
Here is the initialization code:
BOOL CSettingsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
HTREEITEM hParent, hToolbars, hColorScheme, hTabStyles, hPowerUser,
hResetApp;
//HTREEITEM hCompany, hLevel, hLevelNext; // Used in core example, not needed here
hParent = m_TreeCtrl.InsertItem((L"Preferences"), TVI_ROOT);
hToolbars = m_TreeCtrl.InsertItem((L"Toolbars"), hParent);
hColorScheme = m_TreeCtrl.InsertItem((L"Color Scheme"), hParent);
hTabStyles = m_TreeCtrl.InsertItem((L"Tab Styles"), hParent);
hPowerUser = m_TreeCtrl.InsertItem((L"Power User"), hParent);
hResetApp= m_TreeCtrl.InsertItem((L"Reset All Options"), hParent);
m_TreeCtrl.Expand(hParent, TVE_EXPAND);
m_TreeCtrl.SelectItem(hParent);
GetDlgItem(IDC_SETTINGS_CAPTION)->SetWindowText(_T("Preferences Settings"));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Here is the dialog framework that I'm starting from scratch with just to arrive here:
void CSettingsDlg::OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
//LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
//SetDlgItemInt(IDC_TXT_TREE1, m_TreeCtrl.GetItemData(pNMTreeView->itemNew.hItem));
//*pResult = 0;
HTREEITEM sel = m_TreeCtrl.GetSelectedItem();
CPoint point;
CString str;
GetCursorPos(&point);
m_TreeCtrl.ScreenToClient(&point);
UINT flags = 0;
HTREEITEM hitItem = m_TreeCtrl.HitTest(point, &flags);
if (hitItem && sel != hitItem)
{
sel = hitItem;
m_TreeCtrl.SelectItem(sel);
str = m_TreeCtrl.GetItemText(sel);
//MessageBox((LPCTSTR)str); // Just to verify.
}
if (str == "Preferences")
{
this->SetWindowText(_T("Preferences Settings"));
GetDlgItem(IDC_SETTINGS_CAPTION)->SetWindowText(_T("Preferences Settings"));
}
if (str == "Toolbars")
{
this->SetWindowText(_T("Toolbars Settings"));
GetDlgItem(IDC_SETTINGS_CAPTION)->SetWindowText(_T("Toolbars Settings"));
}
if (str == "Color Scheme")
{
this->SetWindowText(_T("Color Scheme"));
GetDlgItem(IDC_SETTINGS_CAPTION)->SetWindowText(_T("Color Scheme Settings"));
}
if (str == "Tab Styles")
{
this->SetWindowText(_T("Tab Styles Settings"));
GetDlgItem(IDC_SETTINGS_CAPTION)->SetWindowText(_T("Tab Styles Settings"));
}
if (str == "Power User")
{
this->SetWindowText(_T("Power User Settings"));
GetDlgItem(IDC_SETTINGS_CAPTION)->SetWindowText(_T("Power User Settings"));
}
if (str == "Reset All Options")
{
this->SetWindowText(_T("Reset All Settings"));
GetDlgItem(IDC_SETTINGS_CAPTION)->SetWindowText(_T("Reset All Settings"));
}
*pResult = 0;
}
So as shown, you can see that I have the ability to change the static caption to the "active" page node that is selected from the tree. I'm looking to solve the best way to handle the GUI elements that will go on the right side....
Some controls for example will be:
Color scheme Node: 5 check boxes for theme changing
Toolbars Node: Radio button for Docked or Floating
Power User Node: Checkbox to disable user warning within program operation
Tab Styles Node: Radio buttons to select flat, 3d, whatever.
and when the user "selects" whatever it writes it to the registry and then I call the function to read the data blah blah blah...
So that is where I'm at. Does anyone have any suggestions on a course of action, so I don't paint myself into a corner?
Although I can't actually speak for how the authors of the "Winamp" software implemented their UI, I would suggest that you consider using a property sheet for your case, where each set of controls can be implemented as separate property pages, each of which will be defined (both in the resource script and in the C++ code) in ways very similar to individual modal dialog boxes.
The 'classic' property sheet has a horizontal row of tabs (normally, at the top of the sheet) to select each page, as shown in the sample below. Indeed, some sources/platforms refer to a property sheet as a "tabbed dialog".
However, the new(ish) CMFCPropertySheet class allows you to replace that tab control with one of several other options, which will show as separate 'panes' (on the left-hand side of the sheet). To use one of these alternative styles, call the SetLook() member function in your constructor override with the CMFCPropertySheet::PropSheetLook_Tree enum value. The example shown in the link is not exactly what you have shown in your question, but the CMFCPropertySheet and CMFCPropertyPage classes allow many, many customizations to their appearance and style.
I have never actually used the PropSheetLook_Tree style, but the image below shows "one I made earlier" with the PropSheetLook_OutlookBar style.

How to insert hyperlink without underline to Win32 RichEdit?

I added a link to RichEdit, use CFM_LINK/CHARFORMAT2 structure. But I can't figure out how to remove the underline effect. I tried:
SendMessage(richEditHWND, EM_AUTOURLDETECT, FALSE, NULL);
SendMessage(richEditHWND, EM_SETEDITSTYLEEX, 0, SES_EX_HANDLEFRIENDLYURL);
CHARFORMAT2 cf2;
memset(&cf2, 0, sizeof(CHARFORMAT2));
cf2.dwMask = CFM_LINK| CFM_UNDERLINE | CFM_COLOR | CFM_LINKPROTECTED;
cf2.dwEffects = CFE_LINK| CFE_UNDERLINE | CFE_LINKPROTECTED;
cf2.crTextColor = RGB(255, 0, 0);
cf2.bUnderlineType = CFU_UNDERLINENONE;
SendMessage(richEditHWND, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
But it don'n work.
Another way is set underline color to white color, which is the RichEdit background color, but it is a hacky way, make character like q, j,... being cut apart, also show the line when select text.
So what's the correct way to do this?
Note: I'm using RICHEDIT50W class.
You can do this using a friendly-name hyperlink. These let you specify arbitrary text (along with its own color and formatting) that is used for display, and the actual URL is hidden.
By default, friendly-name hyperlink text is also displayed in blue
with a blue underline unless the name text is formatted with an
explicit color. Explicit formatting takes precedence
The displayed text needs to have the CFE_LINK and CFE_LINKPROTECTED styles, along with explicit color and formatting styles. You then set the URL using the ITextRange2::SetURL method.
The MSDN blog post RichEdit Friendly Name Hyperlinks has a more detailed description of how to use them.
I just encountered the same problem recently and I just found that it's a bug of Richedit library. When I updated it from v4.1 to v5.0 the underline could be removed with no issues
Try sending an EM_AUTOURLDETECT message to the RichEdit control with wParam=0, lParam=0
"Specify 0 to disable automatic link detection...": https://msdn.microsoft.com/en-us/library/windows/desktop/bb787991(v=vs.85).aspx

How to display Red Squiggly Lines in CRichEditCtrl in MFC

I am working on implementing spellchecker in an MFC application. What I want to do is display red lines under incorrectly spelled words.
I found one example where it is done but it works only for a simple edit box because it can simply use the edit controls default font for doing calculations to draw the squiggly lines. But it does not work for a rich edit control as in rich edit control it is possible that different words can have different fonts. In this case the example I found draws lines at incorrect places.
Please let me know if someone has already done this for CRichEditCtrl? (it must handle text of any font/size that is present in the rich edit control.)
Thanks,
Sachin
CHARFORMAT2 format;
SecureZeroMemory(&format, sizeof(CHARFORMAT2));
format.cbSize = sizeof(CHARFORMAT2);
format.dwMask = CFM_UNDERLINE|CFM_UNDERLINETYPE;
format.dwEffects = CFE_UNDERLINE;
format.bUnderlineType = CFU_UNDERLINEWAVE | 0x50;
SendMessage(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&format);
I hope this will get the underline in your text
Use the EM_SETCHARFORMAT message:
CHARFORMAT2 format;
SecureZeroMemory(&format, sizeof(CHARFORMAT2));
format.cbSize = sizeof(CHARFORMAT2);
format.dwMask = CFM_UNDERLINE|CFM_UNDERLINETYPE;
format.dwEffects = CFE_UNDERLINE;
format.bUnderlineType = CFU_UNDERLINE
window->SendMessage(EM_EXSETSEL, NULL, (LPARAM)&range);
window->SendMessage(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format);