| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 568 人关注过本帖
标题:[求助]关于加载自定义图标的问题]
只看楼主 加入收藏
lucis009
Rank: 1
等 级:新手上路
帖 子:181
专家分:0
注 册:2007-5-2
收藏
 问题点数:0 回复次数:0 
[求助]关于加载自定义图标的问题]
#include<Windows.h>
#include<stdio.h>
#define IDI_ICON1 WM_USER+1
#define IDC_CURSOR2 WM_USER+2
//HICON hIcon;
LRESULT CALLBACK WindowProc(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
);
int WINAPI WinMain(
  HINSTANCE hInstance,      // handle to current instance
  HINSTANCE hPrevInstance,  // handle to previous instance
  LPSTR lpCmdLine,          // command line
  int nCmdShow              // show state
)
{
    WNDCLASS wndclass;
    wndclass.cbClsExtra=0;
    wndclass.cbWndExtra=0;
    wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
    wndclass.hCursor=LoadCursor(hInstance,MAKEINTRESOURCE(IDC_CURSOR2));/*为什么我定义的自定义图标和自定义的光标都加载不了?*/
    wndclass.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
    wndclass.hInstance=hInstance;
    wndclass.lpfnWndProc=WindowProc;
    wndclass.lpszClassName="lucis";
    wndclass.lpszMenuName="Menu";
    wndclass.style=CS_VREDRAW|CS_HREDRAW;
    RegisterClass(&wndclass);

    HWND hwnd;
    hwnd=CreateWindow("lucis","Test",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,
        CW_USEDEFAULT,500,500,NULL,NULL,hInstance,NULL);

    ShowWindow(hwnd,SW_SHOW);

    UpdateWindow(hwnd);
    MSG msg;
    while(GetMessage(&msg,NULL,0,0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}
LRESULT CALLBACK WindowProc(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
)
{
    switch(uMsg)
    {
    case WM_CHAR:
        char ch[20];
        sprintf(ch,"Char is %d",wParam);
        MessageBox(hwnd,ch,"Test",MB_OK);
        break;
    case WM_CLOSE:
        if(IDYES==MessageBox(hwnd,"Are you sure to quit?","Exit",MB_YESNO))
        {
            DestroyWindow(hwnd);
        }
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    case WM_PAINT:
        HDC hdc;
        PAINTSTRUCT paint;
        hdc=BeginPaint(hwnd,&paint);
        SetTextColor(hdc,RGB(0,0,255));
        SetBkColor(hdc,RGB(255,255,255));
        SetBkMode(hdc,OPAQUE);


        TextOut(hdc,0,0,"I have a test this afternoon!",strlen("I have a test this aftenoon!"));

        EndPaint(hwnd,&paint);
        break;
    case WM_LBUTTONDOWN:
        MessageBox(hwnd,"The test is successfully","Your success",MB_ICONWARNING);
        break;
    default:
        return DefWindowProc(hwnd,uMsg,wParam,lParam);
        break;
    }
    return 0;
}
搜索更多相关主题的帖子: 加载 定义 图标 
2007-12-26 00:26
快速回复:[求助]关于加载自定义图标的问题]
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036719 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved