或者,如果不存在预定义的const,那么任何算法如何用这种颜色创建一个Brush?谢谢!
我直观的第一选择Systemcolors.Scrollbar与.Control或.buttonFace(‘tabPage2’的BG)相同,这实际上是滚动条的“面部”颜色,而不是我称之为“背景”的颜色.
Systemcolors.Controllight或Systemcolors.Controllightlight不再接近..
当放大时,控件的那个区域看起来像带有.Control和.Window像素的棋盘格,所以对我来说暗示这种颜色可能会抖动;也许这表明标准Systemcolors枚举没有定义它的原因?我如何将它应用于另一个控件?
PS:我正在尝试增强自定义TabControl(它支持可禁用的标签 – std控件中缺少的另一个好东西,但这是另一个已经解决过的故事),所以当它的.Appearance设置为buttons或Flatbuttons时,它看起来很相似到原件(如上图所示).选定的选项卡由推入按钮指示,但其背景颜色设置为Control或buttonFace:
解决方法 好吧,事实证明这比我想象的要简单得多 – 它只是用于填充BG-rect的Brush:protected overrIDe voID OnDrawItem( DrawItemEventArgs e ){ base.OnDrawItem( e ); int i= e.Index; TabPage p= this.TabPages[ i ]; Rectangle r= GetTabRect( i ); Brush br= null; if( this.Appearance != TabAppearance.normal && i == this.Selectedindex ) br= new HatchBrush( HatchStyle.Percent50,Systemcolors.Control,Systemcolors.Window ); else br= new SolIDBrush( p.Backcolor ); try // fill the BG-rectangle { e.Graphics.FillRectangle( br,r ); } finally { br.dispose( ); } // make sure brush is disposed of .. // the rest of the event-handler}
唯一的技巧是无法应用using(Brush br = new ..){..}块,因为初始化与结果对象类型不同.因此,一个有点丑陋的尝试 – 终结构造.充当魅力!
总结以上是内存溢出为你收集整理的c# – 如何引用一些Windows元素(滚动条,推入选项按钮等)使用的BG颜色?全部内容,希望文章能够帮你解决c# – 如何引用一些Windows元素(滚动条,推入选项按钮等)使用的BG颜色?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)