Click here to Skip to main content
15,886,110 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: icon on button not displayed in XP. Pin
Richard MacCutchan7-Feb-13 23:07
mveRichard MacCutchan7-Feb-13 23:07 
GeneralRe: icon on button not displayed in XP. Pin
VCProgrammer7-Feb-13 23:52
VCProgrammer7-Feb-13 23:52 
GeneralRe: icon on button not displayed in XP. Pin
Richard MacCutchan8-Feb-13 0:37
mveRichard MacCutchan8-Feb-13 0:37 
GeneralRe: icon on button not displayed in XP. Pin
VCProgrammer8-Feb-13 1:15
VCProgrammer8-Feb-13 1:15 
GeneralRe: icon on button not displayed in XP. Pin
Richard MacCutchan8-Feb-13 1:21
mveRichard MacCutchan8-Feb-13 1:21 
JokeRe: icon on button not displayed in XP. Pin
David Crow8-Feb-13 2:38
David Crow8-Feb-13 2:38 
JokeRe: icon on button not displayed in XP. Pin
Richard MacCutchan8-Feb-13 5:16
mveRichard MacCutchan8-Feb-13 5:16 
GeneralRe: icon on button not displayed in XP. Pin
VCProgrammer8-Feb-13 20:33
VCProgrammer8-Feb-13 20:33 
in my test application for button icon:

i have 2 Icon,load them in resource with id IDI_ICON1,and IDI_ICON2

2 buttons :CButton m_btn;
CButton m_btn2; on which i wan to set the icon

if i set the icon style true for buth buttons its working fine and display the icon on button in XP.

but when i FALSE the ICON style for button and run this application,only text of button is display not the icon on button.

now please help,if want something more please tel me what information i provide you to better assist me...

BOOL CBtnIconDlg::OnInitDialog()
{

        HICON hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
	
	AfxMessageBox(ErrorMsg());//here i get GetLastError =0 (The operation completed successfully.)
	if(hIcon)
	{
		//ok valid icon found
	}
	else
	{
		AfxMessageBox(_T("NULL hIcon"));//this not popup
	}
		
	m_btn.SetIcon(hIcon);	
	AfxMessageBox(ErrorMsg());//here i get GetLastError =87 (The parameter is incorrect.)
	
	HICON icon =NULL;
	HINSTANCE	hInstResource	= NULL;	
	hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE(IDI_ICON2), RT_GROUP_ICON);
	
	AfxMessageBox(ErrorMsg());//here i get GetLastError =0 (The operation completed successfully.)

	if(hInstResource)
	{
		//ok valid hInstResource found
	}
	else
	{
		AfxMessageBox(_T("hInstResource null"));//this not popup
	}
	
	icon = (HICON) LoadImage(hInstResource,
							MAKEINTRESOURCE(IDI_ICON2),
							IMAGE_ICON,
							16,
							16,
							LR_DEFAULTCOLOR); 

	
	AfxMessageBox(ErrorMsg());//here i get GetLastError =0 (The operation completed successfully.)
	if(icon )
	{
		//valid icon 
	}
	else
	{
		AfxMessageBox(_T("NULL icon "));//this not popup
	}
		
	m_btn2.SetIcon(icon);
	
	AfxMessageBox(ErrorMsg());//here i get GetLastError =87 (The parameter is incorrect.)

        return TRUE;
}

CString CBtnIconDlg::ErrorMsg()
{
	CString ret_msg=_T("");

	LPVOID lpMsgBuf;
	HRESULT hr;

	hr = GetLastError();

	ret_msg.Format(_T("%d :: "),GetLastError());
	
	FormatMessage( 
		FORMAT_MESSAGE_ALLOCATE_BUFFER | 
		FORMAT_MESSAGE_FROM_SYSTEM | 
		FORMAT_MESSAGE_IGNORE_INSERTS,
		NULL,
		hr,
		0, // Default language
		(LPTSTR) &lpMsgBuf,
		0,
		NULL 
	);

	ret_msg+=(LPCTSTR)lpMsgBuf;	
	LocalFree( lpMsgBuf);

	return ret_msg;
}

GeneralRe: icon on button not displayed in XP. Pin
Richard MacCutchan8-Feb-13 22:42
mveRichard MacCutchan8-Feb-13 22:42 
GeneralRe: icon on button not displayed in XP. Pin
VCProgrammer9-Feb-13 1:00
VCProgrammer9-Feb-13 1:00 
GeneralRe: icon on button not displayed in XP. Pin
Richard MacCutchan9-Feb-13 1:08
mveRichard MacCutchan9-Feb-13 1:08 
GeneralRe: icon on button not displayed in XP. Pin
VCProgrammer9-Feb-13 1:20
VCProgrammer9-Feb-13 1:20 
GeneralRe: icon on button not displayed in XP. Pin
Richard MacCutchan9-Feb-13 1:30
mveRichard MacCutchan9-Feb-13 1:30 
GeneralRe: icon on button not displayed in XP. Pin
VCProgrammer9-Feb-13 1:36
VCProgrammer9-Feb-13 1:36 
GeneralRe: icon on button not displayed in XP. Pin
Richard MacCutchan9-Feb-13 2:05
mveRichard MacCutchan9-Feb-13 2:05 
GeneralRe: icon on button not displayed in XP. Pin
VCProgrammer10-Feb-13 20:31
VCProgrammer10-Feb-13 20:31 
GeneralRe: icon on button not displayed in XP. Pin
Richard MacCutchan11-Feb-13 0:35
mveRichard MacCutchan11-Feb-13 0:35 
GeneralRe: icon on button not displayed in XP. Pin
VCProgrammer11-Feb-13 20:29
VCProgrammer11-Feb-13 20:29 
GeneralRe: icon on button not displayed in XP. Pin
Richard MacCutchan11-Feb-13 22:13
mveRichard MacCutchan11-Feb-13 22:13 
GeneralRe: icon on button not displayed in XP. Pin
Richard MacCutchan12-Feb-13 9:37
mveRichard MacCutchan12-Feb-13 9:37 
GeneralRe: icon on button not displayed in XP. Pin
VCProgrammer12-Feb-13 19:59
VCProgrammer12-Feb-13 19:59 
QuestionShellExecute Problem Pin
LFK_Michael4-Feb-13 22:56
LFK_Michael4-Feb-13 22:56 
AnswerRe: ShellExecute Problem Pin
Richard MacCutchan5-Feb-13 0:00
mveRichard MacCutchan5-Feb-13 0:00 
GeneralRe: ShellExecute Problem Pin
LFK_Michael5-Feb-13 0:16
LFK_Michael5-Feb-13 0:16 
GeneralRe: ShellExecute Problem Pin
Richard MacCutchan5-Feb-13 0:26
mveRichard MacCutchan5-Feb-13 0:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.