Which control in C++ Win32 equal with "Run" control in C# WPF? - c++

Which control in Win32 support wrap text like bellow and support mouse down event like Run in C# (as in picture below)? If there isn's have built in control, which libray I can use? Thank!
<TextBlock TextWrapping="Wrap" FontSize="20" Margin="10">
<Run>A text run.</Run>
<Run Background="Yellow" MouseDown="Run_MouseDown">
<!-- Support mouse down event -->
This is long Run that auto wrap to begin of the below line.
</Run>
</TextBlock>

One candidate would be the STATIC control.
Use the SS_LEFT style:
A simple rectangle and left-aligns the text in the rectangle. The text is formatted before it is displayed. Words that extend past the end of a line are automatically wrapped to the beginning of the next left-aligned line. Words that are longer than the width of the control are truncated.
The parent control is sent STN_CLICKED notifications when the control is clicked.
What you cannot do with a STATIC control is highlight some part of the text as shown in your screenshot. To achieve that you would likely need to use windowless rich edit controls.

Related

way to remove comma from format of windows edit control? (C++)

using a windows EDIT control with ES_NUMBER style and with an accompanying UPDOWN control, the default number written to the EDIT control uses a comma in the thousands place. Is there any way to turn off this behavior?
I tried intercepting a notification from the UPDOWN control and immediately overwriting the text but it looks like either the notification isn't being detected or I'm overwriting the text just before it writes the new value.
Add the UDS_NOTHOUSANDS style to the spin button control.

Visual Studio C++ how to display a dynamic message (i.e., string) in my About box?

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.

c++ win32 create a text only button

I would like to add a simple text button to my c++ win32 application. I'm creating the button using CreateWindowEx function, but can't figure out the correct style to do so. I would like to display a text only button and be able to recive messages when the user clicks on it. The style i would like to get is identical to the text button in windows 7 system volume control (where it says "Mixer"). If possible i would like to display a tooltip also.
That mixer control looks more like a hyperlink control than a button. I'd go for the SysLink control if that's what you need.
You could create a "Button" class window with the BS_OWNERDRAW style and handle the WM_DRAWITEM messages. In your WM_DRAWITEM message handler you can simply display the text.
Actually that button is an owner draw button - it listens to mouse move messages and when you hover over it, it underlines the text (the syslink control doesn't have this behavior). Otherwise it's a stock button.

Manipulating scrollbars in third-party application

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.

Having trouble enabling vertical scrolling in edit box

I'm using Visual Studio 2005 and programming a dialog-based MFC application in C++.
I have an edit box and I'm trying to make it auto-scroll.
When I make auto vscroll true, it still won't auto-scroll when I have too many lines in my edit box.
Any ideas in what could be wrong? Is there maybe some code line I have to add to my edit box?
What do you mean by "Auto-Scroll"?
Turning on auto vscroll enables the ES_AUTOVSCROLL edit control style which:
ES_AUTOVSCROLL -
Automatically scrolls text up one page when the user presses the ENTER key on the last line.
This may not be what you think "Auto-Scroll" means. A common misconception is that auto vscroll will automatically turn on/off the vertical scroll bar as more text is typed into the edit control. This is not the case, you have to either always have the scroll bar displayed or you have to come up with your own code to turn on and off the scroll bar yourself.