quick qustion

This is a discussion on quick qustion within the Windows Programming forums, part of the Platform Specific Boards category; (this sounds stupid) how do I sends a message to my main window?? Code: case IDM_1 sends msg?!? break; weird ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    53

    quick qustion

    (this sounds stupid) how do I sends a message to my main window??

    Code:
    	
     case IDM_1
    
    sends msg?!?
    					 
    					 
     break;
    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
    Its all a matter of willpower

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    17
    i dont know but perhaps this will help you

    SendMessage(
    HWND hWnd,
    UINT Msg,
    WPARAM wParam,
    LPARAM lParam
    );


    you can read it here at msdn:
    MSDN

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    53
    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
    Its all a matter of willpower

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    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.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Registered User
    Join Date
    Nov 2003
    Posts
    53
    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!
    Its all a matter of willpower

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    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
    Last edited by Hunter2; 02-20-2004 at 12:39 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #7
    Registered User
    Join Date
    Nov 2003
    Posts
    53
    okay thanks a lot.....I think I understand most of it
    Its all a matter of willpower

  8. #8
    Registered User
    Join Date
    Nov 2003
    Posts
    53
    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....
    Its all a matter of willpower

  9. #9
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    You use the name of the class ie. "STATIC", not STATIC

  10. #10
    Registered User
    Join Date
    Nov 2003
    Posts
    53
    ah like that! ok thanks
    Its all a matter of willpower

  11. #11
    Registered User
    Join Date
    Nov 2003
    Posts
    53
    Need a bit more help hehe

    there are 2 parameters i dont really get... :

    hInstance
    and
    lpParam

    What does it want me to put in there?
    Its all a matter of willpower

  12. #12
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    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.

  13. #13
    Registered User
    Join Date
    Nov 2003
    Posts
    53
    now I am getting this error :

    error C2078: too many initializers

    Any ideas?
    Its all a matter of willpower

  14. #14
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    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..

  15. #15
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    What's the line of code? It sounds like you might be passing too many parameters.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 10:33 AM
  3. quick qustion
    By PanzTec in forum C++ Programming
    Replies: 1
    Last Post: 11-09-2004, 08:12 AM
  4. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 09:06 AM
  5. Replies: 0
    Last Post: 04-30-2002, 07:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21