aplimedia
asked on
Visual basics 6 - Textbox border color
I am using Visual basics 6 to which I am new, and come from a web design/development background.
I have a textbox and want to define the border colour! Now in web design this is easy and not worthy of much stress, but this Visual basic 6 on the other hand has me stumped.
I can set its properties from ‘Appearance : 1 –3D to flat’ But then a very loud dark blue/black border appears.
Now I want to change that border color…
How do I do that???
I have a textbox and want to define the border colour! Now in web design this is easy and not worthy of much stress, but this Visual basic 6 on the other hand has me stumped.
I can set its properties from ‘Appearance : 1 –3D to flat’ But then a very loud dark blue/black border appears.
Now I want to change that border color…
How do I do that???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot. Jon Taramona - aplimedia -
Module :
Private Declare Function CreateRectRgn Lib "gdi32.dll" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32.dll" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
Private Declare Function FrameRgn Lib "gdi32.dll" (ByVal hDC As Long, ByVal hRgn As Long, ByVal hBrush As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Public Sub BorderColor(ByVal Ctl As Control, ByVal lColor As OLE_COLOR, Optional ByVal BorderWidth As Integer = 2)
Dim l As Long
l = CreateRectRgn(BorderWidth, BorderWidth, (Ctl.Width / Screen.TwipsPerPixelX) - BorderWidth, (Ctl.Height / Screen.TwipsPerPixelY) - BorderWidth)
SetWindowRgn Ctl.hwnd, l, False
l = CreateRectRgn(Ctl.Left / Screen.TwipsPerPixelX, Ctl.Top / Screen.TwipsPerPixelY, Ctl.Width / Screen.TwipsPerPixelX + (Ctl.Left / Screen.TwipsPerPixelX), Ctl.Height / Screen.TwipsPerPixelY + (Ctl.Top / Screen.TwipsPerPixelY))
FrameRgn Ctl.Container.hDC, l, CreateSolidBrush(lColor), BorderWidth, BorderWidth
End Sub
In Form :
1. Insert a PictureBox into Form,
Properties : AutoRedraw = True
2. Insert Textbox inside PictureBox
Private Sub Form_Load()
BorderColor Text1, VbBlue
End Sub
Private Declare Function CreateRectRgn Lib "gdi32.dll" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32.dll" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
Private Declare Function FrameRgn Lib "gdi32.dll" (ByVal hDC As Long, ByVal hRgn As Long, ByVal hBrush As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Public Sub BorderColor(ByVal Ctl As Control, ByVal lColor As OLE_COLOR, Optional ByVal BorderWidth As Integer = 2)
Dim l As Long
l = CreateRectRgn(BorderWidth,
SetWindowRgn Ctl.hwnd, l, False
l = CreateRectRgn(Ctl.Left / Screen.TwipsPerPixelX, Ctl.Top / Screen.TwipsPerPixelY, Ctl.Width / Screen.TwipsPerPixelX + (Ctl.Left / Screen.TwipsPerPixelX), Ctl.Height / Screen.TwipsPerPixelY + (Ctl.Top / Screen.TwipsPerPixelY))
FrameRgn Ctl.Container.hDC, l, CreateSolidBrush(lColor), BorderWidth, BorderWidth
End Sub
In Form :
1. Insert a PictureBox into Form,
Properties : AutoRedraw = True
2. Insert Textbox inside PictureBox
Private Sub Form_Load()
BorderColor Text1, VbBlue
End Sub
VB6 can't handle tranparency/opacity/alpha capability picture and icon.