按钮中添加位图和图标
来源:优易学  2011-1-6 10:26:35   【优易学:中国教育考试门户网】   资料下载   IT书店

  #ifdef APSTUDIO_INVOKED
  #ifndef APSTUDIO_READONLY_SYMBOLS
  #define _APS_3D_CONTROLS     1
  #define _APS_NEXT_RESOURCE_VALUE    146
  #define _APS_NEXT_COMMAND_VALUE     32776
  #define _APS_NEXT_CONTROL_VALUE     1000
  #define _APS_NEXT_SYMED_VALUE   101
  #endif
  #endif
  找不到类似与 #define EnsureU 1000 的定义.
  9. In your application’s dialog class (derived from CDialog), add a CBitmapButton member   object.
  10.In the CDialog object’s OnInitDialog routine, call the CBitmapButton object’s AutoLoad function, using as parameters the button’s control ID and the CDialog object’s this pointer.
  If you want to handle Windows notification messages, such as BN_CLICKED, sent by a bitmap-button control to its parent (usually a class derived from CDialog), add to the CDialog-derived object a message-map entry and message-handler member function for each message. The notifications sent by a CBitmapButton object are the same as those sent by a CButton object.
  The class CToolBar takes a different approach to bitmap buttons.
  For more information on CBitmapButton, seeControl Topics in Visual C++ Programmer’s Guide.
  使用图标制作按钮
  1. 打开按钮的属性页,在Style中选中Icon.
  2. 在对话框类的头文件中定义成员变量(
  注意一定要使用ClassWizard加入这个成员变量)
  CButton    m_IconBtn;;//对应于图标按钮
  3. 创建相应的图标或者位图资源:
  图标资源:IDI_ICONBTN
  4.在初始化中加入如下代码:  BOOL CAboutDlg::OnInitDialog()
  {
  CDialog::OnInitDialog();
  // TODO: Add extra initialization here
  HICON Icon=AfxGetApp()->LoadIcon(IDI_ICONBTN);
  m_IconBtn.SetIcon(Icon);
  m_BmpBtn.AutoLoad(IDOK,this);
  return TRUE; // return TRUE unless you set the focus to a control
  // EXCEPTION: OCX Property Pages should return FALSE
  }
  …
  重新编译运行我们的程序。OK.

上一页  [1] [2] 

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训