• Welcome to Dark Bit Factory & Gravity.
 

Win32 - How to draw a WCHAR (Unicode Char) with TextOut() ?

Started by va!n, June 07, 2012

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

va!n

For my Win32 project i want like to draw special chars with something like TextOut()... I will define the special chars as WCHAR and set its HexValue like following codesnip but i cant get it work. Any idea how to solve this? Thanks!


WCHAR testchar = 0x00A9;

TextOut( hdc, 20, 10, TEXT("A"), 1);        // Works fine !
TextOut( hdc, 80, 10, (WCHAR)testchar , 2);   // Does not work :(


Btw yes, the project is compiled by using unicode charset!
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Jim

WCHAR tc[2]={0};
tc[0]=testchar;
TextOut(,,,tc,2);

TextOut prints strings not characters so you need to make a string.
Jim
Challenge Trophies Won:

va!n

@Jim:
Cool! Many thanks for your help, it works fantastic now! This problem has cost me some hours ^^
K++
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Canopy

if TextOut doesn't need a NULL terminator you could just do..

WCHAR testchar = 0x00A9;

TextOut( hdc, 20, 10, &testchar, 1);       




;)

va!n

@Canopy:
Thanks! I am not sure if TextOut() requires a NULL terminated string or not...
However, it seems to work ;) K++
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

energy

MultiByteToWideChar
QuoteThis function maps a character string to a wide-character (Unicode) string.
http://msdn.microsoft.com/en-us/library/bb202786.aspx
coding: jwasm,masm
hobby: www.scd2003.de