如何根据路径加载ico图片,在程序的左上角的 程序图标
这样加载的话 需要编译的
HICON m_hIcon=AfxGetApp()->LoadIcon(IDI_ICONOLD);
m_pMainWnd->SetIcon(m_hIcon,false); 可不可以更具指定的图片路径 加载这个ico文件???
请知道说的说下……
这样加载的话 需要编译的
HICON m_hIcon=AfxGetApp()->LoadIcon(IDI_ICONOLD);
m_pMainWnd->SetIcon(m_hIcon,false); 可不可以更具指定的图片路径 加载这个ico文件???
请知道说的说下……
如果我没记错的哈哈哈哈哈哈啊哈哈哈哈哈
使用这个!!!!!
参数为
IMAGE_ICON
及
LR_LOADFROMFILELoadImage Function--------------------------------------------------------------------------------Loads an icon, cursor, animated cursor, or bitmap.SyntaxHANDLE LoadImage( HINSTANCE hinst,
LPCTSTR lpszName,
UINT uType,
int cxDesired,
int cyDesired,
UINT fuLoad
);
The LoadIcon function loads the specified icon resource from the executable (.exe) file associated with an application instance.Note This function hase been superseded by the LoadImage function.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
谢了
但是 MFC程序在那里
HICON hIcon = (HICON)::LoadImage(NULL, (LPCTSTR)szIcoPath, IMAGE_ICON, 20, 20, LR_LOADFROMFILE);
m_pMainWnd->SetIcon(hIcon,false);
调用呢? 我在app类的 InitInstance()函数里面调用 但是没有马上变 而是 启动了2到3秒后才变的 请问我改在那里调用呢?
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);之前
函数里面的
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
执行后程序就显示出来了,这个时候的程序logo不是我想要的
我现在只能在上诉代码后添加
char szIcoPath[MAX_PATH];
sprintf(szIcoPath, "%scg.ico", g_dll.GetRunPath());
HICON hIcon = (HICON)::LoadImage(NULL, (LPCTSTR)szIcoPath, IMAGE_ICON, 20, 20, LR_LOADFROMFILE);
m_pMainWnd->SetIcon(hIcon,false);
实现加载我自己的logo图片
但是这个就有一个图片切换的过程 很容易就看出来了……
//如果在ProcessShellCommand函数前添加m_pMainWnd就是NULL会报错!
那个能帮我想想办法 把setico改放在那个位置 在程序显示出来前就设置成我自己定义的ico
函数里面的
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
执行后程序就显示出来了,这个时候的程序logo不是我想要的
我现在只能在上诉代码后添加
char szIcoPath[MAX_PATH];
sprintf(szIcoPath, "%scg.ico", g_dll.GetRunPath());
HICON hIcon = (HICON)::LoadImage(NULL, (LPCTSTR)szIcoPath, IMAGE_ICON, 20, 20, LR_LOADFROMFILE);
m_pMainWnd->SetIcon(hIcon,false);
实现加载我自己的logo图片
但是这个就有一个图片切换的过程 很容易就看出来了……
//如果在ProcessShellCommand函数前添加m_pMainWnd就是NULL会报错!
那个能帮我想想办法 把setico改放在那个位置 在程序显示出来前就设置成我自己定义的ico
sprintf(szIcoPath, "%scg.ico", g_dll.GetRunPath());
HICON hIcon = (HICON)::LoadImage(NULL, (LPCTSTR)szIcoPath, IMAGE_ICON, 20, 20, LR_LOADFROMFILE);
CxxxApp* pMainFrame = new CxxxApp;
if (!pMainFrame || !pMainFrame->SetIcon(hIcon,false))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);if (!ProcessShellCommand(cmdInfo))
return FALSE;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();return TRUE;恩,你可以试试看。