I have an empty window... how do I...
1) How do I add text on the window?
2) How do I add text entry boxes and buttons? And how do I set the text in the box at the time of the button press to a variable?
thanks
I have an empty window... how do I...
1) How do I add text on the window?
2) How do I add text entry boxes and buttons? And how do I set the text in the box at the time of the button press to a variable?
thanks
One solution id DrawText().
Kuphryn
Can you give me a example please?
CRect rect;
DrawText(TEXT("Display Texts"), &rect, DT_CENTER);
Kuphryn
Errors:
1)`CRect' undeclared (first use this function)
2)`rect' undeclared (first use this function)
3) passing `const char *' as argument 1 of `DrawTextA(HDC__ *, const CHAR *, int, tagRECT *, unsigned int)'
Please post your ccode here!
Do not make direct eye contact with me.
I used exactly what kuphryn said:
Code:void posttext() { CRect rect; DrawText(TEXT("Display Texts"), &rect, DT_CENTER); }
Kuphryn's example uses MFC, I suspect you are not.
1) How do I add text on the window?
Using Win32 API: Handle the WM_PAINT message and:2) How do I add text entry boxes and buttons? And how do I set the text in the box at the time of the button press to a variable?Code:PAINTSTRUCT ps; TCHAR chTxt[]=TEXT("Hello world"); BeginPaint(hwnd,&ps); SetBkMode(ps.hdc,TRANSPARENT); TextOut(ps.hdc,20,20,chTxt,lstrlen(chTxt)); EndPaint(hwnd,&ps);
These are windows controls. You will find examples in msdn from that link, elsewhere on the web and by searching this board.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
This compiles successfully buit does not put any text
Code:void posttext() { HWND hwnd; PAINTSTRUCT ps; TCHAR chTxt[]=TEXT("Hello world"); BeginPaint(hwnd,&ps); SetBkMode(ps.hdc,TRANSPARENT); TextOut(ps.hdc,20,20,chTxt,lstrlen(chTxt)); EndPaint(hwnd,&ps); }
That should draw some text, but you need to have that within your window procedure. Somewhere, you handle WM_CLOSE, etc?
You need to handle WM_PAINT there as well. When you get a WM_PAINT, you should run that code.
I don't, how do I do that?That should draw some text, but you need to have that within your window procedure. Somewhere, you handle WM_CLOSE, etc?
Check out Adrianxw's example in this thread:
http://www.cprogramming.com/cboard/s...threadid=39836
Copying and pasting code to make a window won't help you if you don't know what any of it does. I'm sorry, but if you can't figure out where your window procedure is, go back to console.
I couldn't care less how it works if it does what I want it to do
http://www.cprogramming.com/cboard/showthread.php?threadid=39836 wont open.