How can I make a TextBox a mask for a background image?
I'm making a program that uses Unicode, to make it more international, and I would like to be able to make some titles for some parts of the program as was done very easily in Flash, that is, one wrote a text, put an image or a symbol in the background with colors, and the text would look like this:
Can this be done in VB6?
Does LaVolpe's great control "Alpha Image Control V2 " allow you to do this?:
But I don't know if the VB6 browser supports this with unicode utf8, but I think it's very possible that it does, I'll try it... If anyone has any other ideas, it would be appreciated?
Re: How can I make a TextBox a mask for a background image?
FWIW, vbRichClient-users can accomplish such a task as shown in the small snippet below:
Code:
Option Explicit
Private Sub Form_Load()
Dim Pat As cCairoPattern, CC As cCairoContext
Set Pat = Cairo.CreateLinearPattern(0, 0, 0, 64) 'create a linear gradient pattern(brush)
Pat.AddGaussianStops_TwoColors vbRed, vbYellow 'and define the color-stops
Set CC = Cairo.CreateSurface(256, 64).CreateContext 'create a small surface(bitmap) and its context
CC.SelectFont "Arial", 34, , True
CC.DrawText 0, 0, 256, 64, "Some Text", True, vbCenter, 2, True, , , True '<- last param True, for "Text-Path-Only"-output
CC.Clip 'set the currently active (Text)Path as the new clipping-region
CC.Paint 1, Pat 'render-cmd for the Gradient-Pattern (now restricted to the clipped region, aka "the text-string-path")
Set Picture = CC.Surface.Picture 'set the result (in our Cairo-Surface) as the new Form-Picture
'Set Image1.Picture = CC.Surface.Picture 'in case one wants to reflect the result in an image-control
End Sub
Re: How can I make a TextBox a mask for a background image?
Originally Posted by Schmidt
FWIW, vbRichClient-users can accomplish such a task as shown in the small snippet below:
Code:
Option Explicit
Private Sub Form_Load()
Dim Pat As cCairoPattern, CC As cCairoContext
Set Pat = Cairo.CreateLinearPattern(0, 0, 0, 64) 'create a linear gradient pattern(brush)
Pat.AddGaussianStops_TwoColors vbRed, vbYellow 'and define the color-stops
Set CC = Cairo.CreateSurface(256, 64).CreateContext 'create a small surface(bitmap) and its context
CC.SelectFont "Arial", 34, , True
CC.DrawText 0, 0, 256, 64, "Some Text", True, vbCenter, 2, True, , , True '<- last param True, for "Text-Path-Only"-output
CC.Clip 'set the currently active (Text)Path as the new clipping-region
CC.Paint 1, Pat 'render-cmd for the Gradient-Pattern (now restricted to the clipped region, aka "the text-string-path")
Set Picture = CC.Surface.Picture 'set the result (in our Cairo-Surface) as the new Form-Picture
'Set Image1.Picture = CC.Surface.Picture 'in case one wants to reflect the result in an image-control
End Sub
All the modern TextRendering-Output-Functions and Controls in a Win-environment,
expect the passed Strings in UTF16.
And VB6-(B)Strings are by default UTF16-aware (contain UTF16-content - aka "Wide-Strings").
RC6 is unicode-aware throughout - and anywhere a MethodParam is of type String,
that String should contain UTF16 (I say that, because a VB-String can contain anything, even "plain 8Bit-binary").
The same goes for any larger modern Control-Libs (like e.g. Timo Kunzes or Krools Unicode-Controls) -
all expect VB-Strings with UTF16-content (e.g. when you set the .Text-Prop of an Unicode-capable Ctl).
So, since VBStrings "default to" UTF16-content (even when fed ANSI-StringLiterals directly from with the IDE) -
you have to take "special care" when it comes to "Resources, which contain UTF8-binary-streams" -
meaning an explicit conversion from an UTF8-ByteArray into an (UTF16-)VB-String will be necessary.
RC6 contains several helper-functions for that like e.g.:
S = New_c.FSO.ReadTextContent("MyUTF8File.txt", False, CP_UTF8) 'direct conversion of UTF8-FileContent into S(as UTF16)
or for example, when you got an UTF8-Bytearray from a WebServer-http-Request, in B():
S = New_c.Crypt.UTF8ToVBString(B()) 'direct conversion of UTF8-ByteArrayContent into S(as UTF16)
Re: How can I make a TextBox a mask for a background image?
Originally Posted by Schmidt
All the modern TextRendering-Output-Functions and Controls in a Win-environment,
expect the passed Strings in UTF16.
And VB6-(B)Strings are by default UTF16-aware (contain UTF16-content - aka "Wide-Strings").
RC6 is unicode-aware throughout - and anywhere a MethodParam is of type String,
that String should contain UTF16 (I say that, because a VB-String can contain anything, even "plain 8Bit-binary").
The same goes for any larger modern Control-Libs (like e.g. Timo Kunzes or Krools Unicode-Controls) -
all expect VB-Strings with UTF16-content (e.g. when you set the .Text-Prop of an Unicode-capable Ctl).
So, since VBStrings "default to" UTF16-content (even when fed ANSI-StringLiterals directly from with the IDE) -
you have to take "special care" when it comes to "Resources, which contain UTF8-binary-streams" -
meaning an explicit conversion from an UTF8-ByteArray into an (UTF16-)VB-String will be necessary.
RC6 contains several helper-functions for that like e.g.:
S = New_c.FSO.ReadTextContent("MyUTF8File.txt", False, CP_UTF8) 'direct conversion of UTF8-FileContent into S(as UTF16)
or for example, when you got an UTF8-Bytearray from a WebServer-http-Request, in B():
S = New_c.Crypt.UTF8ToVBString(B()) 'direct conversion of UTF8-ByteArrayContent into S(as UTF16)
Olaf
Very important response Olaf, to take into account the issue of being able to display all kinds of characters - Chinese, Japanese, Hindu, and a long etc -... Thank you, sincerely...
And, sorry for the trouble, and if you can, I could read all the Cairo documentation, but if you would be so kind, how could I change the background color, with your code it is pure black, I have tried to change parameters, and I don't see where to put another background color...
Apart from that, I see this code that you have put very simple to put in a UserControl, an Ocx... Very practical, little code...
Re: How can I make a TextBox a mask for a background image?
Olaf, You don't need to bother with the code I told you about the background color, ChatGPT 4o has already given me the code and it works fine:
Code:
Private Sub Form_Load()
Dim Pat As cCairoPattern, CC As cCairoContext
Set Pat = Cairo.CreateLinearPattern(0, 0, 0, 64)
Pat.AddGaussianStops_TwoColors vbRed, vbYellow
Set CC = Cairo.CreateSurface(256, 64).CreateContext
CC.SetSourceColor vbWhite
CC.Paint
CC.SelectFont "Arial", 34, , True
CC.DrawText 0, 0, 256, 64, "Some Text", True, vbCenter, 2, True, , , True
CC.Clip
CC.Paint
CC.Paint 1, Pat
Set Image1.Picture = CC.Surface.Picture
End Sub
I see a huge danger in Artificial Intelligence, because the control capacity that it can give in a few hands is very dangerous, as Lord Acton said, Power Corrupts, and Absolute Power Corrupts Absolutely...
But it is really very practical for programming, and I use the philosophy of Judo, trying to take advantage of the opponent's strength...
And well, Artificial Intelligence takes us for a ride a bit, because I have consulted him several times about this thing of making unicode utf8 texts with gradient, and he has confused me with GDI+, with other codes, instead of going for example to this dll RC6.dll, that is, if you don't control him, he gives you very useless codes, when, as soon as I have commented on Cairo and RC6.dll, he knows perfectly well how it works... But It doesn't tell you, when it is the simplest solution, instead of using CreateCompatibleDC, DeleteDC, MaskBlt, GetWindowDC, ReleaseDC, BitBlt, etc...
It seems to be done on purpose so that it doesn't give you the right information at the start and wastes time...
VB6 is a bit obsolete now, but it does everything for my needs, and learning a new language takes time, which I lack, and I hope that Microsoft still takes some time to remove compatibility with 32 bits, because there are millions of companies with 32-bit programs, which would be chaos to remove compatibility, and once they have this program that I am making, AI will help me to easily change, later with more time, to vb.net or similar...
Anyway, as I said, thank you very much Olaf, you have saved me a lot of searching and wasting time... Regards...
Last edited by James Reynolds; Oct 8th, 2024 at 04:03 AM.
Re: How can I make a TextBox a mask for a background image?
Originally Posted by Schmidt
FWIW, vbRichClient-users can accomplish such a task as shown in the small snippet below:
Code:
Option Explicit
Private Sub Form_Load()
Dim Pat As cCairoPattern, CC As cCairoContext
Set Pat = Cairo.CreateLinearPattern(0, 0, 0, 64) 'create a linear gradient pattern(brush)
Pat.AddGaussianStops_TwoColors vbRed, vbYellow 'and define the color-stops
Set CC = Cairo.CreateSurface(256, 64).CreateContext 'create a small surface(bitmap) and its context
CC.SelectFont "Arial", 34, , True
CC.DrawText 0, 0, 256, 64, "Some Text", True, vbCenter, 2, True, , , True '<- last param True, for "Text-Path-Only"-output
CC.Clip 'set the currently active (Text)Path as the new clipping-region
CC.Paint 1, Pat 'render-cmd for the Gradient-Pattern (now restricted to the clipped region, aka "the text-string-path")
Set Picture = CC.Surface.Picture 'set the result (in our Cairo-Surface) as the new Form-Picture
'Set Image1.Picture = CC.Surface.Picture 'in case one wants to reflect the result in an image-control
End Sub
Olaf
Hello Olaf again, I wanted to ask you, if you have time and desire, I've been looking at the documentation and so on, and I can't find 2 questions:
1.- How to know the measurements of the text to be displayed - to make an autosize property in a usercontrol -, I found this page: https://lists.freedesktop.org/archiv...ly/027587.html
But I can't adapt the code...
2.- How to make the gradient in different angles, in your very simple and fast code it is from Top to Bottom, how could it be done at any Angle?
The AI ??for these things, more in depth, always does it wrong... It made me a code that didn't work.
If you could make me the code that you made, very simple, but with which can put an angle from 0 to 359 in the gradient, and could show me how to measure the text according to the font it has, you would do me a great favor, but if you can and want...
Regards Olaf
Last edited by James Reynolds; Oct 8th, 2024 at 06:00 PM.
Re: How can I make a TextBox a mask for a background image?
Originally Posted by James Reynolds
1.- How to know the measurements of the text to be displayed - to make an autosize property in a usercontrol
The method: CC.GetTextExtents is, what you're looking for...
(which will give you the FontHeight as well, when you provide it with the Optional ByRef-Params)
Originally Posted by James Reynolds
2.- How to make the gradient in different angles, in your very simple and fast code it is from Top to Bottom, how could it be done at any Angle?
Re: How can I make a TextBox a mask for a background image?
Originally Posted by Schmidt
The method: CC.GetTextExtents is, what you're looking for...
(which will give you the FontHeight as well, when you provide it with the Optional ByRef-Params)
Thanks another time Olaf, I go to see the link, the size of Text I find searching here, you write in another topic, and work fine, the only problem I have is the angle of gradient, I go to see tthe link you write, thanks...
Re: How can I make a TextBox a mask for a background image?
Ok Olaf, good, here the 4 diagonals:
Code:
Private Sub Form_Load()
Caption = "Click me"
End Sub
Private Sub Form_Click()
Dim WPxl: WPxl = Me.ScaleX(Me.ScaleWidth, Me.ScaleMode, vbPixels)
Dim HPxl: HPxl = Me.ScaleY(Me.ScaleHeight, Me.ScaleMode, vbPixels)
Dim WPx2: WPx2 = Me.ScaleX(Me.ScaleWidth, Me.ScaleMode, vbPixels)
Dim HPx2: HPx2 = Me.ScaleY(Me.ScaleHeight, Me.ScaleMode, vbPixels)
SetGradientPictureOn Me, WPxl, HPxl, vbBlue, vbYellow, 0, 0, WPxl, HPxl
MsgBox "you see a Top-Left(blue) to Bottom-Right(yellow) gradient"
SetGradientPictureOn Me, WPxl, HPxl, vbBlue, vbYellow, WPxl, 0, 0, HPxl
MsgBox "and now a Top-Right(blue) to Bottom-Left(yellow) gradient"
SetGradientPictureOn Me, WPxl, HPxl, vbYellow, vbBlue, 0, 0, WPxl, HPxl
MsgBox "you see a Top-Left(yellow) to Bottom-Right(blue) gradient"
SetGradientPictureOn Me, WPxl, HPxl, vbYellow, vbBlue, WPxl, 0, 0, HPxl
MsgBox "and now a Top-Right(yellow) to Bottom-Left(blue) gradient"
End Sub
Sub SetGradientPictureOn(Dest As Object, WPxls, HPxls, Color1, Color2, x1, y1, x2, y2)
Dim CC As cCairoContext, Grd As cCairoPattern
Set CC = Cairo.CreateSurface(WPxls, HPxls).CreateContext
Set Grd = Cairo.CreateLinearPattern(x1, y1, x2, y2)
Grd.AddColorStop 0, Color1
Grd.AddColorStop 1, Color2
CC.Paint 1, Grd
Set Dest.Picture = CC.Surface.Picture
End Sub
But how could it be made to rotate 360 degrees without jumping?
For example, with a timer and it would rotate from 0 to 359 degrees
Re: How can I make a TextBox a mask for a background image?
Here I have the OCX, although I still need a few improvements:
1.- Olaf, when it obtains the Width and Height of the Text, calculates it as if there were - even if there aren't - letters with a downward size, like the lowercase q, the lowercase p, and others, and leaves a margin above, that makes the gradient not be exact in the exact size of the Text. And if the text size is changed, those margins change, so it is difficult to calibrate it well. At least for me.
2.- I have played with changing the Sin, Cos, etc., when I go over a 90 Degree Angle, but I haven't managed it, and I would like it to be able to rotate to any angle.
3.- I need to check well what you told me about Unicode UTF8, those functions that you gave me.
Except for this, I think the Gradient Label OCX is quite complete.
And thanks to your excellent work with RC6.dll, I hope that the OCX is useful to someone and that they can improve it. I am also working on improving it by solving those things that I am missing.
And I don't quite understand why there isn't - at least I haven't found anything out there - an OCX that is a Label with Gradient, aesthetically it is very useful.
When it is more polished in those things that I am missing, I will upload it to CodeBank.
Re: How can I make a TextBox a mask for a background image?
A bit confusing to handle the Sin and Cos, and where they should go in Cairo.CreateLinearPattern
It's one of those things that one gets confused easily, I think Olaf - sorry, it's not a criticism, you've already done a lot, criticizing would be a complete lack of respect apart from stupidity on my part, it's just a suggestion - it would be good to have a function that automatically adapts the gradient according to the angle from 0 to 359.999999
Now I want to experiment by making it move from bottom to top, to achieve the effect of the Indiana Jones and Atlantis game that was made in 1992, although I don't know if that would saturate Resources or CPU or GPU:
If anyone knows how to do this and can give me a code, I would appreciate it, not because I don't have to do the work myself, but because I'm very short on time and have to finish a program before December...
Here is the solution to rotate 2 colors in 360 degrees, click in the form and reference to RC6.dll: Cairo360Angles.zip
Last edited by James Reynolds; Oct 10th, 2024 at 06:02 AM.
Re: How can I make a TextBox a mask for a background image?
Originally Posted by James Reynolds
A bit confusing to handle the Sin and Cos, and where they should go in Cairo.CreateLinearPattern
It's one of those things that one gets confused easily, I think Olaf - sorry, it's not a criticism, you've already done a lot, criticizing would be a complete lack of respect apart from stupidity on my part, it's just a suggestion - it would be good to have a function that automatically adapts the gradient according to the angle from 0 to 359.999999
Now I want to experiment by making it move from bottom to top, to achieve the effect of the Indiana Jones and Atlantis game that was made in 1992, although I don't know if that would saturate Resources or CPU or GPU:
If anyone knows how to do this and can give me a code, I would appreciate it, not because I don't have to do the work myself, but because I'm very short on time and have to finish a program before December...
Here is the solution to rotate 2 colors in 360 degrees, click in the form and reference to RC6.dll: Cairo360Angles.zip
Well, I answer myself, here is the animation, in all rect directions (Left to Right, Right to Left, Up to Down and Down to UP):
Re: How can I make a TextBox a mask for a background image?
Originally Posted by James Reynolds
Well, I answer myself, here is the animation, in all rect directions (Left to Right, Right to Left, Up to Down and Down to UP):
Glad you figured out yourself, how to work with the different "Pattern-Extend"-Options (Reflect, Repeat, etc.).
As for your Gradient-Rotation-Demo - there's a more coding-efficient way to handle the whole thing -
using another property of a cCairoPattern -> the Pattern.Matrix (which allows Transformation-settings on the Pattern itself).
Here's a Demo for an empty VB6-Form (RC6-reference is needed in the Project):
Code:
Option Explicit
Private AngDeg As Long, WithEvents tmrRotate As cTimer '<- let's use an RC6.cTimer here (WithEvents)
Private Sub Form_Load()
Caption = "Click Me"
End Sub
Private Sub Form_Click()
AngDeg = 0
Set tmrRotate = New_c.Timer(15, True)
End Sub
Private Sub Form_Resize()
RenderToFormOrPicBox Me, 0, Array(vbRed, vbYellow)
End Sub
Private Sub tmrRotate_Timer()
AngDeg = AngDeg + 1
If AngDeg = 360 Then AngDeg = 0: Set tmrRotate = Nothing
RenderToFormOrPicBox Me, AngDeg, Array(vbRed, vbYellow)
Caption = AngDeg & "°"
End Sub
Private Sub RenderToFormOrPicBox(Canvas, ByVal AngDeg, ColorStops)
Canvas.ScaleMode = vbPixels
Dim A: A = AngDeg / 180 * Cairo.PI
Dim W: W = Canvas.ScaleWidth
Dim H: H = Canvas.ScaleHeight
If W = 0 Or H = 0 Then Exit Sub
Dim CC As cCairoContext, Pat As cCairoPattern, M As cCairoMatrix, i As Long
Set CC = Cairo.CreateSurface(W, H).CreateContext
Set Pat = Cairo.CreateLinearPattern(0, 0, W, 0)
Set M = Cairo.CreateIdentityMatrix
M.TranslateCoords W / 2, H / 2
M.ScaleCoords Sqr(Cos(A) ^ 2 + (W / H * Sin(A)) ^ 2), 1
M.RotateCoordsDeg -AngDeg
M.TranslateCoords -W / 2, -H / 2
Set Pat.Matrix = M
For i = 0 To UBound(ColorStops) 'now add the Color-Stops for this gradient-pattern
Pat.AddColorStop i / UBound(ColorStops), ColorStops(i)
Next
CC.Paint 1, Pat
Set Canvas.Picture = CC.Surface.Picture
End Sub
BTW, you don't need to include the RC6-Dll in your Zipped-Examples.
Those who want to test things out, already have RC6 installed and registered on their machines...
And just in case you do that (placing a copy of RC6.dll in the Project-Path of "each of your own Projects") - it is not needed...
The RC6.dll is of no use when placed "isolated from all its other Dll-dependencies" (cairo_sqlite.dll, DirectCom.dll, etc.).
For development, it needs to reside "in only one place" on your machine (also being registered in that folder, once after unpacking the BaseDlls-zip).
Re: How can I make a TextBox a mask for a background image?
Originally Posted by Schmidt
Glad you figured out yourself, how to work with the different "Pattern-Extend"-Options (Reflect, Repeat, etc.).
As for your Gradient-Rotation-Demo - there's a more coding-efficient way to handle the whole thing -
using another property of a cCairoPattern -> the Pattern.Matrix (which allows Transformation-settings on the Pattern itself).
Here's a Demo for an empty VB6-Form (RC6-reference is needed in the Project):
Code:
Option Explicit
Private AngDeg As Long, WithEvents tmrRotate As cTimer '<- let's use an RC6.cTimer here (WithEvents)
Private Sub Form_Load()
Caption = "Click Me"
End Sub
Private Sub Form_Click()
AngDeg = 0
Set tmrRotate = New_c.Timer(15, True)
End Sub
Private Sub Form_Resize()
RenderToFormOrPicBox Me, 0, Array(vbRed, vbYellow)
End Sub
Private Sub tmrRotate_Timer()
AngDeg = AngDeg + 1
If AngDeg = 360 Then AngDeg = 0: Set tmrRotate = Nothing
RenderToFormOrPicBox Me, AngDeg, Array(vbRed, vbYellow)
Caption = AngDeg & "°"
End Sub
Private Sub RenderToFormOrPicBox(Canvas, ByVal AngDeg, ColorStops)
Canvas.ScaleMode = vbPixels
Dim A: A = AngDeg / 180 * Cairo.PI
Dim W: W = Canvas.ScaleWidth
Dim H: H = Canvas.ScaleHeight
If W = 0 Or H = 0 Then Exit Sub
Dim CC As cCairoContext, Pat As cCairoPattern, M As cCairoMatrix, i As Long
Set CC = Cairo.CreateSurface(W, H).CreateContext
Set Pat = Cairo.CreateLinearPattern(0, 0, W, 0)
Set M = Cairo.CreateIdentityMatrix
M.TranslateCoords W / 2, H / 2
M.ScaleCoords Sqr(Cos(A) ^ 2 + (W / H * Sin(A)) ^ 2), 1
M.RotateCoordsDeg -AngDeg
M.TranslateCoords -W / 2, -H / 2
Set Pat.Matrix = M
For i = 0 To UBound(ColorStops) 'now add the Color-Stops for this gradient-pattern
Pat.AddColorStop i / UBound(ColorStops), ColorStops(i)
Next
CC.Paint 1, Pat
Set Canvas.Picture = CC.Surface.Picture
End Sub
BTW, you don't need to include the RC6-Dll in your Zipped-Examples.
Those who want to test things out, already have RC6 installed and registered on their machines...
And just in case you do that (placing a copy of RC6.dll in the Project-Path of "each of your own Projects") - it is not needed...
The RC6.dll is of no use when placed "isolated from all its other Dll-dependencies" (cairo_sqlite.dll, DirectCom.dll, etc.).
For development, it needs to reside "in only one place" on your machine (also being registered in that folder, once after unpacking the BaseDlls-zip).
HTH
Olaf
Thanks Olaf, not is easy work with "Pattern-Extend"-Options (Reflect, Repeat, etc.),
It requires a good abstract mind, and at 65 years old I lose some faculties hehe...
Well, I think there will be people like me who didn't know about these dlls, and if they don't know where to find them, it might be a waste of time to look for them, I think.
Thanks for your time, because I imagine you are very busy, because I have seen that you are in compilers and very complex things, so it is appreciated that you dedicate some time to me...
And well, if you have time, and you want, with the thing about making the letters of the Indiana Jones Game, I can't get them to look quite right, the effect they make is curious, there is a moment when they all stay red-orange, and when it is yellow, there they do not stay completely yellow, I put 2 images here:
I have played with this part of the code that seems to be a bit key, but I can't get it to look the same as the effect of the Indiana Jones game, which is very nice, it is not bad, but it is not as good as the one in the game, well that is it, in the game there are 2 parts, when it stays in red-orange it is completely the letters in red-orange, but in the yellow part, it never stays as complete yellow, but with a gradient that starts at the top and bottom, it is complex to do, and it seems to be here is the key unless there is another type of code in Cairo that handles it perfectly:
Dim WidthText As Double
Dim HeightText As Double
Const CAIRO_EXTEND_NONE = 0
Const CAIRO_EXTEND_REPEAT = 1
Const CAIRO_EXTEND_REFLECT = 2
Const CAIRO_EXTEND_PAD = 3
Dim Offset As Double
Dim OffsetMultiplier As Double
Private Sub Form_Load()
ResetValues
End Sub
Private Sub ResetValues()
Me.AutoRedraw = True
Me.ScaleMode = vbPixels
Timer1.Interval = 20
Timer1.Enabled = True
Offset = 0
OffsetMultiplier = 6
Option1(0).Value = True
Caption = "Gradient Label Animation"
Label3(0).Caption = CStr(Timer1.Interval)
Label3(1).Caption = CStr(OffsetMultiplier)
End Sub
Private Sub Form_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Form_Resize()
Image1.Left = (Me.ScaleWidth - Image1.Width) / 2
Picture1.Left = (Me.ScaleWidth - Picture1.Width) / 2
End Sub
Private Sub Label1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Index = 0 Then
If Timer1.Interval < 100 Then
If Button = 1 Then
NewInterval% = Timer1.Interval + 1
Else
NewInterval% = Timer1.Interval + 5
End If
If NewInterval% > 100 Then
NewInterval% = 100
End If
Timer1.Interval = NewInterval%
Label3(0).Caption = CStr(Timer1.Interval)
End If
ElseIf Index = 1 Then
If OffsetMultiplier <= 30 Then
If Button = 1 Then
OffsetMultiplier = OffsetMultiplier - 1
Else
OffsetMultiplier = OffsetMultiplier - 2
End If
If OffsetMultiplier < 1 Then
OffsetMultiplier = 1
End If
Label3(1).Caption = CStr(OffsetMultiplier)
End If
End If
End Sub
Private Sub Label2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Index = 0 Then
If Timer1.Interval < 100 Then
If Button = 1 Then
NewInterval% = Timer1.Interval - 1
Else
NewInterval% = Timer1.Interval - 5
End If
If NewInterval% < 1 Then
NewInterval% = 1
End If
Timer1.Interval = NewInterval%
Label3(0).Caption = CStr(Timer1.Interval)
End If
ElseIf Index = 1 Then
If OffsetMultiplier >= 0 Then
If Button = 1 Then
OffsetMultiplier = OffsetMultiplier + 1
Else
OffsetMultiplier = OffsetMultiplier + 2
End If
If OffsetMultiplier > 30 Then
OffsetMultiplier = 30
End If
Label3(1).Caption = CStr(OffsetMultiplier)
End If
End If
End Sub
Private Sub Label4_Click()
ResetValues
End Sub
Private Sub Option1_Click(Index As Integer)
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If Option1(0).Value Or Option1(2).Value Then
Offset = (Offset + OffsetMultiplier) Mod 128 ' Ajusta este valor para cambiar la velocidad
Else
Offset = (Offset - OffsetMultiplier) Mod 128 ' Ajusta este valor para cambiar la velocidad
End If
PaintTextGradient Offset
End Sub
Private Sub PaintTextGradient(ByVal Offset As Double)
Dim Pat As cCairoPattern, CC As cCairoContext
ForntSizeText# = 60
TxtStr$ = "Some Text"
WidthText = 300
HeightText = 100
Set CC = Cairo.CreateSurface(WidthText, HeightText).CreateContext
CC.SelectFont "Arial", ForntSizeText#, , True
WidthText = CC.GetTextExtents(TxtStr$, HeightText) 'ahora determina TextWidth y FontHeight en las coordenadas del dispositivo
Set CC = Cairo.CreateSurface(WidthText, HeightText).CreateContext
CC.SetSourceColor &H4000&
CC.Paint
If Option1(0).Value Or Option1(1).Value Then
Set Pat = Cairo.CreateLinearPattern(Offset + 128, 0, Offset, 0)
Else
Set Pat = Cairo.CreateLinearPattern(0, Offset + 128, 0, Offset)
End If
Pat.AddColorStop 0, &H373FF
'Pat.AddColorStop 0.1, &H373FF
'Pat.AddColorStop 0.2, &H373FF
'Pat.AddColorStop 0.3, &H54D8FF
'Pat.AddColorStop 0.4, &H54D8FF
Pat.AddColorStop 0.5, &H54D8FF
'Pat.AddColorStop 0.6, &H54D8FF
'Pat.AddColorStop 0.7, &H54D8FF
'Pat.AddColorStop 0.8, &H373FF
'Pat.AddColorStop 0.9, &H373FF
Pat.AddColorStop 1, &H373FF
Pat.Extend = CAIRO_EXTEND_REPEAT
CC.SelectFont "Arial", ForntSizeText#, , True
CC.DrawText 0, 0, WidthText, HeightText, "Some Text", True, vbCenter, 2, True, , , True
CC.Clip
CC.SetSourcePattern Pat
CC.Paint
Set Image1.Picture = CC.Surface.Picture
Image1.Left = (Me.ScaleWidth - Image1.Width) / 2
End Sub
If you have time and fancy it - if not, if you're really busy, obviously leave it - do you have any idea how to do it like in the game?
At all, another time, thanks for your time, and, of course, only if you have time, and you want...
Re: How can I make a TextBox a mask for a background image?
Originally Posted by James Reynolds
If you have time and fancy it - if not, if you're really busy, obviously leave it - do you have any idea how to do it like in the game?
If you want to make the "Waving" between two colors symmetrical -
you should only define two ColorStops (at 0# and 1#) and use Pattern-Reflection.
(along with a continuosly increasing or decreasing Offset As Double - without Modulo-Operation)...
Here's the adapted Form-Code of your posted example:
Code:
Option Explicit
Private Offset As Double
Private Sub Form_Load()
Me.AutoRedraw = True
Me.ScaleMode = vbPixels
Timer1.Interval = 100
Timer1.Enabled = False
Offset = 0 ' Comenzamos desde cero
Caption = "Click Me"
Label3.Caption = CStr(Timer1.Interval)
End Sub
Private Sub Form_Click()
' Iniciar o detener la animación al hacer clic en el formulario
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Label1_Click()
If Timer1.Interval < 100 Then
Timer1.Interval = Timer1.Interval + 1
Label3.Caption = CStr(Timer1.Interval)
End If
End Sub
Private Sub Label2_Click()
If Timer1.Interval > 2 Then
Timer1.Interval = Timer1.Interval - 1
Label3.Caption = CStr(Timer1.Interval)
End If
End Sub
Private Sub Option1_Click(Index As Integer)
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
' Actualizamos el offset para mover el gradiente hacia arriba de forma continua
Offset = Offset + IIf(Option1(0).Value Or Option1(2).Value, 2, -2) ' Ajusta este valor para cambiar la velocidad
PaintTextGradient Offset
End Sub
Private Sub PaintTextGradient(ByVal Offset As Double)
Dim Pat As cCairoPattern, CC As cCairoContext
' Crear un contexto Cairo del tamaño deseado
Set CC = Cairo.CreateSurface(480, 120).CreateContext
' Establecer el color de fondo
CC.SetSourceColor &H4000& ' Color de fondo personalizado
CC.Paint
' Crear el patrón de gradiente lineal y configurarlo para que se repita
' Ajustamos las coordenadas del gradiente directamente usando Offset
If Option1(0).Value Or Option1(1).Value Then
Set Pat = Cairo.CreateLinearPattern(0, 0, 96, 0)
Set Pat.Matrix = Pat.Matrix.TranslateCoords(-Offset, 0)
Else
Set Pat = Cairo.CreateLinearPattern(0, 0, 0, 96)
Set Pat.Matrix = Pat.Matrix.TranslateCoords(0, -Offset)
End If
Pat.AddColorStop 0#, vbRed
Pat.AddColorStop 1#, vbYellow
Pat.Extend = CAIRO_EXTEND_REFLECT ' Hacemos que el gradiente se repita
' Seleccionar la fuente y dibujar el texto
CC.SelectFont "Arial", 66, , True
CC.DrawText 0, 0, CC.Surface.Width, CC.Surface.Height, "Some Text", True, vbCenter, 2, True, , , True
' Aplicar clipping al texto
CC.Clip
' Establecer el patrón como fuente y pintar dentro del área del texto
CC.SetSourcePattern Pat
CC.Paint
' Actualizar la imagen en el formulario
Set Image1.Picture = CC.Surface.Picture
End Sub
Re: How can I make a TextBox a mask for a background image?
Well Olaf, here an almost complete OCX.
I still need some small details, but it is very complete Thanks to your codes Olaf: GradientTextOCX2.zip
It has animation in the 4 cardinal angles, 0, 90, 180, 270, and in the horizontal animations - left to right or right to left - the bands can be enlarged with the AnimHorzWidthBands property.
I would like to make a 360 degree rotation animation, and change the height of the bands in the vertical animations, and have it animate at any angle, and be able to add a random that changes colors, as well as being able to add several colors, it is not very difficult, but I am short on time, for now it works for my needs, and I will do it in the future.
I only have one problem with FontItalic, which leaves it like this, I not know wath pass about the Last Letter, in your original codes it doesn't happen, I don't know why it happens inside the OCX:
And well, although it may seem silly, on a psychological level if there is something in motion, more attention is paid to it and it is remembered better, which is good for a program...
I am Spanish from Spain, and my father was the pioneer in Spain in the 1960s and 1970s in what everyone knows now, Creativity, Brainstorming, Lateral Thinking, Marketing, Edward de Bono, etc...
In those days, in Franco's Spain, they had no idea about all this, and well, I know something about Psychology and Marketing from my Father, and my Uncle who was Sales Director of the American Express Card for the entire Northern Zone of Spain, and I know that, although it may seem silly, the aesthetics and some things that are activated in movement at some given moment - not always, because that tires, but if you go through a section of a program, and suddenly something moves, it captures the attention of the brain, even if it is only for a few seconds and then it stops - they capture attention, and the I'm finishing the program, if they don't block it, it could be a bomb, and I want a lot of aesthetics...
Greetings Olaf and everyone...
Last edited by James Reynolds; Oct 13th, 2024 at 09:42 AM.
Re: How can I make a TextBox a mask for a background image?
Originally Posted by James Reynolds
Olaf, sorry, is possible the gradient text have the background transparent? How the label control BackStyle Transparent?
You can do that by using the GDIAlphaBlend-API in the UserControl_Paint-Event of a WindowLess-Control.
Here's complete example-code (to be placed in a windowless UserControl):
Code:
Option Explicit
Private Declare Function GdiAlphaBlend& Lib "gdi32" (ByVal hDC&, ByVal x&, ByVal y&, ByVal dx&, ByVal dy&, ByVal hdcSrc&, ByVal srcx&, ByVal srcy&, ByVal SrcdX&, ByVal SrcdY&, ByVal lBlendFunction&)
Private BBuf As cCairoSurface 'let's use a BackBuffer-Surface
Private Sub UserControl_Initialize()
ScaleMode = vbPixels: BackStyle = 0: FillStyle = 1
End Sub
Private Sub UserControl_Resize()
Redraw
End Sub
Private Sub UserControl_HitTest(x As Single, y As Single, HitResult As Integer)
HitResult = vbHitResultHit
End Sub
'finally all Cairo-Drawing-related routines, beginning with the entry-point of the Drawing-Stack (the Refresh-Routine below)
Public Sub Redraw()
Set BBuf = Cairo.CreateWin32Surface(ScaleWidth, ScaleHeight) 'creates a Surface with an internal hDC
DrawOn BBuf.CreateContext
UserControl.Refresh '<- this will trigger the UserControl_Paint-Event finally
End Sub
Private Sub UserControl_Paint() 'we use a GDI-call in the Paint-Routine for Flipping things over (for "deep BackBuffer-Refreshs", use the Refresh-Method)
GdiAlphaBlend hDC, 0, 0, BBuf.Width, BBuf.Height, BBuf.GetDC, 0, 0, BBuf.Width, BBuf.Height, 2 ^ 24 + &HFF0000 * 1
End Sub
Private Sub DrawOn(CC As cCairoContext)
CC.Operator = CAIRO_OPERATOR_CLEAR: CC.Paint 'clear the BackBuffer
CC.Operator = CAIRO_OPERATOR_OVER 'reset to the default-Blending-Operator
CC.Arc 10, 10, 8 'draw something on the now cleared Surface
CC.Fill , Cairo.CreateSolidPatternLng(vbBlue)
End Sub
Re: How can I make a TextBox a mask for a background image?
Originally Posted by Schmidt
You can do that by using the GDIAlphaBlend-API in the UserControl_Paint-Event of a WindowLess-Control.
Here's complete example-code (to be placed in a windowless UserControl):
Code:
Option Explicit
Private Declare Function GdiAlphaBlend& Lib "gdi32" (ByVal hDC&, ByVal x&, ByVal y&, ByVal dx&, ByVal dy&, ByVal hdcSrc&, ByVal srcx&, ByVal srcy&, ByVal SrcdX&, ByVal SrcdY&, ByVal lBlendFunction&)
Private BBuf As cCairoSurface 'let's use a BackBuffer-Surface
Private Sub UserControl_Initialize()
ScaleMode = vbPixels: BackStyle = 0: FillStyle = 1
End Sub
Private Sub UserControl_Resize()
Redraw
End Sub
Private Sub UserControl_HitTest(x As Single, y As Single, HitResult As Integer)
HitResult = vbHitResultHit
End Sub
'finally all Cairo-Drawing-related routines, beginning with the entry-point of the Drawing-Stack (the Refresh-Routine below)
Public Sub Redraw()
Set BBuf = Cairo.CreateWin32Surface(ScaleWidth, ScaleHeight) 'creates a Surface with an internal hDC
DrawOn BBuf.CreateContext
UserControl.Refresh '<- this will trigger the UserControl_Paint-Event finally
End Sub
Private Sub UserControl_Paint() 'we use a GDI-call in the Paint-Routine for Flipping things over (for "deep BackBuffer-Refreshs", use the Refresh-Method)
GdiAlphaBlend hDC, 0, 0, BBuf.Width, BBuf.Height, BBuf.GetDC, 0, 0, BBuf.Width, BBuf.Height, 2 ^ 24 + &HFF0000 * 1
End Sub
Private Sub DrawOn(CC As cCairoContext)
CC.Operator = CAIRO_OPERATOR_CLEAR: CC.Paint 'clear the BackBuffer
CC.Operator = CAIRO_OPERATOR_OVER 'reset to the default-Blending-Operator
CC.Arc 10, 10, 8 'draw something on the now cleared Surface
CC.Fill , Cairo.CreateSolidPatternLng(vbBlue)
End Sub
Olaf
Ok Olaf, thanks, but this not print the gradient label?
Option Explicit
Private BackBuf As cCairoSurface
Private Sub Form_Load()
Me.AutoRedraw = True:
Cairo.ImageList.AddImage "bg", App.Path & "\bg.jpg" 'preload a (usually non-alpha) background-image-resource
End Sub
Private Sub Form_Resize() 'ensure a Form-covering "backbuffer-surface"
ScaleMode = vbPixels: Set BackBuf = Cairo.CreateSurface(ScaleWidth, ScaleHeight)
RedrawSceneOnBackBuf BackBuf.CreateContext 'backbuf-refresh
End Sub
Private Sub RedrawSceneOnBackBuf(CC As cCairoContext)
CC.RenderSurfaceContent "bg", 0, 0, CC.Surface.Width, CC.Surface.Height 'instead of painting a solid color, we now use a bg-image to "clear the scene"
DrawHollowedTransformedCircleOn CC 'ClockCopy.CreateContext
BackBuf.DrawToDC Me.hDC 'backbuf-flipping to the Form-hDC
Me.Refresh 'trigger Form_Paint
End Sub
Private Sub DrawHollowedTransformedCircleOn(CC As cCairoContext)
Dim Pat As cCairoPattern
Set Pat = Cairo.CreateLinearPattern(0, 0, 96, 0)
Set Pat.Matrix = Pat.Matrix.TranslateCoords(-2, 0)
Pat.AddColorStop 0#, RGB(255, 26, 0)
Pat.AddColorStop 1#, vbYellow
Pat.Extend = CAIRO_EXTEND_REFLECT ' Hacemos que el gradiente se repita
CC.SelectFont "Times New Roman", 46, , True
CC.DrawText 0, 0, CC.Surface.Width, CC.Surface.Height, "INDIANA JONES", True, vbCenter, 2, True, , , True
CC.Clip
CC.SetSourcePattern Pat
CC.Paint
End Sub
And the result is how this:
Looking for alternatives, well if you can print in a form, why couldn't you do it in the OCX like that? And not windowLess...
I think there must be some simple way to make the gradient text have a transparent background, without having to do the WindowLess control, even if it's copying the sector where it's going to go, saving it as an image, and loading it and playing with the HDC's... Although there may be a simpler way...
Re: How can I make a TextBox a mask for a background image?
Originally Posted by James Reynolds
Ok Olaf, thanks, but this not print the gradient label?
No, #27 just shows the minimal-code for a transparent (cairo-based) UserControl (or OCX, if you want).
Instead of the simple CC.Arc/Fill - you can place the same code-sequence you added into the:
DrawHollowed...Circle-routine in your example in #28.
Originally Posted by James Reynolds
I think there must be some simple way to make the gradient text have a transparent background, ...
It does not get much simpler than #27, when you want to implement a BackStyle==Transparent (Label-like) OCX or Private UserControl.
If you don't like Ctls/OCXes - you can of course always render with certain Offsets against any given Form-BackGround
(either directly from "special routines", or by using Methods of "My special CairoDrawingObj-Classes" which are not a Ctl).
Re: How can I make a TextBox a mask for a background image?
Thanks Olaf
Well, You must have a very good head, I would like to know when you were born hehe, because I am an Astrologist - here I am playing that due to Pavlov's conditioned reflexes, you run away, because in the world, most people follow conditioned patterns instead of doing a rational and experimental analysis, which is what science really is -...
Astrology is a hidden knowledge, and it has been deliberately discredited, because certain groups of power are not interested in it being known, and that is why they have discredited it, they promote hallucinators and storytellers, so that no rational person comes close, so that the vast majority thinks "that is something for the stupid or crazy"...
But no, there is an astrology that is real and that works, and it has been known since ancient times, since the Sumerians...
The program that I am finishing is the Scientific Demonstration of Real Astrology, which will be a program that According to the data of Birth, Date, Time and Place of Birth, the most key periods in the past life of people are given as answers, as well as the future, but the key to verify is in the past life...
And a PC only calculates, it is not a medium, nor does it have intuition, nor is it inspired by the muses, pure calculation, and calculation is mathematics, the universal language of science...
When it is right, the mystery is over!!! And the nonsense!!!
And what is it that a human being can verify the most?
His own life experience!!! We can be convinced of Einstein's formula, E = MC2, but we don't have a direct real proof, however, it is what we can most certainly know about key moments in our lives...
According to my experience of almost 40 years, the accuracy rate will be around 85 to 90%...
If you want to give me your birth data Olaf by private message, I'll surprise you...
Apart from that, regarding the Label Gradient, WindowsLess leaves the Usercontrol very limited, since you can't apply almost any API to it because it lacks hwnd...
I'm finishing capturing the background image of the usercontrol, saving it, loading it into the usercontrol, and putting the label with gradient on top...
I've actually got it almost ready, it will never be a total transparency, it's more of a trick, but in most cases it's functional, unless something moves under the usercontrol, which I don't know how to know!!!
Greetings!!! And thanks again for your time Olaf...
Re: How can I make a TextBox a mask for a background image?
Originally Posted by Schmidt
You can do that by using the GDIAlphaBlend-API in the UserControl_Paint-Event of a WindowLess-Control.
Here's complete example-code (to be placed in a windowless UserControl):
Code:
Option Explicit
Private Declare Function GdiAlphaBlend& Lib "gdi32" (ByVal hDC&, ByVal x&, ByVal y&, ByVal dx&, ByVal dy&, ByVal hdcSrc&, ByVal srcx&, ByVal srcy&, ByVal SrcdX&, ByVal SrcdY&, ByVal lBlendFunction&)
Private BBuf As cCairoSurface 'let's use a BackBuffer-Surface
Private Sub UserControl_Initialize()
ScaleMode = vbPixels: BackStyle = 0: FillStyle = 1
End Sub
Private Sub UserControl_Resize()
Redraw
End Sub
Private Sub UserControl_HitTest(x As Single, y As Single, HitResult As Integer)
HitResult = vbHitResultHit
End Sub
'finally all Cairo-Drawing-related routines, beginning with the entry-point of the Drawing-Stack (the Refresh-Routine below)
Public Sub Redraw()
Set BBuf = Cairo.CreateWin32Surface(ScaleWidth, ScaleHeight) 'creates a Surface with an internal hDC
DrawOn BBuf.CreateContext
UserControl.Refresh '<- this will trigger the UserControl_Paint-Event finally
End Sub
Private Sub UserControl_Paint() 'we use a GDI-call in the Paint-Routine for Flipping things over (for "deep BackBuffer-Refreshs", use the Refresh-Method)
GdiAlphaBlend hDC, 0, 0, BBuf.Width, BBuf.Height, BBuf.GetDC, 0, 0, BBuf.Width, BBuf.Height, 2 ^ 24 + &HFF0000 * 1
End Sub
Private Sub DrawOn(CC As cCairoContext)
CC.Operator = CAIRO_OPERATOR_CLEAR: CC.Paint 'clear the BackBuffer
CC.Operator = CAIRO_OPERATOR_OVER 'reset to the default-Blending-Operator
CC.Arc 10, 10, 8 'draw something on the now cleared Surface
CC.Fill , Cairo.CreateSolidPatternLng(vbBlue)
End Sub
Olaf
I am testing... And Sorry Olaf, but something is not right in the code for the Transparent Usercontrol with WindowLess, because nothing is visible, not even the Arc or anything. I left the code in the Zip, and it is a copy paste of what you posted. I think something is missing in that code, sorry... CairoWindowLessTransparent.zip
Re: How can I make a TextBox a mask for a background image?
Originally Posted by James Reynolds
I am testing... And
Sorry Olaf, but something is not right in the code for the Transparent Usercontrol with WindowLess, because nothing is visible, not even the Arc or anything.
Forgot to adapt one of the UC-DefaultProps in Initialize...have added it in this version here:
Code:
Private Sub UserControl_Initialize()
ScaleMode = vbPixels: BackStyle = 0: FillStyle = 1: ClipBehavior = 0
End Sub
P.S. since I see you posting these zipped OCX-Project-Types (which contain your new Control)...
Are you aware, that you can compile a normal "Std-Exe" Project with any number of Private User-Controls?
(all hosted - and later "shipped" in the same hosting *.exe-Project - no OCX-shipping, no registering...)?
Re: How can I make a TextBox a mask for a background image?
Originally Posted by Schmidt
Are you aware, that you can compile a normal "Std-Exe" Project with any number of Private User-Controls?
(all hosted - and later "shipped" in the same hosting *.exe-Project - no OCX-shipping, no registering...)?
Frankly in this day and age the only sane option. Unless you are selling OCXes to other developers or using 3-rd party ones.
Re: How can I make a TextBox a mask for a background image?
Originally Posted by Schmidt
Forgot to adapt one of the UC-DefaultProps in Initialize...have added it in this version here:
Code:
Private Sub UserControl_Initialize()
ScaleMode = vbPixels: BackStyle = 0: FillStyle = 1: ClipBehavior = 0
End Sub
P.S. since I see you posting these zipped OCX-Project-Types (which contain your new Control)...
Are you aware, that you can compile a normal "Std-Exe" Project with any number of Private User-Controls?
(all hosted - and later "shipped" in the same hosting *.exe-Project - no OCX-shipping, no registering...)?
Especially when the Font-Renderings get larger, you will be better of,
when (using Cairo) you render the Fonts as Paths, followed by a CC.Fill.
Couldn't find the Font you were using on my System, so for the examples below
I've choosen 'Segoe Print' (in 42pt Size), rendered onto a 96dpi Bitmap.
Here's what Windows-ClearType will produce (on a Win8-System).
And here's the result when using Cairo-TextPath-Rendering/Filling:
Here the same sequences in White-TextColor again - first Windows-ClearType:
And here Cairo again:
I'd consider (with these larger Font-Sizes) the Cairo-Path-Outputs better than the Windows-ClearType-Output.
The first line in the Cairo-produced Images are (as said) normal Path-Filling...
The second Line in the Cairo-Outputs is normal Path-Filling, followed by some PostProcessing.
The third Line in the Cairo-Output is also PostProcessed (in the same way as Line2), but with a Pre-Blurring.
Maybe what the first line of the Cairo-Outputs produces, is already good enough for you...
If not, I could post the PostProcessing-algo (used for Lines 2 and 3 in the Cairo-Outputs)...
Olaf
Is it possible Olaf to provide a small example code for people who are not very familiar with Cairo?
For example, this image is make with Flash and Captured and make a Image - but, at now, not remember if is make with some filter -:
Here enlarged, I not upload from here because in the upload, lost the exactly image - if I put with url, rest how http://www.vbforums.com/www.timezone...entinflash.bmp - because this I put only the text of the url:
https:/www.timezonespro.com/textgradientinflash.bmp
And Flash makes it look very nice... Although it is a gradient with only 2 colors...
And the filters in flash were very good, I have seen some of filters in Cairo, in this Forum I have seen something similar with Blur...
Last edited by James Reynolds; Oct 18th, 2024 at 12:21 AM.
Re: How can I make a TextBox a mask for a background image?
Originally Posted by wqweto
Frankly in this day and age the only sane option. Unless you are selling OCXes to other developers or using 3-rd party ones.
cheers,
</wqw>
Yes, how I want to have support for all languages, so I use third-party OCX, especially ComboBox and ListBox from TimoSoft, because in Cairo, which I don't know well - and always, even though Google translates, I don't know English well, and I always have a bit of a handicap - I don't know if it makes ComboBox and ListBox...
And since I consider that Olaf is already spending too much time with me, I'm not asking for too many things, I'm happy with having a nice Label with gradient...
The thing about Fonts with Antialias, I think it's very interesting for Labels...
Thanks wqweto and Olaf
Last edited by James Reynolds; Oct 17th, 2024 at 11:59 PM.
But with Normal Hwnd because I capture the background of the Usercontrol and then use it with:
Cairo.ImageList.AddImage "bg", App.Path + "\capturaUserControl.bmp"
I have tried with:
Cairo.ImageList.Item("bg").DrawToDC Picture1.hDC
But I have not managed to get it to work properly, and since I am short on time, this is enough for me.
The user control background image capture is only necessary when the user control changes position relative to its container, or when it changes size...
If something moves underneath it, which is rare in normal programming, unless there is a video or an animated gif underneath, it does not detect it, that is the bad thing about not being WindowLess...
It certainly has some things to polish, if Olaf wants and has time, he can take a look at it to polish some things...
Here is a short video - Put 4k in quality to look better -:
Greetings!!! Thanks Olaf!!!
Last edited by James Reynolds; Oct 18th, 2024 at 07:02 AM.
Re: How can I make a TextBox a mask for a background image?
Yes, how I want to have support for all languages, so I use third-party OCX, especially ComboBox and ListBox from TimoSoft, because in Cairo, which I don't know well - and always, even though Google translates, I don't know English well, and I always have a bit of a handicap - I don't know if it makes ComboBox and ListBox...