Subversion Repositories projects.vncstarter

Rev

Blame | Last modification | View Log

VERSION 5.00
Begin VB.UserControl jjButton 
   Appearance      =   0  'Flat
   AutoRedraw      =   -1  'True
   ClientHeight    =   570
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   1080
   ClipControls    =   0   'False
   DefaultCancel   =   -1  'True
   FillColor       =   &H8000000F&
   ScaleHeight     =   38
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   72
   ToolboxBitmap   =   "jjButton.ctx":0000
   Begin VB.Timer tmrRedrawButton 
      Enabled         =   0   'False
      Interval        =   1
      Left            =   705
      Top             =   -120
   End
   Begin VB.Timer tmrRepeat 
      Enabled         =   0   'False
      Interval        =   400
      Left            =   60
      Top             =   360
   End
   Begin VB.PictureBox pic1 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ClipControls    =   0   'False
      ForeColor       =   &H80000008&
      Height          =   195
      Left            =   105
      ScaleHeight     =   13
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   15
      TabIndex        =   0
      Top             =   105
      Visible         =   0   'False
      Width           =   225
   End
   Begin VB.Timer tmr1 
      Enabled         =   0   'False
      Interval        =   50
      Left            =   660
      Top             =   360
   End
End
Attribute VB_Name = "jjButton"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit



Dim OS(2) As String                  'Operativsystem 0=versjonsnr. 1=tekstbeskrivelse, 2=MinorVersjonsnr.(Win200=0, XP=1)
Dim NotOptionClick As Boolean
Dim TT As CTooltip
Dim ttInZone As Boolean

Private HarFokus As Boolean
Private mButton As Integer                      'Brukes for å hindre høyreklikking i click event
Dim IconW As Integer, IconH As Integer          'Ikons vidde og høyde
Dim IconL As Integer, IconT As Integer          'Ikons venstre og topp
Dim CaptionW As Integer, CaptionH As Integer    'Captions vidde og høyde
Dim CaptionL As Integer, CaptionT As Integer    'Captions venstre og topp
Dim ucWidth As Long, ucHeight As Long           'Kontrollens bredde og høyde
Dim BorderColor As Long
Dim DefaultColor As Long
Dim OverColor As Long
Dim DownColor As Long

Public Enum jjCopyBGSource
    jj_None
    jj_Form
    jj_PictureBox
    jj_Box
End Enum

Public Enum jjButtonColor
    jj_Standard
    jj_Hoover
    jj_Blå
    jj_Rød
    jj_Grønn
    jj_Gul
    jj_Metall
    jj_Sølv
    jj_BlueFade
    jj_Avrundet
    jj_CheckBox
    jj_Tab
    jj_Tekst
    jj_OptionBox
    jj_XP2003
End Enum

Public Enum jjIconAlign
    jj_Left
    jj_Top
    jj_Right
    jj_Bottom
End Enum

Public Enum jjMode
    jj_Command
    jj_Check
    jj_Option
End Enum

'Default Property Values:
Const m_def_jjTabSelectedColor = &HE1451C
Const m_def_jjTabBorderColor = &HB4A791
Const m_def_CopyBGSource = 0
Const m_def_Repeat = 0
Const m_def_GruppeID = ""
Const m_def_Value = 0
Const m_def_Mode = jj_Command
Const m_def_jjToolTipTime = 5000
Const m_def_jjToolTipStyle = 0
Const m_def_jjToolTipIcon = 0
Const m_def_jjToolTipHeader = ""
Const m_def_jjTooltip = ""
Const m_def_IconAlign = 0
Const m_def_IconSpace = 2
Const m_def_ForeColor = vbButtonText
Const m_def_BackColor = vbButtonFace
Const m_def_FocusRectangle = True
Const m_def_Caption = "jjButton"
Const m_def_jjButtonStyle = jj_Standard

'Property Variables:
Dim m_jjTabSelectedColor As OLE_COLOR
Dim m_jjTabBorderColor As OLE_COLOR
Dim m_CopyBGSource As Integer
Dim m_CopyBGBoxName As Control
Dim m_Repeat As Boolean
Dim m_GruppeID As String
Dim m_Value As Boolean
Dim m_Mode As Integer
Dim m_jjToolTipStyle As Integer
Dim m_jjToolTipIcon As Integer
Dim m_jjToolTipHeader As String
Dim m_jjToolTip As String
Dim m_jjToolTipTime As Integer
Dim m_IconAlign As Integer
Dim m_IconSpace As Integer
Dim m_ForeColor As OLE_COLOR
Dim m_BackColor As OLE_COLOR
Dim m_IconDefault As StdPicture
Private m_FocusRectangle As Boolean
Private m_Caption As String
Private m_jjButtonStyle As Long

'Event Declarations:
Event DoubleClick(Button As Integer)
Event Click()  'MappingInfo=UserControl,UserControl,-1,Click
Attribute Click.VB_MemberFlags = "200"
Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyDown
Event KeyPress(KeyAscii As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyPress
Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyUp
Event MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseDown
Event MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseMove
Event MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)  'MappingInfo=UserControl,UserControl,-1,MouseUp

Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long

Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function FrameRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long

Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function PathToRegion Lib "gdi32" (ByVal hdc As Long) As Long

Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
'Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Private Declare Sub OleTranslateColor Lib "oleaut32.dll" (ByVal clr As Long, ByVal hpal As Long, ByRef lpcolorref As Long)

Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Const PS_SOLID = 0
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function RoundRect Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function FloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

'Flytte til et punkt og tegne linjer
Private Type POINTAPI
    x As Long
    y As Long
End Type
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

'For å tegne ikoner og tekst i disabled state
Private Const DST_PREFIXTEXT = &H2
Private Const DST_ICON = &H3
'Private Const DST_BITMAP = &H4
Private Const DSS_NORMAL = &H0
Private Const DSS_DISABLED = &H20
Private Declare Function DrawState Lib "user32" Alias "DrawStateA" (ByVal hdc As Long, ByVal hBrush As Long, ByVal lpDrawStateProc As Long, ByVal lParam As Long, ByVal wParam As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal flags As Long) As Long
Private Declare Function DrawStateText Lib "user32" Alias "DrawStateA" (ByVal hdc As Long, ByVal hBrush As Long, ByVal lpDrawStateProc As Long, ByVal lString As String, ByVal wParam As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal flags As Long) As Long
'Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal hIcon As Long) As Long
'Private Const DT_CENTER = &H1
'Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
'Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
'Private Type LOGFONT               ' used to create fonts
'  lfHeight As Long
'  lfWidth As Long
'  lfEscapement As Long
'  lfOrientation As Long
'  lfWeight As Long
'  lfItalic As Byte
'  lfUnderline As Byte
'  lfStrikeOut As Byte
'  lfCharSet As Byte
'  lfOutPrecision As Byte
'  lfClipPrecision As Byte
'  lfQuality As Byte
'  lfPitchAndFamily As Byte
'  lfFaceName As String * 32
'End Type

Private Type Oldfont               ' used to create fonts
    Name As String
    Size As Integer
    Bold As Integer
    Italic As Integer
    Strikethru As Integer
    Underline As Integer
End Type
Dim lOldFont As Oldfont

'Tegner fokusrektangel
Private Declare Function DrawFocusRect Lib "user32" (ByVal hdc As Long, lpRect As RECT) As Long
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

'Alphablending
'Private Declare Sub RtlMoveMemory Lib "kernel32.dll" (Destination As Any, Source As Any, ByVal Length As Long)
'Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long
'Const AC_SRC_ALPHA = &H1
'Const AC_SRC_OVER = &H0
'Private Type BLENDFUNCTION
'    BlendOp As Byte
'    BlendFlags As Byte
'    SourceConstantAlpha As Byte
'    AlphaFormat As Byte
'End Type

'For Triangel-fargefyll
Private Type TRIANGEL_COLOR
    ColorLT As Long
    ColorRT As Long
    ColorLB As Long
    ColorRB As Long
End Type
'For Gradient-fargefyll
Private Type GRADIENT_COLOR
    ColorFrom As Long
    ColorTo As Long
End Type
Private Type GRADIENT_TRIANGLE
    Vertex1 As Long
    Vertex2 As Long
    Vertex3 As Long
End Type
Private Type TRIVERTEX
    x As Long
    y As Long
    Red As Integer
    Green As Integer
    Blue As Integer
    Alpha As Integer
End Type
Private Type GRADIENT_RECT
    UpperLeft As Long
    LowerRight As Long
End Type
Const GRADIENT_FILL_RECT_H As Long = &H0
Const GRADIENT_FILL_RECT_V  As Long = &H1
Const GRADIENT_FILL_TRIANGLE As Long = &H2
Private Declare Function GradientFillTriangle Lib "msimg32" Alias "GradientFill" (ByVal hdc As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_TRIANGLE, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long
Private Declare Function GradientFill Lib "msimg32" (ByVal hdc As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_RECT, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long


'Finn type operativsystem
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
 (lpVersionInformation As OSVERSIONINFO) As Long
Private Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128      '  Maintenance string for PSS usage
End Type
Const VER_PLATFORM_WIN32_NT = 2
Const VER_PLATFORM_WIN32_WINDOWS = 1
Const VER_PLATFORM_WIN32s = 0

Private Function ShadeColor(lColor As Long, shadeOffset As Integer, lessBlue As Boolean, _
    Optional bFocusRect As Boolean, Optional bInvert As Boolean) As Long

    ' Basically supply a value between -255 and +255. Positive numbers make
    ' the passed color lighter and negative numbers make the color darker
    
    Dim valRGB(0 To 2) As Integer, I As Integer
    
CalcNewColor:
    valRGB(0) = (lColor And &HFF) + shadeOffset
    valRGB(1) = ((lColor And &HFF00&) / 255&) + shadeOffset
    If lessBlue Then
        valRGB(2) = (lColor And &HFF0000) / &HFF00&
        valRGB(2) = valRGB(2) + ((valRGB(2) * CLng(shadeOffset)) \ &HC0)
    Else
        valRGB(2) = (lColor And &HFF0000) / &HFF00& + shadeOffset
    End If
    
    For I = 0 To 2
        If valRGB(I) > 255 Then valRGB(I) = 255
        If valRGB(I) < 0 Then valRGB(I) = 0
        If bInvert = True Then valRGB(I) = Abs(255 - valRGB(I))
    Next
    ShadeColor = valRGB(0) + 256& * valRGB(1) + 65536 * valRGB(2)
    Erase valRGB
    
    If bFocusRect = True And (ShadeColor = vbBlack Or ShadeColor = vbWhite) Then
        shadeOffset = -shadeOffset
        If shadeOffset = 0 Then shadeOffset = 64
        GoTo CalcNewColor
    End If
End Function

Private Function TranslateColor(aColor As OLE_COLOR) As Long
    Dim newcolor As Long
    OleTranslateColor aColor, UserControl.Palette, newcolor
    TranslateColor = newcolor
End Function

Private Sub SetAcccessKey()
   Dim pos As Integer

   pos = InStr(1, m_Caption, "&")
   If pos Then
      UserControl.AccessKeys = Mid$(m_Caption, pos + 1, 1)
   End If
End Sub

Private Sub DrawFocus(uHdc As Long)
    Dim r As RECT
    Dim pnt As POINTAPI
    
    'Avbryt om fokusrektangel ikke er på
    If m_FocusRectangle = False Then Exit Sub
    
    
    Select Case m_jjButtonStyle
        Case Is = jj_Metall, jj_Sølv, jj_BlueFade, jj_Avrundet
            r.Left = 5
            r.Top = 5
            r.Right = ucWidth - 6
            r.Bottom = ucHeight - 6
            SetTextColor uHdc, vbBlack
            DrawFocusRect uHdc, r
        
        Case Is = jj_CheckBox, jj_OptionBox
            If m_IconAlign = jj_Left Then
                r.Left = 14
                r.Top = 0
                r.Right = UserControl.TextWidth(m_Caption) + 18 + m_IconSpace
                r.Bottom = 13
            Else
                r.Left = 0
                r.Top = 0
                r.Right = ucWidth - 14
                r.Bottom = 13
            End If
            SetTextColor uHdc, vbBlack
            DrawFocusRect uHdc, r
            
        Case Is = jj_Standard, jj_Hoover, jj_Blå, jj_Rød, jj_Grønn, jj_Gul, jj_Tab, jj_XP2003
            r.Left = 5
            r.Top = 5
            r.Right = ucWidth - 5
            r.Bottom = ucHeight - 5
            SetTextColor uHdc, vbBlack
            DrawFocusRect uHdc, r
    End Select
    
    UserControl.Refresh
End Sub

Private Sub HighLight(Button As Integer, x As Single, y As Single, Aktiv As Boolean)
    'Button      Buttonverdien i MouseMove, MouseDown, MouseUp
    'X           Buttonverdien i MouseMove, MouseDown, MouseUp
    'Y           Buttonverdien i MouseMove, MouseDown, MouseUp
    'Aktiv       For å låse musebevegelser til denne kontroll
        
    Dim HitTest As Long
    Static EnGang As Boolean                        'For at noe skal skje bare en gang for hver musebevegelse
    Static EnGangB As Boolean
    
    Dim pnt As POINTAPI
    Dim BckCl As Long
    Dim EtPos As Integer
    Dim hRgn As Long
    Dim hBrush As Long
    Dim StatusValue As Integer
    
    On Error Resume Next
    
    'Avbtyt om feil oppstår
    HitTest = UserControl.hwnd
    If Err.Number <> 0 Then Exit Sub
    
    
    'Diverse innstillinger
    BckCl = TranslateColor(m_BackColor)
    UserControl.ForeColor = TranslateColor(m_ForeColor)
    
    
    'Finn bredde/høyde på et evt. ikon
    'Konverter fra Himetric til Pixels
    IconW = UserControl.ScaleX(m_IconDefault.Width, vbHimetric, vbPixels)
    IconH = UserControl.ScaleY(m_IconDefault.Height, vbHimetric, vbPixels)
    
    
    'Finn teksten og bredde/høyde på den
    If m_Caption <> "" Then
        CaptionW = UserControl.TextWidth(m_Caption)
        CaptionH = UserControl.TextHeight(m_Caption)
    End If
    
    
    'Finn pixellengden til en "&" om det brukes hurtigtast i Caption og trekk fra på tekstvidden
    EtPos = InStr(1, m_Caption, "&")
    If EtPos > 0 Then
        CaptionW = CaptionW - UserControl.TextWidth("&")
    End If
    
    
    'Finn plasseringspunkt for et evt. ikon
    'Om det er tekst med
    If m_Caption <> "" Then
        Select Case m_IconAlign
            Case Is = jj_Top
                'Ikon over caption
                IconL = ucWidth \ 2 - (IconW \ 2)
                IconT = ucHeight \ 2 - (IconH \ 2) - (CaptionH \ 2) - m_IconSpace
            Case Is = jj_Bottom
                'Ikon under caption
                IconL = ucWidth \ 2 - (IconW \ 2)
                IconT = ucHeight \ 2 - (IconW \ 2) + (CaptionH \ 2) + m_IconSpace
            Case Is = jj_Left
                'Ikon til venstre for caption
                IconL = ucWidth \ 2 - (CaptionW \ 2) - (IconW \ 2) - m_IconSpace
                IconT = ucHeight \ 2 - (IconH \ 2)
            Case Is = jj_Right
                'Ikon til høyre for caption
                IconL = ucWidth \ 2 + (CaptionW \ 2) - (IconW \ 2) + m_IconSpace
                IconT = ucHeight \ 2 - (IconH \ 2)
        End Select
        
    'Uten tekst
    Else
        IconL = ucWidth \ 2 - (IconW \ 2)
        IconT = ucHeight \ 2 - (IconH \ 2)
    End If
    
    
    'Finn plasseringspunkt for en evt. tekst
    'Om det er ikon med
    If IconW > 0 Then
        Select Case m_IconAlign
            Case Is = jj_Top
                'Ikon over caption
                CaptionL = ucWidth \ 2 - (CaptionW \ 2)
                CaptionT = ucHeight \ 2 - (CaptionH \ 2) + (IconH \ 2) + m_IconSpace
            Case Is = jj_Bottom
                'Ikon under caption
                CaptionL = ucWidth \ 2 - (CaptionW \ 2)
                CaptionT = ucHeight \ 2 - (CaptionH \ 2) - (IconH \ 2) - m_IconSpace
            Case Is = jj_Left
                'Ikon til venstre for caption
                CaptionL = ucWidth \ 2 - (CaptionW \ 2) + (IconW \ 2) + m_IconSpace
                CaptionT = ucHeight \ 2 - (CaptionH \ 2)
            Case Is = jj_Right
                'Ikon til høyre for caption
                CaptionL = ucWidth \ 2 - (CaptionW \ 2) - (IconW \ 2) - m_IconSpace
                CaptionT = ucHeight \ 2 - (CaptionH \ 2)
        End Select
        
    'Uten ikon
    Else
        CaptionL = ucWidth \ 2 - (CaptionW \ 2)
        CaptionT = ucHeight \ 2 - (CaptionH \ 2)
    End If
    
    
    '************ Farge på knappen *************
    Select Case m_jjButtonStyle
        Case Is = jj_Standard, jj_Hoover
            DefaultColor = BckCl
            BorderColor = RGB(255, 255, 255)
            OverColor = BckCl
            DownColor = BckCl
            
        Case Is = jj_Blå
            DefaultColor = BckCl
            BorderColor = RGB(10, 36, 106)
            OverColor = RGB(182, 189, 210)
            DownColor = RGB(133, 146, 181)
            
        Case Is = jj_Rød
            DefaultColor = BckCl
            BorderColor = RGB(117, 0, 38)
            OverColor = RGB(282, 189, 210)
            DownColor = RGB(255, 136, 174)
        
        Case Is = jj_Grønn
            DefaultColor = BckCl
            BorderColor = RGB(6, 94, 41)
            OverColor = RGB(182, 250, 210)
            DownColor = RGB(77, 242, 142)
            
        Case Is = jj_Gul
            DefaultColor = BckCl
            BorderColor = RGB(117, 114, 0)
            OverColor = RGB(255, 253, 176)
            DownColor = RGB(255, 251, 94)
    End Select
    
    
    
    
    '**************** Action ******************
    '********************************************
    With UserControl
        '------------ Når musen forlater knappen, og ved initiering ---------------
        '**************************************************************************
        If (x < 0) Or (y < 0) Or (x > ucWidth) Or (y > ucHeight) Then
            If Aktiv = True Then ReleaseCapture
            
            If ttInZone Then
                ttInZone = False
                TT.Destroy
            End If
            
            EnGang = False
            EnGangB = False
            tmrRepeat.Interval = 400
            tmrRepeat.Enabled = False
            
            'Er det en jj_Check eller en jj_Option med Value=True tegnes den som inntrykket
            If (m_Mode = jj_Check Or m_Mode = jj_Option) And m_Value = True Then
                StatusValue = 2
            Else
                StatusValue = 0
            End If
                
            'Tegn knappens utseende
            Select Case m_jjButtonStyle
                Case Is = jj_Standard
                    Call TegnStandardKnapp(.hdc, StatusValue)
                    
                Case Is = jj_Hoover
                    Call TegnHooverKnapp(.hdc, StatusValue)
                    
                Case Is = jj_Blå, jj_Rød, jj_Grønn, jj_Gul
                    Call TegnFargetKnapp(.hdc, StatusValue)
                    
                Case Is = jj_Metall
                    Call TegnMetallKnapp(.hdc, StatusValue)
                    
                Case Is = jj_Sølv
                    Call TegnSølvKnapp(.hdc, StatusValue)
                    
                Case Is = jj_BlueFade
                    Call TegnBluefadeKnapp(.hdc, StatusValue)
                    
                Case Is = jj_Avrundet
                    Call TegnAvrundetKnapp(.hdc, StatusValue)
                    
                Case Is = jj_CheckBox
                    Call TegnCheckboxKnapp(.hdc, 0)
                    
                Case Is = jj_OptionBox
                    Call TegnOptionboxKnapp(.hdc, 0)
                    
                Case Is = jj_Tab
                    Call TegnTabKnapp(.hdc, StatusValue)
                    
                Case Is = jj_Tekst
                    Call TegnTekstKnapp(.hdc, StatusValue)
                    
                Case Is = jj_XP2003
                    Call TegnXP2003Knapp(.hdc, StatusValue)
            
            End Select
            BitBlt .hdc, 0, 0, ucWidth, ucHeight, pic1.hdc, 0, 0, vbSrcCopy
            .Refresh
            If HarFokus = True Then Call DrawFocus(.hdc)
            
            
            
        '---------------------- Når musen er over knappen -------------------------
        '**************************************************************************
        Else
            If Aktiv = True Then SetCapture .hwnd
              
            If EnGang = False Then
                EnGang = True
                
                If Not ttInZone Then
                    ttInZone = True
                    TT.Style = m_jjToolTipStyle
                    TT.Icon = m_jjToolTipIcon
                    TT.Title = m_jjToolTipHeader
                    TT.TipText = m_jjToolTip
                    TT.VisibleTime = m_jjToolTipTime
                    TT.Create .hwnd
                End If
    
                'Er det en jj_Check eller en jj_Option med Value=True tegnes den som inntrykket
                If (m_Mode = jj_Check Or m_Mode = jj_Option) And m_Value = True Then
                    StatusValue = 2
                Else
                    StatusValue = 1
                End If
                        
                'Tegn knappens utseende
                Select Case m_jjButtonStyle
                    Case Is = jj_Standard
                        Call TegnStandardKnapp(.hdc, StatusValue)
                        
                    Case Is = jj_Hoover
                        Call TegnHooverKnapp(.hdc, StatusValue)
                    
                    Case Is = jj_Blå, jj_Rød, jj_Grønn, jj_Gul
                        Call TegnFargetKnapp(.hdc, StatusValue)
                        
                    Case Is = jj_Metall
                        Call TegnMetallKnapp(.hdc, StatusValue)
                        
                    Case Is = jj_Sølv
                        Call TegnSølvKnapp(.hdc, StatusValue)
                        
                    Case Is = jj_BlueFade
                        Call TegnBluefadeKnapp(.hdc, StatusValue)
                    
                    Case Is = jj_Avrundet
                        Call TegnAvrundetKnapp(.hdc, StatusValue)
                        
                    Case Is = jj_CheckBox
                        Call TegnCheckboxKnapp(.hdc, 1)
                    
                    Case Is = jj_OptionBox
                        Call TegnOptionboxKnapp(.hdc, 1)
                    
                    Case Is = jj_Tab
                        Call TegnTabKnapp(.hdc, 1)
                        
                    Case Is = jj_Tekst
                        Call TegnTekstKnapp(.hdc, StatusValue)
                    
                    Case Is = jj_XP2003
                        Call TegnXP2003Knapp(.hdc, StatusValue)
                
                End Select
                BitBlt .hdc, 0, 0, ucWidth, ucHeight, pic1.hdc, 0, 0, vbSrcCopy
                .Refresh
                If HarFokus = True Then Call DrawFocus(.hdc)
            End If
            
            
            
            '------------- Om venstre musetast trykkes ned oppå knappen ---------------
            '**************************************************************************
            If Button = vbLeftButton Then
                If EnGangB = False Then
                    EnGangB = True
                                
                    'Tegn knappens utseende
                    Select Case m_jjButtonStyle
                        Case Is = jj_Standard
                            Call TegnStandardKnapp(.hdc, 2)
                            
                        Case Is = jj_Hoover
                            Call TegnHooverKnapp(.hdc, 2)
                    
                        Case Is = jj_Blå, jj_Rød, jj_Grønn, jj_Gul
                            Call TegnFargetKnapp(.hdc, 2)
                            
                        Case Is = jj_Metall
                            Call TegnMetallKnapp(.hdc, 2)
                            
                        Case Is = jj_Sølv
                            Call TegnSølvKnapp(.hdc, 2)
                            
                        Case Is = jj_BlueFade
                            Call TegnBluefadeKnapp(.hdc, 2)
                    
                        Case Is = jj_Avrundet
                            Call TegnAvrundetKnapp(.hdc, 2)
                            
                        Case Is = jj_CheckBox
                            Call TegnCheckboxKnapp(.hdc, 2)
                    
                        Case Is = jj_OptionBox
                            Call TegnOptionboxKnapp(.hdc, 2)
                    
                        Case Is = jj_Tab
                            Call TegnTabKnapp(.hdc, 2)
                            
                        Case Is = jj_Tekst
                            Call TegnTekstKnapp(.hdc, 2)
                    
                        Case Is = jj_XP2003
                            Call TegnXP2003Knapp(.hdc, 2)
                    
                    End Select
                    BitBlt .hdc, 0, 0, ucWidth, ucHeight, pic1.hdc, 0, 0, vbSrcCopy
                    .Refresh
                    If HarFokus = True Then Call DrawFocus(.hdc)
                End If
            End If
            
        End If
    End With
    
    'Denne er for å spare bruken av systemets GDI objekter
    Set pic1.Picture = Nothing
End Sub

Private Sub FadeTriangel(Farge As TRIANGEL_COLOR, jRect As RECT, Optional CheckBx As Boolean, Optional jhDc As Long)
    Dim Vert(3) As TRIVERTEX
    Dim Tri(3) As GRADIENT_TRIANGLE
    Dim f As Integer
    Dim rgbRed(3) As Long, rgbGreen(3) As Long, rgbBlue(3) As Long
    Dim rHex(3) As String, gHex(3) As String, bHex(3) As String
    
    For f = 0 To 3
        Select Case f
            Case Is = 0
                'Konverter til RGB
                rgbRed(f) = Farge.ColorLT Mod 256
                rgbGreen(f) = ((Farge.ColorLT And &HFF00FF00) / 256)
                rgbBlue(f) = (Farge.ColorLT And &HFF0000) / 65536
               
            Case Is = 1
                'Konverter til RGB
                rgbRed(f) = Farge.ColorRT Mod 256
                rgbGreen(f) = ((Farge.ColorRT And &HFF00FF00) / 256)
                rgbBlue(f) = (Farge.ColorRT And &HFF0000) / 65536
                
            Case Is = 2
                'Konverter til RGB
                rgbRed(f) = Farge.ColorRB Mod 256
                rgbGreen(f) = ((Farge.ColorRB And &HFF00FF00) / 256)
                rgbBlue(f) = (Farge.ColorRB And &HFF0000) / 65536
            
            Case Is = 3
                'Konverter til RGB
                rgbRed(f) = Farge.ColorLB Mod 256
                rgbGreen(f) = ((Farge.ColorLB And &HFF00FF00) / 256)
                rgbBlue(f) = (Farge.ColorLB And &HFF0000) / 65536
        End Select
    
        'Gang RGB sin verdi med 256 for å tilpasse maksverdien til GradientFillTriangle sin maksverdi som er 65280
        rgbRed(f) = rgbRed(f) * 256
        rgbGreen(f) = rgbGreen(f) * 256
        rgbBlue(f) = rgbBlue(f) * 256
        
        'Konverter de nye verdiene til Hex verdier
        rHex(f) = "&h" & Hex(rgbRed(f))
        gHex(f) = "&h" & Hex(rgbGreen(f))
        bHex(f) = "&h" & Hex(rgbBlue(f))
    Next f
    

    'Venstre øverst
    Vert(0).x = jRect.Left
    Vert(0).y = jRect.Top
    Vert(0).Red = rHex(0)
    Vert(0).Green = gHex(0)
    Vert(0).Blue = bHex(0)
    Vert(0).Alpha = 0&
    
    'Høyre øverst
    Vert(1).x = jRect.Right
    Vert(1).y = jRect.Top
    Vert(1).Red = rHex(1)
    Vert(1).Green = gHex(1)
    Vert(1).Blue = bHex(1)
    Vert(1).Alpha = 0&
    
    'Høyre nederst
    Vert(2).x = jRect.Right
    Vert(2).y = jRect.Bottom
    Vert(2).Red = rHex(2)
    Vert(2).Green = gHex(2)
    Vert(2).Blue = bHex(2)
    Vert(2).Alpha = 0&

    'Venstre nederst
    Vert(3).x = jRect.Left
    Vert(3).y = jRect.Bottom
    Vert(3).Red = rHex(3)
    Vert(3).Green = gHex(3)
    Vert(3).Blue = bHex(3)
    Vert(3).Alpha = 0&
    
    
    
    Tri(0).Vertex1 = 0
    Tri(0).Vertex2 = 1
    Tri(0).Vertex3 = 2
    
    Tri(1).Vertex1 = 0
    Tri(1).Vertex2 = 2
    Tri(1).Vertex3 = 3
    
    Tri(2).Vertex1 = 1
    Tri(2).Vertex2 = 2
    Tri(2).Vertex3 = 3
    
    Tri(3).Vertex1 = 0
    Tri(3).Vertex2 = 1
    Tri(3).Vertex3 = 3
    
    'API
    If jhDc <> 0 Then
        GradientFillTriangle jhDc, Vert(0), 4, Tri(0), 4, GRADIENT_FILL_TRIANGLE
    Else
        GradientFillTriangle UserControl.hdc, Vert(0), 4, Tri(0), 4, GRADIENT_FILL_TRIANGLE
    End If
    'UserControl.Refresh
End Sub

Private Sub FadeGradient(Farge As GRADIENT_COLOR, X1 As Long, Y1 As Long, X2 As Long, Y2 As Long, Optional jhDc As Long)
    Dim gRect As GRADIENT_RECT
    Dim Vert(1) As TRIVERTEX
    Dim f As Integer
    Dim rgbRed(1) As Long, rgbGreen(1) As Long, rgbBlue(1) As Long
    Dim rHex(1) As String, gHex(1) As String, bHex(1) As String
    
    For f = 0 To 1
        Select Case f
            Case Is = 0
                'Konverter FraFargen til RGB
                rgbRed(f) = Farge.ColorFrom Mod 256
                rgbGreen(f) = ((Farge.ColorFrom And &HFF00FF00) / 256)
                rgbBlue(f) = (Farge.ColorFrom And &HFF0000) / 65536
               
            Case Is = 1
                'Konverter TilFargen til RGB
                rgbRed(f) = Farge.ColorTo Mod 256
                rgbGreen(f) = ((Farge.ColorTo And &HFF00FF00) / 256)
                rgbBlue(f) = (Farge.ColorTo And &HFF0000) / 65536
        End Select
    
        'Gang RGB sin verdi med 256 for å tilpasse maksverdien til GradientFill sin maksverdi som er 65280
        rgbRed(f) = rgbRed(f) * 256
        rgbGreen(f) = rgbGreen(f) * 256
        rgbBlue(f) = rgbBlue(f) * 256
        
        'Konverter de nye verdiene til Hex verdier
        rHex(f) = "&h" & Hex(rgbRed(f))
        gHex(f) = "&h" & Hex(rgbGreen(f))
        bHex(f) = "&h" & Hex(rgbBlue(f))
    Next f
    
    'Fra-farge
    Vert(0).x = X1
    Vert(0).y = Y1
    Vert(0).Red = rHex(0)
    Vert(0).Green = gHex(0)
    Vert(0).Blue = bHex(0)
    Vert(0).Alpha = 0&
    
    'Til-farge
    Vert(1).x = X2
    Vert(1).y = Y2
    Vert(1).Red = rHex(1)
    Vert(1).Green = gHex(1)
    Vert(1).Blue = bHex(1)
    Vert(1).Alpha = 0&
    
    'Rektangelets ytterpunkter
    gRect.UpperLeft = 0
    gRect.LowerRight = 1
    
    'API
    If jhDc <> 0 Then
        GradientFill jhDc, Vert(0), 2, gRect, 1, GRADIENT_FILL_RECT_V
    Else
        GradientFill UserControl.hdc, Vert(0), 2, gRect, 1, GRADIENT_FILL_RECT_V
    End If
    'UserControl.Refresh
End Sub

Private Sub tmr1_Timer()
    tmr1.Enabled = False
    Call HighLight(-1, -1, -1, True)
End Sub


Private Sub tmrRedrawButton_Timer()
    'Refresher knappen 2 ganger når man kaller på kontrollens Refresh (Ikke Usercontrol.Refresh)
    'Dette må ofte gjøres når man har valgt å kopiere inn bakgrunn fra en PictureBox like etter oppstart
    'Eller om man endrer bakgrunnsbildet

    Static Tell As Integer
    Dim f As Integer
    
    tmrRedrawButton.Interval = 60
    Tell = Tell + 1
    If Tell > 1 Then
        tmrRedrawButton.Interval = 1
        Tell = 0
        tmrRedrawButton.Enabled = False
    End If
    
    Call HighLight(-1, -1, -1, False)
End Sub


Private Sub tmrRepeat_Timer()
    RaiseEvent Click
    tmrRepeat.Interval = 50
End Sub

Private Sub UserControl_AccessKeyPress(KeyAscii As Integer)
    If Enabled Then
        UserControl.SetFocus
        'Aktiviser Click bare om det er en standerknapp når den får fokus vi hurtigtaster
        'Click skal jo ikke utføres når hurtigtast brukes på option eller check knapp
        If m_Mode = jj_Command Or KeyAscii = 13 Then
            mButton = vbLeftButton
            Call UserControl_Click
        
        'Aktiviser Click om der er en jj_Tab i Option-mode
        ElseIf m_Mode = jj_Option And m_jjButtonStyle = jj_Tab Then
            mButton = vbLeftButton
            Call UserControl_Click
        End If
    End If
End Sub

Private Sub UserControl_AmbientChanged(PropertyName As String)
'    On Error GoTo AbortCheck
'    Select Case PropertyName
'        Case "DisplayAsDefault" 'changing focus
'            If Ambient.DisplayAsDefault = True Then
'                UserControl.Parent.SetFocus
'            Else
'
'            End If
'
'    End Select
'AbortCheck:
End Sub

Private Sub UserControl_DblClick()
    ' Typical Window buttons do not have a double click event. Each
    ' double click event on a typical button is registered as 2 clicks
    ' with 2 sets of MouseDown & MouseUp events. We simulate that too
    
    Dim mousePt As POINTAPI
    ' another plus... other button routines out there may not pass the
    ' true X,Y coordinates when firing a fake 2nd click event
    GetCursorPos mousePt
    ScreenToClient UserControl.hwnd, mousePt
    RaiseEvent DoubleClick(CInt(mButton))   ' added benefit/information
    If mButton = vbLeftButton Then
        ' double clicked with left mouse button fire a mouse down event
        Call UserControl_MouseDown(vbLeftButton, 0, CSng(mousePt.x), CSng(mousePt.y))
        ' key variable. This flag indicates we will be sending a fake click event
        mButton = -1
    Else
        ' double clicked with middle/right mouse button, send this event only
        RaiseEvent MouseDown(vbLeftButton, 0, CSng(mousePt.x), CSng(mousePt.y))
    End If
End Sub

Private Sub UserControl_GotFocus()
    HarFokus = True
    Call DrawFocus(hdc)
End Sub

Private Sub UserControl_Initialize()
    Set TT = New CTooltip
    
    Call FinnOs
End Sub

'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
    Set UserControl.Font = Ambient.Font
    m_Caption = Ambient.DisplayName
    m_jjButtonStyle = m_def_jjButtonStyle
    m_FocusRectangle = m_def_FocusRectangle
    Set m_IconDefault = LoadPicture("")
    m_BackColor = m_def_BackColor
    m_ForeColor = m_def_ForeColor
    m_IconAlign = m_def_IconAlign
    m_IconSpace = m_def_IconSpace
    m_jjToolTip = m_def_jjTooltip
    m_jjToolTipHeader = m_def_jjToolTipHeader
    m_jjToolTipIcon = m_def_jjToolTipIcon
    m_jjToolTipStyle = m_def_jjToolTipStyle
    m_jjToolTipTime = m_def_jjToolTipTime
    m_Mode = m_def_Mode
    m_Value = m_def_Value
    m_GruppeID = m_def_GruppeID
    m_Repeat = m_def_Repeat
    m_CopyBGSource = m_def_CopyBGSource
    m_jjTabBorderColor = m_def_jjTabBorderColor
    m_jjTabSelectedColor = m_def_jjTabSelectedColor
End Sub

Private Sub UserControl_LostFocus()
    HarFokus = False
    Cls
    Call HighLight(-1, -1, -1, False)
End Sub

Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    On Error Resume Next
    RaiseEvent MouseDown(Button, Shift, x, y)
    
    mButton = Button
    If Button = vbLeftButton Then
        jjButtonMouseLock = True
        jjButtonAmbientName = Ambient.DisplayName
        Call HighLight(Button, x, y, True)
        
        'Repeat funksjon på standerknapper
        If m_Repeat = True Then
            If m_Mode = jj_Command Then
                tmrRepeat.Interval = 400
                tmrRepeat.Enabled = True
            End If
        End If
        
        'DoEvents
    End If
   
End Sub

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    RaiseEvent MouseMove(Button, Shift, x, y)
    
    'For å hindre mouseover på andre kontroller om musetasten er trykket ned på en kontroll
    If jjButtonMouseLock = True And jjButtonAmbientName = Ambient.DisplayName Then
        Call HighLight(Button, x, y, True)
    ElseIf jjButtonMouseLock = True And jjButtonAmbientName <> Ambient.DisplayName Then
        If Button = 0 Then Call HighLight(Button, x, y, True)
        DoEvents
        Exit Sub
    ElseIf jjButtonMouseLock = False And jjButtonAmbientName = "" Then
        Call HighLight(Button, x, y, True)
    End If
    
    
'    If Not ttInZone Then
'        ttInZone = True
'        TT.TTStyle = m_jjToolTipStyle
'        TT.TTIcon = m_jjToolTipIcon
'        TT.TTTitle = m_jjToolTipHeader
'        TT.TTTipText = m_jjToolTip
'        TT.TTVisibleTime = m_jjToolTipTime
'        TT.TTCreate UserControl.hwnd
'    End If
    
    
   DoEvents
End Sub

'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
    Set UserControl.Font = PropBag.ReadProperty("Font", Ambient.Font)
    m_Caption = PropBag.ReadProperty("Caption", "")
    m_jjButtonStyle = PropBag.ReadProperty("jjButtonStyle", m_def_jjButtonStyle)
    m_FocusRectangle = PropBag.ReadProperty("FocusRectangle", m_def_FocusRectangle)
    
    Call SetAcccessKey
    Set Picture = PropBag.ReadProperty("Picture", Nothing)
    Set m_IconDefault = PropBag.ReadProperty("IconDefault", Nothing)
    m_BackColor = PropBag.ReadProperty("BackColor", m_def_BackColor)
    m_ForeColor = PropBag.ReadProperty("ForeColor", m_def_ForeColor)
    m_IconAlign = PropBag.ReadProperty("IconAlign", m_def_IconAlign)
    m_IconSpace = PropBag.ReadProperty("IconSpace", m_def_IconSpace)
    m_jjToolTip = PropBag.ReadProperty("Tooltip", m_def_jjTooltip)
    m_jjToolTipHeader = PropBag.ReadProperty("jjToolTipHeader", m_def_jjToolTipHeader)
    m_jjToolTipIcon = PropBag.ReadProperty("jjToolTipIcon", m_def_jjToolTipIcon)
    m_jjToolTipStyle = PropBag.ReadProperty("jjToolTipStyle", m_def_jjToolTipStyle)
    m_jjToolTipTime = PropBag.ReadProperty("jjToolTipTime", m_def_jjToolTipTime)
    m_Mode = PropBag.ReadProperty("Mode", m_def_Mode)
    m_Value = PropBag.ReadProperty("Value", m_def_Value)
    m_GruppeID = PropBag.ReadProperty("GruppeID", m_def_GruppeID)
    m_Repeat = PropBag.ReadProperty("Repeat", m_def_Repeat)
    Set m_CopyBGBoxName = PropBag.ReadProperty("CopyBGBoxName", Nothing)
    m_CopyBGSource = PropBag.ReadProperty("CopyBGSource", m_def_CopyBGSource)
    m_jjTabBorderColor = PropBag.ReadProperty("jjTabBorderColor", m_def_jjTabBorderColor)
    m_jjTabSelectedColor = PropBag.ReadProperty("jjTabSelectedColor", m_def_jjTabSelectedColor)
End Sub

Private Sub UserControl_Resize()
    'Om vi har valgt Checkbox-knapp må vi hindre at den blir mindre enn 13 pixler i høyde
    If m_jjButtonStyle = jj_CheckBox Or m_jjButtonStyle = jj_OptionBox Then
        UserControl.Height = 13 * 15
    End If
    
    
    'Bredden og høyden på knappen legges i disse
    ucWidth = UserControl.ScaleWidth
    ucHeight = UserControl.ScaleHeight
    pic1.Width = ucWidth
    pic1.Height = ucHeight
        
    Cls
    Call HighLight(-1, -1, -1, False)
    Call SetAcccessKey
    DoEvents
End Sub

'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
    Call PropBag.WriteProperty("Font", UserControl.Font, Ambient.Font)
    Call PropBag.WriteProperty("Caption", m_Caption, "")
    Call PropBag.WriteProperty("jjButtonStyle", m_jjButtonStyle, m_def_jjButtonStyle)
    Call PropBag.WriteProperty("FocusRectangle", m_FocusRectangle, m_def_FocusRectangle)
    Call PropBag.WriteProperty("Picture", Picture, Nothing)
    Call PropBag.WriteProperty("IconDefault", m_IconDefault, Nothing)
    Call PropBag.WriteProperty("BackColor", m_BackColor, m_def_BackColor)
    Call PropBag.WriteProperty("ForeColor", m_ForeColor, m_def_ForeColor)
    Call PropBag.WriteProperty("IconAlign", m_IconAlign, m_def_IconAlign)
    Call PropBag.WriteProperty("IconSpace", m_IconSpace, m_def_IconSpace)
    Call PropBag.WriteProperty("Tooltip", m_jjToolTip, m_def_jjTooltip)
    Call PropBag.WriteProperty("jjToolTipHeader", m_jjToolTipHeader, m_def_jjToolTipHeader)
    Call PropBag.WriteProperty("jjToolTipIcon", m_jjToolTipIcon, m_def_jjToolTipIcon)
    Call PropBag.WriteProperty("jjToolTipStyle", m_jjToolTipStyle, m_def_jjToolTipStyle)
    Call PropBag.WriteProperty("jjToolTipTime", m_jjToolTipTime, m_def_jjToolTipTime)
    Call PropBag.WriteProperty("Value", m_Value, m_def_Value)
    Call PropBag.WriteProperty("Mode", m_Mode, m_def_Mode)
    Call PropBag.WriteProperty("GruppeID", m_GruppeID, m_def_GruppeID)
    Call PropBag.WriteProperty("Repeat", m_Repeat, m_def_Repeat)
    Call PropBag.WriteProperty("CopyBGBoxName", m_CopyBGBoxName, Nothing)
    Call PropBag.WriteProperty("CopyBGSource", m_CopyBGSource, m_def_CopyBGSource)
    Call PropBag.WriteProperty("jjTabBorderColor", m_jjTabBorderColor, m_def_jjTabBorderColor)
    Call PropBag.WriteProperty("jjTabSelectedColor", m_jjTabSelectedColor, m_def_jjTabSelectedColor)
End Sub

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,Enabled
Public Property Get Enabled() As Boolean
Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
    Enabled = UserControl.Enabled
End Property

Public Property Let Enabled(ByVal New_Enabled As Boolean)
    If New_Enabled = UserControl.Enabled Then Exit Property
    
    UserControl.Enabled() = New_Enabled
    PropertyChanged "Enabled"
    
    Cls
    Call HighLight(-1, -1, -1, False)
    DoEvents
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,Font
Public Property Get Font() As Font
Attribute Font.VB_Description = "Returns a Font object."
Attribute Font.VB_UserMemId = -512
    Set Font = UserControl.Font
End Property

Public Property Set Font(ByVal New_Font As Font)
    Set UserControl.Font = New_Font
    PropertyChanged "Font"
    
    Cls
    Call HighLight(-1, -1, -1, False)
    DoEvents
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,Refresh
Public Sub Refresh()
Attribute Refresh.VB_Description = "Forces a complete repaint of a object."
    UserControl.Refresh
    tmrRedrawButton.Enabled = True
End Sub

Private Sub UserControl_Click()
    Dim b As Control
    Dim ID As String
    
    If mButton = vbLeftButton Then
        'Inn her om det er en jj_Sjekk
        If m_Mode = jj_Check Then
            m_Value = IIf(m_Value, False, True)
            If m_Value = True Then
                Call HighLight(1, -1, -1, True)
                RaiseEvent Click
                DoEvents
                Exit Sub
            End If
        End If
        
        
        'Inn her om det er en jj_Option
        If m_Mode = jj_Option Then
            If m_Value = True Then Exit Sub 'Avbryt om verdien allerede er True
            ID = m_GruppeID
            For Each b In UserControl.Parent
                If TypeOf b Is jjButton Then
                    If b.GruppeID = ID Then
                        If b.Value = True Then
                            b.Value = False
                        End If
                    End If
                End If
            Next
            m_Value = True
            Call HighLight(-1, -1, -1, True)
            RaiseEvent Click
            DoEvents
            Exit Sub
        End If
        
        
        'Inn her om det er en jj_Command
        Call HighLight(-1, -1, -1, True)
        'DoEvents
        RaiseEvent Click
    End If
    
End Sub

Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
    
    If KeyCode = 13 Or (KeyCode = 32 And m_Mode = jj_Check) Then 'Enter
        mButton = vbLeftButton
        UserControl_Click
        mButton = -1
    Else
        RaiseEvent KeyDown(KeyCode, Shift)
    End If
End Sub

Private Sub UserControl_KeyPress(KeyAscii As Integer)
    RaiseEvent KeyPress(KeyAscii)
End Sub

Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
    RaiseEvent KeyUp(KeyCode, Shift)
End Sub

Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    jjButtonMouseLock = False
    jjButtonAmbientName = ""
    
    RaiseEvent MouseUp(Button, Shift, x, y)
    mButton = Button
    
    tmr1.Enabled = True
    
    tmrRepeat.Enabled = False
    
End Sub

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=13,0,0,Tekst
Public Property Get Caption() As String
Attribute Caption.VB_Description = "Tekst på knappen"
    Caption = m_Caption
End Property

Public Property Let Caption(ByVal New_Caption As String)
    m_Caption = New_Caption
    
    Cls
    Call HighLight(-1, -1, -1, False)
    Call SetAcccessKey
    DoEvents
    
    PropertyChanged "Caption"
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=7,0,0,0
Public Property Get jjButtonStyle() As jjButtonColor
Attribute jjButtonStyle.VB_Description = "Velg knappetype fra listen"
    jjButtonStyle = m_jjButtonStyle
End Property

Public Property Let jjButtonStyle(ByVal New_jjButtonStyle As jjButtonColor)
    m_jjButtonStyle = New_jjButtonStyle
    PropertyChanged "jjButtonStyle"
    
    'Fjern først en evt. region
    SetWindowRgn UserControl.hwnd, 0, True
    
    'Sett til Checkbox-type om vi velger checkbox knapp
    If m_jjButtonStyle = jj_CheckBox Then
        Me.Mode = jj_Check
    End If
    
    'Sett til Optionbox-type om vi velger optionbox knapp
    If m_jjButtonStyle = jj_OptionBox Then
        Me.Mode = jj_Option
    End If
    
    Cls
    UserControl_Resize
    Call HighLight(-1, -1, -1, False)
    DoEvents
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=0,0,0,True
Public Property Get FocusRectangle() As Boolean
Attribute FocusRectangle.VB_Description = "Tegner fokusmerke på knappen når den har fokus"
    FocusRectangle = m_FocusRectangle
End Property

Public Property Let FocusRectangle(ByVal New_FocusRectangle As Boolean)
    m_FocusRectangle = New_FocusRectangle
    PropertyChanged "FocusRectangle"
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,Picture
Public Property Get Picture() As Picture
Attribute Picture.VB_Description = "Returns/sets a graphic to be displayed in a control."
    Set Picture = UserControl.Picture
End Property

Public Property Set Picture(ByVal New_Picture As Picture)
    Set UserControl.Picture = New_Picture
    PropertyChanged "Picture"
    
    Cls
    Call HighLight(-1, -1, -1, False)
    DoEvents
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=11,0,0,0
Public Property Get IconDefault() As StdPicture
Attribute IconDefault.VB_Description = "Stander ikon på knappen"
    Set IconDefault = m_IconDefault
End Property

Public Property Set IconDefault(ByVal New_IconDefault As StdPicture)
    Set m_IconDefault = New_IconDefault
    PropertyChanged "IconDefault"
    
    Cls
    Call HighLight(-1, -1, -1, False)
    DoEvents
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=10,0,0,0
Public Property Get BackColor() As OLE_COLOR
    BackColor = m_BackColor
End Property

Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
    m_BackColor = New_BackColor
    PropertyChanged "BackColor"
    
    Cls
    Call HighLight(-1, -1, -1, False)
    Call SetAcccessKey
    DoEvents
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=10,0,0,0
Public Property Get ForeColor() As OLE_COLOR
Attribute ForeColor.VB_Description = "Returns/sets the foreground color used to display text and graphics in an object."
    ForeColor = m_ForeColor
End Property

Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
    m_ForeColor = New_ForeColor
    PropertyChanged "ForeColor"
    
    Cls
    Call HighLight(-1, -1, -1, False)
    Call SetAcccessKey
    DoEvents
End Property

Private Sub TegnBluefadeKnapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim Farge As GRADIENT_COLOR
    Dim hRgn As Long
    Dim hBrush As Long
    Dim hPen As Long
    Dim Skyv As Integer
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            Farge.ColorFrom = vbWhite
            Farge.ColorTo = RGB(61, 120, 209)
            Call FadeGradient(Farge, 0, 0, ucWidth, ucHeight / 2, TempHdc)
            
            Farge.ColorFrom = RGB(61, 120, 209)
            Farge.ColorTo = RGB(174, 202, 240)
            Call FadeGradient(Farge, 0, ucHeight / 2, ucWidth, ucHeight, TempHdc)
            
            'Marker region med Mørk blå ramme
            hRgn = CreateRoundRectRgn(0, 0, ucWidth, ucHeight, 5, 5)
            hBrush = CreateSolidBrush(RGB(49, 86, 147))
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            SetWindowRgn UserControl.hwnd, hRgn, True
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Et litt lysere RoundRect innenfor den ytre rammen
            hPen = CreatePen(PS_SOLID, 1, RGB(149, 183, 244))
            SelectObject TempHdc, hPen
            RoundRect TempHdc, 1, 1, ucWidth - 2, ucHeight - 2, 5, 5
            DeleteObject hPen
            
            'Sett noen punkter i hjørnene for at de skal se litt bedre ut
            Call RundeHjorner(TempHdc)
            
            'AlphaBlending TempHdc, 50
            
            MousePos = -1
            Skyv = 0
            
        'MouseOver
        Case Is = 1
            Farge.ColorFrom = RGB(255, 255, 255)
            Farge.ColorTo = RGB(61, 120, 209)
            Call FadeGradient(Farge, 0, 0, ucWidth, ucHeight / 2, TempHdc)
            
            Farge.ColorFrom = RGB(61, 120, 209)
            Farge.ColorTo = RGB(174, 202, 240)
            Call FadeGradient(Farge, 0, ucHeight / 2, ucWidth, ucHeight, TempHdc)

            'Marker region med Mørk blå ramme (lik MouseLeave)
            hRgn = CreateRoundRectRgn(0, 0, ucWidth, ucHeight, 5, 5)
            hBrush = CreateSolidBrush(RGB(49, 86, 147))
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Et litt lysere RoundRect innenfor den ytre rammen (lik MouseLeave)
            hPen = CreatePen(PS_SOLID, 1, RGB(149, 183, 244))
            SelectObject TempHdc, hPen
            RoundRect TempHdc, 1, 1, ucWidth - 2, ucHeight - 2, 5, 5
            DeleteObject hPen
            
            'RoundRect for å indikere MouseOver
            hPen = CreatePen(PS_SOLID, 1, vbGreen)
            SelectObject TempHdc, hPen
            RoundRect TempHdc, 2, 2, ucWidth - 3, ucHeight - 3, 5, 5
            DeleteObject hPen
            
            'Sett noen punkter i hjørnene for at de skal se litt bedre ut
            Call RundeHjorner(TempHdc)
            
            'AlphaBlending TempHdc, 50
            
        'MouseDown
        Case Is = 2
            Farge.ColorFrom = RGB(39, 89, 165)
            Farge.ColorTo = RGB(217, 234, 254)
            Call FadeGradient(Farge, 0, 0, ucWidth, ucHeight / 1.5, TempHdc)

            Farge.ColorFrom = RGB(217, 234, 254)
            Farge.ColorTo = RGB(61, 120, 209)
            Call FadeGradient(Farge, 0, ucHeight / 1.5, ucWidth, ucHeight, TempHdc)
            
            'Marker region med Mørk blå ramme (lik MouseLeave)
            hRgn = CreateRoundRectRgn(0, 0, ucWidth, ucHeight, 5, 5)
            hBrush = CreateSolidBrush(RGB(49, 86, 147))
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            SetWindowRgn UserControl.hwnd, hRgn, True
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Et litt lysere RoundRect innenfor den ytre rammen (lik MouseLeave)
            hPen = CreatePen(PS_SOLID, 1, RGB(149, 183, 244))
            SelectObject TempHdc, hPen
            RoundRect TempHdc, 1, 1, ucWidth - 2, ucHeight - 2, 5, 5
            DeleteObject hPen
            
            MousePos = -1
            Skyv = 1
    End Select
    
    'AlphaBlending TempHdc, 50
    
    If MousePos <> 0 Then
        'Tegn Caption vanlig eller disabled
        SetTextColor TempHdc, m_ForeColor
        If m_Caption <> "" Then
            DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
        End If
        
        'Tegn Ikon vanlig eller disabled
        If m_IconDefault Then
            If UserControl.Enabled = True Then
                pic1.PaintPicture m_IconDefault, IconL + Skyv, IconT + Skyv
                
            Else
                DrawState TempHdc, 0, 0, m_IconDefault.Handle, 0, IconL + Skyv, IconT + Skyv, 0, 0, DST_ICON Or DSS_DISABLED
            End If
        End If
        'UserControl.Refresh
    End If
End Sub

Private Sub TegnSølvKnapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim rc As RECT
    Dim Farge As TRIANGEL_COLOR
    Dim pnt As POINTAPI
    Dim hRgn As Long
    Dim hBrush As Long
    Dim hPen As Long
    Dim Skyv As Integer
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    BorderColor = RGB(64, 64, 64)
    rc.Left = 0
    rc.Top = 0
    rc.Right = ucWidth
    rc.Bottom = ucHeight
    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            'Tegn bakgrunn
            Farge.ColorLT = RGB(245, 245, 245)
            Farge.ColorRT = RGB(230, 240, 250)
            Farge.ColorRB = RGB(140, 150, 160)
            Farge.ColorLB = RGB(180, 190, 200)
            If UserControl.Enabled = False Then
                Farge.ColorLT = RGB(245, 245, 245)
                Farge.ColorRT = RGB(240, 240, 240)
                Farge.ColorRB = RGB(150, 150, 150)
                Farge.ColorLB = RGB(190, 190, 190)
                BorderColor = RGB(150, 150, 150)
            End If
            Call FadeTriangel(Farge, rc, True, TempHdc)
            
            'Lag path av strekene som her tegnes
            BeginPath TempHdc
                'To streker(venstre/topp)
                MoveToEx TempHdc, 0, ucHeight - 1, pnt
                LineTo TempHdc, 0, 0
                LineTo TempHdc, ucWidth - 1, 0
                'To streker(høyre og bunn)
                MoveToEx TempHdc, ucWidth - 1, 0, pnt
                LineTo TempHdc, ucWidth - 1, ucHeight
                LineTo TempHdc, 0, ucHeight - 1
            'Avslutt path
            EndPath TempHdc
            
            'Konverter path til region
            hRgn = PathToRegion(TempHdc)
            hBrush = CreateSolidBrush(BorderColor)
            'Tegn ramme langs regionen
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            'Sett regionen til UserControl
            SetWindowRgn UserControl.hwnd, hRgn, True
            'Slett hendler
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Lag en penn, tegn to hvite streker (venstre/topp)
            hPen = CreatePen(PS_SOLID, 1, vbWhite)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 0, ucHeight - 1, pnt
            LineTo TempHdc, 0, 0
            LineTo TempHdc, ucWidth - 1, 0
            DeleteObject hPen
            
            'UserControl.Refresh
            MousePos = -1
            Skyv = 0
            
        'MouseOver
        Case Is = 1
            'Tegn bakgrunn
            Farge.ColorLT = RGB(240, 240, 240)
            Farge.ColorRT = RGB(230, 240, 250)
            Farge.ColorRB = RGB(180, 190, 200)
            Farge.ColorLB = RGB(210, 220, 230)
            Call FadeTriangel(Farge, rc, True, TempHdc)
            
            'Lag path av strekene som her tegnes
            BeginPath TempHdc
                'To streker(venstre/topp)
                MoveToEx TempHdc, 0, ucHeight - 1, pnt
                LineTo TempHdc, 0, 0
                LineTo TempHdc, ucWidth - 1, 0
                'To streker(høyre og bunn)
                MoveToEx TempHdc, ucWidth - 1, 0, pnt
                LineTo TempHdc, ucWidth - 1, ucHeight
                LineTo TempHdc, 0, ucHeight - 1
            'Avslutt path
            EndPath TempHdc
            
            'Konverter path til region
            hRgn = PathToRegion(TempHdc)
            hBrush = CreateSolidBrush(BorderColor)
            'Tegn ramme langs regionen
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            'Sett regionen til UserControl
            'SetWindowRgn UserControl.hwnd, hRgn, True
            'Slett hendler
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Lag en penn, tegn to grå streker (venstre/topp)
            hPen = CreatePen(PS_SOLID, 1, vbWhite)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 0, ucHeight - 1, pnt
            LineTo TempHdc, 0, 0
            LineTo TempHdc, ucWidth - 1, 0
            DeleteObject hPen
            
            'Skyv = -1
            
        'MouseDown
        Case Is = 2
            'Tegn bakgrunn
            Farge.ColorLT = RGB(140, 140, 140)
            Farge.ColorRT = RGB(230, 240, 250)
            Farge.ColorRB = RGB(130, 140, 150)
            Farge.ColorLB = RGB(160, 170, 180)
            If UserControl.Enabled = False Then
                Farge.ColorLT = RGB(140, 140, 140)
                Farge.ColorRT = RGB(240, 240, 240)
                Farge.ColorRB = RGB(140, 140, 140)
                Farge.ColorLB = RGB(170, 170, 170)
                BorderColor = RGB(150, 150, 150)
            End If
            Call FadeTriangel(Farge, rc, True, TempHdc)
            
            'Lag path av strekene som her tegnes
            BeginPath TempHdc
                'To streker(venstre/topp)
                MoveToEx TempHdc, 0, ucHeight - 1, pnt
                LineTo TempHdc, 0, 0
                LineTo TempHdc, ucWidth - 1, 0
                'To streker(høyre og bunn)
                MoveToEx TempHdc, ucWidth - 1, 0, pnt
                LineTo TempHdc, ucWidth - 1, ucHeight
                LineTo TempHdc, 0, ucHeight - 1
            'Avslutt path
            EndPath TempHdc
            
            'Konverter path til region
            hRgn = PathToRegion(TempHdc)
            hBrush = CreateSolidBrush(vbWhite)
            'Tegn ramme langs regionen
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            'Sett regionen til UserControl
            SetWindowRgn UserControl.hwnd, hRgn, True
            'Slett hendler
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Lag en penn, tegn to grå streker (venstre/topp)
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 0, ucHeight - 1, pnt
            LineTo TempHdc, 0, 0
            LineTo TempHdc, ucWidth - 1, 0
            DeleteObject hPen
            
            Skyv = 1
    End Select
    
    'AlphaBlending TempHdc, 50
    
    If MousePos <> 0 Then
        'Tegn Caption vanlig eller disabled
        SetTextColor TempHdc, m_ForeColor
        If m_Caption <> "" Then
            DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
        End If
        
        'Tegn Ikon vanlig eller disabled
        If m_IconDefault Then
            If UserControl.Enabled = True Then
                pic1.PaintPicture m_IconDefault, IconL + Skyv, IconT + Skyv
                'BitBlt TempHdc, 0, 0, IconW, IconH, m_IconDefault, 0, 0, vbSrcCopy
            
            Else
                DrawState TempHdc, 0, 0, m_IconDefault.Handle, 0, IconL + Skyv, IconT + Skyv, 0, 0, DST_ICON Or DSS_DISABLED
            End If
        End If
        'UserControl.Refresh
    End If
End Sub

Private Sub TegnMetallKnapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim pnt As POINTAPI
    Dim hRgn As Long
    Dim hBrush As Long
    Dim hPen As Long
    Dim Skyv As Integer
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    DefaultColor = RGB(243, 240, 232)
    BorderColor = RGB(0, 0, 0)
    DownColor = RGB(223, 220, 212)
    
    'Tegne med lys grå om kontrollen er disabled
    If UserControl.Enabled = False Then BorderColor = RGB(150, 150, 150)
    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            hRgn = CreateRoundRectRgn(0, 0, ucWidth, ucHeight, 5, 5)
            hBrush = CreateSolidBrush(BorderColor)
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            SetWindowRgn UserControl.hwnd, hRgn, True
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Grå ramme
            hBrush = CreateSolidBrush(DefaultColor)
            hPen = CreatePen(PS_SOLID, 1, RGB(179, 177, 156))
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            RoundRect TempHdc, 1, 1, ucWidth - 2, ucHeight - 2, 4, 4
            DeleteObject hPen
            DeleteObject hBrush
            
            'To hvite streker(venstre og topp)
            hPen = CreatePen(PS_SOLID, 1, vbWhite)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 2, ucHeight - 4, pnt
            LineTo TempHdc, 2, 2
            LineTo TempHdc, ucWidth - 3, 2
            DeleteObject hPen
            
            MousePos = -1
            Skyv = 0
                    
        'MouseOver
        Case Is = 1
            hRgn = CreateRoundRectRgn(0, 0, ucWidth, ucHeight, 5, 5)
            hBrush = CreateSolidBrush(BorderColor)
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            SetWindowRgn UserControl.hwnd, hRgn, True
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Grå ramme
            hBrush = CreateSolidBrush(DefaultColor)
            hPen = CreatePen(PS_SOLID, 1, RGB(179, 177, 156))
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            RoundRect TempHdc, 1, 1, ucWidth - 2, ucHeight - 2, 4, 4
            DeleteObject hPen
            DeleteObject hBrush
            
            'To hvite streker(venstre og topp)
            hPen = CreatePen(PS_SOLID, 1, vbWhite)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 2, ucHeight - 4, pnt
            LineTo TempHdc, 2, 2
            LineTo TempHdc, ucWidth - 3, 2
            DeleteObject hPen
            
            'Tegn lysbrun RoundRect fylt med OverColor
            hBrush = CreateSolidBrush(DefaultColor)
            hPen = CreatePen(PS_SOLID, 1, RGB(177, 179, 156))
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            RoundRect TempHdc, 2, 2, ucWidth - 3, ucHeight - 3, 6, 6
            DeleteObject hPen
            DeleteObject hBrush
            
            'Skyv = -1
            
        'MouseDown
        Case Is = 2
            'Tegn sort RoundRect fylt med DownColor
            hRgn = CreateRoundRectRgn(0, 0, ucWidth, ucHeight, 5, 5)
            hBrush = CreateSolidBrush(DownColor)
            hPen = CreatePen(PS_SOLID, 1, vbBlack)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            SetWindowRgn UserControl.hwnd, hRgn, True
            RoundRect TempHdc, 0, 0, ucWidth - 1, ucHeight - 1, 6, 6
            DeleteObject hPen
            DeleteObject hBrush
            DeleteObject hRgn
            
            'Tegn hvit RoundRect innenfor den ytre fylt med DownColor
            hBrush = CreateSolidBrush(DownColor)
            hPen = CreatePen(PS_SOLID, 1, vbWhite)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            RoundRect TempHdc, 1, 1, ucWidth - 2, ucHeight - 2, 4, 4
            DeleteObject hPen
            DeleteObject hBrush
            
            'To grå streker
            hPen = CreatePen(PS_SOLID, 1, RGB(129, 127, 106))
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 1, ucHeight - 4, pnt
            LineTo TempHdc, 1, 1
            MoveToEx TempHdc, 2, 1, pnt
            LineTo TempHdc, ucWidth - 3, 1
            DeleteObject hPen
            
            'To hvite streker
            hPen = CreatePen(PS_SOLID, 1, vbWhite)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, ucWidth - 4, 2, pnt
            LineTo TempHdc, ucWidth - 4, ucHeight - 4
            LineTo TempHdc, 2, ucHeight - 4
            DeleteObject hPen
            
            'UserControl.Refresh
            Skyv = 1
    End Select
    
    If MousePos <> 0 Then
        'Tegn Caption vanlig eller disabled
        SetTextColor TempHdc, m_ForeColor
        If m_Caption <> "" Then
            DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
        End If
        
        'Tegn Ikon vanlig eller disabled
        If m_IconDefault Then
            If UserControl.Enabled = True Then
                pic1.PaintPicture m_IconDefault, IconL + Skyv, IconT + Skyv
            Else
                DrawState TempHdc, 0, 0, m_IconDefault.Handle, 0, IconL + Skyv, IconT + Skyv, 0, 0, DST_ICON Or DSS_DISABLED
            End If
        End If
        'UserControl.Refresh
    End If
End Sub

Private Sub TegnAvrundetKnapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim rc As RECT
    Dim Farge2 As GRADIENT_COLOR
    Dim Farge As TRIANGEL_COLOR
    Dim pnt As POINTAPI
    Dim hRgn As Long
    Dim hBrush As Long
    Dim hPen As Long
    Dim Skyv As Integer
    Const avr As Integer = 5
    Dim SelectedColor(1) As Long
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    rc.Left = 0
    rc.Top = 0
    rc.Right = ucWidth
    rc.Bottom = ucHeight
    
    
    'Tegne med blålig eller lys grå om kontrollen er enabled/disabled
    'Farger om enabled/disabled
    If UserControl.Enabled = True Then
        DownColor = RGB(252, 252, 254)          'Bakgrunnsfarge på den som har Value=True
        BorderColor = RGB(28, 81, 128)      'Blålig farge       'Blålig farge til ramme RGB(145, 167, 180) '
        SelectedColor(0) = RGB(255, 255, 255)   'Graderingsfargen på toppen om Value=True
        SelectedColor(1) = RGB(236, 235, 230)    'Graderingsfargen på toppen om Value=True
    Else
        DownColor = vbWhite
        BorderColor = RGB(182, 180, 167)
        SelectedColor(0) = vbWhite
        SelectedColor(1) = vbWhite
    End If

    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            'Tegn gradert bakgrunn
            If UserControl.Enabled = True Then
                Farge2.ColorFrom = SelectedColor(0)
                Farge2.ColorTo = SelectedColor(1)
                Call FadeGradient(Farge2, rc.Left, rc.Top, rc.Right, rc.Bottom, TempHdc)
                
                'Skyggestreker
                hPen = CreatePen(PS_SOLID, 1, RGB(214, 208, 197))
                SelectObject TempHdc, hPen
                MoveToEx TempHdc, 0, ucHeight - 3, pnt
                LineTo TempHdc, ucWidth, ucHeight - 3
                DeleteObject hPen
                
                hPen = CreatePen(PS_SOLID, 1, RGB(226, 223, 214))
                SelectObject TempHdc, hPen
                MoveToEx TempHdc, 0, ucHeight - 4, pnt
                LineTo TempHdc, ucWidth, ucHeight - 4
                DeleteObject hPen
                
                hPen = CreatePen(PS_SOLID, 1, RGB(226, 223, 214))
                SelectObject TempHdc, hPen
                MoveToEx TempHdc, ucWidth - 3, 0, pnt
                LineTo TempHdc, ucWidth - 3, ucHeight
                DeleteObject hPen
                
                hPen = CreatePen(PS_SOLID, 1, vbWhite)
                SelectObject TempHdc, hPen
                MoveToEx TempHdc, 1, 0, pnt
                LineTo TempHdc, 1, ucHeight
                DeleteObject hPen
                
                
                
            'Tegn hvit bakgrunn om den er disablet
            ElseIf UserControl.Enabled = False Then
                hBrush = CreateSolidBrush(vbWhite)
                hPen = CreatePen(PS_SOLID, 1, vbWhite)
                SelectObject TempHdc, hBrush
                SelectObject TempHdc, hPen
                Rectangle TempHdc, rc.Left, rc.Top, rc.Right, rc.Bottom
                DeleteObject hPen
                DeleteObject hBrush
            End If
            
            'Tegn regionen
            hRgn = CreateRoundRectRgn(0, 0, ucWidth, ucHeight, avr, avr)
            hBrush = CreateSolidBrush(BorderColor)
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            SetWindowRgn UserControl.hwnd, hRgn, True
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Sett noen punkter i hjørnene for at de skal se litt bedre ut
            Call RundeHjorner(TempHdc)
            
            MousePos = -1
            Skyv = 0
                    
        'MouseOver
        Case Is = 1
            'Tegn gradert bakgrunn
            Farge2.ColorFrom = SelectedColor(0)
            Farge2.ColorTo = SelectedColor(1)
            Call FadeGradient(Farge2, rc.Left, rc.Top, rc.Right, rc.Bottom, TempHdc)
            
            'Skyggestreker
            hPen = CreatePen(PS_SOLID, 1, RGB(214, 208, 197))
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 0, ucHeight - 3, pnt
            LineTo TempHdc, ucWidth, ucHeight - 3
            DeleteObject hPen
            
            hPen = CreatePen(PS_SOLID, 1, RGB(226, 223, 214))
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 0, ucHeight - 4, pnt
            LineTo TempHdc, ucWidth, ucHeight - 4
            DeleteObject hPen
            
            hPen = CreatePen(PS_SOLID, 1, RGB(226, 223, 214))
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, ucWidth - 3, 0, pnt
            LineTo TempHdc, ucWidth - 3, ucHeight
            DeleteObject hPen
            
            hPen = CreatePen(PS_SOLID, 1, vbWhite)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 1, 0, pnt
            LineTo TempHdc, 1, ucHeight
            DeleteObject hPen
                
            'Tegn gradert oransje stripe øverst
            rc.Left = 0
            rc.Top = 1
            rc.Right = ucWidth
            rc.Bottom = 5
            Farge.ColorLT = RGB(255, 240, 207)
            Farge.ColorRT = RGB(251, 200, 99)
            Farge.ColorRB = RGB(248, 179, 48)
            Farge.ColorLB = RGB(251, 200, 99)
            Call FadeTriangel(Farge, rc, True, TempHdc)
            
            'Tegn regionen på nytt
            hRgn = CreateRoundRectRgn(0, 0, ucWidth, ucHeight, avr, avr)
            hBrush = CreateSolidBrush(BorderColor)
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Sett noen punkter i hjørnene for at de skal se litt bedre ut
            Call RundeHjorner(TempHdc)
            
            Skyv = 0
            
        'MouseDown
        Case Is = 2
            'Tegn gradert mørk bakgrunn
            Farge.ColorLT = RGB(176, 176, 167)
            Farge.ColorRT = RGB(215, 213, 200)
            Farge.ColorRB = RGB(241, 239, 223)
            Farge.ColorLB = RGB(215, 213, 200)
            Call FadeTriangel(Farge, rc, True, TempHdc)
            
            'Tegn regionen på nytt
            hRgn = CreateRoundRectRgn(0, 0, ucWidth, ucHeight, avr, avr)
            hBrush = CreateSolidBrush(BorderColor)
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            SetWindowRgn UserControl.hwnd, hRgn, True
            DeleteObject hRgn
            DeleteObject hBrush
            
            'Sett noen punkter i hjørnene for at de skal se litt bedre ut
            Call RundeHjorner(TempHdc)
            
            Skyv = 1
    End Select
    
    If MousePos <> 0 Then
        'Tegn Caption vanlig eller disabled
        SetTextColor TempHdc, m_ForeColor
        If m_Caption <> "" Then
            DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
        End If
        
        'Tegn Ikon vanlig eller disabled
        If m_IconDefault Then
            If UserControl.Enabled = True Then
                pic1.PaintPicture m_IconDefault, IconL + Skyv, IconT + Skyv
            Else
                DrawState TempHdc, 0, 0, m_IconDefault.Handle, 0, IconL + Skyv, IconT + Skyv, 0, 0, DST_ICON Or DSS_DISABLED
            End If
        End If
        'UserControl.Refresh
    End If
End Sub


Private Sub TegnTabKnapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim rc As RECT
    Dim Farge As GRADIENT_COLOR
    Dim Farge2 As TRIANGEL_COLOR
    Dim pnt As POINTAPI
    Dim hRgn As Long
    Dim hBrush As Long
    Dim hPen As Long
    Dim Skyv As Integer
    Dim SelectedColor(1) As Long
    Const avr As Integer = 5
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    rc.Left = 0
    rc.Top = 0
    rc.Right = ucWidth
    rc.Bottom = ucHeight
    
    
    'Farger om enabled
    If UserControl.Enabled = True Then
        DownColor = RGB(252, 252, 254)                          'Bakgrunnsfarge på den som har Value=True
        BorderColor = TranslateColor(m_jjTabBorderColor)        'Rammefarge
        SelectedColor(0) = vbWhite                              'Fra graderingsfargen på toppen om Value=True
        SelectedColor(1) = TranslateColor(m_jjTabSelectedColor) 'Til graderingsfargen på toppen om Value=True
    'Disabled
    Else
        DownColor = vbWhite
        BorderColor = RGB(182, 180, 167)
        SelectedColor(0) = RGB(240, 240, 240)
        SelectedColor(1) = RGB(170, 170, 170)
    End If
    
    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            'Tegn gradert bakgrunn
            If UserControl.Enabled = True Then
                Farge.ColorFrom = RGB(255, 255, 255)
                Farge.ColorTo = RGB(236, 235, 230)
                Call FadeGradient(Farge, rc.Left, rc.Top, rc.Right, rc.Bottom, TempHdc)
            'Tegn hvit bakgrunn om den er disablet
            ElseIf UserControl.Enabled = False Then
                hBrush = CreateSolidBrush(vbWhite)
                hPen = CreatePen(PS_SOLID, 1, vbWhite)
                SelectObject TempHdc, hBrush
                SelectObject TempHdc, hPen
                Rectangle TempHdc, rc.Left, rc.Top, rc.Right, rc.Bottom
                DeleteObject hPen
                DeleteObject hBrush
            End If
            
            'Lag path av strekene som her tegnes
            BeginPath TempHdc
                'Tegn 5 streker
                MoveToEx TempHdc, 0, ucHeight, pnt
                LineTo TempHdc, 0, 2
                LineTo TempHdc, 2, 0
                LineTo TempHdc, ucWidth - 2, 0
                LineTo TempHdc, ucWidth, 2
                LineTo TempHdc, ucWidth, ucHeight
            'Avslutt path
            EndPath TempHdc
            
            'Konverter path til region
            hRgn = PathToRegion(TempHdc)
            hBrush = CreateSolidBrush(BorderColor)
            'Tegn ramme langs regionen
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            'Sett regionen til UserControl
            SetWindowRgn UserControl.hwnd, hRgn, True
            'Tegn bunnstrek
            If m_Value = False Then
                hPen = CreatePen(PS_SOLID, 1, BorderColor)
            Else
                hPen = CreatePen(PS_SOLID, 1, DownColor)
            End If
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 1, ucHeight - 1, pnt
            LineTo TempHdc, ucWidth - 1, ucHeight - 1
            'Slett hendler
            DeleteObject hRgn
            DeleteObject hBrush
            DeleteObject hPen
                        
            MousePos = -1
            'Skyv = 0
                    
        'MouseOver
        Case Is = 1
            'Tegn gradert bakgrunn om Value=False
            If m_Value = False Then
                Farge.ColorFrom = RGB(255, 255, 255)
                Farge.ColorTo = RGB(236, 235, 230)
                Call FadeGradient(Farge, rc.Left, rc.Top, rc.Right, rc.Bottom, TempHdc)
            Else
                'Tegn lys bakgrunn
                hBrush = CreateSolidBrush(DownColor)
                hPen = CreatePen(PS_SOLID, 1, BorderColor)
                SelectObject TempHdc, hBrush
                SelectObject TempHdc, hPen
                Rectangle TempHdc, 0, 0, ucWidth, ucHeight
                DeleteObject hPen
                DeleteObject hBrush
            End If
            
            'Tegn gradert oransje stripe øverst om Value=False
            If m_Value = False Then
                rc.Left = 0
                rc.Top = 0
                rc.Right = ucWidth
                rc.Bottom = 5
                Farge2.ColorLT = RGB(255, 240, 207)
                Farge2.ColorRT = RGB(251, 200, 99)
                Farge2.ColorRB = RGB(248, 179, 48)
                Farge2.ColorLB = RGB(251, 200, 99)
                Call FadeTriangel(Farge2, rc, True, TempHdc)
            Else
                'Tegn gradert blå stripe øverst
                Farge.ColorFrom = SelectedColor(0)
                Farge.ColorTo = SelectedColor(1)
                Call FadeGradient(Farge, 0, 1, ucWidth, 5, TempHdc)
            End If
            
            'Lag path av strekene som her tegnes
            BeginPath TempHdc
                'Tegn 5 streker
                MoveToEx TempHdc, 0, ucHeight, pnt
                LineTo TempHdc, 0, 2
                LineTo TempHdc, 2, 0
                LineTo TempHdc, ucWidth - 2, 0
                LineTo TempHdc, ucWidth, 2
                LineTo TempHdc, ucWidth, ucHeight
            'Avslutt path
            EndPath TempHdc
            
            'Konverter path til region
            hRgn = PathToRegion(TempHdc)
            hBrush = CreateSolidBrush(BorderColor)
            'Tegn ramme langs regionen
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            'Sett regionen til UserControl
            'SetWindowRgn UserControl.hwnd, hRgn, True
            'Tegn bunnstrek
            If m_Value = False Then
                hPen = CreatePen(PS_SOLID, 1, BorderColor)
            Else
                hPen = CreatePen(PS_SOLID, 1, DownColor)
            End If
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 1, ucHeight - 1, pnt
            LineTo TempHdc, ucWidth - 1, ucHeight - 1
            'Slett hendler
            DeleteObject hRgn
            DeleteObject hBrush
            DeleteObject hPen
'
            'Skyv = 1
            
        'MouseDown
        Case Is = 2
            'Tegn lys bakgrunn
            hBrush = CreateSolidBrush(DownColor)
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush
                
            'Tegn gradert blå stripe øverst
            Farge.ColorFrom = SelectedColor(0)
            Farge.ColorTo = SelectedColor(1)
            Call FadeGradient(Farge, 0, 1, ucWidth, 5, TempHdc)
    
            'Lag path av strekene som her tegnes
            BeginPath TempHdc
                'Tegn 5 streker
                MoveToEx TempHdc, 0, ucHeight, pnt
                LineTo TempHdc, 0, 2
                LineTo TempHdc, 2, 0
                LineTo TempHdc, ucWidth - 2, 0
                LineTo TempHdc, ucWidth, 2
                LineTo TempHdc, ucWidth, ucHeight
            'Avslutt path
            EndPath TempHdc
            
            'Konverter path til region
            hRgn = PathToRegion(TempHdc)
            hBrush = CreateSolidBrush(BorderColor)
            'Tegn ramme langs regionen
            FrameRgn TempHdc, hRgn, hBrush, 1, 1
            'Sett regionen til UserControl
            SetWindowRgn UserControl.hwnd, hRgn, True
            'Tegn bunnstrek
            hPen = CreatePen(PS_SOLID, 1, DownColor)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, 1, ucHeight - 1, pnt
            LineTo TempHdc, ucWidth - 1, ucHeight - 1
            'Slett hendler
            DeleteObject hRgn
            DeleteObject hBrush
            DeleteObject hPen
            
            UserControl.Refresh
            'Skyv = -1
    End Select
    
    If MousePos <> 0 Then
        'Tegn Caption vanlig eller disabled
        SetTextColor TempHdc, m_ForeColor
        If m_Caption <> "" Then
            DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
        End If
        
        'Tegn Ikon vanlig eller disabled
        If m_IconDefault Then
            If UserControl.Enabled = True Then
                pic1.PaintPicture m_IconDefault, IconL + Skyv, IconT + Skyv
            Else
                DrawState TempHdc, 0, 0, m_IconDefault.Handle, 0, IconL + Skyv, IconT + Skyv, 0, 0, DST_ICON Or DSS_DISABLED
            End If
        End If
    End If
End Sub



'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=7,0,0,0
Public Property Get IconAlign() As jjIconAlign
Attribute IconAlign.VB_Description = "Plassering av ikon i forhold til knappetekst."
    IconAlign = m_IconAlign
End Property

Public Property Let IconAlign(ByVal New_IconAlign As jjIconAlign)
    m_IconAlign = New_IconAlign
    PropertyChanged "IconAlign"
    
    Call HighLight(-1, -1, -1, False)
    DoEvents
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=7,0,0,1
Public Property Get IconSpace() As Integer
Attribute IconSpace.VB_Description = "Avstand i piksler mellom ikon og knappetekst."
    IconSpace = m_IconSpace
End Property

Public Property Let IconSpace(ByVal New_IconSpace As Integer)
    m_IconSpace = New_IconSpace
    PropertyChanged "IconSpace"
    
    Call HighLight(-1, -1, -1, False)
    DoEvents
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=13,0,0,
Public Property Get jjToolTip() As String
    jjToolTip = m_jjToolTip
End Property

Public Property Let jjToolTip(ByVal New_Tooltip As String)
    m_jjToolTip = New_Tooltip
    PropertyChanged "jjToolTip"
    ttInZone = False '
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=13,0,0,
Public Property Get jjToolTipHeader() As String
Attribute jjToolTipHeader.VB_Description = "Overskrift i tooltip."
    jjToolTipHeader = m_jjToolTipHeader
End Property

Public Property Let jjToolTipHeader(ByVal New_jjToolTipHeader As String)
    m_jjToolTipHeader = New_jjToolTipHeader
    PropertyChanged "jjToolTipHeader"
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=7,0,0,0
Public Property Get jjToolTipIcon() As ttIconType
Attribute jjToolTipIcon.VB_Description = "Ikon i tooltip, vises om overskrift er lagt inn i jjToolTipHeader."
    jjToolTipIcon = m_jjToolTipIcon
End Property

Public Property Let jjToolTipIcon(ByVal New_jjToolTipIcon As ttIconType)
    m_jjToolTipIcon = New_jjToolTipIcon
    PropertyChanged "jjToolTipIcon"
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=7,0,0,0
Public Property Get jjToolTipStyle() As ttStyleEnum
Attribute jjToolTipStyle.VB_Description = "Kvadratisk eller snakkeboble."
    jjToolTipStyle = m_jjToolTipStyle
End Property

Public Property Let jjToolTipStyle(ByVal New_jjToolTipStyle As ttStyleEnum)
    m_jjToolTipStyle = New_jjToolTipStyle
    PropertyChanged "jjToolTipStyle"
End Property

Private Sub AlphaBlending(uHdc As Long, Verdi As Long)
'    Dim BF As BLENDFUNCTION
'    Dim lBF As Long
'
'    'Sett parameter
'    With BF
'        .BlendOp = AC_SRC_OVER
'        .BlendFlags = 0
'        .SourceConstantAlpha = Verdi
'        .AlphaFormat = 0
'    End With
'
'    'Kopiere BLENDFUNCTION-strukturen til en Long
'    RtlMoveMemory lBF, BF, 4
'
'    'Kopier bildet fra kontrollen til pic1 for Alphablending
'    pic1.Picture = LoadPicture()
'    pic1.Picture = UserControl.Picture
'
'    'AlphaBlend fra pic1 til kontrollen
'    AlphaBlend uHdc, 0, 0, ucWidth, ucHeight, pic1.hdc, 0, 0, ucWidth, ucHeight, lBF
End Sub

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=0,0,0,0
Public Property Get Value() As Boolean
Attribute Value.VB_Description = "Verdi på avkryssningsknapp om dette er valgt under Mode"
    Value = m_Value
End Property

Public Property Let Value(ByVal New_Value As Boolean)
    If New_Value = m_Value Then Exit Property
    
    m_Value = New_Value
    PropertyChanged "Value"
    
    If m_Value = True Then
        m_Value = False
        m_Mode = Me.Mode
        mButton = vbLeftButton
        UserControl_Click
        Exit Property
    End If
    
    
    If m_Mode = jj_Option Then
        If m_Value = True Then RaiseEvent Click
    Else
        RaiseEvent Click
    End If
    
    Cls
    Call HighLight(-1, -1, -1, False)
    Call SetAcccessKey
    DoEvents
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=7,0,0,0
Public Property Get Mode() As jjMode
Attribute Mode.VB_Description = "Vanlig knapp eller avkryssningsknapp"
    Mode = m_Mode
End Property

Public Property Let Mode(ByVal New_Mode As jjMode)
    m_Mode = New_Mode
    PropertyChanged "Mode"
    

    Cls
    Call HighLight(-1, -1, -1, False)
    Call SetAcccessKey
    DoEvents
End Property

Private Sub TegnFargetKnapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim hBrush As Long
    Dim hPen As Long
    Dim Skyv As Integer
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    'Gjør DownColor lysere om det er en jj_Check eller jj_Option med Value=True
    If (m_Mode = jj_Check Or m_Mode = jj_Option) And m_Value = True Then
        If jjButtonStyle = jj_Blå Then DownColor = ShadeColor(DownColor, 80, False)
        If jjButtonStyle = jj_Rød Then DownColor = ShadeColor(DownColor, 90, False)
        If jjButtonStyle = jj_Grønn Then DownColor = ShadeColor(DownColor, 130, False)
        If jjButtonStyle = jj_Gul Then DownColor = ShadeColor(DownColor, 140, False)
        
        'Tegne med lys grå om kontrollen er disabled
        If UserControl.Enabled = False Then
            DownColor = RGB(250, 250, 250)
            BorderColor = RGB(150, 150, 150)
        End If
    End If
    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            'Ramme og bakgrunn tegnes i valgt bakgrunnsfarge
            hBrush = CreateSolidBrush(DefaultColor)
            hPen = CreatePen(PS_SOLID, 1, DefaultColor)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush
            
            'Kopier inn bakgrunnen fra formen om dette er valgt
            If m_CopyBGSource = jj_Form Then
                BitBlt TempHdc, 0, 0, ucWidth, ucHeight, UserControl.Parent.hdc, _
                    UserControl.ScaleX(UserControl.Extender.Left, UserControl.Parent.ScaleMode, vbPixels), _
                    UserControl.ScaleY(UserControl.Extender.Top, UserControl.Parent.ScaleMode, vbPixels), vbSrcCopy
            
            'Kopier inn bakgrunnen fra en picturebox om dette er valgt
            ElseIf m_CopyBGSource = jj_PictureBox Then
                If Ambient.UserMode = True Then
                BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
                    m_CopyBGBoxName.ScaleX(UserControl.Extender.Left, m_CopyBGBoxName.ScaleMode, vbPixels), _
                    m_CopyBGBoxName.ScaleY(UserControl.Extender.Top, m_CopyBGBoxName.ScaleMode, vbPixels), vbSrcCopy
                End If
            
            'Kopier inn bakgrunnen fra en jjbox om dette er valgt
            ElseIf m_CopyBGSource = jj_Box Then
                If Ambient.UserMode = True Then
                    BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
                        UserControl.Extender.Left / 15, _
                        UserControl.Extender.Top / 15, vbSrcCopy
                End If
            End If
            
            MousePos = -1
            Skyv = 0
                    
        'MouseOver
        Case Is = 1
            hBrush = CreateSolidBrush(OverColor)
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush
            
            Skyv = 0
            
        'MouseDown
        Case Is = 2
            hBrush = CreateSolidBrush(DownColor)
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush
            
            'UserControl.Refresh
            Skyv = 1
    End Select
    
    'Call TekstOgIkon(MousePos, uHdc, Skyv)
    If MousePos <> 0 Then
        'Tegn Caption vanlig eller disabled
        SetTextColor TempHdc, m_ForeColor
        If m_Caption <> "" Then
            DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
        End If

        'Tegn Ikon vanlig eller disabled
        If m_IconDefault Then
            If UserControl.Enabled = True Then
                pic1.PaintPicture m_IconDefault, IconL + Skyv, IconT + Skyv
            Else
                DrawState TempHdc, 0, 0, m_IconDefault.Handle, 0, IconL + Skyv, IconT + Skyv, 0, 0, DST_ICON Or DSS_DISABLED
            End If
        End If
        'UserControl.Refresh
    End If
End Sub

Private Sub TegnXP2003Knapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim hBrush As Long
    Dim hPen As Long
    Dim Skyv As Integer
    Dim TempHdc As Long
    Dim SelectedColor(1) As Long
    Dim MouseOverColor(1) As Long
    Dim MouseLeaveColor(1) As Long
    Dim BakgrunnsFarge As Long
    Dim Farge2 As GRADIENT_COLOR
    Dim rc As RECT
    
    'Valg bakgrunnsfarge brukes om vi ikke kopierer inn noen bakgrunn
    BakgrunnsFarge = TranslateColor(m_BackColor)
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    'Fadingsområde
    rc.Left = 1
    rc.Top = 1
    rc.Right = ucWidth - 1
    rc.Bottom = ucHeight - 1
    
    'Tegne med blålig eller lys grå om kontrollen er enabled/disabled
    'Farger om enabled/disabled
    If UserControl.Enabled = True Then
        BorderColor = RGB(0, 0, 128)
        SelectedColor(0) = RGB(255, 175, 88)   'Graderingsfargen om Value=True
        SelectedColor(1) = RGB(255, 211, 138)    'Graderingsfargen om Value=True
        MouseOverColor(0) = RGB(255, 241, 198)  'Graderingsfargen ved MouseOver
        MouseOverColor(1) = RGB(255, 213, 154)  'Graderingsfargen ved MouseOver
        MouseLeaveColor(0) = RGB(255, 211, 138)
        MouseLeaveColor(1) = RGB(255, 175, 88)
    Else
        BorderColor = RGB(182, 182, 182)
        MouseLeaveColor(0) = vbWhite
        MouseLeaveColor(1) = vbWhite
    End If
    

            
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            'Ramme og bakgrunn tegnes i valgt bakgrunnsfarge
            hBrush = CreateSolidBrush(BakgrunnsFarge)
            hPen = CreatePen(PS_SOLID, 1, BakgrunnsFarge)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush

            
            'Kopier inn bakgrunnen fra formen om dette er valgt
            If m_CopyBGSource = jj_Form Then
                BitBlt TempHdc, 0, 0, ucWidth, ucHeight, UserControl.Parent.hdc, _
                    UserControl.ScaleX(UserControl.Extender.Left, UserControl.Parent.ScaleMode, vbPixels), _
                    UserControl.ScaleY(UserControl.Extender.Top, UserControl.Parent.ScaleMode, vbPixels), vbSrcCopy

            'Kopier inn bakgrunnen fra en picturebox om dette er valgt
            ElseIf m_CopyBGSource = jj_PictureBox Then
                If Ambient.UserMode = True Then
                    BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
                        m_CopyBGBoxName.ScaleX(UserControl.Extender.Left, m_CopyBGBoxName.ScaleMode, vbPixels), _
                        m_CopyBGBoxName.ScaleY(UserControl.Extender.Top, m_CopyBGBoxName.ScaleMode, vbPixels), vbSrcCopy
                End If
            
            'Kopier inn bakgrunnen fra en jjbox om dette er valgt
            ElseIf m_CopyBGSource = jj_Box Then
                If Ambient.UserMode = True Then
                    BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
                        UserControl.Extender.Left / 15, _
                        UserControl.Extender.Top / 15, vbSrcCopy
                End If
            End If
            
            MousePos = -1
            Skyv = 0
                    
        'MouseOver
        Case Is = 1
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            
            Farge2.ColorFrom = MouseOverColor(0)
            Farge2.ColorTo = MouseOverColor(1)
            Call FadeGradient(Farge2, rc.Left, rc.Top, rc.Right, rc.Bottom, TempHdc)
            
            MousePos = -1
            Skyv = 0
            
        'MouseDown
        Case Is = 2
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            
            If m_Value = False Then
                Farge2.ColorFrom = SelectedColor(0)
                Farge2.ColorTo = SelectedColor(1)
            Else
                Farge2.ColorFrom = MouseLeaveColor(0)
                Farge2.ColorTo = MouseLeaveColor(1)
            End If
            Call FadeGradient(Farge2, rc.Left, rc.Top, rc.Right, rc.Bottom, TempHdc)
            
            Skyv = 1
    End Select
    
    'Call TekstOgIkon(MousePos, uHdc, Skyv)
    If MousePos <> 0 Then
        'Tegn Caption vanlig eller disabled
        SetTextColor TempHdc, m_ForeColor
        If m_Caption <> "" Then
            DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
        End If

        'Tegn Ikon vanlig eller disabled
        If m_IconDefault Then
            If UserControl.Enabled = True Then
                pic1.PaintPicture m_IconDefault, IconL + Skyv, IconT + Skyv
            Else
                DrawState TempHdc, 0, 0, m_IconDefault.Handle, 0, IconL + Skyv, IconT + Skyv, 0, 0, DST_ICON Or DSS_DISABLED
            End If
        End If
    End If
End Sub


Private Sub TegnTekstKnapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim hBrush As Long
    Dim hPen As Long
    Dim Skyv As Integer
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    lOldFont.Name = UserControl.FontName
    lOldFont.Bold = UserControl.FontBold
    lOldFont.Italic = UserControl.FontItalic
    lOldFont.Size = UserControl.FontSize
    lOldFont.Strikethru = UserControl.FontStrikethru
    lOldFont.Underline = UserControl.FontUnderline
    
    DefaultColor = TranslateColor(m_ForeColor)
    OverColor = ShadeColor(DefaultColor, 130, False)
    
    'Ramme og bakgrunn tegnes i valgt bakgrunnsfarge
    hBrush = CreateSolidBrush(TranslateColor(m_BackColor))
    hPen = CreatePen(PS_SOLID, 1, TranslateColor(m_BackColor))
    SelectObject TempHdc, hBrush
    SelectObject TempHdc, hPen
    Rectangle TempHdc, 0, 0, ucWidth, ucHeight
    DeleteObject hPen
    DeleteObject hBrush
        
    'Kopier inn bakgrunnen om dette er valgt
    If m_CopyBGSource = jj_Form Then
        BitBlt TempHdc, 0, 0, ucWidth, ucHeight, UserControl.Parent.hdc, _
            UserControl.ScaleX(UserControl.Extender.Left, UserControl.Parent.ScaleMode, vbPixels), _
            UserControl.ScaleY(UserControl.Extender.Top, UserControl.Parent.ScaleMode, vbPixels), vbSrcCopy

    'Kopier inn bakgrunnen fra en picturebox om dette er valgt
    ElseIf m_CopyBGSource = jj_PictureBox Then
        If Ambient.UserMode = True Then
        BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
            m_CopyBGBoxName.ScaleX(UserControl.Extender.Left, m_CopyBGBoxName.ScaleMode, vbPixels), _
            m_CopyBGBoxName.ScaleY(UserControl.Extender.Top, m_CopyBGBoxName.ScaleMode, vbPixels), vbSrcCopy
        End If
    
    'Kopier inn bakgrunnen fra en jjbox om dette er valgt
    ElseIf m_CopyBGSource = jj_Box Then
        If Ambient.UserMode = True Then
            BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
                UserControl.Extender.Left / 15, _
                UserControl.Extender.Top / 15, vbSrcCopy
        End If
    End If
    
    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            MousePos = 1
            Skyv = 0
                    
        'MouseOver
        Case Is = 1
            UserControl.FontUnderline = True
            SetTextColor TempHdc, OverColor
            If m_Caption <> "" Then
                DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL, CaptionT, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
            End If

            MousePos = 0
            Skyv = 0
            
        'MouseDown
        Case Is = 2
            UserControl.FontUnderline = True
            SetTextColor TempHdc, DefaultColor
            If m_Caption <> "" Then
                DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
            End If
            
            UserControl.Refresh
            MousePos = 0
            Skyv = 0
    End Select
    
    
    'Sett tilbake til valgt font
    With UserControl
        .FontName = lOldFont.Name
        .FontSize = lOldFont.Size
        .FontBold = lOldFont.Bold
        .FontItalic = lOldFont.Italic
        .FontStrikethru = lOldFont.Strikethru
        .FontUnderline = lOldFont.Underline
    End With
        
        
    If MousePos <> 0 Then
        'Tegn Caption vanlig eller disabled
        SetTextColor TempHdc, m_ForeColor
        If m_Caption <> "" Then
            DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
        End If

        UserControl.Refresh
    End If
End Sub


Private Sub TegnCheckboxKnapp(uHdc As Long, MousePos As Integer)
    'Checkbox som er lik XP-standertype
    On Error Resume Next
    
    Dim CheckMark As String
    Dim pnt As POINTAPI
    Dim rc As RECT
    Dim Farge As TRIANGEL_COLOR
    Dim hPen As Long
    Dim hBrush As Long
    Dim CheckedColor As Long
    Const Size As Integer = 12
    Dim a As Integer
    Dim CheckY As Integer
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    'Plasseringspos for det grønne sjekkmerke, ypos varierer fra Win2000 og WinXP
    CheckY = 0
    If OS(2) = "1" Then CheckY = -2
    
    
    'Juster plassering i forhold til høyre/venstre justering
    If m_IconAlign = jj_Left Then
        a = 0
    Else
        a = ucWidth - 13
    End If
    rc.Left = 1 + a
    rc.Top = 1
    rc.Right = 12 + a
    rc.Bottom = 12
        
    'Gamle font verdier
    lOldFont.Name = UserControl.FontName
    lOldFont.Bold = UserControl.FontBold
    lOldFont.Italic = UserControl.FontItalic
    lOldFont.Size = UserControl.FontSize
    lOldFont.Strikethru = UserControl.FontStrikethru
    lOldFont.Underline = UserControl.FontUnderline
    'Checkmerke i Marlett-fonten
    CheckMark = Chr(97)

    
    'Tegne med blålig eller lys grå om kontrollen er enabled/disabled
    If UserControl.Enabled = True Then
        BorderColor = RGB(28, 81, 128)      'Blålig farge
        CheckedColor = RGB(33, 161, 33)     'Grønnlig
    Else
        BorderColor = RGB(182, 180, 167)    'Grålig 'RGB(202, 200, 187)
    End If
    
    'Sett valgt bakgrunnsfarge om dette er valgt
    hBrush = CreateSolidBrush(TranslateColor(m_BackColor))
    hPen = CreatePen(PS_SOLID, 1, TranslateColor(m_BackColor))
    SelectObject TempHdc, hBrush
    SelectObject TempHdc, hPen
    Rectangle TempHdc, 0, 0, ucWidth, ucHeight
    DeleteObject hPen
    DeleteObject hBrush
        
    'Kopier inn bakgrunnen fra formen om dette er valgt
    If m_CopyBGSource = jj_Form Then
        BitBlt TempHdc, 0, 0, ucWidth, ucHeight, UserControl.Parent.hdc, _
            UserControl.ScaleX(UserControl.Extender.Left, UserControl.Parent.ScaleMode, vbPixels), _
            UserControl.ScaleY(UserControl.Extender.Top, UserControl.Parent.ScaleMode, vbPixels), vbSrcCopy
    
    'Kopier inn bakgrunnen fra en picturebox om dette er valgt
    ElseIf m_CopyBGSource = jj_PictureBox Then
        BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
            m_CopyBGBoxName.ScaleX(UserControl.Extender.Left, m_CopyBGBoxName.ScaleMode, vbPixels), _
            m_CopyBGBoxName.ScaleY(UserControl.Extender.Top, m_CopyBGBoxName.ScaleMode, vbPixels), vbSrcCopy
        
    'Kopier inn bakgrunnen fra en jjbox om dette er valgt
    ElseIf m_CopyBGSource = jj_Box Then
        If Ambient.UserMode = True Then
            BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
                UserControl.Extender.Left / 15, _
                UserControl.Extender.Top / 15, vbSrcCopy
        End If
    End If
    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            'Tegn gradert grå stor firkant
            If UserControl.Enabled = True Then
                Farge.ColorLT = RGB(215, 215, 210)
                Farge.ColorRT = RGB(241, 241, 239)
                Farge.ColorRB = RGB(255, 255, 255)
                Farge.ColorLB = RGB(241, 241, 239)
                Call FadeTriangel(Farge, rc, True, TempHdc)
            'Tegn hvit stor firkant om den er disablet
            ElseIf UserControl.Enabled = False Then
                hBrush = CreateSolidBrush(vbWhite)
                hPen = CreatePen(PS_SOLID, 1, vbWhite)
                SelectObject TempHdc, hBrush
                SelectObject TempHdc, hPen
                Rectangle TempHdc, rc.Left, rc.Top, rc.Right, rc.Bottom
                DeleteObject hPen
                DeleteObject hBrush
            End If
            
            
            'Tegn en mindre firkant om den er checked
            If m_Value = True Then
'                'Om den er enabled(grønnlig)
'                If UserControl.Enabled = True Then
'                    hBrush = CreateSolidBrush(CheckedColor)
'                    hPen = CreatePen(PS_SOLID, 1, CheckedColor)
'                'Om den er disabled(grålig)
'                ElseIf UserControl.Enabled = False Then
'                    hBrush = CreateSolidBrush(BorderColor)
'                    hPen = CreatePen(PS_SOLID, 1, BorderColor)
'                End If
'                SelectObject TempHdc, hBrush
'                SelectObject TempHdc, hPen
'                If m_IconAlign = jj_Left Then
'                    Rectangle TempHdc, 3, 3, 10, 10
'                Else
'                    rc.Left = ucWidth - 10
'                    rc.Top = 3
'                    rc.Right = ucWidth - 3
'                    rc.Bottom = 10
'                    Rectangle TempHdc, rc.Left, rc.Top, rc.Right, rc.Bottom
'                End If
'                DeleteObject hPen
'                DeleteObject hBrush

                'Om den er enabled(grønnlig)
                If UserControl.Enabled = True Then
                    SetTextColor TempHdc, CheckedColor
                'Om den er disabled(grålig)
                ElseIf UserControl.Enabled = False Then
                    SetTextColor TempHdc, BorderColor
                End If
                With UserControl
                    .FontName = "Marlett"
                    .FontSize = 12
                    .FontItalic = False
                    .FontBold = False
                    .FontStrikethru = False
                    .FontUnderline = False
                End With
                SetTextColor TempHdc, CheckedColor
                If m_IconAlign = jj_Left Then
                    DrawStateText TempHdc, 0, 0, CheckMark, Len(CheckMark), -1, CheckY, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
                Else
                    DrawStateText TempHdc, 0, 0, CheckMark, Len(CheckMark), ucWidth - 14, CheckY, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
                End If
            End If
            
            'Tegn rammen
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            If m_IconAlign = jj_Left Then
                LineTo TempHdc, Size, 0
                LineTo TempHdc, Size, Size
                LineTo TempHdc, 0, Size
                LineTo TempHdc, 0, 0
            Else
                MoveToEx TempHdc, ucWidth - 1, 0, pnt
                LineTo TempHdc, ucWidth - 1, Size
                LineTo TempHdc, ucWidth - (Size + 1), Size
                LineTo TempHdc, ucWidth - (Size + 1), 0
                LineTo TempHdc, ucWidth, 0
            End If
            DeleteObject hPen
            
            MousePos = -1
            
                    
        'MouseOver
        Case Is = 1
            'Tegn gradert oransje stor firkant
            Farge.ColorLT = RGB(255, 240, 207)
            Farge.ColorRT = RGB(251, 200, 99)
            Farge.ColorRB = RGB(248, 179, 48)
            Farge.ColorLB = RGB(251, 200, 99)
            Call FadeTriangel(Farge, rc, True, TempHdc)
            
            'Tegn gradert grå mindre firkant om den er unchecked
            'If m_Value = False Then
                If m_IconAlign = jj_Left Then
                    rc.Left = 3
                    rc.Top = 3
                    rc.Right = 10
                    rc.Bottom = 10
                Else
                    rc.Left = ucWidth - 10
                    rc.Top = 3
                    rc.Right = ucWidth - 3
                    rc.Bottom = 10
                End If
                Farge.ColorLT = RGB(224, 224, 219)
                Farge.ColorRT = RGB(241, 241, 239)
                Farge.ColorRB = RGB(253, 253, 252)
                Farge.ColorLB = RGB(241, 241, 239)
                Call FadeTriangel(Farge, rc, True, TempHdc)
            
            'Tegn grønn mindre firkant om den er checked
            If m_Value = True Then
'                hBrush = CreateSolidBrush(CheckedColor)
'                hPen = CreatePen(PS_SOLID, 1, CheckedColor)
'                SelectObject TempHdc, hBrush
'                SelectObject TempHdc, hPen
'                If m_IconAlign = jj_Left Then
'                    Rectangle TempHdc, 3, 3, 10, 10
'                Else
'                    rc.Left = ucWidth - 10
'                    rc.Top = 3
'                    rc.Right = ucWidth - 3
'                    rc.Bottom = 10
'                    Rectangle TempHdc, rc.Left, rc.Top, rc.Right, rc.Bottom
'                End If
'                DeleteObject hPen
'                DeleteObject hBrush
                
                With UserControl
                    .FontName = "Marlett"
                    .FontSize = 12
                    .FontItalic = False
                    .FontBold = False
                    .FontStrikethru = False
                    .FontUnderline = False
                End With
                SetTextColor TempHdc, CheckedColor
                If m_IconAlign = jj_Left Then
                    DrawStateText TempHdc, 0, 0, CheckMark, Len(CheckMark), -1, CheckY, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
                Else
                    DrawStateText TempHdc, 0, 0, CheckMark, Len(CheckMark), ucWidth - 14, CheckY, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
                End If
            End If
            
            'Tegn rammen
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            If m_IconAlign = jj_Left Then
                LineTo TempHdc, Size, 0
                LineTo TempHdc, Size, Size
                LineTo TempHdc, 0, Size
                LineTo TempHdc, 0, 0
            Else
                MoveToEx TempHdc, ucWidth - 1, 0, pnt
                LineTo TempHdc, ucWidth - 1, Size
                LineTo TempHdc, ucWidth - (Size + 1), Size
                LineTo TempHdc, ucWidth - (Size + 1), 0
                LineTo TempHdc, ucWidth, 0
            End If
            DeleteObject hPen
            
            MousePos = -1
            
        'MouseDown
        Case Is = 2
            'Tegn gradert mørk grå stor firkant
            Farge.ColorLT = RGB(176, 176, 167)
            Farge.ColorRT = RGB(215, 213, 200)
            Farge.ColorRB = RGB(241, 239, 223)
            Farge.ColorLB = RGB(215, 213, 200)
            Call FadeTriangel(Farge, rc, True, TempHdc)
            
            'Tegn grønn mindre firkant om den er checked
            If m_Value = True Then
'                hBrush = CreateSolidBrush(CheckedColor)
'                hPen = CreatePen(PS_SOLID, 1, CheckedColor)
'                SelectObject TempHdc, hBrush
'                SelectObject TempHdc, hPen
'                If m_IconAlign = jj_Left Then
'                    Rectangle TempHdc, 3, 3, 10, 10
'                Else
'                    rc.Left = ucWidth - 10
'                    rc.Top = 3
'                    rc.Right = ucWidth - 3
'                    rc.Bottom = 10
'                    Rectangle TempHdc, rc.Left, rc.Top, rc.Right, rc.Bottom
'                End If
'                DeleteObject hPen
'                DeleteObject hBrush

                With UserControl
                    .FontName = "Marlett"
                    .FontSize = 12
                    .FontItalic = False
                    .FontBold = False
                    .FontStrikethru = False
                    .FontUnderline = False
                End With
                SetTextColor TempHdc, CheckedColor
                If m_IconAlign = jj_Left Then
                    DrawStateText TempHdc, 0, 0, CheckMark, Len(CheckMark), -1, CheckY, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
                Else
                    DrawStateText TempHdc, 0, 0, CheckMark, Len(CheckMark), ucWidth - 14, CheckY, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
                End If
            End If
            
            'Tegn rammen
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            If m_IconAlign = jj_Left Then
                LineTo TempHdc, Size, 0
                LineTo TempHdc, Size, Size
                LineTo TempHdc, 0, Size
                LineTo TempHdc, 0, 0
            Else
                MoveToEx TempHdc, ucWidth - 1, 0, pnt
                LineTo TempHdc, ucWidth - 1, Size
                LineTo TempHdc, ucWidth - (Size + 1), Size
                LineTo TempHdc, ucWidth - (Size + 1), 0
                LineTo TempHdc, ucWidth, 0
            End If
            DeleteObject hPen

            UserControl.Refresh
    End Select
    
    'Skriv teksten
    If MousePos <> 0 Then
        'Sett tilbake til gamle font verdier
        With UserControl
            .FontName = lOldFont.Name
            .FontSize = lOldFont.Size
            .FontBold = lOldFont.Bold
            .FontItalic = lOldFont.Italic
            .FontStrikethru = lOldFont.Strikethru
            .FontUnderline = lOldFont.Underline
        End With
        
        SetTextColor TempHdc, m_ForeColor
        
        If m_Caption <> "" Then
            'Skriv på venstre side
            If m_IconAlign = jj_Left Then
                DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), 15 + m_IconSpace, 0, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
                
            'Skriv på venstre side
            Else
                DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), m_IconSpace, 0, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
            End If
        End If
        
        UserControl.Refresh
    End If
