Jump to content

Font of controls


Recommended Posts

How can I change the font of a control made with API?

Example:

label = CreateWindow (
                            "Static",
                            "text...",
                            WS_CHILD|
                            WS_VISIBLE,
                            10,
                            230,
                            280,
                            20,
                            window,
                            LABEL,
                            hInstance,
                            NULL
                        );
Link to comment
Share on other sites

HWND window;
    HFONT font;

    font = CreateFont (
                            0,
                            0,
                            0,
                            0,
                            FW_DONTCARE,
                            FALSE,
                            FALSE,
                            FALSE,
                            ANSI_CHARSET,
                            OUT_DEFAULT_PRECIS,
                            CLIP_DEFAULT_PRECIS,
                            DEFAULT_QUALITY,
                            DEFAULT_PITCH | FF_DONTCARE,
                            "Verdana"
                       );

    if (!font)
    {
        return 0xF0;
    }

    if (!(RegisterDefaultClass(hInstance)))
    {
        return 1;
    }

    //
    // CREO LA FINESTRA
    //
    window = CreateWindow (
                                "defaultClass",
                                "Window!!",
                                WS_OVERLAPPEDWINDOW,
                                CW_USEDEFAULT,
                                0,
                                CW_USEDEFAULT,
                                0,
                                (HWND) NULL,
                                (HMENU) NULL,
                                hInstance,
                                NULL
                             );

    if (!window)
    {
        return 1;
    }

    SendMessage(window, WM_SETFONT, font, TRUE);

It runs but the font still be the default one, which is orrible XD.

Another question: how to set font size?

EDIT: all solved, thank you.

Edited by devrandom
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...