win32 GUI output

Aug 9, 2011 at 8:18pm
I'm trying to make a simple win32 GUI program which prints some text on the screen when you press a key.

I learned how to check which key was pressed pretty fast, but I just can't find any good examples which show you how to print some text.

Any one knows some good examples / tutorials?
Aug 9, 2011 at 8:24pm
Aug 9, 2011 at 8:28pm
Your question is a bit on the vague side. Can you describe what you want to do with the printed text?

If you want to display text like Notepad, you just create a an Edit control and the Window does most of the work for you.

Which compiler are you using? And IDE?

Andy

P.S. Regarding the checking of key presses, which technique were you referring to?
Aug 9, 2011 at 8:30pm
as i know GUI(graphic user interface) be used in CLR or .Net application not in win32 Unless im in wrong !! easy way use MessageBox if you use in Win32 but if you use in .Net you have several way to print some text of course Messagebox works that .
every body please help me can we use GUI in Win32 app ?!! of course without game engine or simulation of GUI such as ClanLib !
Aug 9, 2011 at 8:59pm
What I eventually want to make is a program which shows a countdown timer when you press a number. When you press 1 it starts counting down from 10, when you press 2, it counts down from 20, etc..

So what I need to know to make this is:
- how to make a keypress handler (already did this)
- how to print text in my program window
- how to make a timer function

Right now i'm stuck at "how to print text in my program window". My program checks if the '5' or '6' key is pressed and displays a messagebox saying which one of those was pressed. Now I want these messages to show in the main window and not in a message box.

I'm using Dev-Cpp.
Aug 9, 2011 at 9:02pm
ahura24 - yes, you're wrong.

The original WIN32 is a C based API that can be called from C++ code. Windowing support is part of this API.

The MessageBox() function just allows you display a popup displaying a message.
Aug 9, 2011 at 9:12pm
With a Windows program you call SetTimer() so start the timer and KillTimer() to stop it.

Are you using WM_KEYDOWN (or maybe WM_CHAR) or detect the keypress?

Andy
Last edited on Aug 9, 2011 at 9:12pm
Aug 9, 2011 at 9:14pm
Thanks for the timer tip.

I'm using WM_KEYDOWN, but what does that have to do with printing the text in the window?
Aug 9, 2011 at 9:37pm
OK...

If you've for a WM_KEYDOWN handler, it should call SetTimer specifying the required interval (1000 millisecs, maybe?)

Add a WM_TIMER message handler which:
- updates your count variable.
- calls KillTimer when it get to the end of the sequence
- calls InvalidateRect (every time)

Add a WM_PAINT message handler
- this will be called in response to the InvalidateRect call, when Windows want you to repaint your window.
- use TextOut to display your count as a string

See MSDN help on WM_TIMER, WM_PAINT for more info

Andy
Last edited on Aug 9, 2011 at 9:37pm
Aug 9, 2011 at 9:41pm
Thanks!

I think this will keep me busy for a while :)
Aug 9, 2011 at 9:47pm
I suggest you just code a WM_PAINT handler which draws fixed text first.

And then add the timer stuff!
Topic archived. No new replies allowed.