Pelles C forum

C language => Beginner questions => Topic started by: xsilvergs on May 03, 2007, 01:22:40 PM

Title: Using TextOut
Post by: xsilvergs on May 03, 2007, 01:22:40 PM
I am trying to get this code to work but get an error message. This draws an X Y axis but I would also like to add some text

      HDC hDC = GetDC(hwndDlg);
      //draw x-axis
      MoveToEx(hDC,0,240,NULL);   //start of line x y
      LineTo(hDC,240,240);         //finish of line x y
      //draw y-axis
      MoveToEx(hDC,10,50,NULL);   //start of line x y
      LineTo(hDC,10,250);         //finish of line x y
      //origin
      TextOut(hDC, 4,245,L"O",1);

It works fine until I add the last line TextOut(hDC, 4,245,L"O",1);

And here is the error message when I Build:

POLINK: error: Unresolved external symbol 'TextOutW'.
POLINK: fatal error: 1 unresolved external(s).

Can somebody please explain/suggest another way of writting text.

Thank you

Tony
Title: Re: Using TextOut
Post by: Stefan Pendl on May 03, 2007, 03:48:01 PM
Is Gdi32.lib included in the linker options ???
Title: Re: Using TextOut
Post by: xsilvergs on May 03, 2007, 03:53:23 PM
It wasn't so I added under "Library and object files:" was that correct?

It didn't make any difference as I still get the same error messages.
Title: Re: Using TextOut
Post by: frankie on May 03, 2007, 08:41:25 PM
Sounds strange, also because the wingdi.h has the pragma to autoinclude the gdi32.lib.
Please post the project so we'll check.
Title: Re: Using TextOut
Post by: xsilvergs on May 03, 2007, 10:22:52 PM
Hi frankie

Hopefully you can see the attached project, I've shortened it a bit.

Thanks

Tony
Title: Re: Using TextOut
Post by: frankie on May 04, 2007, 12:09:06 PM
Tony your project is for pocketPC, you have to know that the function TextOut doesn't exist for WinCE.
You have to use ExtTextOut. Change yor line:
TextOut(hDC,5,240,L"0",1);
With:
ExtTextOut(hDC, 5, 240, 0, NULL, L"0", 1, NULL);
And it should work.

P.S. for everybody: please specify if your code is for PC or Pocket, and possibly post in the correct thread for pocketPC.
Title: Re: Using TextOut
Post by: xsilvergs on May 04, 2007, 12:15:48 PM
frankie

Thank you that works.

Sorry if I posted in the wrong section but I'm still a beginner, probably three weeks playing with C.

All my code so far has been written for ppc and this is one of a few differences.

Thanks again.

Tony