static text won't change

This is a discussion on static text won't change within the Windows Programming forums, part of the Platform Specific Boards category; I have a dialogbox that pops up containing two static text controls and a text edit control. Now I want ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    380

    static text won't change

    I have a dialogbox that pops up containing two static text controls and a text edit control. Now I want to change the content of the second static control.

    Here's what I have tried:

    In my resource .h
    #define IDC_SCORE 103 // second static text control
    #define IDC_TEXT1 104

    my resource script
    LTEXT "Your score:", IDC_TEXT1, 18, 3, 39, 10
    LTEXT "0", IDC_SCORE, 58, 3, 29, 10 // second static text control

    Now in my dialogProcedure while handling the WM_INITDIALOG message i call SetDlgItemInt(hwnd, IDC_SCORE,score, FALSE );

    But it doesn't change from zero to the new value.

    From reading a previous discussion on this topic I can't see anything wrong with my code. Maybe you can?

    I'm also including an attachment with the code. It's mostly in the hiscore.c in the add_highscore().
    Attached Files Attached Files
    Don't you dare hit me on the head, you know I'm not normal.
    A Stooge Site
    Green Frog Software

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    32
    SetDlgItemInt? You can only SetDialogItemText on a string, can't you?
    Try an itoa() to turn an integer to a string.
    - Tigs

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    Will I tried you suggestion and still didn't work.

    Here's the code I wrote using your suggestion.

    char buffer[20];
    itoa(score,buffer,10);
    SetDlgItemText(hwnd,IDC_SCORE, buffer);
    Don't you dare hit me on the head, you know I'm not normal.
    A Stooge Site
    Green Frog Software

  4. #4
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218
    The only thing i can suggest to you:

    SetFocus(static window);
    before inserting the new value in it.its a very faint chance.
    because no focus is needed for this kind of window.

    but in your dlg why are you returning TRUE for default msgs?

    are you processing all the msgs intended for
    the dlg in your dlg proc. all of it?
    i dont think so.change it to FALSE & see what happens.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    Ok. I have solved my problem by creating a new static text control and removing the old one.

    As for why I'm returning TRUE for default messages, I don't really know yet. I'm following theForger's tutorial.

    Thank all for your help.
    Don't you dare hit me on the head, you know I'm not normal.
    A Stooge Site
    Green Frog Software

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 03:17 PM
  2. Easily change text color
    By d00b in forum C++ Programming
    Replies: 10
    Last Post: 07-24-2005, 06:24 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  4. Change a line of text eash first char to uppercase
    By zp523444 in forum C Programming
    Replies: 17
    Last Post: 03-15-2004, 07:43 PM
  5. changing static text
    By codec in forum Windows Programming
    Replies: 2
    Last Post: 03-23-2002, 09:45 PM

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