Click here to Skip to main content
15,881,455 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to determine the keypress/mouse click is human action or simulation? Pin
mutpan26-Jun-09 1:08
mutpan26-Jun-09 1:08 
GeneralRe: How to determine the keypress/mouse click is human action or simulation? Pin
Rajesh R Subramanian26-Jun-09 1:18
professionalRajesh R Subramanian26-Jun-09 1:18 
AnswerRe: How to determine the keypress/mouse click is human action or simulation? Pin
Rajesh R Subramanian26-Jun-09 1:19
professionalRajesh R Subramanian26-Jun-09 1:19 
AnswerRe: How to determine the keypress/mouse click is human action or simulation? Pin
molesworth26-Jun-09 3:03
molesworth26-Jun-09 3:03 
GeneralRe: How to determine the keypress/mouse click is human action or simulation? Pin
alien viper26-Jun-09 3:35
alien viper26-Jun-09 3:35 
AnswerRe: How to determine the keypress/mouse click is human action or simulation? Pin
Dan Neely26-Jun-09 4:00
Dan Neely26-Jun-09 4:00 
QuestionProblem with Windows Mobile and image scaling Pin
mrmckeb25-Jun-09 23:25
mrmckeb25-Jun-09 23:25 
QuestionBorder color of Textbox not working Pin
mutpan25-Jun-09 22:48
mutpan25-Jun-09 22:48 
I would like to change the border color of Text Box in C#. I subclassed the TextBox control and override the WndProc function to catch the PAINT Messages to draw the border with my color.

But the border color hasn't changed, still i am getting the default border color of text box that is Black color. The same code works fine with .NET 1.0 but not working in .NET 2.0 and the latest versions.

Can anyone tell what is the difference between .NET 1.0 painting and .NET 2.0 painting for TextBox?

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;

class MyTextBox : TextBox {
  private const int WM_NCPAINT = 0x85;
  private const int WM_ERASEBKGND = 0x14;
  private const int WM_PAINT = 0xF;
  [DllImport("user32.dll")]
  static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags);
  [DllImport("user32.dll")]
  static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

  protected override void WndProc(ref Message message) {
    base.WndProc(ref message);
    if (message.Msg == WM_PAINT)
    {
      //get handle to a display device context
      IntPtr hdc = GetDCEx(message.HWnd, (IntPtr)1, 1 | 0x0020);

      if (hdc != IntPtr.Zero) {
        //get Graphics object from the display device context
        Graphics graphics = Graphics.FromHdc(hdc);
        Rectangle rectangle = new Rectangle(0, 0, Width, Height);
        ControlPaint.DrawBorder(graphics, rectangle, Color.White, ButtonBorderStyle.Solid);

        message.Result = (IntPtr)1;
        ReleaseDC(message.HWnd, hdc);
      }
    }
  }
}


Thanks in advance
AnswerRe: Border color of Textbox not working Pin
J4amieC25-Jun-09 23:42
J4amieC25-Jun-09 23:42 
GeneralRe: Border color of Textbox not working Pin
mutpan26-Jun-09 1:00
mutpan26-Jun-09 1:00 
GeneralRe: Border color of Textbox not working Pin
J4amieC26-Jun-09 1:16
J4amieC26-Jun-09 1:16 
GeneralRe: Border color of Textbox not working Pin
DaveyM6926-Jun-09 1:05
professionalDaveyM6926-Jun-09 1:05 
GeneralRe: Border color of Textbox not working Pin
J4amieC26-Jun-09 1:15
J4amieC26-Jun-09 1:15 
GeneralRe: Border color of Textbox not working Pin
DaveyM6926-Jun-09 1:25
professionalDaveyM6926-Jun-09 1:25 
QuestionGet proxy settings from automatic configuration script Pin
Succodimele25-Jun-09 22:33
Succodimele25-Jun-09 22:33 
GeneralDLL creation [modified] Pin
ishika_kukki25-Jun-09 22:29
ishika_kukki25-Jun-09 22:29 
GeneralRe: DLL creation Pin
DaveyM6925-Jun-09 22:39
professionalDaveyM6925-Jun-09 22:39 
GeneralRe: DLL creation Pin
ishika_kukki25-Jun-09 22:56
ishika_kukki25-Jun-09 22:56 
GeneralRe: DLL creation Pin
Mirko198025-Jun-09 23:08
Mirko198025-Jun-09 23:08 
GeneralRe: DLL creation Pin
DaveyM6925-Jun-09 23:11
professionalDaveyM6925-Jun-09 23:11 
QuestionPrinter sometimes hangs [modified] Pin
Member 459609425-Jun-09 21:39
Member 459609425-Jun-09 21:39 
AnswerRe: Printer sometimes hangs Pin
Pete O'Hanlon25-Jun-09 22:00
mvePete O'Hanlon25-Jun-09 22:00 
QuestionSystem.Collections.Specialized.StringCollection Question Pin
Programm3r25-Jun-09 21:14
Programm3r25-Jun-09 21:14 
AnswerRe: System.Collections.Specialized.StringCollection Question Pin
Christian Graus25-Jun-09 21:19
protectorChristian Graus25-Jun-09 21:19 
QuestionRe: System.Collections.Specialized.StringCollection Question Pin
Programm3r25-Jun-09 21:47
Programm3r25-Jun-09 21:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.