VC createwindow: create a window control and set the font

Source: Internet
Author: User

 

VC createwindow: create a window control and set the font
Hwnd hbtn, hedit, htext, hcombbox; hbtn = createwindow (// click to create "button", "Create button", ws_child | ws_visible | bs_pushbutton | bs_center | bs_vcenter, 100,100, 90,28, m_hwnd, null, AfxGetInstanceHandle (), 0); hedit = createwindow (// Edit Control "edit", "CREATE ", ws_visible | ws_child | ws_border/* | dt_center */| dt_vcenter, m_hwnd, null); hfont = (hfont) getstockobject (default_gui_font );:: sendmessage (hedit, wm_setfont, (wparam) hfont, 1); // set the control Font: sendmessage (hbtn, wm_setfont, (wparam) hfont, 1 ); hcombbox = createwindow ("ComboBox", "1", ws_child | ws_visible | ws_border | cbs_autohscroll | cbs_dropdownlist, 220,100,100, 25, m_hwnd, null );

 

1. Solutions to font size problems:
Create a font that you want.
Hfont = (hfont) getstockobject (default_gui_font );

Then send a message to edit.
Sendmessage (mhagreementhand, wm_setfont, (wparam) hnewfont, 1 );

2. For background color issues, simply return a black image in the wm_ctlcolorstatic message of the parent window.
Hbrush HBr = (hbrush) getstockobject (black_brush );
Return (lresult) HBr;

 

Function body

HWND CreateWindow(

    LPCTSTR lpClassName, // pointer to registered class name

    LPCTSTR lpWindowName, // pointer to window name

    DWORD dwStyle, // window style

    int x, // horizontal position of window

    int y, // vertical position of window

    int nWidth, // window width

    int nHeight, // window height

    HWND hWndParent, // handle to parent or owner window

    HMENU hMenu, // handle to menu or child-window identifier

    HANDLE hInstance, // handle to application instance

    LPVOID lpParam // pointer to window-creation data

);

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.