Idc_static font change

This is a discussion on Idc_static font change within the Windows Programming forums, part of the Platform Specific Boards category; Ok, I defined IDC_STATIC in my resource.h file like this: Code: #define IDC_STATIC -1 Then I created a dialog box, ...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    11

    Idc_static font change

    Ok, I defined IDC_STATIC in my resource.h file like this:

    Code:
    #define IDC_STATIC   -1
    Then I created a dialog box, and at runtime, I have created bunch of controls. Here's a sample code:

    Code:
    case WM_INITDIALOG:
    .
    .
    .
    
    CreateWindow("STATIC", "Sentence1", WS_CHILD | WS_VISIBLE, 10, 40, 50, 15, hwnd,
    	(HMENU)IDC_STATIC, NULL, NULL);
    
    SendDlgItemMessage(hwnd, IDC_STATIC, WM_SETFONT, (WPARAM)textFont, 0);
    
    CreateWindow("STATIC", "Sentence2", WS_CHILD | WS_VISIBLE, 10, 40, 50, 15, hwnd,
    	(HMENU)IDC_STATIC, NULL, NULL);
    
    SendDlgItemMessage(hwnd, IDC_STATIC, WM_SETFONT, (WPARAM)textFont, 0);
    break;
    Now the problem is, the font of first STATIC control is sucessfully changed while the second control's remains the same. Is it because I used IDC_STATIC twice? What is the the right way of doing this? by defining another control?

    Thanks!
    Last edited by Prads; 03-12-2010 at 02:33 AM. Reason: I thought that title was little unclear before

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Prads View Post
    Now the problem is, the font of first STATIC control is sucessfully changed while the second control's remains the same. Is it because I used IDC_STATIC twice?
    No, IDC_STATIC is replaced by the preprocessor with "-1" everywhere it occurs in your code.

    Looks like this is a winapi function question/problem, which I know nothing about.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    11
    Hmmm.... then I will make a handle myself like this: HWND dlgHandle = CreateWindow(...) and then use that handle with SendMessage() function to change font.

    If there are any other way, please tell me. Thanks!

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    so you created the 2 controls using same ID
    SendDlgItemMessage cannot distinguish them

    or use different ID or use the hwnd of each control and SendDlgMessage
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Registered User UltraKing227's Avatar
    Join Date
    Jan 2010
    Location
    USA, New york
    Posts
    123
    yep, this topic should have been in the Windows Programming board.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,743
    Right, and so this thread has been moved.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Mar 2010
    Posts
    11
    I am so sorry I posted the thread in wrong place. Won't happen again.

    Yeah, I think I will create a new handle. Thanks!

Popular pages Recent additions subscribe to a feed

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