by some reason the TextOut() function don't show me the text:(
but see these code:

#include <iostream>
#include <string.h>
#include <windows.h>

using namespace std;

int main()
{
    HDC a=GetDC(GetForegroundWindow());
    cout << GetLastError();//i get 0(no errors)

    Rectangle(a,3,4,3+80,4+20);//the rectangule is showed
    TextOut(a,10,10,"hello world",strlen("hello world"));
    cout << GetLastError();//i get 0(no errors)
    cin.get();
}

why i can show the rectangule without problems, and the text isn't showed?
(on my game i use a double buffer, but i belive these isn't the problem)

i found the problem;)
my problem was with

strlen("hello world")

if i do:

strlen("hello world")+1

the text is showed.
thanks

another question: why don't accept an empty spaces string?

(like "                       "... only show me some spaces and not all)

It probably is showing you all the spaces it is just that it is using a variable width font and so thoses spaces are not very wide.

but if i use a letter(instead spaces), shows me normaly

because letters are wider than spaces. Use a fixed-width font and it should work.

sorry how i do fixed-width font?

CreateFont() or CreateFontIndirect(). You are already calling that in the code you postged in your other thread.

Also -- you shouldn't have two threads for the same question, it just causes confusion. This is my last post in this thread.

i didn't understand what means 'fixed-width font'. now i understand.
you have right... sorry about that.
i will 'close' the thread.
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.