sohel14_cse_ju
sohel14_cse_ju

Reputation: 2521

Set Icon on Statictext Control

How to Set and Icon on a StaticText Control in MFC ?

I am trying with :

  static_cast<CStaticText*>(txt)->SetIcon(AfxGetApp()->LoadIcon(IDC_ICON));

The Line of code is executed. But the textcontrol is now showing the icon.

Am I missing anything ?

Upvotes: 0

Views: 1884

Answers (2)

sohel14_cse_ju
sohel14_cse_ju

Reputation: 2521

    CButton* btn
    btn->SetIcon(AfxGetApp()->LoadIcon(IDI_IMG));

Upvotes: 0

hypheni
hypheni

Reputation: 816

Make sure you dropped a Static Image/Icon control over your dialog instead of Static Text control.

You can verify from resource file:

BEGIN
    CTEXT           "",IDC_STATIC_ICON1,10,84,300,20
    ICON            "",IDC_STATIC_ICON2,102,137,20,20
END

First one is Text type and second is Icon. You should use second one.

Upvotes: 1

Related Questions