Drawing? what do we wrong...

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
6 posts Page 1 of 1
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Drawing? what do we wrong...
Dummy1912
Hello,

Can anyone helpme out please
because i don't know anymore how or what to do...

when we run our form and hover over the form it shows great
image 1

when we leave the form and go back it messed up :(
image 2


anyone please
Code: Select all
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports Employee_Planner_17.FormSkin

<ToolboxBitmap(GetType(ToolTip))>
<ToolboxItemFilter("System.Windows.Forms")>
Public Class SkinToolTip
    Inherits ToolTip

#Region "Fields"

    ' TODO: Instead of hiding these, we should implement a property filter

    <DefaultValue(True)>
    <Browsable(False)>
    Public Shadows Property ShowAlways() As Boolean
        Get
            Return MyBase.ShowAlways
        End Get
        Set(value As Boolean)
            MyBase.ShowAlways = True
        End Set
    End Property

    <DefaultValue(True)>
    <Browsable(False)>
    Public Shadows Property OwnerDraw() As Boolean
        Get
            Return MyBase.OwnerDraw
        End Get
        Set(value As Boolean)
            MyBase.OwnerDraw = True
        End Set
    End Property

    <Browsable(False)>
    Public Shadows Property IsBalloon() As Boolean
        Get
            Return MyBase.IsBalloon
        End Get
        Set(value As Boolean)
            MyBase.IsBalloon = False
        End Set
    End Property

    <Browsable(False)>
    Public Shadows Property ToolTipTitle() As String
        Get
            Return MessageText
        End Get
        Set(value As String)
            MessageText = ""
        End Set
    End Property

    <Browsable(False)>
    Public Shadows Property ToolTipIcon() As ToolTipIcon
        Get
            Return MyBase.ToolTipIcon
        End Get
        Set(value As ToolTipIcon)
            MyBase.ToolTipIcon = ToolTipIcon.None
        End Set
    End Property

    Friend EventColor As Color

#End Region

#Region "Constructor"

    Public Sub New()
        OwnerDraw = True
        ShowAlways = True

        AddHandler Draw, AddressOf MToolTip_Draw
        AddHandler Popup, AddressOf MToolTip_Popup

    End Sub

#End Region
#Region ""
    Public Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
        Dim GP As New GraphicsPath()

        Dim W As Integer = 18 '12
        Dim H As Integer = 12 '6

        If flip Then
            GP.AddLine(x + 1, y, x + W + 1, y)
            GP.AddLine(x + W, y, x + H, y + H - 1)
        Else
            GP.AddLine(x, y + H, x + W, y + H)
            GP.AddLine(x + W, y + H, x + H, y)
        End If

        GP.CloseFigure()
        Return GP
    End Function

    Private _TextAlign As ContentAlignment = ContentAlignment.MiddleCenter
    Public Property TextAlign() As ContentAlignment
        Get
            Return _TextAlign
        End Get
        Set(value As ContentAlignment)
            _TextAlign = value
        End Set
    End Property
    Private Function GetStringFormat(ByVal ctrlalign As ContentAlignment) As StringFormat
        Dim strFormat As StringFormat = New StringFormat()
        Select Case ctrlalign
            Case ContentAlignment.MiddleCenter
                strFormat.LineAlignment = StringAlignment.Center
                strFormat.Alignment = StringAlignment.Center
            Case ContentAlignment.MiddleLeft
                strFormat.LineAlignment = StringAlignment.Center
                strFormat.Alignment = StringAlignment.Near
            Case ContentAlignment.MiddleRight
                strFormat.LineAlignment = StringAlignment.Center
                strFormat.Alignment = StringAlignment.Far
            Case ContentAlignment.TopCenter
                strFormat.LineAlignment = StringAlignment.Near
                strFormat.Alignment = StringAlignment.Center
            Case ContentAlignment.TopLeft
                strFormat.LineAlignment = StringAlignment.Near
                strFormat.Alignment = StringAlignment.Near
            Case ContentAlignment.TopRight
                strFormat.LineAlignment = StringAlignment.Near
                strFormat.Alignment = StringAlignment.Far
            Case ContentAlignment.BottomCenter
                strFormat.LineAlignment = StringAlignment.Far
                strFormat.Alignment = StringAlignment.Center
            Case ContentAlignment.BottomLeft
                strFormat.LineAlignment = StringAlignment.Far
                strFormat.Alignment = StringAlignment.Near
            Case ContentAlignment.BottomRight
                strFormat.LineAlignment = StringAlignment.Far
                strFormat.Alignment = StringAlignment.Far
        End Select
        Return strFormat
    End Function
#End Region

#Region "Management Methods"

    Public Shadows Sub SetToolTip(control As Control, caption As String)
        MyBase.SetToolTip(control, caption)

        If TypeOf control Is IButtonControl Then
            ' TODO: This would override tooltips on children
            For Each c As Control In control.Controls
                SetToolTip(c, caption)
            Next
        End If
    End Sub

    Private Sub MToolTip_Popup(sender As Object, e As PopupEventArgs)

        Dim styledWindow As IContainerControl = TryCast(e.AssociatedWindow, IContainerControl)
        e.ToolTipSize = New Size(270, e.ToolTipSize.Height + 150)

    End Sub


#Region "Properties"
    'Layout
    Private _MessageText As String = "ToolTip"
    Public Property MessageText() As String
        Get
            Return _MessageText
        End Get
        Set
            _MessageText = Value
            ' Me.Invalidate()
        End Set
    End Property
    Private _CornerRadius As Integer = 1 '15
    Public Property CornerRadius() As Integer
        Get
            Return _CornerRadius
        End Get
        Set
            _CornerRadius = Value
            ' Me.Invalidate()
        End Set
    End Property
    Private _ArrowSize As Integer = 5
    Public Property ArrowSize() As Integer
        Get
            Return _ArrowSize
        End Get
        Set
            _ArrowSize = Value
            ' Me.Invalidate()
        End Set
    End Property
    Private _GlowRadius As Integer = 1 '15
    Public Property GlowRadius() As Integer
        Get
            Return _GlowRadius
        End Get
        Set
            _GlowRadius = Value
            '  Me.Invalidate()
        End Set
    End Property
    Private _GlowHeight As Integer = 1 '15
    Public Property GlowHeight() As Integer
        Get
            Return _GlowHeight
        End Get
        Set
            _GlowHeight = Value
            '  Me.Invalidate()
        End Set
    End Property
    Private _ArrowPosition As ArrowPossition = ArrowPossition.Left
    Public Property ArrowPosition() As ArrowPossition
        Get
            Return _ArrowPosition
        End Get
        Set
            _ArrowPosition = Value
            ' Me.Invalidate()
        End Set
    End Property
    'Colors
    Private _BackgroundStartColor As Color = Color.FromArgb(42, 42, 42)
    Public Property BackgroundStartColor() As Color
        Get
            Return _BackgroundStartColor
        End Get
        Set
            _BackgroundStartColor = Value
            'Invalidate()
        End Set
    End Property
    Private _BackgroundEndColor As Color = Color.FromArgb(58, 58, 58)
    Public Property BackgroundEndColor() As Color
        Get
            Return _BackgroundEndColor
        End Get
        Set
            _BackgroundEndColor = Value
            ' Me.Invalidate()
        End Set
    End Property
    Private _BorderColor As Color = Color.FromArgb(58, 58, 58)
    Public Property BorderColor() As Color
        Get
            Return _BorderColor
        End Get
        Set
            _BorderColor = Value
            ' Me.Invalidate()
        End Set
    End Property
    Private _GlowStartColor As Color = Color.FromArgb(42, 42, 42)
    Public Property GlowStartColor() As Color
        Get
            Return _GlowStartColor
        End Get
        Set
            _GlowStartColor = Value
            ' Me.Invalidate()
        End Set
    End Property
    Private _GlowEndColor As Color = Color.FromArgb(58, 58, 58)
    Public Property GlowEndColor() As Color
        Get
            Return _GlowEndColor
        End Get
        Set
            _GlowEndColor = Value
            '  Me.Invalidate()
        End Set
    End Property
    Private _TextColor As Color = Color.FromArgb(255, 114, 82)
    Public Property TextColor() As Color
        Get
            Return _TextColor
        End Get
        Set
            _TextColor = Value
            ' Me.Invalidate()
        End Set
    End Property
    Private _TextShadowColor As Color = Color.Transparent
    Public Property TextShadowColor() As Color
        Get
            Return _TextShadowColor
        End Get
        Set
            _TextShadowColor = Value
            ' Me.Invalidate()
        End Set
    End Property
#End Region

#Region "Helper Methods"
    Private Function GlowPath(rec As Rectangle, radius As Integer) As GraphicsPath
        Dim path As New GraphicsPath()
        path.AddArc(Rectangle.FromLTRB(rec.X, rec.Y, rec.X + radius, rec.Y + rec.Height), 90, 180)
        path.AddArc(Rectangle.FromLTRB(rec.Right - radius, rec.Top, rec.Right, rec.Bottom), 270, 180)
        path.CloseFigure()
        Return path
    End Function

    Public Enum ArrowPossition
        Top
        Bottom
        Left
        Right
    End Enum
    Friend Shared Function ArrowPath(rec As Rectangle, arrowPos As ArrowPossition, arrowSize As Integer, radius As Integer) As GraphicsPath
        Dim path As New GraphicsPath()
        If radius > 0 AndAlso arrowSize > 1 Then
            If arrowPos = ArrowPossition.Left Then
                path.AddLine(rec.Left, rec.Top + rec.Height \ 2, rec.Left + arrowSize, rec.Top + rec.Height \ 2 - arrowSize)
                path.AddLine(rec.Left + arrowSize, rec.Top + rec.Height \ 2 - arrowSize, rec.Left + arrowSize, rec.Top + radius)
                path.AddArc(Rectangle.FromLTRB(rec.Left + arrowSize, rec.Top, rec.Left + arrowSize + radius, rec.Top + radius), 180, 90)
                path.AddLine(rec.Left + arrowSize + radius, rec.Top, rec.Right - radius, rec.Top)
                path.AddArc(Rectangle.FromLTRB(rec.Right - radius, rec.Top, rec.Right, rec.Top + radius), -90, 90)
                path.AddLine(rec.Right, rec.Top + radius, rec.Right, rec.Bottom - radius)
                path.AddArc(Rectangle.FromLTRB(rec.Right - radius, rec.Bottom - radius, rec.Right, rec.Bottom), 0, 90)
                path.AddLine(rec.Right - radius, rec.Bottom, rec.Left + arrowSize + radius, rec.Bottom)
                path.AddArc(Rectangle.FromLTRB(rec.Left + arrowSize, rec.Bottom - radius, rec.Left + arrowSize + radius, rec.Bottom), 90, 90)
                path.AddLine(rec.Left + arrowSize, rec.Bottom - radius, rec.Left + arrowSize, rec.Top + rec.Height \ 2 + arrowSize)
                path.AddLine(rec.Left + arrowSize, rec.Top + rec.Height \ 2 + arrowSize, rec.Left, rec.Top + rec.Height \ 2)
                path.CloseFigure()
            ElseIf arrowPos = ArrowPossition.Right Then
                path.AddArc(Rectangle.FromLTRB(rec.Left, rec.Top, rec.Left + radius, rec.Top + radius), 180, 90)
                path.AddLine(rec.Left + radius, rec.Top, rec.Right - arrowSize - radius, rec.Top)
                path.AddArc(Rectangle.FromLTRB(rec.Right - arrowSize - radius, rec.Top, rec.Right - arrowSize, rec.Top + radius), -90, 90)
                path.AddLine(rec.Right - arrowSize, rec.Top + radius, rec.Right - arrowSize, rec.Top + rec.Height \ 2 - arrowSize)
                path.AddLine(rec.Right - arrowSize, rec.Top + rec.Height \ 2 - arrowSize, rec.Right, rec.Top + rec.Height \ 2)
                path.AddLine(rec.Right, rec.Top + rec.Height \ 2, rec.Right - arrowSize, rec.Top + rec.Height \ 2 + arrowSize)
                path.AddLine(rec.Right - arrowSize, rec.Top + rec.Height \ 2 + arrowSize, rec.Right - arrowSize, rec.Bottom - radius)
                path.AddArc(Rectangle.FromLTRB(rec.Right - arrowSize - radius, rec.Bottom - radius, rec.Right - arrowSize, rec.Bottom), 0, 90)
                path.AddLine(rec.Right - arrowSize - radius, rec.Bottom, rec.Left + radius, rec.Bottom)
                path.AddArc(Rectangle.FromLTRB(rec.Left, rec.Bottom - radius, rec.Left + radius, rec.Bottom), 90, 90)
                path.AddLine(rec.Left, rec.Bottom - radius, rec.Left, rec.Top + radius \ 2)
            ElseIf arrowPos = ArrowPossition.Top Then
                path.AddArc(Rectangle.FromLTRB(rec.Left, rec.Top + arrowSize, rec.Left + radius, rec.Top + arrowSize + radius), 180, 90)
                path.AddLine(rec.Left + radius, rec.Top + arrowSize, rec.Left + rec.Width \ 2 - arrowSize, rec.Top + arrowSize)
                path.AddLine(rec.Left + rec.Width \ 2 - arrowSize, rec.Top + arrowSize, rec.Left + rec.Width \ 2, rec.Top)
                path.AddLine(rec.Left + rec.Width \ 2, rec.Top, rec.Left + rec.Width \ 2 + arrowSize, rec.Top + arrowSize)
                path.AddLine(rec.Left + rec.Width \ 2 + arrowSize, rec.Top + arrowSize, rec.Right - radius, rec.Top + arrowSize)
                path.AddArc(Rectangle.FromLTRB(rec.Right - radius, rec.Top + arrowSize, rec.Right, rec.Top + arrowSize + radius), -90, 90)
                path.AddLine(rec.Right, rec.Top + arrowSize + radius, rec.Right, rec.Bottom - radius)
                path.AddArc(Rectangle.FromLTRB(rec.Right - radius, rec.Bottom - radius, rec.Right, rec.Bottom), 0, 90)
                path.AddLine(rec.Right - radius, rec.Bottom, rec.Left + radius, rec.Bottom)
                path.AddArc(Rectangle.FromLTRB(rec.Left, rec.Bottom - radius, rec.Left + radius, rec.Bottom), 90, 90)
                path.AddLine(rec.Left, rec.Bottom - radius, rec.Left, rec.Top + arrowSize + (radius \ 2))
                path.CloseFigure()
            ElseIf arrowPos = ArrowPossition.Bottom Then
                path.AddArc(Rectangle.FromLTRB(rec.Left, rec.Top, rec.Left + radius, rec.Top + radius), 180, 90)
                path.AddLine(rec.Left + radius, rec.Top, rec.Right - radius, rec.Top)
                path.AddArc(Rectangle.FromLTRB(rec.Right - radius, rec.Top, rec.Right, rec.Top + radius), -90, 90)
                path.AddLine(rec.Right, rec.Top + radius, rec.Right, rec.Bottom - arrowSize - radius)
                path.AddArc(Rectangle.FromLTRB(rec.Right - radius, rec.Bottom - arrowSize - radius, rec.Right, rec.Bottom - arrowSize), 0, 90)
                path.AddLine(rec.Right - radius, rec.Bottom - arrowSize, rec.Left + rec.Width \ 2 + arrowSize, rec.Bottom - arrowSize)
                path.AddLine(rec.Left + rec.Width \ 2 + arrowSize, rec.Bottom - arrowSize, rec.Left + rec.Width \ 2, rec.Bottom)
                path.AddLine(rec.Left + rec.Width \ 2, rec.Bottom, rec.Left + rec.Width \ 2 - arrowSize, rec.Bottom - arrowSize)
                path.AddLine(rec.Left + rec.Width \ 2 - arrowSize, rec.Bottom - arrowSize, rec.Left + radius, rec.Bottom - arrowSize)
                path.AddArc(Rectangle.FromLTRB(rec.Left, rec.Bottom - arrowSize - radius, rec.Left + radius, rec.Bottom - arrowSize), 90, 90)
                path.AddLine(rec.Left, rec.Bottom - arrowSize - radius, rec.Left, rec.Top + (radius \ 2))
                path.CloseFigure()
            End If
        End If
        Return path
    End Function
#End Region

    Private Sub MToolTip_Draw(sender As Object, e As DrawToolTipEventArgs)
        e.Graphics.SmoothingMode = 2
        e.Graphics.TextRenderingHint = 5
        '  e.Graphics.Clear(Color.Transparent)


        Dim _BackRect As New Rectangle(0, 0, e.Bounds.Width - 1, e.Bounds.Height - 1)
        Dim _GlowRect As New Rectangle(_CornerRadius \ 2, 1, e.Bounds.Width - _CornerRadius - _ArrowSize, _GlowHeight)
        'Adjust Glow Rectangle
        If _ArrowPosition = ArrowPossition.Left Then
            _GlowRect = New Rectangle(_CornerRadius \ 2 + _ArrowSize, 1, e.Bounds.Width - _CornerRadius - _ArrowSize, _GlowHeight)
        ElseIf _ArrowPosition = ArrowPossition.Right Then
            _GlowRect = New Rectangle(_CornerRadius \ 2, 1, e.Bounds.Width - _CornerRadius - _ArrowSize, _GlowHeight)
        ElseIf _ArrowPosition = ArrowPossition.Top Then
            _GlowRect = New Rectangle(_CornerRadius \ 2, _ArrowSize + 1, e.Bounds.Width - _CornerRadius, _GlowHeight)
        ElseIf _ArrowPosition = ArrowPossition.Bottom Then
            _GlowRect = New Rectangle(_CornerRadius \ 2, 1, e.Bounds.Width - _CornerRadius, _GlowHeight)
        End If
        'Draw
        Using _BackgroundBrush As New LinearGradientBrush(_BackRect, _BackgroundStartColor, _BackgroundEndColor, 90)
            Using _GlowBrush As New LinearGradientBrush(_GlowRect, _GlowStartColor, _GlowEndColor, 90)
                Using _BorderPen As New Pen(_BorderColor)
                    e.Graphics.SmoothingMode = SmoothingMode.AntiAlias

                    'Draw Background First
                    e.Graphics.FillPath(_BackgroundBrush, ArrowPath(_BackRect, _ArrowPosition, _ArrowSize, _CornerRadius))
                    'Draw Glow
                    e.Graphics.FillPath(_GlowBrush, GlowPath(_GlowRect, _GlowRadius))
                    'Draw Border
                    e.Graphics.DrawPath(_BorderPen, ArrowPath(_BackRect, _ArrowPosition, _ArrowSize, _CornerRadius))
                    e.Graphics.SmoothingMode = SmoothingMode.[Default]
                End Using
            End Using
        End Using



        'Get Rectangles
        Dim _ShadowRect As New Rectangle(0, 1, e.Bounds.Width - _ArrowSize, e.Bounds.Height - 1)
        Dim _TextRect As New Rectangle(0, 0, e.Bounds.Width - _ArrowSize, e.Bounds.Height - 1)
        'Adjust Text & Shadow Rectangles
        If _ArrowPosition = ArrowPossition.Left Then
            _ShadowRect = New Rectangle(_ArrowSize, 1, e.Bounds.Width - (_ArrowSize * 2), e.Bounds.Height - 1)
            _TextRect = New Rectangle(_ArrowSize, 0, e.Bounds.Width - (_ArrowSize * 2), e.Bounds.Height - 1)
        ElseIf _ArrowPosition = ArrowPossition.Right Then
            _ShadowRect = New Rectangle(0, 1, e.Bounds.Width - _ArrowSize, e.Bounds.Height - 1)
            _TextRect = New Rectangle(0, 0, e.Bounds.Width - _ArrowSize, e.Bounds.Height - 1)
        ElseIf _ArrowPosition = ArrowPossition.Top Then
            _ShadowRect = New Rectangle(0, _ArrowSize * 2 + 1, e.Bounds.Width - _ArrowSize, e.Bounds.Height - (_ArrowSize * 3) - 1)
            _TextRect = New Rectangle(0, _ArrowSize * 2, e.Bounds.Width - _ArrowSize, e.Bounds.Height - (_ArrowSize * 3))
        ElseIf _ArrowPosition = ArrowPossition.Bottom Then
            _ShadowRect = New Rectangle(0, _ArrowSize + 1, e.Bounds.Width - _ArrowSize, e.Bounds.Height - (_ArrowSize * 3) - 1)
            _TextRect = New Rectangle(0, _ArrowSize, e.Bounds.Width - _ArrowSize, e.Bounds.Height - (_ArrowSize * 3))
        End If
        'Get String Format
        Dim _TextFormat, default_ As New StringFormat()
        _TextFormat.Alignment = StringAlignment.Near
        _TextFormat.LineAlignment = StringAlignment.Near
        default_.Alignment = StringAlignment.Center
        default_.LineAlignment = StringAlignment.Near
        'Draw
        Using _ShadowBrush As New SolidBrush(_TextShadowColor)
            Using _TextBrush As New SolidBrush(_TextColor)
                'Draw Shadow First
                e.Graphics.DrawString(ToolTipTitle, New Font("Segoe UI", 9, FontStyle.Bold), _ShadowBrush, _ShadowRect, default_)
                'Draw Text
                e.Graphics.DrawString(ToolTipTitle, New Font("Segoe UI", 9, FontStyle.Bold), _TextBrush, _TextRect, default_)

            End Using
        End Using
        e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
        e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality
    End Sub

End Class
how to use:
Code: Select all
    Private Sub Form2_MouseHover(sender As Object, e As EventArgs) Handles Me.MouseHover
        SkinToolTip1.ToolTipTitle = Nothing
        SkinToolTip1.MessageText = "Just a test :p"
        SkinToolTip1.SetToolTip(sender, Text)
    End Sub

    Private Sub Form2_MouseLeave(sender As Object, e As EventArgs) Handles Me.MouseLeave
        SkinToolTip1.ToolTipTitle = Nothing
        SkinToolTip1.MessageText = Nothing
        SkinToolTip1.RemoveAll()
        SkinToolTip1.SetToolTip(sender, Text)
    End Sub
Thanks
You do not have the required permissions to view the files attached to this post.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: Drawing? what do we wrong...
CodenStuff
I had a quick play with the code but was unable to solve the problem. I do recall having a similar issue with a control I made a long time ago but can't remember if I fixed it or not.

It must be down to the rendering somewhere as it only happens when the tooltip is re-shown after the first initiation :duh; ...maybe try create it dynamically each time its required and destroy it when it fades depending on how you need to use it.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Drawing? what do we wrong...
Dummy1912
Hello Cns,

:crying; that's sad to hear
yeah i know sometimes .net is a pain :D

well maybe someone will give us both the answer
thanks for trying
in the meanwhile i keep trying myself
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Drawing? what do we wrong...
Dummy1912
Its seems when we add
Code: Select all
        e.Graphics.Clear(Color.Transparent)
it keeps a black line at the background
but then we don't get the previous mess up part :)
but how to get rid of the black part??
You do not have the required permissions to view the files attached to this post.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Drawing? what do we wrong...
Dummy1912
this code helps a little :)
but not 100% what it must be but
its lot better :D
Code: Select all
    <DllImport("user32.dll")>
    Private Shared Function GetWindowRect(hWnd As IntPtr, ByRef lpRect As RECT) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function

    Private Function GetWindowRect() As Rectangle
        Dim rect As New RECT()
        Dim window = TryCast(GetType(ToolTip).GetField("window", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me), NativeWindow)
        GetWindowRect(window.Handle, rect)
        Return rect
    End Function
Code: Select all
Private Sub MToolTip_Draw(sender As Object, e As DrawToolTipEventArgs)
Dim graphics = e.Graphics
        Dim windowRect = GetWindowRect()
        Graphics.CopyFromScreen(windowRect.Left, windowRect.Top, 0, 0, New Size(e.Bounds.Width, e.Bounds.Height))

visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Drawing? what do we wrong...
Dummy1912
So guys
who has an better solution? so its truly transparent even when moving the mouse
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
6 posts Page 1 of 1
Return to “Coding Help & Support”