can anyone explain to me what is: 'T', 'L', 'wchar_t', 'LPCWSTR' and 'LPCTSTR'?
how can i convert strings\char* to these types?
(i understand these isn't a tutorial, but i realy need these introdution)
or you can give me just a nice link.

_T() is the same as _TEXT(), which converts a string literal to UNICODE, for example _TEXT("Hello World"); Those two macros do nothing for character arrays. These macros are translated at compile time as either wide characters (wchar_t*) or normal ascii characters (char *).

L is not a macro but forces the string literal to be wchar_t*, regardless of whether the program is compiled for UNICODE or not.

LPCWSTR is typedef for a pointer -- same as const wchar_t*, and LPCTSTR is typedef for const char*

Here is a more comprehensive tutorial

sorry i didn't understand 1 thing: how can use strings\char* variable names in these functions?

You can't. Those are macros that work only on string literals -- text within quotes such as "Hello World". You have to call a conversion function to convert char* to wchar_t*. Study the link I gave you.

so instead use LPTSTR or LPSTR, i can use char* or wchar_t*.
char* is non-unicode and wchar_t* is unicode.
that's why, too, we can't print 'é' directly on console.
for that we can use wcout with 'L'.
i have the windows.h include, but the 'L' where is declared?
or i must declare it?

i have the windows.h include, but the 'L' where is declared?
or i must declare it?

The prepend L is a feature of the C language itself, and is implemented inside the compiler; there is no definition for it. If you think it through, this has to be the case, because the compiler has to be able to interpret the string literal's glyphs as text characters.

windows.h should be sufficient. There are a lot of other macros in tchar.h. My preference is to (almost) never use L because L is not portable between UNICODE and non-UNICODE programs, while the _T() and _TEXT() macros are. If you use _T() you can turn UNICODE on and off without changing the program.

sorry, but i get the same error :(
'error: '_T' was not declared in this scope'
the same with '_TEXT'. i use them like a function:

_T(argument)

what is "argument"? It has to be a string literal, can not be the name of a variable. And did you include tchar.h? For edxample

#include <Windows.h>
#include <tchar.h>
#include <iostream>

int _tmain(int argc, _TCHAR* argv[])
{
    std::cout << _T("Hello World\n");
    return 0;
}

thanks.. yes i wasn't using the tchar.h
thanks.

i allways have the same problem with some API functions :(
see these function:

unsigned __stdcall BlinkLoop(string Text, int x, int y)
{
    char *EmptyText;
    const char *CharText=Text.c_str();
    EmptyText=new char[ Text.length() ] ;
    int i;
    for( i=0;i<=(int)Text.length();i++)
    {
        EmptyText[i] = ' ';
    }
    EmptyText[i] ='\0';
    HDC a=GetDC(GetForegroundWindow());
    char *v;
    while (true)
    {

        sprintf(v,Text.c_str());
        TextOut(a,x,y,v,Text.length);
        Sleep(1000);
        sprintf(v,EmptyText);
        TextOut(a,y,x,v,Text.length);
        Sleep(500);
    }
    return 0;
}

my problem is with TextOut() with strings:(
please tell me what is my problem

The problem is on line 17 and 20, not with TextOut(). Neither of those two lines are needed, and they are both wrong anyway. The whole function is just too complicated.

unsigned __stdcall BlinkLoop(string Text, int x, int y)
{
    char EmptyText[Text.length()+1];
    memset(EmptyText,' ', sizeof(EmptyText));
    EmptyText[ sizeof(EmptyText)-1) ] ='\0';
    HDC hDC=GetDC(GetForegroundWindow());
    while (true)
    {
        TextOut(hDC,x,y,Text.c_str(),Text.length);
        Sleep(1000);
        TextOut(hDC,y,x,EmptyText,Text.length);
        Sleep(500);
    }
    return 0;
}

i get errors:
EmptyText[ sizeof(EmptyText)-1) ] ='\0';
"C:\Users\Joaquim\Documents\CodeBlocks\blinktext\blinktext.h|39|error: expected ']' before ')' token|"

i resolve that.. i found ')'.. was the problem.
and i fixed these line too:

TextOut(hDC,x,y,Text.c_str(),(int)Text.length());

i must cast it to int and use '()';)
thanks for all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.