鱼C论坛

 找回密码
 立即注册
查看: 2800|回复: 2

vc6 自己手动建rc文件 自定义图标不能加载

[复制链接]
发表于 2012-4-12 16:08:59 | 显示全部楼层 |阅读模式
3鱼币
file:///c:/2.jpgfile:///c:/3.jpg
//window_eg.cpp - a complete window program
//includes///////////////////////////////////////////////////////////////////////////////////////////////////////
# include <windows.h>         //all window include
# include <windowsx.h>        //useful macros
# include <stdio.h>
# include <math.h>
# include "resource.h"
//define////////////////////////////////////////////////////////////////////////////////////////////////////////
//define for window
# define WINDOW_CLASS_NAME "WINCLASS1"
//functions////////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WindowProc(HWND hwnd,
       UINT msg, WPARAM wparam,
           LPARAM lparam)
{
//this is main message handler of the system
PAINTSTRUCT ps; //used in WM_PAINT
HDC         hdc; //handle to a device context
HINSTANCE   hinstance;
//char load_string[80];
switch(msg)
{
case WM_CREATE:
  {
   //do initialization stuff here
   //LoadString(hinstance, IDS_STRING_LOAD_GAME, load_string, 80);
   //return success
   return 0;
  }
break;
case WM_PAINT:
  {
   //simply validate the window
   hdc = BeginPaint(hwnd, &ps);
   //you would do all your painting here
   EndPaint(hwnd, &ps);
   //return success
   return 0;
  }
break;
case WM_DESTROY:
  {
   //kill the application this send a WM_QUIT message
   PostQuitMessage(0);
   //return success
   return 0;
  }
break;
default:
  break;
}//end switch
return(DefWindowProc(hwnd, msg, wparam, lparam));
}//end winproc

//winmain////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hinstance,
       HINSTANCE hprevinstance,
       LPSTR lpcmdline,
       int ncmdshow)
{
WNDCLASSEX winclass;//this will hold the class we create
HWND hwnd;          //generic window handle
MSG  msg;           //generic messgae
//first fill int the window class structure
winclass.cbSize = sizeof(WNDCLASSEX);  //size of this structure
winclass.style = CS_DBLCLKS | CS_OWNDC | //style flage
  CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;    //function pointer to handler
winclass.cbClsExtra  = 0;   //extra class info
winclass.cbWndExtra  = 0;   //extra window info
winclass.hInstance  = hinstance; //the instance of the application
winclass.hIcon   = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ICON1)); //the main icon
winclass.hCursor   = LoadCursor(hinstance, MAKEINTRESOURCE(IDC_CURSOR1));  //the cursor for the window
winclass.hbrBackground  = (HBRUSH)GetStockObject(BLACK_BRUSH); //the cursor for the window
winclass.lpszMenuName   = NULL;         //the background brush to paint the window
winclass.lpszClassName  = WINDOW_CLASS_NAME;     //the name of the menu to attach
winclass.hIconSm  = LoadIcon(NULL, IDI_APPLICATION);  //the handle of the small icon

//register the window class
if(!RegisterClassEx(&winclass))
  return 0;
//create the window
if(!(hwnd = CreateWindowEx(NULL,
        WINDOW_CLASS_NAME,
        "My basic window",
        WS_OVERLAPPEDWINDOW | WS_VISIBLE,
        0,0,
        400,400,
        NULL,
        NULL,
        hinstance,
        NULL)))
return 0;
//enter main event loop
while(GetMessage(&msg, NULL, 0, 0))
{
  TranslateMessage(&msg);

  DispatchMessage(&msg);
}
return(msg.wParam);
}
//error
//libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main .(.g.d){j.  
//libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main .*.+oJ.(e.  

//Windows项目要使用Windows子系统, 而不是Console, 可以这样设置
//[Project] --> [Settings] --> 选择"Link"属性页
//在Project Options中将/subsystem:console改成/subsystem:windows  
// winclass.hbrBackground  = (HBRUSH)GetStockObject(WHITE_BRUSH);   type to change

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2012-4-12 19:54:41 | 显示全部楼层
搞了一天 原来是hiconsm结构成员。。。搞了hicon
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-1-21 13:34:54 | 显示全部楼层
学习学习
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-25 13:40

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表