winforms - changing the text box border style in windows form - c# -


i have text box , in square form want convert square oval shape using win forms application

can 1 tell idea

you can use setwindowrgn api function change shape of window. function - can see here - gets 3 arguments:

  1. window handle: can textbox handle , can handle property.
  2. a window rgn: can create calling createroundrectrgn (or rgn creator functions can find them here)
  3. a boolean determine redraw: better true.

you can subclass textbox , create oval shaped textbox using functions in onhandlecreated method. class can this:

class ovaltextbox : textbox {     [dllimport("user32.dll")]     static extern int setwindowrgn(intptr hwnd, intptr hrgn, bool bredraw);      [dllimport("gdi32.dll")]     static extern intptr createroundrectrgn(int x1, int y1, int x2, int y2, int cx, int cy);      public ovaltextbox()     {         base.borderstyle = system.windows.forms.borderstyle.none;     }      protected override void onhandlecreated(eventargs e)     {         base.onhandlecreated(e);         setwindowrgn(this.handle, createroundrectrgn(0, 0, this.width, this.height, 20, 20), true);     } } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -