Solved

Need Round corner text box in Visual Basic 6

Posted on 2010-11-17
9
4,054 Views
Last Modified: 2012-05-10
Hi Experts,
I need to use text box that has rounded corners, in a Visual Basic 6 application . A customer has specifically asked for rounded-corner text boxes. If anyone has used it or know where to find it, please pass on the information.
0
Comment
Question by:uzairp
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 6

Expert Comment

by:Codebot
ID: 34162293
0
 

Author Comment

by:uzairp
ID: 34164119
Codebot, The source code is in VB.net that I do not have much experience with. How can I use it in VB6?
0
 
LVL 6

Expert Comment

by:Codebot
ID: 34164231
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 34164868
You can create round edges using the following functions. You will want to change the borderstyle of your textboxe to - None to get a decent result. See code block for example.

CreateRoundRectRgn
http://msdn.microsoft.com/en-us/library/dd183516(VS.85).aspx

SetWindowRgn
http://msdn.microsoft.com/en-us/library/dd145102(VS.85).aspx


Option Explicit

Private Declare Function CreateRoundRectRgn Lib "Gdi32.dll" (ByVal nLeftRect As Long, ByVal nTopRect As Long, ByVal nRightRect As Long, ByVal nBottomRect As Long, ByVal nWidthEllipse As Long, ByVal nHeightEllipse As Long) As Long
Private Declare Function SetWindowRgn Lib "User32.dll" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
Private Declare Function DeleteObject Lib "Gdi32.dll" (ByVal hObject As Long) As Long

Public Sub MakeRound(ByRef t As TextBox)
    Dim hRgn As Long
    
    hRgn = CreateRoundRectRgn(0, 0, _
        t.Width / Screen.TwipsPerPixelX, _
        t.Height / Screen.TwipsPerPixelX, 5, 5)
        
    If hRgn Then
        SetWindowRgn t.hWnd, hRgn, 1
        DeleteObject hRgn
    End If

End Sub

Private Sub Form_Load()
    MakeRound Text1
End Sub

Open in new window

0
 
LVL 1

Expert Comment

by:sabrehagen
ID: 34185812
An alternate way of creating a textbox with round corners is by using an image and creating a pseudo-round cornered textbox. You could make the image in photoshop then use it as a background for your form or place an image control on the form to contain the picture. Your form would look like this: http://dennisdel.com/wp-content/uploads/2010/07/image4.png. From there, place a text box with no border on top of that picture box and make sure the bounds of the text box fit within the text box image. This is the way I always used to do my custom style controls. It's not perfect, but it works, and it's quick. For any clarifications, just ask :)
0
 

Author Comment

by:uzairp
ID: 34193532
sabrehagen;
The textbox looks nice. Would you be able to point me to the code that is ready to be used for the textbox you sent?

Codebot: I have not been able to create the textbox with the example you sent. where do I put the Xml code that is followed by the line, shown in the link you sent?
The manifest XML document required to use XP Visual Styles is as follows:
.....
0
 
LVL 1

Accepted Solution

by:
sabrehagen earned 500 total points
ID: 34193636
I have attached an example solution illustrating the method described in my post above. The jpg in the folder is used as the form background, and the only code on the form sets the background colour of the grey text box. Rounded-Corners.zip
0
 
LVL 1

Expert Comment

by:sabrehagen
ID: 34271734
Has this solved your problem uzairp? If so, could you please select a comment as the solution please?
0
 

Author Comment

by:uzairp
ID: 34388667
Yes, I can use the code example that sabrehagen sent. Thank you.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

840 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