Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: DrawTextW not found in c++ seattle build


This question is answered.


Permlink Replies: 5 - Last Post: Mar 10, 2016 5:44 PM Last Post By: Remy Lebeau (Te...
Barry Andrews

Posts: 71
Registered: 9/19/03
DrawTextW not found in c++ seattle build  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 3, 2016 10:53 PM
I have converted a project from XE7 for win32 target

Under XE7 I used DrawTextW in my string grid on draw cell event and it worked fine.

However with the project now moved to C++ 10 Seattle I get a linker error

no matching function for DrawTextW

If this has moved / changed, what has it changed to?

I tried searching through the c++ seattle page and cannot get any hits on DrawText or DrawTextW

full use of DrawText

DrawText(pCanvas, CellText, CellText.length(), Rect, Flags);
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: DrawTextW not found in c++ seattle build  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 4, 2016 10:39 AM   in response to: Barry Andrews in response to: Barry Andrews
Barry wrote:

DrawText(pCanvas, CellText, CellText.length(), Rect, Flags);

The fact that you are apparently passing a Canvas object pointer in the first
parameter, and a string object without using its c_str() method in the second
parameter, suggests that you are calling a wrapper function, not the Win32
API DrawText() function directly. So where is the wrapper coming from to
begin with? Embarcadero's RTL has no DrawText() wrapper that accepts a Canvas
object in the first parameter, and System::String does not have a lowercase
length() method so you must be passing a std::(w)string (or other similar
string class) instead. Is your project including the source file, or precompiled
library, that implements that wrapper? If not, that would account for your
linker error.

--
Remy Lebeau (TeamB)
Barry Andrews

Posts: 71
Registered: 9/19/03
Re: DrawTextW not found in c++ seattle build  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 10, 2016 5:15 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Barry wrote:

DrawText(pCanvas, CellText, CellText.length(), Rect, Flags);

The fact that you are apparently passing a Canvas object pointer in the first
parameter, and a string object without using its c_str() method in the second
parameter, suggests that you are calling a wrapper function, not the Win32
API DrawText() function directly. So where is the wrapper coming from to
begin with? Embarcadero's RTL has no DrawText() wrapper that accepts a Canvas
object in the first parameter, and System::String does not have a lowercase
length() method so you must be passing a std::(w)string (or other similar
string class) instead. Is your project including the source file, or precompiled
library, that implements that wrapper? If not, that would account for your
linker error.

--
Remy Lebeau (TeamB)

I tried changing to
DrawText(pCanvas->Handle, CellText.w_str(), CellText.Length(), Rect, Flags);
but still get compiler errors.

I can use
pCanvas->TextRect(Rect, CellText, TTextFormat());
but don't get the text alignment I could get with DrawText(Left, Center, right).

How do I now get the same functionality of DrawText I had in XE7 in c++ Seattle?
Do I need to include a different header file to get access to the old DrawText?
Is this the correct way to do the text drawing in the cell?
David Millington

Posts: 257
Registered: 5/29/05
Re: DrawTextW not found in c++ seattle build  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 10, 2016 8:41 AM   in response to: Barry Andrews in response to: Barry Andrews
On 2016-03-10 13:15:08 +0000, Barry Andrews said:
I tried changing to
DrawText(pCanvas->Handle, CellText.w_str(), CellText.Length(), Rect, Flags);
but still get compiler errors.

I can use
pCanvas->TextRect(Rect, CellText, TTextFormat());
but don't get the text alignment I could get with DrawText(Left,
Center, right).

How do I now get the same functionality of DrawText I had in XE7 in c++
Seattle?
Do I need to include a different header file to get access to the old DrawText?
Is this the correct way to do the text drawing in the cell?

Where is the DrawText you are using defined? What compiler errors are
you getting?

If you are including windows.h you should get it.

FWIW, if you just want to control left/right/center/up/down/vertcenter
alignment, the TCanvas.TextOut method lets you do that, I think.
Barry Andrews

Posts: 71
Registered: 9/19/03
Re: DrawTextW not found in c++ seattle build  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 10, 2016 5:11 PM   in response to: David Millington in response to: David Millington
David Millington wrote:
On 2016-03-10 13:15:08 +0000, Barry Andrews said:
I tried changing to
DrawText(pCanvas->Handle, CellText.w_str(), CellText.Length(), Rect, Flags);
but still get compiler errors.

I can use
pCanvas->TextRect(Rect, CellText, TTextFormat());
but don't get the text alignment I could get with DrawText(Left,
Center, right).

How do I now get the same functionality of DrawText I had in XE7 in c++
Seattle?
Do I need to include a different header file to get access to the old DrawText?
Is this the correct way to do the text drawing in the cell?

Where is the DrawText you are using defined? What compiler errors are
you getting?

If you are including windows.h you should get it.

FWIW, if you just want to control left/right/center/up/down/vertcenter
alignment, the TCanvas.TextOut method lets you do that, I think.

The error I get is
E2034 Cannot convert 'TRect &' to 'tagRECT *'
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: DrawTextW not found in c++ seattle build
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 10, 2016 5:44 PM   in response to: Barry Andrews in response to: Barry Andrews
Barry wrote:

The error I get is E2034 Cannot convert 'TRect &' to 'tagRECT *'

Use the '&' operator to pass the address of the Rect variable:

::DrawText(pCanvas->Handle, CellText.w_str(), CellText.Length(), &Rect, Flags);


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02