Home > Back-end >  Graphic wrap text control problem
Graphic wrap text control problem

Time:10-01

Made a call ShapeButton controls
The class PACKAGE TShapeButton: public TCustomControl
There are two problems in use process
1, draw in Paint function word use
DrawText (Canvas - & gt; Handle, Caption. C_str (), the Caption. The Length (), & amp; TextRect, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
How can I like normal Label space, in the Text assignment can identify in the string "\ r \ n"?

2, the program generated dynamically ShapeButton, every time to restart the program will be unable to connect TShapeButton. The obj mistakes, this component directly will drag form then compiled ones can get through it, what's the solution?

CodePudding user response:

The first question, DrawText function of the last parameter, remove the DT_SINGLELINE went, what do you mean by know SingleLine,
 DrawText (Canvas - & gt; Handle, Caption. C_str (), the Caption. The Length (), & amp; TextRect, DT_VCENTER | DT_CENTER); 


Second question, call the ShapeButton project, a line is added in the unit:
# pragma link "ShapeButton
"Have a try

CodePudding user response:

reference 1st floor ccrun response:
your first question, DrawText function of the last parameter, remove the DT_SINGLELINE went, what do you mean by know SingleLine,
 DrawText (Canvas - & gt; Handle, Caption. C_str (), the Caption. The Length (), & amp; TextRect, DT_VCENTER | DT_CENTER); 


Second question, call the ShapeButton project, a line is added in the unit:
# pragma link "ShapeButton
"Try


Is mainly the DT_SINGLELINE removed DT_VCENTER vertical center to live, can't have a headache

CodePudding user response:

And demon elder brother, ask how to make me this control after each change Caption redraw?

CodePudding user response:

Caption changes after call Invalidate function

CodePudding user response:

reference 4 floor ccrun response:
Caption changes later call once Invalidate function


The first question should do demon elder brother, DT_VCENTER must match with DT_SINGLELINE effect to have

CodePudding user response:

You want to break, you should first veto SingleLine, want to vertical center, can consider to combine DT_CALCRECT, to coordinate the position of drawing area manually implement vertical center,
  • Related