如何直接从内存块中得到一个ICON handle roland_c,你的方法是通过得到图标而绘制的,不用句柄的话,应该用什么?请说说具体过程 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 回去查了一下书,可以直接使用ExtractIcon(hInst,lpszExe,index)hInst是程序实例句柄,lpszExe是包含图标的exe或DLL或ICO文件的文件名,index为图标在文件中的索引号。我试了一下,示例如下:// icon.cpp : Defines the entry point for the application.//#include "stdafx.h"#include "windows.h"#include "shellapi.h"HINSTANCE hInst;LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ // TODO: Place code here. static TCHAR szAppName[]=TEXT("Icon Demo"); HWND hwnd; MSG msg; WNDCLASS wndclass; hInst=hInstance; wndclass.style=CS_HREDRAW|CS_VREDRAW; wndclass.lpfnWndProc=WndProc; wndclass.cbClsExtra=0; wndclass.cbWndExtra=0; wndclass.hInstance=hInstance; wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION); wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName=NULL; wndclass.lpszClassName=szAppName; if(!RegisterClass(&wndclass)) { MessageBox(NULL,TEXT("This program requires Windows NT!"),szAppName,MB_ICONERROR); return 0; } hwnd=CreateWindow(szAppName,TEXT("Icon Demostration"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL); ShowWindow(hwnd,nCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam;}LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){ PAINTSTRUCT ps; static HICON hIcon; HDC hdc; switch(message) { case WM_CREATE: hIcon=ExtractIcon(hInst,"e:\\mydoc\\x.ico",0); return 0; case WM_PAINT: hdc=BeginPaint(hwnd,&ps); DrawIcon(hdc,10,10,hIcon); EndPaint(hwnd,&ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,message,wParam,lParam);} 这个方法好,可以直接从ico文件获得icon句柄来绘图。对于有很多图标的这个事例正是再适合不过了。 已知IP,求网络运营商 c 语言中的UNION结构体的用法?请赐教! 在已有工作区中在插入一个外部工程后LNK2001错误 VS.net2003中,调试控制台程序如何让他出现类似vc6的Press any key to continue字样? 请问如何在word里嵌入一个工具条 各位,我在读一个实时监控的程序,但是不知道如何下手? vc源文件大小超标的问题 文件拷备问题.在线等待!立即给分!!! 调查一下,有没有人是做CAD/CAM开发的或相关的,用什么开发工具,在哪个城市,什么公司 关于CCheckListBox的问题 请高手回答简单问题。 请简短讨论 const 和 static
hInst是程序实例句柄,lpszExe是包含图标的exe或DLL或ICO文件的文件名,index为图标在文件中的索引号。我试了一下,示例如下:
// icon.cpp : Defines the entry point for the application.
//#include "stdafx.h"
#include "windows.h"
#include "shellapi.h"HINSTANCE hInst;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
static TCHAR szAppName[]=TEXT("Icon Demo");
HWND hwnd;
MSG msg;
WNDCLASS wndclass; hInst=hInstance; wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName; if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("This program requires Windows NT!"),szAppName,MB_ICONERROR);
return 0;
} hwnd=CreateWindow(szAppName,TEXT("Icon Demostration"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT ps;
static HICON hIcon;
HDC hdc; switch(message)
{
case WM_CREATE:
hIcon=ExtractIcon(hInst,"e:\\mydoc\\x.ico",0);
return 0; case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
DrawIcon(hdc,10,10,hIcon);
EndPaint(hwnd,&ps); return 0; case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}