(this sounds stupid) how do I sends a message to my main window??
weird thing is that there seems to be no tutorials out there to answer a simple qustion like this!
been working with dialog boxes mostly so....any help on this would be great :)
i dont know but perhaps this will help you
you can read it here at msdn:
thanks but i dont think its that (or maybe i am just doing it wrong hehe)
Its very simple what I want to do, just want to print out some text on the main window :)
Is your main window a dialog box, or is it a normal window? Anyhow, there's 2 ways to print text on your window: Have a static text control on the window somewhere and use SetDlgItemText(hwndMain, IDC_MYSTATICTEXT, "some text"), or you can figure out how to use Windows GDI and call TextOut() or some other related function.
Neither way, as you can see, is exactly "simple" if you mean to print text like a console program, where it goes to the next line automatically etc. although it's somewhat easier if you're just trying to display status or something that stays in one spot.
Its a normal window
So how do i set up a static text control in the window?
Know how to do it in a dialog box but got no idea with a window :)
btw thanks for helping me out!
Well, to set up a static control in a normal window, you can call CreateWindow() and pass "STATIC" for the lpClassName parameter, include the WS_CHILD style, and pass hwndMain as the parent window. The hMenu parameter should be the control ID (you can typecast the id to HMENU type). The rest of the parameters you can fiddle with to your heart's content (i.e. add extra styles like WS_TABSTOP, and set the position/size, etc.).
As a note, all of the other common controls can also be created in a similar fashion, you just need to change "STATIC" to "EDIT", or whatever it is (a list is here). Also, for some extended styles you may need to use CreateWindowEx() instead of CreateWindow() in order to get the control to look like it did in a dialogbox.
Have fun! :)
>>btw thanks for helping me out!
You're most welcome ;)
okay thanks a lot.....I think I understand most of it ;)
weird...when i try and put STATIC as you told me it comes up and says :
'STATIC' : undeclared identifier
useing VC++ and usede the wizard to make a hello world application....
You use the name of the class ie. "STATIC", not STATIC
ah like that! ok thanks :)
Need a bit more help hehe
there are 2 parameters i dont really get... :
What does it want me to put in there?
The hInstance is the handle of your application, use GetModuleHandle(0) or GetWindowLong() to achieve this.
The lpParam is a parameter you can send to the WM_CREATE part of your new window(the static control). If you don't need to pass any parameters, simply pass 0 in this variable.
now I am getting this error :
error C2078: too many initializers
Try to check your helpfile for documentation on CreateWindowEx().
If you don't have a helpfile, try to search msdn..Here you will find all the documentation you need..
What's the line of code? It sounds like you might be passing too many parameters.