how to brush color into a textbox ?
-
-
you know, Combobox has property Drawmode = OwerDrawFixed that allow us catch DrawItem events to brush color for each item in Combobox. But a Textbox hasnot this usefull property. Can you guide me how to brush color into a textbox? special thanks! dungti
Dungti, If you are using VB.NET then just set the background color. If you are using VB 6 then you will have to work your way through this lot...It's on MSDN. PSS ID Number: Q174301 Article Last Modified on 01-11-2001 -------------------------------------------------------------------------------- The information in this article applies to: Microsoft Visual Basic Learning Edition for Windows 6.0 Microsoft Visual Basic Professional Edition for Windows 6.0 Microsoft Visual Basic Enterprise Edition for Windows 6.0 Microsoft Visual Basic Control Creation Edition for Windows 5.0 Microsoft Visual Basic Learning Edition for Windows 5.0 Microsoft Visual Basic Professional Edition for Windows 5.0 Microsoft Visual Basic Enterprise Edition for Windows 5.0 -------------------------------------------------------------------------------- Summary When a dithered color is selected as the background of a TextBox, the background around the text is displayed as a different, solid color when the display is set for 256 colors or less. To work around this limitation, you must hook the WM_CTLCOLOREDIT message and set the text background color to TRANSPARENT. This is not a trivial alternative, and using a solid background color is recommended if at all possible. More Information WARNING: ANY USE BY YOU OF THE SAMPLE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this sample code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. WARNING: Failure to unhook a window before its imminent destruction will result in application errors, Invalid Page Faults, and data loss. This is due to the fact that the new WindowProc function being pointed to no longer exists, but the window has not been notified of the change. Always unhook the sub-classed window upon unloading the sub-classed form or exiting the application. This is especially important while debugging an application that uses this technique within the Microsoft Visual Basic 5.0 Development Environment. Pressing the END button or selecting End from the Run menu without unhooking will cause an Invalid Page Fault and close Microsoft Visual Basic. A TextBox control cannot draw text with a dithered background color, but it can draw text with a transparent background color. If the background of the control is dithered, this achieves the same visual effect. (Note the distinction between the back
-
Dungti, If you are using VB.NET then just set the background color. If you are using VB 6 then you will have to work your way through this lot...It's on MSDN. PSS ID Number: Q174301 Article Last Modified on 01-11-2001 -------------------------------------------------------------------------------- The information in this article applies to: Microsoft Visual Basic Learning Edition for Windows 6.0 Microsoft Visual Basic Professional Edition for Windows 6.0 Microsoft Visual Basic Enterprise Edition for Windows 6.0 Microsoft Visual Basic Control Creation Edition for Windows 5.0 Microsoft Visual Basic Learning Edition for Windows 5.0 Microsoft Visual Basic Professional Edition for Windows 5.0 Microsoft Visual Basic Enterprise Edition for Windows 5.0 -------------------------------------------------------------------------------- Summary When a dithered color is selected as the background of a TextBox, the background around the text is displayed as a different, solid color when the display is set for 256 colors or less. To work around this limitation, you must hook the WM_CTLCOLOREDIT message and set the text background color to TRANSPARENT. This is not a trivial alternative, and using a solid background color is recommended if at all possible. More Information WARNING: ANY USE BY YOU OF THE SAMPLE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this sample code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. WARNING: Failure to unhook a window before its imminent destruction will result in application errors, Invalid Page Faults, and data loss. This is due to the fact that the new WindowProc function being pointed to no longer exists, but the window has not been notified of the change. Always unhook the sub-classed window upon unloading the sub-classed form or exiting the application. This is especially important while debugging an application that uses this technique within the Microsoft Visual Basic 5.0 Development Environment. Pressing the END button or selecting End from the Run menu without unhooking will cause an Invalid Page Fault and close Microsoft Visual Basic. A TextBox control cannot draw text with a dithered background color, but it can draw text with a transparent background color. If the background of the control is dithered, this achieves the same visual effect. (Note the distinction between the back
Hi! Thanks for your idea but my matter is that, I am using VB.NET My background of Textbox is still COLOR.WHITE, and I would like to draw a small color rectangle first and then a draw my text (like you add each color beside each text item in a Combobox). Could you give a new idea to handle this matter. Special thanks!!! dungti