#### Archived

This topic is now archived and is closed to further replies.

# DirectDraw question

This topic is 6384 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''ll try to make this as simple as possible, its really not that difficult of a problem but I cant seem to figure it out I have a text file, I want to display on the screen in my DirectX program (ver 6.0). I want the text to scroll, displayed one character at a time. The only way to display text on the screen in DDraw that I know of is TextOut or DrawText and they take a LPCTSTR as the parameter, so TextOut("hi this is text") works, and TextOut(letter), letter being a char I read in, doesnt. What Ive tried to do is read in one character at a time and write that, but no matter what I cant get it to work because of what the functions take and because Im not too good with this stuff Hope I made my question simple enough, Id appreciate any input Thanks

##### Share on other sites
It could be you forgot to ''\0'' terminate the string. You must give a char pointer to the TextOut function.

Maybe this will work:

  char Str[2] = { 0,0 };// read charStr[0] = ''a''; // orsoTextOut((LPCTSTR)Str);

I think the LPCTSTR type can be explained as:
LP = long pointer (long comes from 32bit)
C = constant
T = zero terminated
STR = string

##### Share on other sites
I did just that, the call

Draw_Text_GDI((LPCTSTR)Str, x,y, RGB(0,255,0), lpddsprimary);

results in error:
error C2665: ''Draw_Text_GDI'' : none of the 2 overloads can convert parameter 1 from type ''const char *''
Error executing cl.exe.

heres the function prototype:
int Draw_Text_GDI(char *text, int x,int y,int color, LPDIRECTDRAWSURFACE4 lpdds)

thats simpler I guess, when I typed the function out it said LPCTSTR, you know how vis c++ does that for you so you can see what to put in

##### Share on other sites
I''m guessing your using Lamothe''s function, right ?
Draw_Text_GDI() doesn''t recieve an LPCTSTR parameter, you should use Draw_Text_GDI() like this:
Draw_Text_GDI((char*)Str, x,y, RGB(0,255,0), lpddsprimary);
Should also work without the (char*), but just to be safe...

The road to success is always under construction