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

    Using an icon as a button's face

    I have a class derived from CDaoRecordView with two buttons on it. I want to use icons I made as the faces of these buttons. In my CMyRecordView::OnInitialUpdate() I have the following code:

    CButton *curButton = (CButton*)GetDlgItem(IDC_BUTTON_CV_ADD);
    curButton->SetIcon(::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON_CV_ADD)));
    // curButton->UpdateData();

    curButton = (CButton*)GetDlgItem(IDC_BUTTON_CV_SUB);
    curButton->SetIcon(::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON_CV_SUB)));
    // curButton->UpdateData();



    But when I run my program I have two blank buttons. How do I get the icons to show up correctly?

    Thanks,
    Erik


  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Using an icon as a button's face

    Did you check appropriate style of the button in resource editor? It must be set to Icon.


    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    Aug 1999
    Location
    Michigan
    Posts
    37

    Re: Using an icon as a button's face

    Yes I did.


  4. #4
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Using an icon as a button's face

    Got it. I have overlooked something.
    Change:


    curButton->SetIcon(::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON_CV_ADD)));




    To:


    curButton->SetIcon(::LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON_CV_ADD)));






    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

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