CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

请问如何显示一副“*.ico”图像?

楼主ilovesnow()2002-04-15 16:19:33 在 VC/MFC / 基础类 提问

请问:  
   
          如何在对话框中,调用显示一副“*.ico”图像?()注意;不是*.bmp     !!!  
   
          希望高手指点!  
   
              一定给分! 问题点数:90、回复次数:10Top

1 楼cz()回复于 2002-04-15 16:57:32 得分 6

::LoadIcon()  
   
  ::DrawIcon()Top

2 楼quengzi(Hades)回复于 2002-04-15 17:06:40 得分 16

HICON   LoadIcon(   LPCTSTR   lpszResourceName   )   const;  
   
  HICON   LoadIcon(   UINT   nIDResource   )   const;  
   
  HICON   LoadStandardIcon(   LPCTSTR   lpszIconName   )   const;  
  HICON   LoadOEMIcon(   UINT   nIDIcon   )   const;  
   
  BOOL   DrawIcon(   int   x,   int   y,   HICON   hIcon   );  
   
  BOOL   DrawIcon(   POINT   point,   HICON   hIcon   );  
   
  if   (IsIconic())  
  {  
        CPaintDC   dc(this);   //   device   context   for   painting  
   
        IconEraseBkgnd(dc);  
   
        //   Center   icon   in   client   rectangle  
        int   cxIcon   =   GetSystemMetrics(SM_CXICON);  
        int   cyIcon   =   GetSystemMetrics(SM_CYICON);  
        CRect   rect;  
        GetClientRect(&rect);  
        int   x   =   (rect.Width()   -   cxIcon   +   1)   /   2;  
        int   y   =   (rect.Height()   -   cyIcon   +   1)   /   2;  
   
        //   Draw   the   icon  
        dc.DrawIcon(x,   y,   m_hIcon);  
  }  
  HICON   CreateIcon(  
      HINSTANCE   hInstance,         //   handle   to   application   instance  
      int   nWidth,                           //   icon   width  
      int   nHeight,                         //   icon   height  
      BYTE   cPlanes,                       //   number   of   planes   in   XOR   bitmask  
      BYTE   cBitsPixel,                 //   number   of   BPP   in   XOR   bitmask  
      CONST   BYTE   *lpbANDbits,   //   AND   bitmask  
      CONST   BYTE   *lpbXORbits     //   XOR   bitmask  
  );  
  Parameters  
  hInstance    
  [in]   Handle   to   the   instance   of   the   module   creating   the   icon.    
  nWidth    
  [in]   Specifies   the   width,   in   pixels,   of   the   icon.    
  nHeight    
  [in]   Specifies   the   height,   in   pixels,   of   the   icon.    
  cPlanes    
  [in]   Specifies   the   number   of   planes   in   the   XOR   bitmask   of   the   icon.    
  cBitsPixel    
  [in]   Specifies   the   number   of   bits-per-pixel   in   the   XOR   bitmask   of   the   icon.    
  lpbANDbits    
  [in]   Pointer   to   an   array   of   bytes   that   contains   the   bit   values   for   the   AND   bitmask   of   the   icon.   This   bitmask   describes   a   monochrome   bitmap.    
  lpbXORbits    
  [in]   Pointer   to   an   array   of   bytes   that   contains   the   bit   values   for   the   XOR   bitmask   of   the   icon.   This   bitmask   describes   a   monochrome   or   device-dependent   color   bitmap.    
  Top

3 楼LegerWu(Legerwu_cn)回复于 2002-04-15 17:06:42 得分 8

DrawIcon  
  The   DrawIcon   function   draws   an   icon   or   cursor   into   the   specified   device   context.    
   
  To   specify   additional   drawing   options,   use   the   DrawIconEx   function.    
   
  BOOL   DrawIcon(  
      HDC   hDC,             //   handle   to   DC  
      int   X,                 //   x-coordinate   of   upper-left   corner  
      int   Y,                 //   y-coordinate   of   upper-left   corner  
      HICON   hIcon       //   handle   to   icon  
  );  
  Top

4 楼jxpxhxy(冷酷的羔羊)回复于 2002-04-15 17:09:16 得分 39

这样行不行  
  CClientDC   dc(this);  
  HICON   icon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);  
  dc.DrawIcon(point,icon);Top

5 楼ilovesnow()回复于 2002-04-15 17:17:25 得分 0

好想“不能奏效”,   我是想:在一个对话框中,按一个button   按钮,   就跳出一个一固定好的*.Ico格式的图像!Top

6 楼anson_program(江慧峰)回复于 2002-04-15 21:01:38 得分 9

DRAWICONEX()Top

7 楼ilovesnow()回复于 2002-04-15 21:29:35 得分 0

为什么,   我LoadIcon(),DrawIcon()在debug   的时候是合理的,   但是,就是画不出图来,这是为什么呀?  
   
      请高手     指教!  
   
  多谢了!  
  Top

8 楼y_may(witch)回复于 2002-04-15 23:32:02 得分 0

哇,说的这么复杂  
  我也弄过,很成功但不知道合不合你心意  
  我是这样做的:  
  先在对话框上添加一个picture控件,(工具条上有)  
  然后在参数框内的type栏选icon,Image框内选所对应的id  
  你可以选择初始化是可见还是不可见,就可以了。  
  你还可以到时候在load另外一张图标,那就麻烦一些  
  需不需要?如果要的话我再告诉你。Top

9 楼y_may(witch)回复于 2002-04-15 23:40:21 得分 10

o,我又仔细看了你的问题,我明白你的意思了  
  你做的东西我做过  
  首先第一步还是要按我上面的那样做,并且记住要选不可见  
  即不选Visible  
  然后,修改ID成为你喜欢的名字  
  然后去classvizard,为该静态id添加一个CStatic的变量  
  假设是light  
  然后你在button的消息映射函数里添加一句话就ok  
  void   CtempDlg::OnBUTTONup()    
  {        
  light.SetIcon(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_ICON1)));  
  }  
  如果你button的映射函数不是在dlg类里,则这样调用:  
  dlg.light.SetIcon(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_ICON1)));  
  不清楚可以再联系Top

10 楼ttzzgg_80713(身无立锥地,常有四海心---老子有条命)回复于 2002-04-15 23:42:21 得分 2

LoadIcon  
  DrawState  
  Top

相关问题

  • 图像显示???
  • directx 图像显示
  • Java显示图像
  • 如何显示jpg图像
  • ★BMP图像显示问题★
  • 怎样显示bmp图像
  • 显示动态图像
  • 图像显示问题
  • ctreectrl怎样显示图像?
  • 图像显示问题!

关键词

  • 图像
  • dc
  • bitmask
  • hicon
  • drawicon
  • icon
  • loadicon
  • ico
  • xor
  • cyicon

得分解答快速导航

  • 帖主:ilovesnow
  • cz
  • quengzi
  • LegerWu
  • jxpxhxy
  • anson_program
  • y_may
  • ttzzgg_80713

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo