$OPTION EXPLICIT
SUB Fast_QBtnToQTBtn( _
BtnType AS STRING, _
PartID AS INTEGER, _
NumBMPs AS INTEGER, _
Sender AS QBUTTON)
DIM Dest AS QRECT, Source AS QRECT
DIM tmpBitmap1 AS QBITMAP, _
NBitmap1 AS QBITMAP, _
XPBitmap1 AS QBITMAP
DIM XPBtnType AS STRING
DIM XPPartID AS INTEGER
DIM Width1 AS INTEGER, Height1 AS INTEGER
DIM Width2 AS INTEGER, Height2 AS INTEGER
DIM tR AS RECT_QTBtn
DIM btnCount AS INTEGER
Sender.Spacing = False
btnCount = NumBMPs
IF btnCount > maxnumbmp_QTBtn OR btnCount < True THEN _
btnCount = maxnumbmp_QTBtn
Sender.NumBMPs = btncount
DIM fixTab AS INTEGER
fixTab = False
IF isXP_QTBtn AND BtnType = xpt_TabBtn THEN _
fixTab = True
IF isXP_QTBtn AND (XPBtnType = xpt_pushbtn OR XPBtnType = xpt_toolbarbtn OR XPBtnType = xpt_TabBtn) THEN _
PartID = True
Width1 = ((Sender.Width +3) *btnCount) +True
Height1 = Sender.Height +3
IF QTBtnOptimize <> True OR _
(isXP_QTBtn = True AND (XPBtnType <> BtnType OR PartID <> XPPartID)) OR _
((rWidth > False OR rHeight > False) AND _
(tmpBitmap1.Width <> Width1 AND tmpBitmap1.Height <> Height1 AND _
Width2 <> tmpBitmap1.Width AND Height2 <> tmpBitmap1.Width)) THEN
DrawCount ++
WITH NBitmap1
.Width = Width1
.Height = Height1
.FillRect(False, False, .Width, .Height, clBtnFace)
END WITH
WITH XPBitmap1
.Width = Width1
.Height = Height1
.FillRect(False, False, .Width, .Height, clBtnFace)
END WITH
Width1 = Sender.Width *btnCount
Height1 = Sender.Height
tmpBitmap1.Font.Name = Sender.Font.Name
tmpBitmap1.Font.Size = Sender.Font.Size
tmpBitmap1.Font.COLOR = Sender.Font.COLOR
tmpBitmap1.Font.Bold = Sender.Font.Bold
tmpBitmap1.Font.Italic = Sender.Font.Italic
tmpBitmap1.Font.Underline = Sender.Font.Underline
IF isXP_QTBtn = False THEN
DIM J AS INTEGER, I AS INTEGER
FOR J = False TO btnCount -True
WITH Dest
.Left = ((Width1 \btnCount) *J) +3 +(True *(J +True)) +(J *2) -IIF(J = 2, True, False)
.Top = maxnumbmp_QTBtn -IIF(J=2, True, False)
.Right = .Left +(Width1 \btnCount) -6
.Bottom = Height1 -2 -IIF(J = 2, True, False)
END WITH
WITH Source: .Left = ((QTBtnBMP.Width \btnCount) *J) +3: .Top = 3: _
.Right = .Left +(QTBtnBMP.Width \btnCount) -6
.Bottom = QTBtnBMP.Height -3
END WITH
NBitmap1.CopyRect(Dest, QTBtnBMP, Source)
FOR I = False TO 3
WITH Dest
.Left = ((Width1 \btnCount) *J) _
+IIF(I = False OR I = 2, False, (Width1 \btnCount) -3) +(True *(J +True)) +(J *2) _
-IIF(J = 2, True, False)
.Top = IIF(I<2, True, Height1 -2) -IIF(J = 2, True, False)
.Right = .Left +3
.Bottom = .Top +3
END WITH
WITH Source
.Left = ((QTBtnBMP.Width \btnCount) *J) _
+IIF(I = False OR I = 2, False, (QTBtnBMP.Width \btnCount) -3)
.Top = IIF(I < 2, False, QTBtnBMP.Height -3)
.Right = .Left +3
.Bottom = .Top +3
END WITH
NBitmap1.CopyRect(Dest, QTBtnBMP, Source)
NEXT I
FOR I = False TO True
WITH Dest
.Left = ((Width1 \btnCount) *J) +3 +(True *(J +True)) +(J *2) -IIF(J = 2, True, False)
.Top = IIF(I = False, True, Height1 -2) -IIF(J = 2, True, False)
.Right = .Left +(Width1 \btnCount) -6
.Bottom = .Top +3
END WITH
WITH Source
.Left = (QTBtnBMP.Width \btnCount) *J +3
.Top = IIF(I = False, False, QTBtnBMP.Height -3)
.Right = .Left +(QTBtnBMP.Width \btnCount) -6
.Bottom = .Top +3
END WITH
NBitmap1.CopyRect(Dest, QTBtnBMP, Source)
NEXT I
FOR I = False TO True
WITH Dest
.Left = ((Width1 \btnCount) *J) _
+IIF(I = False, False, (Width1 \btnCount) -3) +(True *(J +True)) +(J *2) _
-IIF(J = 2, True, False)
.Top = maxnumbmp_QTBtn -IIF(J = 2, True, False)
.Right = .Left +3
.Bottom = Height1 -2 -IIF(J = 2, True, False)
END WITH
WITH Source
.Left = ((QTBtnBMP.Width \btnCount) *J) +IIF(I = False, False, (QTBtnBMP.Width \btnCount) -3)
.Top = 3
.Right = .Left +3
.Bottom = QTBtnBMP.Height -3
END WITH
NBitmap1.CopyRect(Dest, QTBtnBMP, Source)
NEXT I
NEXT J
NBitmap1.PixelFormat = DefPixelFormat
ELSE
DIM hTheme AS LONG
DIM rtButton AS STRING
rtButton = ""
FOR I = True TO LEN(BtnType)
rtButton = rtButton +MID$(BtnType, I, True) +rqNullChr
NEXT I
rtButton = rtButton +rqNullChr
hTheme = OpenThemeData_QTBtn(Sender.Handle, VARPTR(rtButton))
IF hTheme = False THEN _
hTheme = OpenThemeData_QTBtn(Sender.Handle, VARPTR(rtButton))
IF hTheme <> False THEN
DIM lR AS LONG
DIM m_hDC AS LONG
DIM m_lPartId AS LONG, m_lStateId AS LONG
m_hDC = XPBitmap1.Handle
IF PartID > True THEN _
m_lPartId = PartID _
ELSE _
m_lPartId = True
FOR I = False TO 2 STEP 2
m_lStateId = I +True
tR.Left = ((I *(Sender.Width +3)) +IIF(I <> 2, True, False))
tR.Top = True -IIF(I <> 2, False, True) +fixTab
tR.Right = (tR.Left +Sender.Width)
tR.Bottom = (Sender.Height +True -IIF(I <> 2, False, True) +fixTab)
lR = DrawThemeBackground_QTBtn(hTheme, _
m_hDC, _
m_lPartId, _
m_lStateId, _
tR, tR)
NEXT I
FOR I = True TO 3 STEP 2
m_lStateId = I +True
tR.Left = (((I +IIF(I = True, 2, -2)) *(Sender.Width +3)) +True)
tR.Top = True
tR.Right = (tR.Left +Sender.Width)
tR.Bottom = Sender.Height +True +fixTab
lR = DrawThemeBackground_QTBtn(hTheme, _
m_hDC, _
m_lPartId, _
m_lStateId, _
tR, tR)
NEXT I
END IF
CloseThemeData_QTBtn hTheme
CloseThemeData_QTBtn hTheme
XPBitmap1.PixelFormat = DefPixelFormat
END IF
END IF
Width2 = ((Sender.Width +3) *btnCount) +True
Height2 = Sender.Height +3
IF isXP_QTBtn THEN
tmpBitmap1.BMP = XPBitmap1.BMP
ELSE
tmpBitmap1.BMP = NBitmap1.BMP
END IF
IF Sender.CAPTION = "" THEN
Sender.Layout = False
ELSE
SetBkMode_QTBtn tmpBitmap1.Handle, True
FOR I = False TO 2 STEP 2
tR.Left = ((I *(Sender.Width +3)) +IIF(I <> 2, True, False))
tR.Top = True -IIF(I <> 2, False, True)
tR.Right = (tR.Left +Sender.Width)
tR.Bottom = (Sender.Height +True -IIF(I <> 2, False, True) +fixTab)
DrawText_QTBtn (tmpBitmap1.Handle, Sender.CAPTION, LEN(Sender.CAPTION), _
tR, DT_CENTER_QTBtn OR DT_SINGLELINE_QTBtn OR DT_VCENTER_QTBtn)
NEXT I
FOR I = True TO 3 STEP 2
tR.Left = (((I +IIF(I = True, 2, -2)) *(Sender.Width +3)) +True)
tR.Top = True
tR.Right = (tR.Left +Sender.Width)
tR.Bottom = Sender.Height +True +fixTab
DrawText_QTBtn (tmpBitmap1.Handle, Sender.CAPTION, LEN(Sender.CAPTION), _
tR, DT_CENTER_QTBtn OR DT_SINGLELINE_QTBtn OR DT_VCENTER_QTBtn)
NEXT I
tmpBitmap1.Height = (Height1 +True) +tmpBitmap1.TextHeight(Sender.CAPTION)
Sender.Layout = 3
END IF
tmpBitmap1.PixelFormat = DefPixelFormat
XPBtnType = BtnType
tmpBitmap1.TransparentColor = tmpBitmap1.Pixel(True, True)
Sender.BMP = tmpBitmap1.BMP
END SUB
SUB Fast_QCBtnToQTBtn( _
BtnType AS STRING, _
PartID AS INTEGER, _
NumBMPs AS INTEGER, _
Sender AS QCOOLBTN)
DIM Dest AS QRECT, Source AS QRECT
DIM tmpBitmap1 AS QBITMAP, _
NBitmap1 AS QBITMAP, _
XPBitmap1 AS QBITMAP
DIM XPBtnType AS STRING
DIM XPPartID AS INTEGER
DIM Width1 AS INTEGER, Height1 AS INTEGER
DIM Width2 AS INTEGER, Height2 AS INTEGER
DIM tR AS RECT_QTBtn
DIM btnCount AS INTEGER
Sender.Flat = False
Sender.Spacing = False
btnCount = NumBMPs
IF btnCount > maxnumbmp_QTBtn OR btnCount < True THEN _
btnCount = maxnumbmp_QTBtn
Sender.NumBMPs = btncount
DIM fixTab AS INTEGER
fixTab = False
IF isXP_QTBtn AND BtnType = xpt_TabBtn THEN _
fixTab = True
IF isXP_QTBtn AND (XPBtnType = xpt_pushbtn OR XPBtnType = xpt_toolbarbtn OR XPBtnType = xpt_TabBtn) THEN _
PartID = True
Width1 = ((Sender.Width +3) *btnCount) +True
Height1 = Sender.Height +3
IF QTBtnOptimize <> True OR _
(isXP_QTBtn = True AND (XPBtnType <> BtnType OR PartID <> XPPartID)) OR _
((rWidth > False OR rHeight > False) AND _
(tmpBitmap1.Width <> Width1 AND tmpBitmap1.Height <> Height1 AND _
Width2 <> tmpBitmap1.Width AND Height2 <> tmpBitmap1.Width)) THEN
DrawCount ++
WITH NBitmap1
.Width = Width1
.Height = Height1
.FillRect(False, False, .Width, .Height, clBtnFace)
END WITH
WITH XPBitmap1
.Width = Width1
.Height = Height1
.FillRect(False, False, .Width, .Height, clBtnFace)
END WITH
Width1 = Sender.Width *btnCount
Height1 = Sender.Height
tmpBitmap1.Font.Name = Sender.Font.Name
tmpBitmap1.Font.Size = Sender.Font.Size
tmpBitmap1.Font.COLOR = Sender.Font.COLOR
tmpBitmap1.Font.Bold = Sender.Font.Bold
tmpBitmap1.Font.Italic = Sender.Font.Italic
tmpBitmap1.Font.Underline = Sender.Font.Underline
IF isXP_QTBtn = False THEN
DIM J AS INTEGER, I AS INTEGER
FOR J = False TO btnCount -True
WITH Dest
.Left = ((Width1 \btnCount) *J) +3 +(True *(J +True)) +(J *2) -IIF(J = 2 OR J = 3, True, False)
.Top = maxnumbmp_QTBtn -IIF(J = 2 OR J = 3, True, False)
.Right = .Left +(Width1 \btnCount) -6
.Bottom = Height1 -2 -IIF(J = 2, True, False)
END WITH
WITH Source: .Left = ((QTBtnBMP.Width \btnCount) *J) +3: .Top = 3: _
.Right = .Left +(QTBtnBMP.Width \btnCount) -6
.Bottom = QTBtnBMP.Height -3
END WITH
NBitmap1.CopyRect(Dest, QTBtnBMP, Source)
FOR I = False TO 3
WITH Dest
.Left = ((Width1 \btnCount) *J) _
+IIF(I = False OR I = 2, False, (Width1 \btnCount) -3) +(True *(J +True)) +(J *2) _
-IIF(J = 2 OR J = 3, True, False)
.Top = IIF(I < 2, True, Height1 -2) -IIF(J = 2 OR J = 3, True, False)
.Right = .Left +3
.Bottom = .Top +3
END WITH
WITH Source
.Left = ((QTBtnBMP.Width \btnCount) *J) _
+IIF(I = False OR I = 2, False, (QTBtnBMP.Width \btnCount) -3)
.Top = IIF(I < 2, False, QTBtnBMP.Height -3)
.Right = .Left +3
.Bottom = .Top +3
END WITH
NBitmap1.CopyRect(Dest, QTBtnBMP, Source)
NEXT I
FOR I = False TO True
WITH Dest
.Left = ((Width1 \btnCount) *J) +3 +(True *(J +True)) +(J *2) -IIF(J = 2 OR J = 3, True, False)
.Top = IIF(I = False, True, Height1 -2) -IIF(J = 2 OR J = 3, True, False)
.Right = .Left +(Width1 \btnCount) -6
.Bottom = .Top +3
END WITH
WITH Source
.Left = (QTBtnBMP.Width \btnCount) *J +3
.Top = IIF(I = False, False, QTBtnBMP.Height -3)
.Right = .Left +(QTBtnBMP.Width \btnCount) -6
.Bottom = .Top +3
END WITH
NBitmap1.CopyRect(Dest, QTBtnBMP, Source)
NEXT I
FOR I = False TO True
WITH Dest
.Left = ((Width1 \btnCount) *J) _
+IIF(I = False, False, (Width1 \btnCount) -3) +(True *(J +True)) +(J *2) _
-IIF(J = 2 OR J = 3, True, False)
.Top = maxnumbmp_QTBtn -IIF(J = 2 OR J = 3, True, False)
.Right = .Left +3
.Bottom = Height1 -2 -IIF(J = 2, True, False)
END WITH
WITH Source
.Left = ((QTBtnBMP.Width \btnCount) *J) +IIF(I = False, False, (QTBtnBMP.Width \btnCount) -3)
.Top = 3
.Right = .Left +3
.Bottom = QTBtnBMP.Height -3
END WITH
NBitmap1.CopyRect(Dest, QTBtnBMP, Source)
NEXT I
NEXT J
NBitmap1.PixelFormat = DefPixelFormat
ELSE
DIM hTheme AS LONG
DIM rtButton AS STRING
rtButton = ""
FOR I = True TO LEN(BtnType)
rtButton = rtButton +MID$(BtnType, I, True) +rqNullChr
NEXT I
rtButton = rtButton +rqNullChr
hTheme = OpenThemeData_QTBtn(Sender.PARENT, VARPTR(rtButton))
IF hTheme = False THEN _
hTheme = OpenThemeData_QTBtn(Sender.PARENT, VARPTR(rtButton))
IF hTheme <> False THEN
DIM lR AS LONG
DIM m_hDC AS LONG
DIM m_lPartId AS LONG, m_lStateId AS LONG
m_hDC = XPBitmap1.Handle
IF PartID > True THEN _
m_lPartId = PartID _
ELSE _
m_lPartId = True
FOR I = False TO 2 STEP 2
m_lStateId = I +True
tR.Left = ((I *(Sender.Width +3)) +IIF(I <> 2, True, False))
tR.Top = True -IIF(I <> 2, False, True) +fixTab
tR.Right = (tR.Left +Sender.Width)
tR.Bottom = (Sender.Height +True -IIF(I <> 2, False, True) +fixTab)
lR = DrawThemeBackground_QTBtn(hTheme, _
m_hDC, _
m_lPartId, _
m_lStateId, _
tR, tR)
NEXT I
FOR I = True TO 3 STEP 2
m_lStateId = (I +True) +IIF(I = True, True, False)
tR.Left = (((I +IIF(I = True, 2, -2)) *(Sender.Width +3)) +IIF(I = True, False, True))
tR.Top = IIF(I = True, False, True +fixTab)
tR.Right = (tR.Left +Sender.Width)
tR.Bottom = Sender.Height +True +IIF(fixTab = True, fixTab, -True)
lR = DrawThemeBackground_QTBtn(hTheme, _
m_hDC, _
m_lPartId, _
m_lStateId, _
tR, tR)
NEXT I
END IF
CloseThemeData_QTBtn hTheme
CloseThemeData_QTBtn hTheme
XPBitmap1.PixelFormat = DefPixelFormat
END IF
END IF
Width2 = ((Sender.Width +3) *btnCount) +True
Height2 = Sender.Height +3
IF isXP_QTBtn THEN
tmpBitmap1.BMP = XPBitmap1.BMP
ELSE
tmpBitmap1.BMP = NBitmap1.BMP
END IF
IF Sender.CAPTION = "" THEN
Sender.Layout = False
ELSE
SetBkMode_QTBtn tmpBitmap1.Handle, True
FOR I = False TO 2 STEP 2
tR.Left = ((I *(Sender.Width +3)) +IIF(I <> 2, True, False))
tR.Top = True -IIF(I <> 2, False, True) +fixTab
tR.Right = (tR.Left +Sender.Width)
tR.Bottom = (Sender.Height +True -IIF(I <> 2, False, True) +fixTab)
DrawText_QTBtn (tmpBitmap1.Handle, Sender.CAPTION, LEN(Sender.CAPTION), _
tR, DT_CENTER_QTBtn OR DT_SINGLELINE_QTBtn OR DT_VCENTER_QTBtn)
NEXT I
FOR I = True TO 3 STEP 2
tR.Left = (((I +IIF(I = True, 2, -2)) *(Sender.Width +3)) +IIF(I = True, False, True))
tR.Top = IIF(I = True, False, True +fixTab)
tR.Right = (tR.Left +Sender.Width)
tR.Bottom = Sender.Height +True +fixTab
DrawText_QTBtn (tmpBitmap1.Handle, Sender.CAPTION, LEN(Sender.CAPTION), _
tR, DT_CENTER_QTBtn OR DT_SINGLELINE_QTBtn OR DT_VCENTER_QTBtn)
NEXT I
tmpBitmap1.Height = (Height1 +True) +tmpBitmap1.TextHeight(Sender.CAPTION)
Sender.Layout = 3
END IF
tmpBitmap1.PixelFormat = DefPixelFormat
XPBtnType = BtnType
IF PartID <> True THEN PartID = True
XPPartID = True
tmpBitmap1.TransparentColor = tmpBitmap1.Pixel(True, True)
Sender.BMP = tmpBitmap1.BMP
END SUB
|
|