RECT font_rect;
SetRect(&font_rect,200,rock_scale*1000+200,300,rock_scale*1000+300);
g_font->DrawText(NULL, //pSprite
screen_text, //pString
-1, //Count
&font_rect, //pRect
DT_LEFT|DT_NOCLIP,//Format,
0xFFFFFFFF); //Color
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
return;
}
DrawText won't cooperate.
hey guys
These are my wits [start end]
I'm somewhere over here-----^
Im attempting to use DrawText, ive gotten it to display static text that I code into the call.
but it refuses to accept anything external (fps, messages, whatever)
I was following the drunken hyena tutorial and it has gotten me this far, however when i try to have it use anything else it says
[C++ Error] File1.cpp(265): E2034 Cannot convert 'AnsiString' to 'const char *'
in the Documentation, it specifically DOES support AnsiString
"[in] Pointer to a string to draw. This parameter supports ANSI and Unicode text strings"
what am i doing wrong?
Quote:
in the Documentation, it specifically DOES support AnsiString
"[in] Pointer to a string to draw. This parameter supports ANSI and Unicode text strings"
ANSI and Unicode are encodings for strings, not C++ types. An ANSI string can be stored both as a char* and as an AnsiString. Which of the two does your function use? The compiler seems to agree on char*.
It starts life as:
String screen_text = "hi";
which is rejected with the error i listed in the previous post
It accepts
char* screen_text = "hi";
and
const char* screen_text = "hi";
but then i get an error of
[C++ Error] File1.cpp(237): E2060 Illegal use of floating point
when I try to copy the data into the string
String screen_text = "hi";
which is rejected with the error i listed in the previous post
It accepts
char* screen_text = "hi";
and
const char* screen_text = "hi";
but then i get an error of
[C++ Error] File1.cpp(237): E2060 Illegal use of floating point
when I try to copy the data into the string
Check the documentation of your String object for a conversion to const char*. One of its methods should provide this.
I have tried sever things to convert my string over and i keep running into
[C++ Error] File1.cpp(259): E2034 Cannot convert 'AnsiString' to 'char *'
any thoughts on direction to head in ?
[C++ Error] File1.cpp(259): E2034 Cannot convert 'AnsiString' to 'char *'
any thoughts on direction to head in ?
Use the c_str() of the AnsiString class (which is not a standard C++ class, as far as I can tell, so I can only make guesses about what it does), copy the resulting const char* into an appropriately-sized char* buffer, then pass the buffer to the function. Use the buffer value, and then delete it.
well that was annoyingly undocumented :)
thanks the solution for those that are interested was adding the ".c_str()"
after the string name
thanks the solution for those that are interested was adding the ".c_str()"
after the string name
g_font->DrawText(NULL, //pSprite screen_text.c_str(), //pString -1, //Count &font_rect, //pRect DT_LEFT|DT_NOCLIP,//Format, 0xFFFFFFFF); //Color
As a side note, the std::string class is better documented than that [wink] and it's standard, too.
AnsiString, typedefed to String (with a capital) is Borland's string class used with the VCL so I assume the OP is using Builder.
c_str() is listed under AnsiString->Methods in the help along with all its other methods if you are looking for any other ways to use it.
std::string is indeed probably superior but all the VCL and other Borland library stuff uses String so if I am correct and you are using Builder, it is well worth learning to use their String as well.
c_str() is listed under AnsiString->Methods in the help along with all its other methods if you are looking for any other ways to use it.
std::string is indeed probably superior but all the VCL and other Borland library stuff uses String so if I am correct and you are using Builder, it is well worth learning to use their String as well.
Quote:Original post by EasilyConfused
AnsiString, typedefed to String (with a capital) is Borland's string class used with the VCL so I assume the OP is using Builder.
That's what I feared, too. The class does have some nifty possibilities, and good interaction with the rest of Borland functionality, but it sucks when dealing with the SC++L.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement