Blame | Last modification | View Log
VERSION 5.00Begin VB.UserControl jjShadeBoxAlignable = -1 'TrueAppearance = 0 'FlatAutoRedraw = -1 'TrueClientHeight = 1410ClientLeft = 0ClientTop = 0ClientWidth = 1950ControlContainer= -1 'TrueScaleHeight = 94ScaleMode = 3 'PixelScaleWidth = 130ToolboxBitmap = "jjShadeBox.ctx":0000Begin VB.PictureBox pic1Appearance = 0 'FlatAutoRedraw = -1 'TrueBackColor = &H80000005&BorderStyle = 0 'NoneClipControls = 0 'FalseForeColor = &H80000008&Height = 300Left = 1320ScaleHeight = 20ScaleMode = 3 'PixelScaleWidth = 20TabIndex = 0TabStop = 0 'FalseTop = 420Visible = 0 'FalseWidth = 300EndEndAttribute VB_Name = "jjShadeBox"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = TrueAttribute VB_PredeclaredId = FalseAttribute VB_Exposed = FalseOption Explicit'***************************************************************************************************************'Nytt i denne versjonen er at man kan velge en tekst i boksen i valgfri font, fontfarge, størrelse og alignment'Feltene for dette er Font, Text, TextColor og TextAlign.'***************************************************************************************************************Private Type HSLHue As IntegerSaturation As IntegerLuminance As IntegerEnd TypePrivate Type RGBRed As IntegerGreen As IntegerBlue As IntegerEnd TypePrivate h As HSLPrivate r As RGBPublic Enum jjFadejj_LeftRightjj_TopBottomjj_TriangelEnd EnumPublic Enum jjTextAlignjj_Leftjj_Rightjj_CenterEnd Enum'For Triangel-fargefyllPrivate Type TRIANGEL_COLORColorTL As LongColorTR As LongColorBL As LongColorBR As LongEnd Type'For Gradient-fargefyllPrivate Type GRADIENT_COLORColorFrom As LongColorTo As LongEnd TypePrivate Type RECTLeft As LongTop As LongRight As LongBottom As LongEnd TypePrivate Type GRADIENT_TRIANGLEVertex1 As LongVertex2 As LongVertex3 As LongEnd TypePrivate Type TRIVERTEXx As Longy As LongRed As IntegerGreen As IntegerBlue As IntegerAlpha As IntegerEnd TypePrivate Type GRADIENT_RECTUpperLeft As LongLowerRight As LongEnd TypeConst GRADIENT_FILL_RECT_H As Long = &H0Const GRADIENT_FILL_RECT_V As Long = &H1Const GRADIENT_FILL_TRIANGLE As Long = &H2'Const SM_CXBORDER = 5'Const SM_CYBORDER = 6'Const SM_CXEDGE = 45'Const SM_CYEDGE = 46Private Const DT_CENTER = &H1Private Const DT_RIGHT = &H2Private Const DT_LEFT = &H0Private Const DT_NOPREFIX = &H800Private Const DT_WORDBREAK = &H10Private 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 LongPrivate Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As LongPrivate 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 LongPrivate 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 LongPrivate 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 UpdateWindow Lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongPrivate Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As LongPrivate Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long'Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As LongPrivate Declare Sub OleTranslateColor Lib "oleaut32.dll" (ByVal clr As Long, ByVal hpal As Long, ByRef lpcolorref 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 LongPrivate 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 LongPrivate Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long'Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As LongPrivate Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long'Flytte til et punkt og tegne linjerPrivate Type POINTAPIx As Longy As LongEnd TypePrivate Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As LongPrivate Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As LongPrivate Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As LongPrivate Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As LongPrivate Const PS_SOLID = 0'Default Property Values:Const m_def_Text = ""Const m_def_TextColor = 0Const m_def_TextAlign = 2Const m_def_StatusBar = 0Const m_def_MakeRegionLines = 0Const m_def_FadeDoublePoint = 50Const m_def_BorderColor = 0Const m_def_Border = 0Const m_def_MakeRegion = 0Const m_def_FadeDouble = 0Const m_def_FadeType = 1Const m_def_ColorA = vbWhiteConst m_def_ColorB = &HD78853 'BlåConst m_def_TriColorTL = &HEDFEABConst m_def_TriColorTR = &HD78853Const m_def_TriColorBL = &HD78853Const m_def_TriColorBR = &HEDFEAB'Property Variables:Dim m_Text As StringDim m_TextColor As OLE_COLORDim m_TextAlign As IntegerDim m_StatusBar As BooleanDim m_MakeRegionLines As BooleanDim m_FadeDoublePoint As LongDim m_BorderColor As OLE_COLORDim m_Border As BooleanDim m_MakeRegion As BooleanDim m_FadeDouble As BooleanDim m_FadeType As IntegerDim m_ColorA As OLE_COLORDim m_ColorB As OLE_COLORDim m_TriColorTL As OLE_COLORDim m_TriColorTR As OLE_COLORDim m_TriColorBL As OLE_COLORDim m_TriColorBR As OLE_COLOR'Kontrollens bredde og høydeDim ucWidth As LongDim ucHeight As LongDim xDif As LongDim yDif As LongDim WResize As Boolean'Event Declarations:Event DblClick() 'MappingInfo=UserControl,UserControl,-1,DblClickAttribute DblClick.VB_Description = "Occurs when the user presses and releases a mouse button and then presses and releases it again over an object."Event MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseDownAttribute MouseDown.VB_Description = "Occurs when the user presses the mouse button while an object has the focus."Event MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseMoveAttribute MouseMove.VB_Description = "Occurs when the user moves the mouse."Event MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseUpAttribute MouseUp.VB_Description = "Occurs when the user releases the mouse button while an object has the focus."Event Resize() 'MappingInfo=UserControl,UserControl,-1,ResizeAttribute Resize.VB_Description = "Occurs when a form is first displayed or the size of an object changes."Event Click() 'MappingInfo=UserControl,UserControl,-1,ClickAttribute Click.VB_Description = "Occurs when the user presses and then releases a mouse button over an object."Attribute Click.VB_MemberFlags = "200"Private Function HSLtoRGB(ByVal Hue As Integer, ByVal Saturation As Integer, ByVal Luminance As Integer) As RGBDim pHue As SingleDim pSat As SingleDim pLum As SingleDim retval As RGBDim pRed As SingleDim pGreen As SingleDim pBlue As SingleDim temp2 As SingleDim temp3() As SingleDim temp1 As SingleDim n As IntegerReDim temp3(0 To 2)pHue = Hue / 239pSat = Saturation / 239pLum = Luminance / 239If pSat = 0 ThenpRed = pLum!pGreen = pLumpBlue = pLumElseIf pLum < 0.5 Thentemp2 = pLum * (1 + pSat)Elsetemp2 = pLum + pSat - pLum * pSatEnd Iftemp1! = 2 * pLum! - temp2!temp3(0) = pHue + 1 / 3temp3(1) = pHuetemp3(2) = pHue - 1 / 3For n = 0 To 2If temp3(n) < 0 Then temp3(n) = temp3(n) + 1If temp3(n) > 1 Then temp3(n) = temp3(n) - 1If 6 * temp3(n) < 1 Thentemp3(n) = temp1 + (temp2 - temp1) * 6 * temp3(n)ElseIf 2 * temp3(n) < 1 Thentemp3(n) = temp2ElseIf 3 * temp3(n%) < 2 Thentemp3(n%) = temp1 + (temp2 - temp1) _* ((2 / 3) - temp3(n%)) * 6Elsetemp3(n%) = temp1End IfEnd IfEnd IfNext n%pRed = temp3(0)pGreen = temp3(1)pBlue = temp3(2)End Ifretval.Red = Int(pRed * 255)retval.Green = Int(pGreen * 255)retval.Blue = Int(pBlue * 255)HSLtoRGB = retvalEnd FunctionPrivate Function RGBtoHSL(ByVal Red As Integer, ByVal Green As Integer, ByVal Blue As Integer) As HSLDim pRed As SingleDim pGreen As SingleDim pBlue As SingleDim retval As HSLDim pMax As SingleDim pMin As SingleDim pLum As SingleDim pSat As SingleDim pHue As SinglepRed = Red / 255pGreen = Green / 255pBlue = Blue / 255If pRed > pGreen ThenIf pRed > pBlue ThenpMax = pRedElsepMax = pBlueEnd IfElseIf pGreen > pBlue ThenpMax = pGreenElsepMax = pBlueEnd IfIf pRed < pGreen ThenIf pRed < pBlue ThenpMin = pRedElsepMin = pBlueEnd IfElseIf pGreen < pBlue ThenpMin = pGreenElsepMin = pBlueEnd IfpLum = (pMax + pMin) / 2If pMax = pMin ThenpSat = 0pHue = 0ElseIf pLum < 0.5 ThenpSat = (pMax - pMin) / (pMax + pMin)ElsepSat = (pMax - pMin) / (2 - pMax - pMin)End IfSelect Case pMax!Case pRedpHue = (pGreen - pBlue) / (pMax - pMin)Case pGreenpHue = 2 + (pBlue - pRed) / (pMax - pMin)Case pBluepHue = 4 + (pRed - pGreen) / (pMax - pMin)End SelectEnd Ifretval.Hue = pHue * 239 \ 6If retval.Hue < 0 Then retval.Hue = retval.Hue + 240retval.Saturation = Int(pSat * 239)retval.Luminance = Int(pLum * 239)RGBtoHSL = retvalEnd FunctionPrivate Sub FadeGradient(Farge As GRADIENT_COLOR, LeftRight As Boolean, X1 As Long, Y1 As Long, X2 As Long, Y2 As Long)On Error GoTo PROC_ERRDim gRect As GRADIENT_RECTDim Vert(1) As TRIVERTEXDim f As IntegerDim rgbRed(1) As Long, rgbGreen(1) As Long, rgbBlue(1) As LongDim rHex(1) As String, gHex(1) As String, bHex(1) As StringDim Retning As LongFor f = 0 To 1Select Case fCase Is = 0'Konverter FraFargen til RGBrgbRed(f) = Farge.ColorFrom Mod 256rgbGreen(f) = ((Farge.ColorFrom And &HFF00FF00) / 256)rgbBlue(f) = (Farge.ColorFrom And &HFF0000) / 65536Case Is = 1'Konverter TilFargen til RGBrgbRed(f) = Farge.ColorTo Mod 256rgbGreen(f) = ((Farge.ColorTo And &HFF00FF00) / 256)rgbBlue(f) = (Farge.ColorTo And &HFF0000) / 65536End Select'Gang RGB sin verdi med 256 for å tilpasse maksverdien til GradientFill sin maksverdi som er 65280rgbRed(f) = rgbRed(f) * 256rgbGreen(f) = rgbGreen(f) * 256rgbBlue(f) = rgbBlue(f) * 256'Konverter de nye verdiene til Hex verdierrHex(f) = "&h" & Hex(rgbRed(f))gHex(f) = "&h" & Hex(rgbGreen(f))bHex(f) = "&h" & Hex(rgbBlue(f))Next f'Fra-fargeVert(0).x = X1Vert(0).y = Y1Vert(0).Red = rHex(0)Vert(0).Green = gHex(0)Vert(0).Blue = bHex(0)Vert(0).Alpha = 0&'Til-fargeVert(1).x = X2Vert(1).y = Y2Vert(1).Red = rHex(1)Vert(1).Green = gHex(1)Vert(1).Blue = bHex(1)Vert(1).Alpha = 0&'Rektangelets ytterpunktergRect.UpperLeft = 0gRect.LowerRight = 1'Retning på fadingIf LeftRight = False ThenRetning = GRADIENT_FILL_RECT_VElseRetning = GRADIENT_FILL_RECT_HEnd If'APIGradientFill pic1.hdc, Vert(0), 2, gRect, 1, Retningpic1.RefreshPROC_EXIT:Exit SubPROC_ERR:If Err.Number = 91 Then GoTo PROC_EXITEnd SubPrivate Sub FadeTriangel(Farge As TRIANGEL_COLOR, jRect As RECT)On Error GoTo PROC_ERRDim Vert(3) As TRIVERTEXDim Tri(3) As GRADIENT_TRIANGLEDim f As IntegerDim rgbRed(3) As Long, rgbGreen(3) As Long, rgbBlue(3) As LongDim rHex(3) As String, gHex(3) As String, bHex(3) As StringFor f = 0 To 3Select Case fCase Is = 0'Konverter til RGBrgbRed(f) = Farge.ColorTL Mod 256rgbGreen(f) = ((Farge.ColorTL And &HFF00FF00) / 256)rgbBlue(f) = (Farge.ColorTL And &HFF0000) / 65536Case Is = 1'Konverter til RGBrgbRed(f) = Farge.ColorTR Mod 256rgbGreen(f) = ((Farge.ColorTR And &HFF00FF00) / 256)rgbBlue(f) = (Farge.ColorTR And &HFF0000) / 65536Case Is = 2'Konverter til RGBrgbRed(f) = Farge.ColorBR Mod 256rgbGreen(f) = ((Farge.ColorBR And &HFF00FF00) / 256)rgbBlue(f) = (Farge.ColorBR And &HFF0000) / 65536Case Is = 3'Konverter til RGBrgbRed(f) = Farge.ColorBL Mod 256rgbGreen(f) = ((Farge.ColorBL And &HFF00FF00) / 256)rgbBlue(f) = (Farge.ColorBL And &HFF0000) / 65536End Select'Gang RGB sin verdi med 256 for å tilpasse maksverdien til GradientFillTriangle sin maksverdi som er 65280rgbRed(f) = rgbRed(f) * 256rgbGreen(f) = rgbGreen(f) * 256rgbBlue(f) = rgbBlue(f) * 256'Konverter de nye verdiene til Hex verdierrHex(f) = "&h" & Hex(rgbRed(f))gHex(f) = "&h" & Hex(rgbGreen(f))bHex(f) = "&h" & Hex(rgbBlue(f))Next f'Venstre øverstVert(0).x = jRect.LeftVert(0).y = jRect.TopVert(0).Red = rHex(0)Vert(0).Green = gHex(0)Vert(0).Blue = bHex(0)Vert(0).Alpha = 0&'Høyre øverstVert(1).x = jRect.RightVert(1).y = jRect.TopVert(1).Red = rHex(1)Vert(1).Green = gHex(1)Vert(1).Blue = bHex(1)Vert(1).Alpha = 0&'Høyre nederstVert(2).x = jRect.RightVert(2).y = jRect.BottomVert(2).Red = rHex(2)Vert(2).Green = gHex(2)Vert(2).Blue = bHex(2)Vert(2).Alpha = 0&'Venstre nederstVert(3).x = jRect.LeftVert(3).y = jRect.BottomVert(3).Red = rHex(3)Vert(3).Green = gHex(3)Vert(3).Blue = bHex(3)Vert(3).Alpha = 0&Tri(0).Vertex1 = 0Tri(0).Vertex2 = 1Tri(0).Vertex3 = 2Tri(1).Vertex1 = 0Tri(1).Vertex2 = 2Tri(1).Vertex3 = 3Tri(2).Vertex1 = 1Tri(2).Vertex2 = 2Tri(2).Vertex3 = 3Tri(3).Vertex1 = 0Tri(3).Vertex2 = 1Tri(3).Vertex3 = 3'APIGradientFillTriangle pic1.hdc, Vert(0), 4, Tri(0), 4, GRADIENT_FILL_TRIANGLEpic1.RefreshPROC_EXIT:Exit SubPROC_ERR:If Err.Number = 91 Then GoTo PROC_EXITEnd SubPrivate Function TranslateColor(aColor As OLE_COLOR) As LongDim newcolor As LongOleTranslateColor aColor, UserControl.Palette, newcolorTranslateColor = newcolorEnd Function'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=7,0,0,0Public Property Get FadeType() As jjFadeAttribute FadeType.VB_Description = "Velg graderingstype, Topp-bunn, Venstre-høyre eller Triangel som er en firkant med valgfri farge i hvert hjørne."FadeType = m_FadeTypeEnd PropertyPublic Property Let FadeType(ByVal New_FadeType As jjFade)m_FadeType = New_FadeTypePropertyChanged "FadeType"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=10,0,0,0Public Property Get ColorA() As OLE_COLORAttribute ColorA.VB_Description = "Fra farge på vanlig gradering."ColorA = m_ColorAEnd PropertyPublic Property Let ColorA(ByVal New_ColorA As OLE_COLOR)m_ColorA = New_ColorAPropertyChanged "ColorA"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=10,0,0,0Public Property Get ColorB() As OLE_COLORAttribute ColorB.VB_Description = "Til farge på vanlig gradering."ColorB = m_ColorBEnd PropertyPublic Property Let ColorB(ByVal New_ColorB As OLE_COLOR)m_ColorB = New_ColorBPropertyChanged "ColorB"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=10,0,0,0Public Property Get TriColorTL() As OLE_COLORAttribute TriColorTL.VB_Description = "Farge til Triangelgradering, topp-venstre."TriColorTL = m_TriColorTLEnd PropertyPublic Property Let TriColorTL(ByVal New_TriColorTL As OLE_COLOR)m_TriColorTL = New_TriColorTLPropertyChanged "TriColorTL"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=10,0,0,0Public Property Get TriColorTR() As OLE_COLORAttribute TriColorTR.VB_Description = "Farge til Triangelgradering, topp-høyre."TriColorTR = m_TriColorTREnd PropertyPublic Property Let TriColorTR(ByVal New_TriColorTR As OLE_COLOR)m_TriColorTR = New_TriColorTRPropertyChanged "TriColorTR"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=10,0,0,0Public Property Get TriColorBL() As OLE_COLORAttribute TriColorBL.VB_Description = "Farge til Triangelgradering, bunn-venstre."TriColorBL = m_TriColorBLEnd PropertyPublic Property Let TriColorBL(ByVal New_TriColorBL As OLE_COLOR)m_TriColorBL = New_TriColorBLPropertyChanged "TriColorBL"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=10,0,0,0Public Property Get TriColorBR() As OLE_COLORAttribute TriColorBR.VB_Description = "Farge til Triangelgradering, bunn-høyre."TriColorBR = m_TriColorBREnd PropertyPublic Property Let TriColorBR(ByVal New_TriColorBR As OLE_COLOR)m_TriColorBR = New_TriColorBRPropertyChanged "TriColorBR"Call FadeEnd Property'Initialize Properties for User ControlPrivate Sub UserControl_InitProperties()m_FadeType = m_def_FadeTypem_ColorA = m_def_ColorAm_ColorB = m_def_ColorBm_TriColorTL = m_def_TriColorTLm_TriColorTR = m_def_TriColorTRm_TriColorBL = m_def_TriColorBLm_TriColorBR = m_def_TriColorBRm_FadeDouble = m_def_FadeDoublem_MakeRegion = m_def_MakeRegionm_Border = m_def_Borderm_BorderColor = m_def_BorderColorm_FadeDoublePoint = m_def_FadeDoublePointm_MakeRegionLines = m_def_MakeRegionLinesm_StatusBar = m_def_StatusBarSet UserControl.Font = Ambient.Fontm_Text = m_def_Textm_TextColor = m_def_TextColorm_TextAlign = m_def_TextAlignEnd Sub'Load property values from storagePrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)m_FadeType = PropBag.ReadProperty("FadeType", m_def_FadeType)m_ColorA = PropBag.ReadProperty("ColorA", m_def_ColorA)m_ColorB = PropBag.ReadProperty("ColorB", m_def_ColorB)m_TriColorTL = PropBag.ReadProperty("TriColorTL", m_def_TriColorTL)m_TriColorTR = PropBag.ReadProperty("TriColorTR", m_def_TriColorTR)m_TriColorBL = PropBag.ReadProperty("TriColorBL", m_def_TriColorBL)m_TriColorBR = PropBag.ReadProperty("TriColorBR", m_def_TriColorBR)m_FadeDouble = PropBag.ReadProperty("FadeDouble", m_def_FadeDouble)m_MakeRegion = PropBag.ReadProperty("MakeRegion", m_def_MakeRegion)m_Border = PropBag.ReadProperty("Border", m_def_Border)m_BorderColor = PropBag.ReadProperty("BorderColor", m_def_BorderColor)UserControl.Enabled = PropBag.ReadProperty("Enabled", True)m_FadeDoublePoint = PropBag.ReadProperty("FadeDoublePoint", m_def_FadeDoublePoint)m_MakeRegionLines = PropBag.ReadProperty("MakeRegionLines", m_def_MakeRegionLines)m_StatusBar = PropBag.ReadProperty("StatusBar", m_def_StatusBar)UserControl.MousePointer = PropBag.ReadProperty("MousePointer", 0)Set UserControl.Font = PropBag.ReadProperty("Font", Ambient.Font)m_Text = PropBag.ReadProperty("Text", m_def_Text)m_TextColor = PropBag.ReadProperty("TextColor", m_def_TextColor)m_TextAlign = PropBag.ReadProperty("TextAlign", m_def_TextAlign)End SubPrivate Sub UserControl_Resize()RaiseEvent Resize'Bredden og høyden på knappen legges i disseucWidth = UserControl.ScaleWidthucHeight = UserControl.ScaleHeightpic1.Width = ucWidthpic1.Height = ucHeightCall FadeEnd Sub'Write property values to storagePrivate Sub UserControl_WriteProperties(PropBag As PropertyBag)Call PropBag.WriteProperty("FadeType", m_FadeType, m_def_FadeType)Call PropBag.WriteProperty("ColorA", m_ColorA, m_def_ColorA)Call PropBag.WriteProperty("ColorB", m_ColorB, m_def_ColorB)Call PropBag.WriteProperty("TriColorTL", m_TriColorTL, m_def_TriColorTL)Call PropBag.WriteProperty("TriColorTR", m_TriColorTR, m_def_TriColorTR)Call PropBag.WriteProperty("TriColorBL", m_TriColorBL, m_def_TriColorBL)Call PropBag.WriteProperty("TriColorBR", m_TriColorBR, m_def_TriColorBR)Call PropBag.WriteProperty("FadeDouble", m_FadeDouble, m_def_FadeDouble)Call PropBag.WriteProperty("MakeRegion", m_MakeRegion, m_def_MakeRegion)Call PropBag.WriteProperty("Border", m_Border, m_def_Border)Call PropBag.WriteProperty("BorderColor", m_BorderColor, m_def_BorderColor)Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)Call PropBag.WriteProperty("FadeDoublePoint", m_FadeDoublePoint, m_def_FadeDoublePoint)Call PropBag.WriteProperty("MakeRegionLines", m_MakeRegionLines, m_def_MakeRegionLines)Call PropBag.WriteProperty("StatusBar", m_StatusBar, m_def_StatusBar)Call PropBag.WriteProperty("MousePointer", UserControl.MousePointer, 0)Call PropBag.WriteProperty("Font", UserControl.Font, Ambient.Font)Call PropBag.WriteProperty("Text", m_Text, m_def_Text)Call PropBag.WriteProperty("TextColor", m_TextColor, m_def_TextColor)Call PropBag.WriteProperty("TextAlign", m_TextAlign, m_def_TextAlign)End SubPrivate Sub FadeGradientInit(LeftRight As Boolean)On Error GoTo PROC_ERRDim Farger As GRADIENT_COLOR'FadeFargeFarger.ColorFrom = TranslateColor(m_ColorA)Farger.ColorTo = TranslateColor(m_ColorB)'EnkelFadeIf m_FadeDouble = False ThenCall FadeGradient(Farger, LeftRight, 0, 0, ucWidth, ucHeight)'DobbelFadeElse'ToppBunnIf LeftRight = False ThenCall FadeGradient(Farger, LeftRight, 0, 0, ucWidth, Prosent2(m_FadeDoublePoint, ucHeight))Farger.ColorTo = TranslateColor(m_ColorA)Farger.ColorFrom = TranslateColor(m_ColorB)Call FadeGradient(Farger, LeftRight, 0, Prosent2(m_FadeDoublePoint, ucHeight), ucWidth, ucHeight)' Farger.ColorFrom = Lys(30, TranslateColor(m_ColorA))' Farger.ColorTo = Lys(-10, TranslateColor(m_ColorA))' Call FadeGradient(Farger, LeftRight, 0, 0, ucWidth, ucHeight / 2)' Farger.ColorFrom = Lys(-30, TranslateColor(m_ColorA))' Farger.ColorTo = Lys(50, TranslateColor(m_ColorA))' Call FadeGradient(Farger, LeftRight, 0, ucHeight / 2, ucWidth, ucHeight)'VentreHøyreElseCall FadeGradient(Farger, LeftRight, 0, 0, Prosent2(m_FadeDoublePoint, ucWidth), ucHeight)Farger.ColorTo = TranslateColor(m_ColorA)Farger.ColorFrom = TranslateColor(m_ColorB)Call FadeGradient(Farger, LeftRight, Prosent2(m_FadeDoublePoint, ucWidth), 0, ucWidth, ucHeight)End IfEnd IfPROC_EXIT:Exit SubPROC_ERR:If Err.Number = 91 Then GoTo PROC_EXITEnd SubPrivate Sub FadeTriangelInit()On Error GoTo PROC_ERRDim TriFarger As TRIANGEL_COLORDim rct As RECTTriFarger.ColorTL = TranslateColor(m_TriColorTL)TriFarger.ColorTR = TranslateColor(m_TriColorTR)TriFarger.ColorBL = TranslateColor(m_TriColorBL)TriFarger.ColorBR = TranslateColor(m_TriColorBR)rct.Left = 0rct.Top = 0rct.Right = ucWidthrct.Bottom = ucHeightCall FadeTriangel(TriFarger, rct)PROC_EXIT:Exit SubPROC_ERR:If Err.Number = 91 Then GoTo PROC_EXITEnd SubPrivate Sub Fade()On Error Resume NextDim hRgn As LongDim hPen As LongDim pnt As POINTAPIDim RammeFarge As LongDim TempHdc As LongDim y As IntegerDim TextJust As Integer, TextJust2 As IntegerDim rc As RECT, Align As LongTempHdc = pic1.hdcSet pic1.Font = UserControl.Font'Utfør valgt fadingIf FadeType = jj_LeftRight ThenCall FadeGradientInit(True)ElseIf FadeType = jj_TopBottom ThenCall FadeGradientInit(False)ElseIf FadeType = jj_Triangel ThenCall FadeTriangelInitEnd If'Tegn ramme om dette er valgtIf m_MakeRegion = False ThenIf m_Border = True ThenSetWindowRgn UserControl.hwnd, 0, TrueRammeFarge = TranslateColor(m_BorderColor)hPen = CreatePen(PS_SOLID, 1, RammeFarge)SelectObject TempHdc, hPenMoveToEx TempHdc, 0, 0, pntLineTo TempHdc, ucWidth - 1, 0LineTo TempHdc, ucWidth - 1, ucHeight - 1LineTo TempHdc, 0, ucHeight - 1LineTo TempHdc, 0, 0DeleteObject hPenpic1.RefreshEnd IfEnd If'Tegn Drageikon om den skal fremtre som en statusbarIf m_StatusBar = True ThenIf Parent.WindowState = vbNormal ThenhPen = CreatePen(PS_SOLID, 2, vbWhite)SelectObject TempHdc, hPenMoveToEx TempHdc, ucWidth - 2, ucHeight - 2, pntLineTo TempHdc, ucWidth - 3, ucHeight - 3MoveToEx TempHdc, ucWidth - 6, ucHeight - 2, pntLineTo TempHdc, ucWidth - 7, ucHeight - 3MoveToEx TempHdc, ucWidth - 10, ucHeight - 2, pntLineTo TempHdc, ucWidth - 11, ucHeight - 3MoveToEx TempHdc, ucWidth - 2, ucHeight - 6, pntLineTo TempHdc, ucWidth - 3, ucHeight - 7MoveToEx TempHdc, ucWidth - 6, ucHeight - 6, pntLineTo TempHdc, ucWidth - 7, ucHeight - 7MoveToEx TempHdc, ucWidth - 2, ucHeight - 10, pntLineTo TempHdc, ucWidth - 3, ucHeight - 11DeleteObject hPenhPen = CreatePen(PS_SOLID, 2, Lys(-20, TranslateColor(m_ColorB)))SelectObject TempHdc, hPenMoveToEx TempHdc, ucWidth - 3, ucHeight - 3, pntLineTo TempHdc, ucWidth - 4, ucHeight - 4MoveToEx TempHdc, ucWidth - 7, ucHeight - 3, pntLineTo TempHdc, ucWidth - 8, ucHeight - 4MoveToEx TempHdc, ucWidth - 11, ucHeight - 3, pntLineTo TempHdc, ucWidth - 12, ucHeight - 4MoveToEx TempHdc, ucWidth - 3, ucHeight - 7, pntLineTo TempHdc, ucWidth - 4, ucHeight - 8MoveToEx TempHdc, ucWidth - 7, ucHeight - 7, pntLineTo TempHdc, ucWidth - 8, ucHeight - 8MoveToEx TempHdc, ucWidth - 3, ucHeight - 11, pntLineTo TempHdc, ucWidth - 4, ucHeight - 12DeleteObject hPenEnd IfEnd If'Lag region om dette er valgtIf m_MakeRegion = True Then'Lag regionhRgn = CreateRoundRectRgn(2, 0, ucWidth - 1, ucHeight, 5, 5)SetWindowRgn UserControl.hwnd, hRgn, TrueDeleteObject hRgny = 2ElseSetWindowRgn UserControl.hwnd, 0, Truey = 1End If'Lag topp/bunnlinje om dette er valgtIf m_MakeRegionLines = True Then'ToppstrekhPen = CreatePen(PS_SOLID, 1, Lys(-20, TranslateColor(m_ColorA)))SelectObject TempHdc, hPenMoveToEx TempHdc, 0, 0, pntLineTo TempHdc, ucWidth, 0DeleteObject hPen'BunnstrekhPen = CreatePen(PS_SOLID, 1, Lys(-50, TranslateColor(m_ColorB)))SelectObject TempHdc, hPenMoveToEx TempHdc, 0, ucHeight - y, pntLineTo TempHdc, ucWidth, ucHeight - yDeleteObject hPenpic1.RefreshEnd If'Tegn teksten vanlig eller disabledIf m_Text <> "" ThenTextJust = 3If m_MakeRegion = True Then TextJust = 6If m_StatusBar = True Then TextJust2 = 12rc.Left = TextJustrc.Right = ucWidth - TextJust - TextJust2rc.Top = 3rc.Bottom = ucHeight - 3Select Case m_TextAlignCase Is = 0 'LeftAlign = DT_LEFTCase Is = 1 'RightAlign = DT_RIGHTCase Is = 2 'CenterAlign = DT_CENTEREnd SelectIf UserControl.Enabled = True ThenSetTextColor TempHdc, TranslateColor(m_TextColor)ElseSetTextColor TempHdc, TranslateColor(vbGrayText)End IfDrawText TempHdc, m_Text, -1, rc, DT_WORDBREAK Or DT_NOPREFIX Or AlignEnd If'Kopier tempbildet over til kontrollenBitBlt UserControl.hdc, 0, 0, ucWidth, ucHeight, pic1.hdc, 0, 0, vbSrcCopyUserControl.Refresh'Nullstill tempboksen for å spare GDI ressurserSet pic1 = NothingEnd Sub'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=17Public Function Refreshing() As AmbientPropertiesCall FadeEnd Function'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=0,0,0,0Public Property Get FadeDouble() As BooleanAttribute FadeDouble.VB_Description = "Deler området i to og fader motsatt på siste del. Gjelder når FadeType er satt til 1 eller 2."FadeDouble = m_FadeDoubleEnd PropertyPublic Property Let FadeDouble(ByVal New_FadeDouble As Boolean)m_FadeDouble = New_FadeDoublePropertyChanged "FadeDouble"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=0,0,0,0Public Property Get MakeRegion() As BooleanAttribute MakeRegion.VB_Description = "Lager avrundede hjørner."MakeRegion = m_MakeRegionEnd PropertyPublic Property Let MakeRegion(ByVal New_MakeRegion As Boolean)m_MakeRegion = New_MakeRegionPropertyChanged "MakeRegion"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=0,0,0,0Public Property Get Border() As BooleanAttribute Border.VB_Description = "Om destinasjon er en PictureBox kan det tegnes en tynn ramme på denne. Velg BorderColor for farge på rammen."Border = m_BorderEnd PropertyPublic Property Let Border(ByVal New_Border As Boolean)m_Border = New_BorderPropertyChanged "Border"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=10,0,0,0Public Property Get BorderColor() As OLE_COLORAttribute BorderColor.VB_Description = "Farge på rammen om Border er satt til True."BorderColor = m_BorderColorEnd PropertyPublic Property Let BorderColor(ByVal New_BorderColor As OLE_COLOR)m_BorderColor = New_BorderColorPropertyChanged "BorderColor"Call FadeEnd PropertyPrivate Sub UserControl_Click()RaiseEvent ClickEnd Sub'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MappingInfo=UserControl,UserControl,-1,hDCPublic Property Get hdc() As LongAttribute hdc.VB_Description = "Returns a handle (from Microsoft Windows) to the object's device context."hdc = UserControl.hdcEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MappingInfo=UserControl,UserControl,-1,EnabledPublic Property Get Enabled() As BooleanEnabled = UserControl.EnabledEnd PropertyPublic Property Let Enabled(ByVal New_Enabled As Boolean)UserControl.Enabled() = New_EnabledPropertyChanged "Enabled"Call FadeEnd PropertyPrivate Function Lys(Verdi As Long, Farge As Long) As LongDim lrgb As LongDim pr As Long'Gjør long om til RGB som lagres i rCall LongToRGB(Farge)'legg RGB inn i HSLh = RGBtoHSL(r.Red, r.Green, r.Blue)'Juster lystyrken i HSLIf Verdi >= 0 Thenpr = Prosent2(Verdi, 239 - h.Luminance)If pr + h.Luminance > 239 Then pr = 239h.Luminance = h.Luminance + prElseIf Verdi < 0 Thenpr = Prosent2(Abs(Verdi), CLng(h.Luminance))If h.Luminance - pr < 0 Then pr = 0h.Luminance = h.Luminance - prEnd If'Legg inn den nye HSL i RGB som lagres i rr = HSLtoRGB(h.Hue, h.Saturation, h.Luminance)'Gjør RGB om til longlrgb = RGB(r.Red, r.Green, r.Blue)'ReturverdiLys = lrgbEnd FunctionPrivate Function Prosent2(Prosent As Long, MaksVerdi As Long, Optional Desimal As Boolean) As Long'Returnerer verdien av gitt Prosent i forhold til gitt MaksVerdi'---------------------------------------------------------------'Prosent = en verdi fra 0 til 100'MaksVerdi = tallet det skal finnes en prosentverdi av'Desimal = Settes til true om det ønskes en desimal på returverdien'Returvariabelen til Prosent2 må endres fra Long til String før denne virker.On Error Resume NextDim DesFormat As StringDim Pros As LongDesFormat = "#0"If Desimal = True Then DesFormat = "#0.0"Pros = (MaksVerdi * Prosent) / 100Prosent2 = Format(Pros, DesFormat)End FunctionPrivate Function Prosent(Verdi As Long, Maks As Long, Optional Desimal As Boolean) As LongOn Error Resume Next'Returnerer i prosent Verdi i forhold til MaksDim Pros As DoubleDim DesFormat As StringDesFormat = "#0"If Desimal = True Then DesFormat = "#0.0"Pros = (Maks - Verdi) / Maks * 100Prosent = Format(100 - (Pros), DesFormat)End FunctionPrivate Sub LongToRGB(LongColor As Long)'Selvstendig funksjon'Konverterer lang fargeverdi til RGB verdieneOn Error Resume Nextr.Red = LongColor Mod 256r.Green = ((LongColor And &HFF00FF00) / 256)r.Blue = (LongColor And &HFF0000) / 65536End Sub'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=7,0,0,50Public Property Get FadeDoublePoint() As IntegerAttribute FadeDoublePoint.VB_Description = "Tast et tall mellom 10-90 for å plassere delingseffekten om FadeDouble=True."FadeDoublePoint = m_FadeDoublePointEnd PropertyPublic Property Let FadeDoublePoint(ByVal New_FadeDoublePoint As Integer)If New_FadeDoublePoint < 10 Then New_FadeDoublePoint = 10If New_FadeDoublePoint > 90 Then New_FadeDoublePoint = 90m_FadeDoublePoint = New_FadeDoublePointPropertyChanged "FadeDoublePoint"Call FadeEnd PropertyPrivate Sub UserControl_DblClick()RaiseEvent DblClickEnd SubPrivate Sub UserControl_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)RaiseEvent MouseDown(Button, Shift, x, y)Dim rc As RECTDim pnt As POINTAPI'For endring av vindus sizeIf Button = vbLeftButton ThenIf m_StatusBar = True ThenIf Parent.WindowState = vbNormal ThenIf UserControl.Extender.Align = 2 ThenIf x > ucWidth - 13 And y > ucHeight - 13 Then'Finn vindusstørrelse og musepos.GetWindowRect UserControl.Parent.hwnd, rcGetCursorPos pnt'Finn diff mellom vinduets høyre/bunn pos og musepos.xDif = rc.Right - pnt.xyDif = rc.Bottom - pnt.yWResize = TrueEnd IfEnd IfEnd IfEnd IfEnd IfEnd SubPrivate Sub UserControl_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)RaiseEvent MouseMove(Button, Shift, x, y)Dim rc As RECTDim pnt As POINTAPI'Skifte til resize musemarkørom musen er over resize merketIf m_StatusBar = True ThenIf Parent.WindowState = vbNormal ThenIf x > ucWidth - 13 And y > ucHeight - 13 ThenMousePointer = 8ElseMousePointer = 0End IfEnd IfEnd If'Mulighet for å resize winduet kontrollen står iIf WResize = True ThenMousePointer = 8GetWindowRect UserControl.Parent.hwnd, rcGetCursorPos pntMoveWindow UserControl.Parent.hwnd, rc.Left, rc.Top, pnt.x - rc.Left + xDif, pnt.y - rc.Top + yDif, 1End IfEnd SubPrivate Sub UserControl_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)RaiseEvent MouseUp(Button, Shift, x, y)WResize = FalseEnd Sub'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=0,0,0,TruePublic Property Get MakeRegionLines() As BooleanAttribute MakeRegionLines.VB_Description = "Tegner en pyntelinje på topp og i bunn."MakeRegionLines = m_MakeRegionLinesEnd PropertyPublic Property Let MakeRegionLines(ByVal New_MakeRegionLines As Boolean)m_MakeRegionLines = New_MakeRegionLinesPropertyChanged "MakeRegionLines"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=0,0,0,0Public Property Get StatusBar() As BooleanAttribute StatusBar.VB_Description = "Settes til True for å få StatusBar ikon i høyre hjørne. Gjelder bare om Align=2."StatusBar = m_StatusBarEnd PropertyPublic Property Let StatusBar(ByVal New_StatusBar As Boolean)m_StatusBar = New_StatusBar'Man skal ikke kunne resize uten at controllen er alignet til bunnIf UserControl.Extender.Align <> 2 Then m_StatusBar = FalsePropertyChanged "StatusBar"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MappingInfo=UserControl,UserControl,-1,MousePointerPublic Property Get MousePointer() As IntegerAttribute MousePointer.VB_Description = "Returns/sets the type of mouse pointer displayed when over part of an object."Attribute MousePointer.VB_MemberFlags = "40"MousePointer = UserControl.MousePointerEnd PropertyPublic Property Let MousePointer(ByVal New_MousePointer As Integer)UserControl.MousePointer() = New_MousePointerPropertyChanged "MousePointer"End Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MappingInfo=UserControl,UserControl,-1,FontPublic Property Get Font() As FontAttribute Font.VB_Description = "Returns a Font object."Attribute Font.VB_UserMemId = -512Set Font = UserControl.FontEnd PropertyPublic Property Set Font(ByVal New_Font As Font)Set UserControl.Font = New_FontPropertyChanged "Font"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=13,0,0,Public Property Get Text() As StringAttribute Text.VB_Description = "Valgfri tekst."Text = m_TextEnd PropertyPublic Property Let Text(ByVal New_Text As String)m_Text = New_TextPropertyChanged "Text"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=10,0,0,0Public Property Get TextColor() As OLE_COLORAttribute TextColor.VB_Description = "Tekstfarge."TextColor = m_TextColorEnd PropertyPublic Property Let TextColor(ByVal New_TextColor As OLE_COLOR)m_TextColor = New_TextColorPropertyChanged "TextColor"Call FadeEnd Property'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!'MemberInfo=7,0,0,0Public Property Get TextAlign() As jjTextAlignAttribute TextAlign.VB_Description = "Plassering av tekst."TextAlign = m_TextAlignEnd PropertyPublic Property Let TextAlign(ByVal New_TextAlign As jjTextAlign)m_TextAlign = New_TextAlignPropertyChanged "TextAlign"Call FadeEnd Property