gw7rib
4/13/2011 9:26:00 PM
On Apr 13, 4:56 pm, Wonyong <ds1...@gmail.com> wrote:
> #include <stdio.h>
> int main()
> {
> printf("Hello, World!\n");
> system("Pause");
> return 0;
>
> }
>
> I install Visual C++ 2010 Express, now.
>
> And, I test above source.
>
> So, I want to output "Hello, World!" at window (such as Notepad), not
> commandline.
>
> How to?
>
> I am begginer. :)
As Keith has said, this is more to do with Windows than with the C
language, and so you are likely to get better answers in a Windows
newsgroup. I use comp.os.ms-windows.programmer.win32 as well, though
I'm not sure if it's the best one (there seems an awful lot of them).
But, to whet your appetite...
I think what you are asking is how to write a proper Windows program
rather than a console application. (I could be wrong here - I've never
written a console application myself.) Anyhow, to do this (at least in
Visual C++ 2005, I hope it's not too different now) do:
File > New > Project
Select "Win32" and "Win32 console application" and choose a suitable
name
Click OK, then Next
Select "Windows application" and click "Finish"
This will give you a sample application - it will put up a window, and
let you select File > Exit or Help > About.
To print "Hello world!", look through the code until you find a
function WndProc with the following in it:
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
and where the comment is, add:
TextOut(hdc, 10, 10, _TEXT("Hello world!"), 11);
(The 10s are the position, the 11 is the length of text to print.)
And you're done!
But writing a proper Windows program does need a lot of effort,
including in finding out how the program is supposed to work. I'd
recommend a good book, such as Programming Windows by Charles Petzold.
Hope this is useful.
Paul.