[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Change the shape of a textbox control.

Posted on 2006-04-13
3
Medium Priority
?
268 Views
Last Modified: 2012-06-21
Hi, i'm new here and this will be my first question. I have seen this asked on many forums and it seems know one can come up with a solution, yet i know it's possible because it's available to buy as a control library from SickWin. I liked the look of it and attempted to replicate the effect, but without luck. Now it's become a mission for me!!! I have done much with the textbox control, even managed to create one that can support transparent backcolors, however i can't work out how i could change it's shape. To start with all i want to be able to do is give it round corners. Sounds simple, but it turns out the .net textbox is just a thin wrapper around the old win32 textbox and is not easily customizable. So has anyone implemented this before, and if so would they be kind enough to point me in the right direction.

Thanks.
0
Comment
Question by:Vis781
1 Comment
 
LVL 8

Accepted Solution

by:
wguerram earned 2000 total points
ID: 16446021
'You can take the idea with this code.

<Description("Returns a window handler."), _
        DllImport("user32.dll", _
        SetLastError:=True, CharSet:=CharSet.Auto, ExactSpelling:=True, _
        CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function GetWindowDC(ByVal hWnd As IntPtr) As IntPtr
        End Function

        <Description("frees a window handler."), _
        DllImport("user32.dll", _
        SetLastError:=True, CharSet:=CharSet.Auto, ExactSpelling:=True, _
        CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As Integer
        End Function

Public Class FlatTextBox
   Public Sub New()
        SetStyle(Windows.Forms.ControlStyles.DoubleBuffer, True)
   end sub

   Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Select Case m.Msg            
            Case APIConst.WndMsg.WM_PAINT
                MyBase.WndProc(m)

                Dim hDC As IntPtr = GetWindowDC(m.HWnd)
                Dim gdc As Drawing.Graphics = Drawing.Graphics.FromHdc(hDC)

               'Draw using this variable, search on the help, about the graphics class

               ReleaseDC(m.HWnd, hDC)
            Case Else
                MyBase.WndProc(m)
        End Select
    End Sub
end class
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question