|
It still flickers when i mouse hover in and out of it and during resize.
I have added these but still flickers ;(
switch (m.Msg)
{
case WM_MOUSEACTIVATE:
case WM_MOUSEFIRST:
case WM_MOUSELAST:
case WM_MOUSEHOVER:
case WM_MOUSELEAVE:
m.Result = (IntPtr)1;
break;
...
}
|
|
|
|
|
|
In the designer, the control paints as expected. However, when the application is actually run, the control has an inner white border (including one that separates the down-arrow button with the control's text area).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I haven't got the environment to try that out and fixing it. Hopefully someone else can give it a go.
|
|
|
|
|
|
can any one please help on this issue that was found when I'm using C# .NET 2005 and when i click on the control it appears like this
PInvokeStackImbalance was detected
Message: A call to PInvoke function 'SSLib!SSLib.UserControls.ExtendedComboBox::SendMessage' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Isara
|
|
|
|
|
Didn't remember seeing this post on my email and just realize it now. Hope you have resolved this issue by now, if not try this.
Try changing the declaration to this
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
And when invoking it, replace the last parameter from "0" to IntPtr.Zero
|
|
|
|
|
great work and thanks for this article.
my wish is to customise the drop dawn list, not the items but the border and the backcolor of this.
thanks again
|
|
|
|
|
Hi, first of all I wanna thank you for this article.
I'm having a little problem when the control is disabled because an extra border is drawn, but when it is enabled again, it draws correctly.
I've tried to avoid the drawing of the rectangle when the control is disable, but nothing happens.
Any suggestions would be appreciated.
Thanks.
PD. sorry for my english
|
|
|
|
|
Hi,
Try put in if statement to check for the enable state of the control before drawing the rectangle and dropdown.
case WM_PAINT:
...............
if (this.Enabled)
{
Pen p = new Pen((this.Enabled ? BackColor : SystemColors.Control), 2);
gdc.DrawRectangle(p, new Rectangle(2, 2, this.Width - 3, this.Height - 3));
PaintFlatDropDown(this, gdc);
}
...............
I only tried this with Vista and VS2005, so I'm not sure if this fix will work for you, but it certainly works for me. Let me know how you go. If you still have trouble please let me know your dev platform and I will try to replicate that.
Fadrian
|
|
|
|
|
Thanks for your answer!
With your code, the extra line disappears, but the controls draws in 3D.
I made some changes and now the combo is completly flat when it is disabled.
Here are the changes that I made...
case WM_PAINT:
...........
Pen p;
if (!this.Enabled)
BackColor = SystemColors.Control;
else
BackColor = SystemColors.Window;
p = new Pen(BackColor, 2);
gdc.DrawRectangle(p, new Rectangle(2, 2, this.Width - 3, this.Height - 3));
........
I'm under WinXP, but I would like to know if this solution works fine in vista too.
Thanks for your help!!
Regards,
Jorge
|
|
|
|
|
Hi
I did as u said in this Article.
FlatCombBox cmd = new FlatComboBox(); // On Page Load Event
Then..
cmd.Items.Add("A");
cmd.Items.Add("B");
cmd.Items.Add("C");
And on Button Click event
cmd.Show();
But i am unable to see the cmd ComboBox on my asp.net Page.
Is i am wrong any where....
Then please tell me.
Thanking you... Mrun
Mrun
|
|
|
|
|
Hi Mrun,
This control is a WinForm control and not to be used in ASP.NET page.
Fadrian
|
|
|
|
|
|
I have a need for a combo box control that will allow me to show but not select values from a data source that are marked inactive. For example, let's say I have a list of options A, B and C. I have some old records in my database that are linked to option B, but that option is no longer in use as is flagged inactive in the option table. I'd like the combo box to show the current value for the record as B, but if a user opens the value list they only see options A and C.
The way I was planning to do this is to somehow add another field name to the data binding so that the paint routine can tell which records are active and only show those when the list is opened. In other words, I'd have a DisplayMember, a ValueMember and an ActiveMember property for the combo box. If the field pointed to by the ActiveMember property is false for a record in the data source, that value doesn't show up in the list and cannot be selected by the user.
Can you give me some guidance on how I would alter the standard combo box to add that functionality?
|
|
|
|
|
Instead of customizing a combobox for the above scenario, the easiest way is just use normal combobox and use a few simple methods to achieve this:
- Populate the list: you will look at your data and only populate active entry (A, C) to the combo
- Set selection: if entry value is valid, then select. If the entry value not in the list, check if it is one of your inactive data (e.g. B), then insert that and select (select B).
- Write validator code to make sure your business rule are enforced on when inactive values can be used before saving the data.
|
|
|
|
|
Thank you for your help. This solution is similar to the one I came up with. What I ended up doing is pulling in all the records for the dataset and using a dataview to populate the list. If the record I was looking at used an active list member, I set the RowFilter for populating the combo box to active = 1. If the row used an inactive member I set the RowFilter to active = 1 or id = the record key for the inactive record. That way the user could see the inactive value but they could only either keep it the same or change it to an active value from the combo box. Problem solved.
|
|
|
|
|
<br />
protected override void WndProc(ref Message m)<br />
{<br />
if (this.DropDownStyle == ComboBoxStyle.Simple)<br />
{<br />
base.WndProc(ref m);<br />
return;<br />
}<br />
<br />
IntPtr hDC = IntPtr.Zero;<br />
Graphics gdc = this.CreateGraphics();<br />
switch (m.Msg)<br />
{<br />
case WM_NC_PAINT:<br />
base.WndProc(ref m);<br />
PaintFlatControlBorder(this, gdc);<br />
gdc.Dispose();<br />
break;<br />
case WM_PAINT:<br />
base.WndProc(ref m);<br />
Pen p = new Pen((this.Enabled ? BackColor : SystemColors.Control), 2);<br />
gdc.DrawRectangle(p, new Rectangle(2, 2, this.Width - 3, this.Height - 3));<br />
PaintFlatDropDown(this, gdc);<br />
PaintFlatControlBorder(this, gdc);<br />
gdc.Dispose();<br />
break;<br />
default:<br />
base.WndProc(ref m);<br />
break;<br />
}<br />
}<br />
I just hate .NET + win32 :>...
|
|
|
|
|
Hi,
There is a slight difference between Graphics.CreateGraphics and Win32 Graphics.FromHdc using the Win32 device context. CreateGraphics give you the DC for the client area only, whereby FromHdc gives you the entire window area including non-client area. We need this to paint our border around the bound of the control. WM_NC_PAINT (Non Client area paint) is the windows event message sent specifically for paintint the non client area.
Hope the explaination above helps.
Fadrian
|
|
|
|
|
|
How to make birthday reminders in C# 2003
Thimani
|
|
|
|
|
By your code,I tried to make standard TextBox appear flat,but i couldn't handle the ScrollBars property very well,especially when ScrollBars property set
System.Windows.Forms.ScrollBars.Vertical(I want to make the TextBox Border Color can looks other color,include the ScrollBars,not standard style),It always has some problem.My english is poor,I hope that you can understand,thank you very much.
-- modified at 23:13 Thursday 13th April, 2006
Follow is Mainly code
private void DrawScrollButton(System.Drawing.Graphics g)
{
if ( ScrollBars == System.Windows.Forms.ScrollBars.Vertical )
{
Int16 btnHeight = (Int16)Math.Min(Math.Ceiling((this.Height - 4) / 2.0),MaxScrollButtonHeight);
Int32 left = this.Width - this.ScrollButtonWidth -3;
Int32 downButtonTop = this.Height - btnHeight - 3;
System.Drawing.Rectangle upBtn = new Rectangle(left,3,ScrollButtonWidth,btnHeight);
ControlPaint.DrawScrollButton(g,upBtn,ScrollButton.Up,ButtonState.Flat);
System.Drawing.Rectangle downBtn = new Rectangle(left,downButtonTop,ScrollButtonWidth,btnHeight);
ControlPaint.DrawScrollButton(g,downBtn,ScrollButton.Down,ButtonState.Flat);
// if ( ( downButtonTop - 1) > (btnHeight + 4) )
// {
// g.FillRectangle(new SolidBrush(Focused ? Color.Transparent : _ScrollBarColor),new Rectangle(left,btnHeight + 4,ScrollButtonWidth,downButtonTop - btnHeight -5));
// }
if ( this.ReadOnly == true || this.Enabled == false )
{
// DrawLine(g,left,3,left,downButtonTop,_DisableColor);
DrawRectangle(g,upBtn,_DisableColor);
DrawRectangle(g,downBtn,_DisableColor);
return;
}
if ( this.Focused )
{
// DrawLine(g,left,3,left,downButtonTop,_HightlightColor);
DrawRectangle(g,upBtn,_HightlightColor);
DrawRectangle(g,downBtn,_HightlightColor);
}
else
{
// DrawLine(g,left,3,left,downButtonTop,_NormalColor);
DrawRectangle(g,upBtn,_NormalColor);
DrawRectangle(g,downBtn,_NormalColor);
}
}
}
|
|
|
|
|
Hi,
Completely redrawing over the scrollbar is not easy and it requires you to do a lot more then the above.
To get a flat text box, you can simply do:
- Create a textbox and set the border to FixedSingle
- The standard border is quite awful, so you can use similar method to above to draw the border of your prefered colour or style
I haven't tried to paint over scrollbar before, but I believe you will need to trap the scroll event as well
Fadrian
|
|
|
|
|
I can't seem to get this working in vs2005, even though in vs2003 it all works fine. Its reporting the following error:
A call to PInvoke function 'ELSA 1.1!ELSA.FlatComboBox::SendMessage' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
relating to line 108:
switch (m.Msg)<br />
{<br />
case WM_NC_PAINT: <br />
hDC = GetWindowDC(this.Handle);<br />
gdc = Graphics.FromHdc(hDC);<br />
SendMessage(this.Handle, WM_ERASEBKGND, hDC, 0);
SendPrintClientMsg();
PaintFlatControlBorder(this, gdc);<br />
m.Result = (IntPtr) 1;
ReleaseDC(m.HWnd, hDC);<br />
gdc.Dispose(); <br />
<br />
break;<br />
At the moment I am struggling to fix it. Any ideas?
|
|
|
|
|
Hi,
I tested and it actually works fine. I start to suspect it is either the installed framework is corrupted or perhaps you have a later operating system then what I'm running?
Also, if you are using VS2005, wouldn't it be just as easy to just use the standard combobox provided - which is now have the proper flat mode?
Fadrian
|
|
|
|
|