Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Locale project

jarrah_12jarrah_12 Member Posts: 6
Hello Im developing an accounting system in visual c++ .net ,the problem I need to use Unicde character set in order to use our language but every time i get errors was not in the app. when i use multi byte character set for example :

[code]
char ecode[15];
GetDlgItemText(IDC_EDIT1,ecode,15);
[/code]

after using unicode set i got the following error :
cannot convert parameter 2 from char[15] to 'LPTSTR'


please any idea are welcome , all the best .

Comments

  • zibadianzibadian Member Posts: 6,349
    : Hello Im developing an accounting system in visual c++ .net ,the
    : problem I need to use Unicde character set in order to use our
    : language but every time i get errors was not in the app. when i use
    : multi byte character set for example :
    :
    : [code]:
    : char ecode[15];
    : GetDlgItemText(IDC_EDIT1,ecode,15);
    : [/code]:
    :
    : after using unicode set i got the following error :
    : cannot convert parameter 2 from char[15] to 'LPTSTR'
    :
    :
    : please any idea are welcome , all the best .
    :
    Nearly all strings in the windows API are pointers to an array of char. Instead of supplying a pointer, you supply the actual array.
  • jarrah_12jarrah_12 Member Posts: 6
    : : Hello Im developing an accounting system in visual c++ .net ,the
    : : problem I need to use Unicde character set in order to use our
    : : language but every time i get errors was not in the app. when i use
    : : multi byte character set for example :
    : :
    : : [code]: :
    : : char ecode[15];
    : : GetDlgItemText(IDC_EDIT1,ecode,15);
    : : [/code]: :
    : :
    : : after using unicode set i got the following error :
    : : cannot convert parameter 2 from char[15] to 'LPTSTR'
    : :
    : :
    : : please any idea are welcome , all the best .
    : :
    : Nearly all strings in the windows API are pointers to an array of
    : char. Instead of supplying a pointer, you supply the actual array.

    Still the same problem .
  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    Try making it type TCHAR, instead of char.

    TCHAR can be a couple of things, depending on pre-processor definitions. If UNICODE is enabled, TCHAR is something like wchar_t, and when not it's char.


    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • bosebonasbosebonas Member Posts: 87
    Try also changing your char to char* that is a characted pointer.
  • jarrah_12jarrah_12 Member Posts: 6
    : Try making it type TCHAR, instead of char.
    :
    : TCHAR can be a couple of things, depending on pre-processor
    : definitions. If UNICODE is enabled, TCHAR is something like wchar_t,
    : and when not it's char.
    :
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry
    Dear Richard ,bosebonas .thank you for help .
    Is there any articles explain the deffirence between all this type and their use because im really get confuse when using them .
  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    : Dear Richard ,bosebonas .thank you for help .
    : Is there any articles explain the deffirence between all this type
    : and their use because im really get confuse when using them .

    Probably, but I don't know any out of my head.

    I wager there is something in the Standards about datatypes.

    Anyway, it helps to make a difference between two types of 'types'.
    There are the all-lowercase names (char, char*, int, long, void, etc...) that are the fundamental compiler types. However, these can change from compiler to compiler and from version to version.

    That's why in any Windows application you'll find a lot of all-capital names (CHAR, LPCHAR, TCHAR, INT, DWORD, VOID, BOOL, etc) {and also a couple of other names that fall into this category (like size_t)} that are not fundamental types but are pre-processor symbols.
    What fundamental type they eventually resolve to can differ (as you have experienced with TCHAR being a 'char' and later a 'short' {or 'wchar_t', on some compilers}).
    This is done to make C more platform independent: you can always use TCHAR, knowing that it's type will be right for your application. When using Unicode this becomes a wide character, and else it's a char. You can use the code on any compiler, and all you'll ever have to change is the pre-processor definition in one header!

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • jarrah_12jarrah_12 Member Posts: 6
    Really nice explaination thanx alot .
Sign In or Register to comment.