win32 application 的应用程序怎么加人程序图标?

sunmono 2001-12-03 11:16:06
怎么才能改变编译出来exe程序的图标?
...全文
813 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
wormholes 2001-12-04
  • 打赏
  • 举报
回复
还有一种简单的办法
就是作个图表,和原来默认的文件名相同
替换,呵呵
thinp 2001-12-04
  • 打赏
  • 举报
回复
我来补充一点,如果你的资源调用不成功,VC并不会提示你,而是你原来的默认文件。
再有一点刚想起来,就是也许你忘了一个东西,你的图标有两种类型,用的是同一个ID
16*16的,40*40的,你只必变了其中的一个另一个没删掉或者没有改写,当然怎么试都出来你没改的那一个,会不会你是这个问题?查查看吧!!
csky 2001-12-03
  • 打赏
  • 举报
回复
你在向导的第一部选A typical "Hello World!" application
把MyRegisterClass(HINSTANCE hInstance)里的
wcex.hIconSm= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
改为
wcex.hIconSm= LoadIcon(wcex.hInstance, (LPCTSTR)图标ID);
就行拉。
如果你选Empty就要自己写注册类,WNDPROC回调函数等等,选了HELLO WORLD 再改是一个很好的解决方法。
rainwind 2001-12-03
  • 打赏
  • 举报
回复
那就插入资源啊
Insert-->Resource

然后#include"yoursource.rc"
sunmono 2001-12-03
  • 打赏
  • 举报
回复
没有任何资源的,只有一个主函数
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
ccnuxjg 2001-12-03
  • 打赏
  • 举报
回复
你的wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_QUESTION);
有问题,改成下面的:
wcex.hIcon = LoadIcon(hInstance, "myicon");
//"myicon"是资源的ID,用字符串的形式
TigerHu 2001-12-03
  • 打赏
  • 举报
回复
用我的方法肯定行!
sunmono 2001-12-03
  • 打赏
  • 举报
回复
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = NULL;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_QUESTION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "AAA";
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_QUESTION);

RegisterClassEx(&wcex);
这样写还是不行
TigerHu 2001-12-03
  • 打赏
  • 举报
回复
在YourPrgmApp.
YourPrgmApp::InitInstance()
{
m_pMainWnd->SetIcon(
::LoadIcon(::AfxGetInstanceHandle(),(LPCTSTR)IDR_YOUR_PICTURE),TRUE);

}
waterbogie 2001-12-03
  • 打赏
  • 举报
回复
呵呵,我来补充一句,LoadIcon里的那个Icon是在.rc文件中定义的
也就是说:
在.rc中: Icon ICON "XXX.ico"(XXX.ico就是你的图标)
然后再:
wc.hIcom=LoadIcon(hInst,"Icon")就可以了...
csky 2001-12-03
  • 打赏
  • 举报
回复
在注册窗口类的时候改就行拉。
ccnuxjg 2001-12-03
  • 打赏
  • 举报
回复
WNDCLASS wc;
wc.hIcon = LoadIcon (....) ;
csky 2001-12-03
  • 打赏
  • 举报
回复
win32 application都可以用资源文件啊.
masterz 2001-12-03
  • 打赏
  • 举报
回复
Updating Resources
The following example copies a dialog box resource from one executable file, Hand.exe, to another, Foot.exe, by following these steps:

Use the LoadLibrary function to load the executable file Hand.exe.
Use the FindResource and LoadResource functions to locate and load the dialog box resource.
Use the LockResource function to retrieve a pointer to the dialog box resource data.
Use the BeginUpdateResource function to open an update handle to Foot.exe.
Use the UpdateResource function to copy the dialog box resource from Hand.exe to Foot.exe.
Use the EndUpdateResource function to complete the update.
The following code implements these steps.

HRSRC hResLoad; // handle to loaded resource
HANDLE hExe; // handle to existing .EXE file
HRSRC hRes; // handle/ptr. to res. info. in hExe
HANDLE hUpdateRes; // update resource handle
char *lpResLock; // pointer to resource data
BOOL result;
// Load the .EXE file that contains the dialog box you want to copy.
hExe = LoadLibrary("hand.exe");
if (hExe == NULL)
{
ErrorHandler("Could not load exe.");
}

// Locate the dialog box resource in the .EXE file.
hRes = FindResource(hExe, "AboutBox", RT_DIALOG);
if (hRes == NULL)
{
ErrorHandler("Could not locate dialog box.");
}

// Load the dialog box into global memory.
hResLoad = LoadResource(hExe, hRes);
if (hResLoad == NULL)
{
ErrorHandler("Could not load dialog box.");
}

// Lock the dialog box into global memory.
lpResLock = LockResource(hResLoad);
if (lpResLock == NULL)
{
ErrorHandler("Could not lock dialog box.");
}

// Open the file to which you want to add the dialog box resource.
hUpdateRes = BeginUpdateResource("foot.exe", FALSE);
if (hUpdateRes == NULL)
{
ErrorHandler("Could not open file for writing.");
}

// Add the dialog box resource to the update list.
result = UpdateResource(hUpdateRes, // update resource handle
RT_DIALOG, // change dialog box resource
"AboutBox", // dialog box name
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), // neutral language
lpResLock, // ptr to resource info
SizeofResource(hExe, hRes)); // size of resource info.
if (result == FALSE)
{
ErrorHandler("Could not add resource.");
}

// Write changes to FOOT.EXE and then close it.
if (!EndUpdateResource(hUpdateRes, FALSE))
{
ErrorHandler("Could not write changes to file.");
}

// Clean up.
if (!FreeLibrary(hExe))
{
ErrorHandler("Could not free executable.");
}
sunmono 2001-12-03
  • 打赏
  • 举报
回复
我重申这是一个win32的application应用程序
没有用到资源文件,
csky 2001-12-03
  • 打赏
  • 举报
回复
那你有没有在资源里加那个icon啊?
yheysj 2001-12-03
  • 打赏
  • 举报
回复
县插入图标,而后呢,在用
wc.hIcon = LoadIcon(hInstance, "myicon");
来进行载入!!不过呢,你可以在给予对话框的程序中,来进行图表操作,似乎简单一点!
用mfc 来做!!好吗??共同学习!!ok??
sunmono 2001-12-03
  • 打赏
  • 举报
回复
我就是按照hello world那样写!

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