Problems with MFC link control wrapping - visual-c++

I'm using a CMFCLinkCtrl in my custom dialog that inherits from CDialog. The CMFCLinkCtrl is set dynamically using data that is set by the user in another part of the application, so I have to handle long urls.
Is there a way to have the link control truncate what is displayed in the dialog and add an ellipse to the end? Currently the control is wrapping to the next line when it is too long to fit in the dialog or sees the "//" in the http://.

Static controls have an SS_ENDELLIPSIS style that does exactly what you want, but unfortunately this won't work with CMFCLinkCtrl which is derived from CButton. So you have two choices:
Use a static control with the SS_ENDELLIPSIS style, but you'll have to set the text colour and font yourself, and handle click events and open the URL manually.
Subclass CMFCLinkCtrl and add custom drawing code to add the ellipsis.

I think you're out of luck. You'll have to do what casablanca said or without subclassing truncate the text yourself (calculate the font size and link control size) and set it using SetWindowText.
You can easily resize the control to contain the entire text using SizeToContent, but I don't think this works for you.

Related

How to create a scalable multi-line button in Godot?

A Button in Godot can only hold a single line of text. I can overcome this limitation by placing RichTextLabel node inside the button.
Now the button can contain more lines of text, but its height doesn't change automatically when more lines are needed. Instead the text just overflows:
Of course I can manually resize the button to be higher, but I'd like this to happen automatically depending on the amount of text inside. Specifically, I'm generating a list of these buttons programmatically and showing inside a HBoxContainer, with some buttons having longer and other shorter text.
Is there a way to achieve this with Godot layout tools?
Since the Button is in a Container, it is in control of its rect_size. The best we can do is specify a rect_min_size. There is no layout preset to have a Control depend on children Control. So, to answer the question as posted: No, we cannot achieve this with Godot layout tools. We need some scripting.
We need to set the rect_min_size for the Button depending on the RichTextLabel. We can ask it for the height of its content with get_content_height. Which also means we need to set the width beforehand. However, it will not update right away when we set the text (we are going to use yield).
Apparently you don't want the Container to control the height of the Button. If that is the case, I think you can remove all the flags from size_flags_vertical.
About the width, since as I was explaining before we need to set the width to get the height… I suggest you let the Container expand the width of the Button as much a posible. Which mean setting both the Fill and Expand flags on size_flags_horizontal.
Then, with the RichTextLabel properly set to take as much width of the parent Button as possible, you can read it height, and use it to set the height of the rect_min_size of the Button.
One more thing: you want to set the mouse filter of the RichTextLabel to Ignore or Pass, or it will prevent pressing the Button.
This is the code I came up with:
var b := Button.new()
b.size_flags_vertical = 0
b.size_flags_horizontal = SIZE_EXPAND_FILL
add_child(b)
var l := RichTextLabel.new()
l.mouse_filter = Control.MOUSE_FILTER_IGNORE
l.set_anchors_and_margins_preset(Control.PRESET_WIDE)
l.text = "Some\nMultiline\nText"
b.add_child(l)
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
I'd like this to happen automatically depending on the amount of text inside
Sadly changing the text does not resize, nor change the minimum size of the RichTextLabel. And RichTextLabel does not have a "text changed" signal. Nor "bbcode text changed" signal. Furthermore, it might not be feasible to intercept these properties (see append_bbcode et.al). It is proabaly easier to do with a regular Label.
Anyway, what I'm going to suggest for this is to make a Control that wraps the RichTextLabel, offers whatever interface you actually need, and in any method where you change the text, afterwards, you do the equivalent of this:
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
(Godot 3.x)
Without using scripting, it is also possible to achieve the same goal by wrapping both nodes as sibilings within a container, for example a MarginContainer. Enable the RichTextLabel's fit_content_height property, which will result in the label expanding the container's area as much as necessary, which will in turn resize the Button.

Options of message box in Excel

We would like to change the font, color and size of the text displayed in message boxes.
Can/how do you VBA this?
Nothing tried, we are not finding any help in online manuals, including the Microsoft help site.
We would like to make the message box big, bold and loud.
Easy answer: You can't.
That's why you can't find anything about it in the official documentation of the MsgBox function.
A workaround can be to create your own UserForm where you are free in how to style it.
Add a UserForm in your workbook's code module, and configure it with as many Label and CommandButton controls as needed.
If the label text will be static, you can configure these all through the Properties window in the IDE:
Labels, Command Buttons, etc., are accessible Controls on the UserForm, and can be altered dynamically during runtime if needed, e.g., during the form's Initialize or Activate or any other event handlers. Controls on the form can even alter other controls, for example you could leverage the command button's Click event handler to modify the text associated with Label1 control, etc.
You can even add (or remove) controls (labels and such) dynamically, too, and fully control their appearance/formatting/etc.

How to change color of TEdit when focused

It's probably easy question, bu I can't find an answer.
I want to change background color of TEdit component when I click on it (on Focus), and the background should back to previous color when I click somewhere else.
P.S. I use a Firemonkey and it's multiplatform app, so I need to use a style.
The easiest way (and best) - place TRectangle without Stroke into Tedit, set its Align to Client and change its Fill color in Object Inspector.
Hard way:
Tedit is using bitmap from styles. You can see your current style for Tedit - place StyleBook, Load your style from file, find 'editstyle' object.
You can create a new style for Tedit (copy 'editstyle' in your current style, and name it like editstyle1, select background > Source Link in Object Inspector - select part on global style bitmap with your color, then you can change to new style like Edit1.StyleLookup := 'editstyle1';
Also use a useful forum: http://fire-monkey.ru with Google Translate.

TextArea without Scrollbars

I have a TextArea in my application that actually takes no interactions from the user.
Is there a way to either
Remove the scrollbar entirely and let me handle what happens when the scrollbar would appear?
Use a different object to display text to the screen? I need to be able to append text, but I don't need it to be highlight-able or take any user input.
According to your needs, you need to use label.
If you need TextArea, to remove scrollBars, you can do the next :
Use lookupAll(java.lang.String selector) method to find scrollBars, and
call scrollBar.setOpacity(0.0) for each found scrollBar.
2a. Don't call setVisible(false), as visible property (I believe) is used to TextArea to control scrollBar visibility.

How to make a dialog as same size as another dialog in MFC?

I am in process of creating a dialog IDD_DIALOG2 which i want to be in the same size as existing dialog IDD_DIALOG1, what would be the easiest way to do this in VC++?
Just resize in design view. The dialog's size shows up in the status bar.
(you could also edit the .rc file and copy the 4 numbers that follow the dialog's ID)
The sane way would be to look up the IDD_DIALOG1's dialog definition and use the same sizes.
If you don't have access to IDD_DIALOG1's dialog definition, you could bring up IDD_DIALOG1, use GetWindowRect() on it to record its actual size, close it, open IDD_DIALOG2, and then use MoveWindow() to resize to the same size. Not generally recommended, but it's possible.
It's possible to copy & paste the dialog in the Resource View - all the controls come with it also.

Resources