ownerdrawn

Draw controls in tab control tab header area in Winforms

妖精的绣舞 提交于 2019-12-13 06:19:06
问题 I am trying to add some controls to the left of the tab header area for my tab control but not affect the tab page area (like internet explorer). I think I would have to owner draw the control, but I'm not sure where to start. Can anyone offer any suggestions? 回答1: Have you searched before you ask you question mate ?!! there are many articles outside. I think the following links are exactly what you want, take a look. Y(et)A(nother)TabControl: A Custom Tab Control With Owner Drawn Tabs

Redrawing of owner-drawn winforms combobox items

荒凉一梦 提交于 2019-12-13 04:05:48
问题 I need to show items in a combobox with a different background color. I also want to change what that color is depending on if the item is selected (or the mouse is on top of it), just the same way it works when a combobox is not owner-drawn. It is all working fine, except that when the mouse comes off one of the items that I changed the color for, the item keeps the same color as when the mouse was on top. In the example below, the item 'other' is initially correctly drawn with

Why does AlphaBlend always return false (drawing on canvas)?

折月煮酒 提交于 2019-12-13 01:22:55
问题 I am trying to blend two canvases together using the windows alphablend API call. First I draw some thing on the main canvas (destination), then instantiate another canvas using TBitmap, draw onto that, and then blend the two together (following an answer here on SO). However, I am finding that it always returns false, at first I thought it had something to do with passing the wrong handles for source and destination, but I cannot figure it out. what could it be? unit MainWnd; interface uses

“List index out of bounds” on TListBox

眉间皱痕 提交于 2019-12-13 00:38:03
问题 I have a TListBox on a form, and items are added with listbox1.ItemIndex := listbox1.Items.AddObject('msg', TObject(grp)); grp is an integer. The listbox is set to lbOwnerDrawFixed . In the onDrawItem event I get the exception EStringListError raised on the marked line: msg := (control as Tlistbox).Items.Strings[index]; // this line works grp := integer((control as Tlistbox).Items.Objects[index]); // exception here msg and grp are local string and integer variables. Project ### raised

Label UserPaint drawn text doesn't fit

风格不统一 提交于 2019-12-12 02:55:00
问题 I have a custom Label class, drawn text doesn't fits. What am I doing wrong here? class MyLabel: Label { public MyLabel() { SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true); } protected override void OnPaint(PaintEventArgs e) { using (LinearGradientBrush brush = new LinearGradientBrush(ClientRectangle, Color.Black, Color.LightGray, LinearGradientMode.ForwardDiagonal)) e.Graphics.DrawString(Text, Font, brush, ClientRectangle); } } If I set text of MyLabel to

c# MeasureItemEvent handler: e.ItemHeight not changing

﹥>﹥吖頭↗ 提交于 2019-12-11 15:33:39
问题 Is it me or can I only set the itemheight - e.ItemHeight - once for a listbox? Although I handle the MeasureItemEvent on my ownerdrawn listbox and set the e.ItemHeight to the right value, only the first height that is set will be used. Oops, I am new to this, sorry about that. This is the code (DrawItemHandler is of course in the actual program): // Add eventhandler to draw and measure items this.listBox1.DrawItem += new DrawItemEventHandler(this.DrawItemHandler); this.listBox1.MeasureItem +=

TreeView owner draw glitch when selecting

允我心安 提交于 2019-12-06 04:43:14
问题 I'm trying to add a few more icons to elements of a standard System.Windows.Forms.TreeView control. My plan was to only change the label area of the treeview control, but it shows a strange behaviour. If I click a node to select it, when the mouse button is depressed the background is draw correctly with the highlight color. However, the text is the wrong unselected color until I release the mouse button. It's as if e.State contains the wrong state between when the mouse button is pressed and

Alphablend and TransparentBlt

随声附和 提交于 2019-12-06 02:47:56
问题 This question is related to my earlier question on SO. I want to combine two layers with alpha applied only to a specific portion of the source layer. One way I tried was to set SourceConstantAlpha to $ff (and have the function use the alpha channel in the source layer). This kind of works - although slow (I guess I can speed it up by using ScanLines), the kind of part is that I cannot figure out what to set the alpha channel to. The documentation suggests that the calculation is: st.Red =

How a Combobox with the csOwnerDrawFixed Style can behave like the csDropDown style?

試著忘記壹切 提交于 2019-12-04 21:57:57
问题 I'm using a TComboBox component with the style property set to csOwnerDrawFixed , I implement the OnDrawItem And everything works fine, Now I want which the combobox to behave like when had the csDropDown style (with the csOwnerDrawFixed style behaves like the csDropDownList style) , I mean with a inner editor. is this possible? 回答1: Delphi's TComboBox wrapper doesn't support an owner draw editable style, but the underlying Windows control does, and it's easy to enable it. Create a new

TreeView owner draw glitch when selecting

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 09:48:52
I'm trying to add a few more icons to elements of a standard System.Windows.Forms.TreeView control. My plan was to only change the label area of the treeview control, but it shows a strange behaviour. If I click a node to select it, when the mouse button is depressed the background is draw correctly with the highlight color. However, the text is the wrong unselected color until I release the mouse button. It's as if e.State contains the wrong state between when the mouse button is pressed and released. Here is what I'm doing: I init with this.DrawMode = TreeViewDrawMode.OwnerDrawText and then