End Sub


Private Sub TegnOptionboxKnapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim CheckMark As String
    Dim pnt As POINTAPI
    Dim rc As RECT
    Dim Farge As TRIANGEL_COLOR
    Dim hPen As Long
    Dim hBrush As Long
    Dim CheckedColor As Long
    Const Size As Integer = 12
    Dim a As Integer
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    'Juster plassering i forhold til høyre/venstre justering
    If m_IconAlign = jj_Left Then
        a = 0
    Else
        a = ucWidth - 13
    End If
    rc.Left = 1 + a
    rc.Top = 1
    rc.Right = 12 + a
    rc.Bottom = 12
        

    'Tegne med blålig eller lys grå om kontrollen er enabled/disabled
    If UserControl.Enabled = True Then
        BorderColor = RGB(28, 81, 128)      'Blålig farge
        CheckedColor = RGB(33, 161, 33)     'Grønnlig
    Else
        BorderColor = RGB(182, 180, 167)    'Grålig 'RGB(202, 200, 187)
    End If
    
    'Sett valgt bakgrunnsfarge om dette er valgt
    hBrush = CreateSolidBrush(TranslateColor(m_BackColor))
    hPen = CreatePen(PS_SOLID, 1, TranslateColor(m_BackColor))
    SelectObject TempHdc, hBrush
    SelectObject TempHdc, hPen
    Rectangle TempHdc, 0, 0, ucWidth, ucHeight
    DeleteObject hPen
    DeleteObject hBrush
    
    'Kopier inn bakgrunnen fra formen om dette er valgt
    If m_CopyBGSource = jj_Form Then
        BitBlt TempHdc, 0, 0, ucWidth, ucHeight, UserControl.Parent.hdc, _
            UserControl.ScaleX(UserControl.Extender.Left, UserControl.Parent.ScaleMode, vbPixels), _
            UserControl.ScaleY(UserControl.Extender.Top, UserControl.Parent.ScaleMode, vbPixels), vbSrcCopy
    
    'Kopier inn bakgrunnen fra en picturebox om dette er valgt
    ElseIf m_CopyBGSource = jj_PictureBox Then
        BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
            m_CopyBGBoxName.ScaleX(UserControl.Extender.Left, m_CopyBGBoxName.ScaleMode, vbPixels), _
            m_CopyBGBoxName.ScaleY(UserControl.Extender.Top, m_CopyBGBoxName.ScaleMode, vbPixels), vbSrcCopy
    
    'Kopier inn bakgrunnen fra en jjbox om dette er valgt
    ElseIf m_CopyBGSource = jj_Box Then
        If Ambient.UserMode = True Then
            BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
                UserControl.Extender.Left / 15, _
                UserControl.Extender.Top / 15, vbSrcCopy
        End If
    End If
    
    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            'Tegn gradert grå stor firkant
            If UserControl.Enabled = True Then
                Farge.ColorLT = RGB(215, 215, 210)
                Farge.ColorRT = RGB(241, 241, 239)
                Farge.ColorRB = RGB(255, 255, 255)
                Farge.ColorLB = RGB(241, 241, 239)
                Call FadeTriangel(Farge, rc, True, TempHdc)
            'Tegn hvit stor firkant om den er disablet
            ElseIf UserControl.Enabled = False Then
                hBrush = CreateSolidBrush(vbWhite)
                hPen = CreatePen(PS_SOLID, 1, vbWhite)
                SelectObject TempHdc, hBrush
                SelectObject TempHdc, hPen
                Rectangle TempHdc, rc.Left, rc.Top, rc.Right, rc.Bottom
                DeleteObject hPen
                DeleteObject hBrush
            End If
            
            
            'Tegn en liten sirkel om den er checked
            If m_Value = True Then
                'Om den er enabled(grønnlig)
                If UserControl.Enabled = True Then
                    hBrush = CreateSolidBrush(CheckedColor)
                    hPen = CreatePen(PS_SOLID, 1, CheckedColor)
                'Om den er disabled(grålig)
                ElseIf UserControl.Enabled = False Then
                    hBrush = CreateSolidBrush(BorderColor)
                    hPen = CreatePen(PS_SOLID, 1, BorderColor)
                End If
                SelectObject TempHdc, hBrush
                SelectObject TempHdc, hPen
                If m_IconAlign = jj_Left Then
                    Ellipse TempHdc, 3, 3, 10, 10
                Else
                    rc.Left = ucWidth - 10
                    rc.Top = 3
                    rc.Right = ucWidth - 3
                    rc.Bottom = 10
                    Ellipse TempHdc, rc.Left, rc.Top, rc.Right, rc.Bottom
                End If
                DeleteObject hPen
                DeleteObject hBrush
            End If
            
            'Tegn rammen
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            If m_IconAlign = jj_Left Then
                LineTo TempHdc, Size, 0
                LineTo TempHdc, Size, Size
                LineTo TempHdc, 0, Size
                LineTo TempHdc, 0, 0
            Else
                MoveToEx TempHdc, ucWidth - 1, 0, pnt
                LineTo TempHdc, ucWidth - 1, Size
                LineTo TempHdc, ucWidth - (Size + 1), Size
                LineTo TempHdc, ucWidth - (Size + 1), 0
                LineTo TempHdc, ucWidth, 0
            End If
            DeleteObject hPen
            
            MousePos = -1
            
                    
        'MouseOver
        Case Is = 1
            'Tegn gradert oransje stor firkant
            Farge.ColorLT = RGB(255, 240, 207)
            Farge.ColorRT = RGB(251, 200, 99)
            Farge.ColorRB = RGB(248, 179, 48)
            Farge.ColorLB = RGB(251, 200, 99)
            Call FadeTriangel(Farge, rc, True, TempHdc)
            
            
            'Tegn grønn mindre firkant om den er checked
            If m_Value = True Then
                hBrush = CreateSolidBrush(CheckedColor)
                hPen = CreatePen(PS_SOLID, 1, CheckedColor)
                SelectObject TempHdc, hBrush
                SelectObject TempHdc, hPen
                If m_IconAlign = jj_Left Then
                    Ellipse TempHdc, 3, 3, 10, 10
                Else
                    rc.Left = ucWidth - 10
                    rc.Top = 3
                    rc.Right = ucWidth - 3
                    rc.Bottom = 10
                    Ellipse TempHdc, rc.Left, rc.Top, rc.Right, rc.Bottom
                End If
                DeleteObject hPen
                DeleteObject hBrush
            End If
            
            'Tegn rammen
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            If m_IconAlign = jj_Left Then
                LineTo TempHdc, Size, 0
                LineTo TempHdc, Size, Size
                LineTo TempHdc, 0, Size
                LineTo TempHdc, 0, 0
            Else
                MoveToEx TempHdc, ucWidth - 1, 0, pnt
                LineTo TempHdc, ucWidth - 1, Size
                LineTo TempHdc, ucWidth - (Size + 1), Size
                LineTo TempHdc, ucWidth - (Size + 1), 0
                LineTo TempHdc, ucWidth, 0
            End If
            DeleteObject hPen
            
            MousePos = -1
            
        'MouseDown
        Case Is = 2
            'Tegn gradert mørk grå stor firkant
            Farge.ColorLT = RGB(176, 176, 167)
            Farge.ColorRT = RGB(215, 213, 200)
            Farge.ColorRB = RGB(241, 239, 223)
            Farge.ColorLB = RGB(215, 213, 200)
            Call FadeTriangel(Farge, rc, True, TempHdc)
            
            'Tegn grønn mindre firkant om den er checked
            If m_Value = True Then
                hBrush = CreateSolidBrush(CheckedColor)
                hPen = CreatePen(PS_SOLID, 1, CheckedColor)
                SelectObject TempHdc, hBrush
                SelectObject TempHdc, hPen
                If m_IconAlign = jj_Left Then
                    Ellipse TempHdc, 3, 3, 10, 10
                Else
                    rc.Left = ucWidth - 10
                    rc.Top = 3
                    rc.Right = ucWidth - 3
                    rc.Bottom = 10
                    Ellipse TempHdc, rc.Left, rc.Top, rc.Right, rc.Bottom
                End If
                DeleteObject hPen
                DeleteObject hBrush
            End If
            
            'Tegn rammen
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            If m_IconAlign = jj_Left Then
                LineTo TempHdc, Size, 0
                LineTo TempHdc, Size, Size
                LineTo TempHdc, 0, Size
                LineTo TempHdc, 0, 0
            Else
                MoveToEx TempHdc, ucWidth - 1, 0, pnt
                LineTo TempHdc, ucWidth - 1, Size
                LineTo TempHdc, ucWidth - (Size + 1), Size
                LineTo TempHdc, ucWidth - (Size + 1), 0
                LineTo TempHdc, ucWidth, 0
            End If
            DeleteObject hPen

            UserControl.Refresh
    End Select
    
    'Skriv teksten
    If MousePos <> 0 Then
        SetTextColor TempHdc, m_ForeColor
        
        If m_Caption <> "" Then
            'Skriv på venstre side
            If m_IconAlign = jj_Left Then
                DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), 15 + m_IconSpace, 0, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
                
            'Skriv på venstre side
            Else
                DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), m_IconSpace, 0, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
            End If
        End If
        
        UserControl.Refresh
    End If
End Sub



Private Sub FinnOs()
    On Error GoTo PROC_ERR
    
    Dim sOS As OSVERSIONINFO
        
    sOS.dwOSVersionInfoSize = Len(sOS)
    GetVersionEx sOS
    
    If sOS.dwMajorVersion < 4 Then
        MsgBox "Beklager, Windows 95 eller Windows NT 3.51 eller nyere kreves.", vbOKOnly + vbInformation
        
    
    Else
        Select Case sOS.dwPlatformId
            'Windows 95-98
            Case VER_PLATFORM_WIN32_WINDOWS
                If CStr(sOS.dwMinorVersion) = 0 Then
                    OS(0) = 1
                    OS(1) = "Windows 95"
                ElseIf CStr(sOS.dwMinorVersion) > 0 Then
                    OS(0) = 2
                    OS(1) = "Windows 98"
                End If
                
            'Windows NT 3.51 - 4.0 - 2000 - XP
            Case VER_PLATFORM_WIN32_NT
                OS(0) = CStr(sOS.dwMajorVersion)
                OS(2) = CStr(sOS.dwMinorVersion) 'Win2000=0, WinXP=1
                
                If CStr(sOS.dwMajorVersion) = 3 Then
                    OS(1) = "Windows NT 3." & CStr(sOS.dwMinorVersion)
                
                ElseIf CStr(sOS.dwMajorVersion) = 4 Then
                    OS(1) = "Windows NT 4." & CStr(sOS.dwMinorVersion)
                
                ElseIf CStr(sOS.dwMajorVersion) = 5 Then
                    If CStr(sOS.dwMinorVersion) = 0 Then
                        OS(1) = "Windows 2000"
                    
                    ElseIf CStr(sOS.dwMinorVersion) = 1 Then
                        OS(1) = "Windows XP"
                    End If
                End If
            
            Case Else
                OS(0) = "0"
                OS(1) = ""
        End Select
    End If
    
PROC_EXIT:
    Exit Sub
    
PROC_ERR:
    GoTo PROC_EXIT
End Sub
Private Sub TegnHooverKnapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim pnt As POINTAPI
    Dim hBrush As Long
    Dim hPen As Long
    Dim Skyv As Integer
    Dim DisColor As Long
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    DisColor = RGB(64, 64, 64)
    If UserControl.Enabled = False Then
        DisColor = RGB(150, 150, 150)
    End If
    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            'Ramme og bakgrunn tegnes i valgt bakgrunnsfarge
            hBrush = CreateSolidBrush(DefaultColor)
            hPen = CreatePen(PS_SOLID, 1, DefaultColor)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush
                
            'Kopier inn bakgrunnen fra formen om dette er valgt
            If m_CopyBGSource = jj_Form Then
                BitBlt TempHdc, 0, 0, ucWidth, ucHeight, UserControl.Parent.hdc, _
                    UserControl.ScaleX(UserControl.Extender.Left, UserControl.Parent.ScaleMode, vbPixels), _
                    UserControl.ScaleY(UserControl.Extender.Top, UserControl.Parent.ScaleMode, vbPixels), vbSrcCopy

            'Kopier inn bakgrunnen fra en picturebox om dette er valgt
            ElseIf m_CopyBGSource = jj_PictureBox Then
                If Ambient.UserMode = True Then
                BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
                    m_CopyBGBoxName.ScaleX(UserControl.Extender.Left, m_CopyBGBoxName.ScaleMode, vbPixels), _
                    m_CopyBGBoxName.ScaleY(UserControl.Extender.Top, m_CopyBGBoxName.ScaleMode, vbPixels), vbSrcCopy
                End If
            
            'Kopier inn bakgrunnen fra en jjbox om dette er valgt
            ElseIf m_CopyBGSource = jj_Box Then
                If Ambient.UserMode = True Then
                    BitBlt TempHdc, 0, 0, ucWidth, ucHeight, m_CopyBGBoxName.hdc, _
                        UserControl.Extender.Left / 15, _
                        UserControl.Extender.Top / 15, vbSrcCopy
                End If
            End If
            
            MousePos = -1
            Skyv = 0
                    
        'MouseOver
        Case Is = 1
            'Tegn rektangel med hvit ramme
            hBrush = CreateSolidBrush(DefaultColor)
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush
            
            'To grå streker(høyre/bunn)
            hPen = CreatePen(PS_SOLID, 1, DisColor)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, ucWidth - 1, 0, pnt
            LineTo TempHdc, ucWidth - 1, ucHeight - 1
            LineTo TempHdc, -1, ucHeight - 1
            DeleteObject hPen
            
        'MouseDown
        Case Is = 2
            'Tegn rektangel med grå ramme
            hBrush = CreateSolidBrush(DefaultColor)
            hPen = CreatePen(PS_SOLID, 1, DisColor)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush
            
            'To hvite streker(høyre/bunn)
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, ucWidth - 1, 0, pnt
            LineTo TempHdc, ucWidth - 1, ucHeight - 1
            LineTo TempHdc, -1, ucHeight - 1
            DeleteObject hPen
            
            Skyv = 1
    End Select
    
    If MousePos <> 0 Then
        'Tegn Caption vanlig eller disabled
        SetTextColor TempHdc, m_ForeColor
        If m_Caption <> "" Then
            DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
        End If
        
        'Tegn Ikon vanlig eller disabled
        If m_IconDefault Then
            If UserControl.Enabled = True Then
                pic1.PaintPicture m_IconDefault, IconL + Skyv, IconT + Skyv
            Else
                DrawState TempHdc, 0, 0, m_IconDefault.Handle, 0, IconL + Skyv, IconT + Skyv, 0, 0, DST_ICON Or DSS_DISABLED
            End If
        End If
    End If
End Sub

Private Sub TegnStandardKnapp(uHdc As Long, MousePos As Integer)
    On Error Resume Next
    
    Dim pnt As POINTAPI
    Dim hBrush As Long
    Dim hPen As Long
    Dim Skyv As Integer
    Dim DisColor As Long
    Dim TempHdc As Long
    
    TempHdc = pic1.hdc
    Set pic1.Font = UserControl.Font
    
    DisColor = RGB(64, 64, 64)
    If UserControl.Enabled = False Then
        DisColor = RGB(150, 150, 150)
    End If
    
    Select Case MousePos
        'MouseLeave og ved initiering
        Case Is = 0
            'Ramme og bakgrunn tegnes i valgt bakgrunnsfarge
            hBrush = CreateSolidBrush(DefaultColor)
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush
            
            'To grå streker(høyre/bunn)
            hPen = CreatePen(PS_SOLID, 1, DisColor)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, ucWidth - 1, 0, pnt
            LineTo TempHdc, ucWidth - 1, ucHeight - 1
            LineTo TempHdc, -1, ucHeight - 1
            DeleteObject hPen
            
            MousePos = -1
            Skyv = 0
                    
        'MouseOver
        Case Is = 1
            'Tegn rektangel med hvit ramme
            hBrush = CreateSolidBrush(DefaultColor)
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush
            
            'To grå streker(høyre/bunn)
            hPen = CreatePen(PS_SOLID, 1, DisColor)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, ucWidth - 1, 0, pnt
            LineTo TempHdc, ucWidth - 1, ucHeight - 1
            LineTo TempHdc, -1, ucHeight - 1
            DeleteObject hPen
            
        'MouseDown
        Case Is = 2
            'Tegn rektangel med grå ramme
            hBrush = CreateSolidBrush(DefaultColor)
            hPen = CreatePen(PS_SOLID, 1, DisColor)
            SelectObject TempHdc, hBrush
            SelectObject TempHdc, hPen
            Rectangle TempHdc, 0, 0, ucWidth, ucHeight
            DeleteObject hPen
            DeleteObject hBrush
            
            'To hvite streker(høyre/bunn)
            hPen = CreatePen(PS_SOLID, 1, BorderColor)
            SelectObject TempHdc, hPen
            MoveToEx TempHdc, ucWidth - 1, 0, pnt
            LineTo TempHdc, ucWidth - 1, ucHeight - 1
            LineTo TempHdc, -1, ucHeight - 1
            DeleteObject hPen
            
            UserControl.Refresh
            Skyv = 1
    End Select
    
    If MousePos <> 0 Then
        'Tegn Caption vanlig eller disabled
        SetTextColor TempHdc, m_ForeColor
        If m_Caption <> "" Then
            DrawStateText TempHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
        End If
        
        'Tegn Ikon vanlig eller disabled
        If m_IconDefault Then
            If UserControl.Enabled = True Then
                pic1.PaintPicture m_IconDefault, IconL + Skyv, IconT + Skyv
            Else
                DrawState TempHdc, 0, 0, m_IconDefault.Handle, 0, IconL + Skyv, IconT + Skyv, 0, 0, DST_ICON Or DSS_DISABLED
            End If
        End If
        'UserControl.Refresh
    End If
End Sub

Private Sub TekstOgIkon(MousePos As Integer, uHdc As Long, Skyv As Integer)
'    If MousePos <> 0 Then
'        'Tegn Caption vanlig eller disabled
'        SetTextColor uHdc, m_ForeColor
'        If m_Caption <> "" Then
'            DrawStateText uHdc, 0, 0, m_Caption, Len(m_Caption), CaptionL + Skyv, CaptionT + Skyv, 0, 0, DST_PREFIXTEXT Or IIf(UserControl.Enabled, DSS_NORMAL, DSS_DISABLED)
'        End If
'
'        'Tegn Ikon vanlig eller disabled
'        If m_IconDefault Then
'            If UserControl.Enabled = True Then
'                UserControl.PaintPicture m_IconDefault, IconL + Skyv, IconT + Skyv
'            Else
'                DrawState uHdc, 0, 0, m_IconDefault.Handle, 0, IconL + Skyv, IconT + Skyv, 0, 0, DST_ICON Or DSS_DISABLED
'            End If
'        End If
'        UserControl.Refresh
'    End If
End Sub

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=13,0,0,
Public Property Get GruppeID() As String
Attribute GruppeID.VB_Description = "Om det er valgt Option-knapp, settes en identisk ID på de som hører sammen."
    GruppeID = m_GruppeID
