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 anoth开发者_如何转开发er 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.
精彩评论