CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2000
    Posts
    4

    Coloring of edit box and button

    Is there any methods to color the Edit field and Button in VC++.


  2. #2
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    1,793

    Re: Coloring of edit box and button

    Hi..
    check the WM_CTLCOLOR message..

    Good luck
    kishk91


    kishk91@hotmail.com
    http://www.path.co.il
    ICQ: 13610258

  3. #3
    Join Date
    Aug 2000
    Location
    Madrid, Spain
    Posts
    11

    Re: Coloring of edit box and button

    You can change the color of an edit, but can't change the color of a button.

    To change the color of an edit:

    1. Define a CBrush var in your Dialog class definition.

    class CYourDlg : public Dialog
    {
    ...
    protected:
    CBrush m_brush;
    ...
    };




    2. Initialize the brush in the OnInitDialog method:

    BOOL CYourDlg::OnInitDialog()
    {
    ....
    m_brush.CreateSolidBrush(RGB(255,255,250)); // Light Yellow
    ...
    }




    3. Finally do this on the ID_CTLCOLOR handle, in the method WM_CTLCOLOR of your dialog:

    HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, nCtlColor);
    {
    ...
    switch(nCtlColor)
    {
    case CTLCOLOR_EDIT:
    pDC->SetTextColor(RGB(0,0,255)); // If you want to change the text color
    pDC->SetBkColor(RGB(0,255,0)); // If you want to change the background color
    return m_brush; // If you want to change the edit's background color
    ....
    }






    It's not possible to change the color of a button, but you can use any ActiveX to do that, or you can look for a control in codeguru.

    Good luck, and sorry for my english!


  4. #4
    Join Date
    Jan 2000
    Location
    The Netherlands, Overijssel
    Posts
    733

    Re: Coloring of edit box and button

    you should check out the example at maxcode.com
    go here:
    sourcecodes
    vcpp
    controls
    and there it is!
    it's with insource comment!

    >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
    Visit: http://www.maxcode.com/ for VC++ samples...
    >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
    [url=http://www.maxcode.com/modules.php?name=Topics] Articles [url] | [url=http://www.maxcode.com/modules.php?name=Downloads&d_op=viewdownload&cid=4]
    Compilers [url] | [url=http://www.maxcode.com/modules.php?name=Downloads]Code Samples[url]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured