大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> 程序开发 -> VC编程实现IE风格的界面

VC编程实现IE风格的界面

时间: 2021-07-31 作者:daque

刘 涛  运用过ie欣赏器的伙伴都领会ie界面上的扁平东西条、地方栏,扁平东西栏上的按钮平常状况下为扁平态,按钮上的图像为灰色,当鼠标放在按钮上时,按钮崛起(这种状况称为手柄),而且其上的图像变得灿烂刺眼,少许按钮上再有中国字证明或标有小黑三角的下拉按钮,单击时表露下拉菜单,那些本领是如何实行的呢,正文对准那些题目引见了怎样运用vc编制程序来实行它们。  ie作风的实行重要在主框架类的cmainframe::oncreate()实行,它的重要思维如次:开始设置一个crebar东西,用以作东西条、地方栏的容器,而后辨别证明图像列表东西img用来保存东西栏上按钮的热门图像和平常状况下表露的图像。为了表露扁平东西栏,须要用createex()因变量创造ctoolbar东西m_wndtoolbar,用modifystyle()因变量将东西栏的作风设为扁平典型,你不许用ctoolbar::create() 或 ctoolbar:: setbarstyle()树立这种新作风。ctoolbar 类不扶助tbstyle_flat。要处置这个题目,必需绕过ctoolbar类,运用cwnd::modifystyle()。东西栏东西挪用setbuttoninfo()树立按钮的作风为tbstyle_dropdown,就不妨将东西栏按钮树立为附带有下拉按钮。至于按钮带有华文提醒,用功具栏的setbuttontext()就不妨轻快实行了。底下是实行ie作风界面包车型的士局部代码和解释:int cmainframe::oncreate(lpcreatestruct lpcreatestruct){ crebar m_wndrebar;//证明crebar东西 cimagelist img;//证明图像列表东西 cstring str; if (cframewnd::oncreate(lpcreatestruct) == -1)  return -1; if (!m_wndrebar.create(this))//创造crebar东西 {  trace0("failed to create rebar\n");  return -1; // fail to create } if (!m_wndtoolbar.createex(this))//创造东西条东西 {  trace0("failed to create toolbar\n");  return -1; // fail to create } // set up toolbar properties m_wndtoolbar.gettoolbarctrl().setbuttonwidth(50, 150); file://树立东西条上按钮的最大、最小尺寸 m_wndtoolbar.gettoolbarctrl().setextendedstyle(tbstyle_ex_drawddarrows); file://东西条不妨带有下拉按钮 img.create(idb_hottoolbar, 22, 0, rgb(255, 0, 255)); file://向图像列表承载热门图像资源,idb_hottoolbar为热门图像资源id m_wndtoolbar.gettoolbarctrl().sethotimagelist(&img);//东西条承载热门图像 img.detach(); img.create(idb_coldtoolbar, 22, 0, rgb(255, 0, 255)); file://图象列表承载平常状况的图像资源,idb_coldtoolbar为图像资源id m_wndtoolbar.gettoolbarctrl().setimagelist(&img);//将图像装入东西条 img.detach(); m_wndtoolbar.modifystyle(0, tbstyle_flat | tbstyle_transparent); file://东西条为扁平作风 m_wndtoolbar.setbuttons(null, 9);//东西条上有9个按钮 // set up each toolbar button file://以次辨别对九个按钮辨别树立作风和按钮华语提醒 m_wndtoolbar.setbuttoninfo(0, id_button0, tbstyle_button, 0); str.loadstring(ids_ button0); m_wndtoolbar.setbuttontext(0, str); m_wndtoolbar.setbuttoninfo(1, id_button1, tbstyle_button, 1); str.loadstring(ids_ button1); m_wndtoolbar.setbuttontext(1, str); m_wndtoolbar.setbuttoninfo(2, id_button2, tbstyle_button, 2); str.loadstring(ids_ button2); m_wndtoolbar.setbuttontext(2, str); m_wndtoolbar.setbuttoninfo(3, id_button3, tbstyle_button, 3); str.loadstring(ids_ button3); m_wndtoolbar.setbuttontext(3, str); m_wndtoolbar.setbuttoninfo(4, id_button4, tbstyle_button, 4); str.loadstring(ids_ button4); m_wndtoolbar.setbuttontext(4, str); m_wndtoolbar.setbuttoninfo(5, id_button5, tbstyle_button, 5); str.loadstring(ids_ button5); m_wndtoolbar.setbuttontext(5, str); m_wndtoolbar.setbuttoninfo(6, id_button6, tbstyle_button | tbstyle_dropdown, 6); str.loadstring(ids_ button6); m_wndtoolbar.setbuttontext(6, str); m_wndtoolbar.setbuttoninfo(7, id_button7, tbstyle_button, 7); str.loadstring(ids_ button7); m_wndtoolbar.setbuttontext(7, str); m_wndtoolbar.setbuttoninfo(8,id_button8, tbstyle_button | tbstyle_dropdown, 8); str.loadstring(ids_ button8); m_wndtoolbar.setbuttontext(8, str); file://从新安排按钮的尺寸 crect recttoolbar; m_wndtoolbar.getitemrect(0, &recttoolbar);//获得东西条第一个按钮的尺寸 m_wndtoolbar.setsizes(recttoolbar.size(), csize(30,20)); file://第一个参数为按钮尺寸,第二个参数为图像尺寸 file://创造一个拉拢框动作地方栏 if (!m_wndaddress.create(cbs_dropdown | ws_child, crect(0, 0, 200, 120), this, afx_idw_toolbar + 1)) {  trace0("failed to create combobox\n");  return -1; // fail to create } file://介入东西栏、地方栏 m_wndrebar.addbar(&m_wndtoolbar); str.loadstring(ids_address); m_wndrebar.addbar(&m_wndaddress, str, null, rbbs_fixedbmp | rbbs_break);file://设置rebarbandinfo东西,对东西条和地方栏树立理念尺寸 rebarbandinfo rbbi; rbbi.cbsize = sizeof(rbbi); rbbi.fmask = rbbim_childsize | rbbim_idealsize | rbbim_size; rbbi.cxminchild = recttoolbar.width(); rbbi.cyminchild = recttoolbar.height(); rbbi.cx = rbbi.cxideal = recttoolbar.width() * 9; m_wndrebar.getrebarctrl().setbandinfo(0, &rbbi);//树立东西栏尺寸 rbbi.cxminchild = 0; crect rectaddress; rbbi.fmask = rbbim_childsize | rbbim_idealsize; m_wndaddress.geteditctrl()->getwindowrect(&rectaddress); rbbi.cyminchild = rectaddress.height() + 10; rbbi.cxideal = 200; m_wndrebar.getrebarctrl().setbandinfo(2, &rbbi);//树立地方栏尺寸 m_wndtoolbar.setbarstyle(m_wndtoolbar.getbarstyle() | cbrs_tooltips | cbrs_flyby | cbrs_size_fixed);  if (!m_wndstatusbar.create(this) ||  !m_wndstatusbar.setindicators(indicators,  sizeof(indicators)/sizeof(uint)))  {   trace0("failed to create status bar\n");   return -1; // fail to create  }  return 0; }   之上代码在windows2000和visual c++情况下编写翻译经过,步调运转平常,有爱好的伙伴不妨发端亲身试验一下。

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.