Thread: wm_command

  1. #1
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161

    wm_command

    i can't seem to get window to write text when a button is clicked. i can write it normally in wm_paint but not in wm_conmand when i have created a but in wm_create. it compiles but never runs. can anybody show me a simple peice of source code which creates some kind of window, with a button which when i click it write text to the screen.

    thanks in advance
    I started out with nothing and I still have most of it left.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Use WM_COMMAND to catch the button click event. Then call SetWindowText() on an existing static text control (or text edit control) to change its text. Can also be called on the window itself to change the caption.

    To create a static text control use the class string "STATIC" ( CreateWindow("ClassName", "STATIC", ... ) ).
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User Finchie_88's Avatar
    Join Date
    Aug 2004
    Posts
    154
    here is a partial sample, u'll have to finish it off, with the print text bit, cos I can't be bothered, here is the code for the rest though
    Code:
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
            HINSTANCE g_hinst;
        switch (message)                  /* handle the messages */
        {
               case WM_CREATE:
                    CreateWindowEx(1,
                TEXT("BUTTON"),
                TEXT("A Simple Button"),
                WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON,
                7,
                5,
                480,
                40,
                hwnd,
                (HMENU)1,
                g_hinst,
                NULL
                );
                break;
               case WM_COMMAND:
                    if(LOWORD(wParam) == 1){
                    if(HIWORD(wParam) == BN_CLICKED){
                                      // Put in message output thing here //
                    }
               }
               break;
    // finish off the message switch //


Popular pages Recent additions subscribe to a feed