End Property

Public Property Let GruppeID(ByVal New_GruppeID As String)
    m_GruppeID = New_GruppeID
    PropertyChanged "GruppeID"
End Property


'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=7,0,0,5000
Public Property Get jjToolTipTime() As Integer
Attribute jjToolTipTime.VB_Description = "Tid i millisekunder tooltipen skal vises."
    jjToolTipTime = m_jjToolTipTime
End Property

Public Property Let jjToolTipTime(ByVal New_jjToolTipTime As Integer)
    'Min og maks verdier
    If New_jjToolTipTime < 1000 Then New_jjToolTipTime = 1000
    If New_jjToolTipTime > 30000 Then New_jjToolTipTime = 30000
    
    m_jjToolTipTime = New_jjToolTipTime
    PropertyChanged "jjToolTipTime"
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=0,0,0,0
Public Property Get Repeat() As Boolean
Attribute Repeat.VB_Description = "Settes til True om knappen skal repetere når musen holdes nede, gjelder bare om Mode=jj_Command"
    Repeat = m_Repeat
End Property

Public Property Let Repeat(ByVal New_Repeat As Boolean)
    If m_Mode = jj_Command Then
        m_Repeat = New_Repeat
        
    Else
        m_Repeat = False
    End If
    
    PropertyChanged "Repeat"
End Property


Private Sub RundeHjorner(hdc As Long)
    Dim Pixclr As Long
    
    Pixclr = GetPixel(hdc, 1, 3)
    SetPixelV hdc, 1, 2, Pixclr
    Pixclr = GetPixel(hdc, 3, 1)
    SetPixelV hdc, 2, 1, Pixclr
    
    Pixclr = GetPixel(hdc, ucWidth - 5, 1)
    SetPixelV hdc, ucWidth - 4, 1, Pixclr
    Pixclr = GetPixel(hdc, ucWidth - 3, 3)
    SetPixelV hdc, ucWidth - 3, 2, Pixclr
    
    Pixclr = GetPixel(hdc, ucWidth - 3, ucHeight - 5)
    SetPixelV hdc, ucWidth - 3, ucHeight - 4, Pixclr
    Pixclr = GetPixel(hdc, ucWidth - 5, ucHeight - 3)
    SetPixelV hdc, ucWidth - 4, ucHeight - 3, Pixclr
    
    Pixclr = GetPixel(hdc, 1, ucHeight - 5)
    SetPixelV hdc, 1, ucHeight - 4, Pixclr
    Pixclr = GetPixel(hdc, 3, ucHeight - 3)
    SetPixelV hdc, 2, ucHeight - 3, Pixclr
End Sub
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=15,0,0,0
Public Property Get CopyBGBoxName() As Control
    Set CopyBGBoxName = m_CopyBGBoxName
End Property

Public Property Set CopyBGBoxName(ByVal New_CopyBGBoxName As Control)
    Set m_CopyBGBoxName = New_CopyBGBoxName
    PropertyChanged "CopyBGBoxName"
    
    Call HighLight(-1, -1, -1, False)
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=7,0,0,0
Public Property Get CopyBGSource() As jjCopyBGSource
Attribute CopyBGSource.VB_Description = "Settes til Form eller PicturBox, velges PictureBox må CopyBGBoxName settes i formens Load prosedyre."
    CopyBGSource = m_CopyBGSource
End Property

Public Property Let CopyBGSource(ByVal New_CopyBGSource As jjCopyBGSource)
    m_CopyBGSource = New_CopyBGSource
    PropertyChanged "CopyBGSource"
    
    tmr1.Enabled = True
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=10,0,0,0
Public Property Get jjTabBorderColor() As OLE_COLOR
Attribute jjTabBorderColor.VB_Description = "Rammefarge på jjTab knapp."
    jjTabBorderColor = m_jjTabBorderColor
End Property

Public Property Let jjTabBorderColor(ByVal New_jjTabBorderColor As OLE_COLOR)
    m_jjTabBorderColor = New_jjTabBorderColor
    PropertyChanged "jjTabBorderColor"
    
    Call HighLight(-1, -1, -1, False)
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=10,0,0,0
Public Property Get jjTabSelectedColor() As OLE_COLOR
Attribute jjTabSelectedColor.VB_Description = "Farge på toppstreken på jjTab knapp når den er valgt."
    jjTabSelectedColor = m_jjTabSelectedColor
End Property

Public Property Let jjTabSelectedColor(ByVal New_jjTabSelectedColor As OLE_COLOR)
    m_jjTabSelectedColor = New_jjTabSelectedColor
    PropertyChanged "jjTabSelectedColor"
    
    Call HighLight(-1, -1, -1, False)
End Property