@@ -78,9 +78,9 @@ Private Type XFORM
7878 eDyAs Single
7979End Type
8080
81- Private Declare Function SetGraphicsMode Lib "gdi32 " (ByVal hdc As Long ,ByVal iModeAs Long )As Long
82- Private Declare Function SetWorldTransform Lib "gdi32 " (ByVal hdc As Long , lpXformAs XFORM )As Long
83- Private Declare Function ModifyWorldTransform Lib "gdi32 " (ByVal hdc As Long , lpXformAs XFORM ,ByVal iModeAs Long )As Long
81+ Private Declare Function SetGraphicsMode Lib "gdi32 " (ByVal hDC As Long ,ByVal iModeAs Long )As Long
82+ Private Declare Function SetWorldTransform Lib "gdi32 " (ByVal hDC As Long , lpXformAs XFORM )As Long
83+ Private Declare Function ModifyWorldTransform Lib "gdi32 " (ByVal hDC As Long , lpXformAs XFORM ,ByVal iModeAs Long )As Long
8484Private Const MWT_IDENTITY =1
8585Private Const MWT_LEFTMULTIPLY =2
8686'Private Const MWT_RIGHTMULTIPLY = 3
@@ -93,10 +93,10 @@ Private Const Pi = 3.14159265358979
9393Private Const WM_USERAs Long =&H400
9494Private Const WM_INVALIDATEAs Long = WM_USER +11 ' custom message
9595
96- Private Declare Function GetClipRgn Lib "gdi32 " (ByVal hdc As Long ,ByVal hRgnAs Long )As Long
96+ Private Declare Function GetClipRgn Lib "gdi32 " (ByVal hDC As Long ,ByVal hRgnAs Long )As Long
9797Private Declare Function GetRgnBox Lib "gdi32 " (ByVal hRgnAs Long , lpRectAs RECT )As Long
9898Private Declare Function CreateRectRgn Lib "gdi32 " (ByVal x1As Long ,ByVal y1As Long ,ByVal x2As Long ,ByVal y2As Long )As Long
99- Private Declare Function SelectClipRgn Lib "gdi32 " (ByVal hdc As Long ,ByVal hRgnAs Long )As Long
99+ Private Declare Function SelectClipRgn Lib "gdi32 " (ByVal hDC As Long ,ByVal hRgnAs Long )As Long
100100Private Declare Function DeleteObject Lib "gdi32 " (ByVal hObjectAs Long )As Long
101101Private Declare Function InvalidateRectAsNull Lib "user32 "Alias "InvalidateRect " (ByVal hWndAs Long ,ByVal lpRectAs Long ,ByVal bEraseAs Long )As Long
102102'Private Declare Function GetUpdateRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT, ByVal bErase As Long) As Long
@@ -111,21 +111,15 @@ Private Type RECT
111111 BottomAs Long
112112End Type
113113
114- Private Type GDIPlusStartupInput
115- GdiPlusVersionAs Long
116- DebugEventCallbackAs Long
117- SuppressBackgroundThreadAs Long
118- SuppressExternalCodecsAs Long
119- End Type
120114
121115Private Type POINTL
122116 XAs Long
123117 YAs Long
124118End Type
125119
126- Private Declare Function GdipCreateFromHDC Lib "gdiplus " (ByVal hdc As Long ,ByRef graphicsAs Long )As Long
120+ Private Declare Function GdipCreateFromHDC Lib "gdiplus " (ByVal hDC As Long ,ByRef graphicsAs Long )As Long
127121Private Declare Function GdipDeleteGraphics Lib "gdiplus " (ByVal graphicsAs Long )As Long
128- Private Declare Function GdiplusStartup Lib "gdiplus " (ByRef token As Long ,ByRef lpInput As GDIPlusStartupInput ,Optional ByRef lpOutput As Any )As Long
122+ Private Declare Function GdiplusStartup Lib "gdiplus " (hToken As Long ,pInputBuf As Any ,Optional ByVal pOutputBuf As Long = 0 )As Long
129123Private Declare Function GdiplusShutdown Lib "gdiplus " (ByVal tokenAs Long )As Long
130124Private Declare Function GdipSetSmoothingMode Lib "GdiPlus .dll " (ByVal mGraphicsAs Long ,ByVal mSmoothingModeAs Long )As Long
131125Private Declare Function GdipDeleteBrush Lib "GdiPlus .dll " (ByVal mBrushAs Long )As Long
@@ -301,15 +295,21 @@ Private mStyle3D As SEStyle3DConstants
301295Private mStyle3DEffectAs SEStyle3DEffectConstants
302296Private mUseSubclassingAs SESubclassingConstants
303297
304- Private mGdipTokenAs Long
305- Private mContainerHwndAs Long
306298Private mAttachedAs Boolean
307299Private mShiftPutAutomaticallyAs Single
308300Private mCurvingFactor2As Single
309301Private mUserModeAs Boolean
310302Private mSubclassedAs Boolean
311303Private mDrawingOutsideUCAs Boolean
312-
304+ Property Get enabled()As Boolean
305+ enabled = UserControl.enabled
306+ End Property
307+ Property Let enabled(ByVal bValueAs Boolean )
308+ If UserControl.enabled <> bValueThen
309+ UserControl.enabled = bValue
310+ End If
311+ PropertyChanged
312+ End Property
313313Private Sub tmrPainting_Timer ()
314314 tmrPainting.enabled =False
315315End Sub
@@ -360,7 +360,6 @@ Private Sub UserControl_InitProperties()
360360 mUseSubclassing = mdef_UseSubclassing
361361
362362On Error Resume Next
363- mContainerHwnd = UserControl.ContainerHwnd
364363 mUserMode = Ambient.UserMode
365364On Error GoTo 0
366365 SetCurvingFactor2
@@ -404,8 +403,8 @@ Private Sub UserControl_Paint()
404403Dim iAuxExpandAs Long
405404
406405If (mRotationDegrees >0 )Or (mFlipped <> seFlippedNo)Then
407- iGMPrev = SetGraphicsMode(UserControl.hdc , GM_ADVANCED)
408- ModifyWorldTransform UserControl.hdc , mtx1, MWT_IDENTITY
406+ iGMPrev = SetGraphicsMode(UserControl.hDC , GM_ADVANCED)
407+ ModifyWorldTransform UserControl.hDC , mtx1, MWT_IDENTITY
409408If mRotationDegrees =0 Then
410409 c =1
411410 s =0
@@ -486,7 +485,7 @@ Private Sub UserControl_Paint()
486485
487486 mDrawingOutsideUC =False
488487 hRgn = CreateRectRgn(0 ,0 ,0 ,0 )
489- If GetClipRgn(UserControl.hdc , hRgn) =0 &Then ' hDc is one passed to Paint
488+ If GetClipRgn(UserControl.hDC , hRgn) =0 &Then ' hDc is one passed to Paint
490489 DeleteObject hRgn: hRgn =0
491490Else
492491 GetRgnBox hRgn, rgnRect' get its bounds & adjust our region accordingly (i.e.,expand 1 pixel)
@@ -495,11 +494,11 @@ Private Sub UserControl_Paint()
495494If (iExpandForPen <>0 )Or (iExpandOutsideForAngle <>0 )Or (iExpandOutsideForFigure <>0 )Or sTheLastTimeWasExpandedThen
496495 hRgnExpand = CreateRectRgn(rgnRect.Left - iExpandForPen - iExpandOutsideForAngle - iExpandOutsideForFigure, rgnRect.top - iExpandForPen - iExpandOutsideForAngle - iExpandOutsideForFigure, rgnRect.Right + iExpandForPen + iExpandOutsideForAngle + iExpandOutsideForFigure, rgnRect.Bottom + iExpandForPen + iExpandOutsideForAngle + iExpandOutsideForFigure)
497496
498- SelectClipRgn UserControl.hdc , hRgnExpand
497+ SelectClipRgn UserControl.hDC , hRgnExpand
499498 DeleteObject hRgnExpand
500499If Not tmrPainting.enabledThen
501- If (mContainerHwnd <>0 )And mSubclassedThen
502- PostMessagemContainerHwnd , WM_INVALIDATE,0 &,0 &
500+ If (UserControl.ContainerHwnd <>0 )And mSubclassedThen
501+ PostMessageUserControl.ContainerHwnd , WM_INVALIDATE,0 &,0 &
503502End If
504503End If
505504 mDrawingOutsideUC =True
@@ -510,17 +509,17 @@ Private Sub UserControl_Paint()
510509 tmrPainting.enabled =True
511510
512511If (mRotationDegrees >0 )Or (mFlipped <> seFlippedNo)Then
513- SetWorldTransform UserControl.hdc , mtx1
514- ModifyWorldTransform UserControl.hdc , mtx2, MWT_LEFTMULTIPLY
512+ SetWorldTransform UserControl.hDC , mtx1
513+ ModifyWorldTransform UserControl.hDC , mtx2, MWT_LEFTMULTIPLY
515514End If
516515
517516 Draw
518517
519- If hRgnExpand <>0 Then SelectClipRgn UserControl.hdc , hRgn' restore original clip region
518+ If hRgnExpand <>0 Then SelectClipRgn UserControl.hDC , hRgn' restore original clip region
520519If hRgn <>0 Then DeleteObject hRgn
521520
522521If (mRotationDegrees >0 )Or (mFlipped <> seFlippedNo)Then
523- SetGraphicsMode UserControl.hdc , iGMPrev
522+ SetGraphicsMode UserControl.hDC , iGMPrev
524523End If
525524End Sub
526525
@@ -552,7 +551,6 @@ Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
552551Set UserControl.MouseIcon = mMouseIcon
553552
554553On Error Resume Next
555- mContainerHwnd = UserControl.ContainerHwnd
556554 mUserMode = Ambient.UserMode
557555On Error GoTo 0
558556 SetCurvingFactor2
@@ -561,11 +559,8 @@ End Sub
561559
562560Private Sub UserControl_Terminate ()
563561 pvUnsubclass
564- If mGdipToken <>0 Then
565- TerminateGDI
566- End If
567-
568- If (mBorderWidth >1 )Or (mRotationDegrees >0 )Then InvalidateRectAsNull mContainerHwnd,0 &,1 &' paint the container when the control is deleted if the BorderWidth is greater than 1 or the control is rotated (if it painted outside its bounds)
562+ On Error Resume Next
563+ If (mBorderWidth >1 )Or (mRotationDegrees >0 )Then InvalidateRectAsNull UserControl.ContainerHwnd,0 &,1 &' paint the container when the control is deleted if the BorderWidth is greater than 1 or the control is rotated (if it painted outside its bounds)
569564End Sub
570565
571566Private Sub UserControl_WriteProperties (PropBagAs PropertyBag )
@@ -793,8 +788,8 @@ Public Property Let RotationDegrees(ByVal nValue As Single)
793788 mRotationDegrees = nValue
794789 Me.Refresh
795790If mDrawingOutsideUCThen
796- If (mContainerHwnd <>0 )And mSubclassedThen
797- PostMessagemContainerHwnd , WM_INVALIDATE,0 &,0 &
791+ If (UserControl.ContainerHwnd <>0 )And mSubclassedThen
792+ PostMessageUserControl.ContainerHwnd , WM_INVALIDATE,0 &,0 &
798793End If
799794End If
800795 PropertyChanged"RotationDegrees"
@@ -818,8 +813,8 @@ Public Property Let Opacity(ByVal nValue As Single)
818813 mOpacity = nValue
819814 Me.Refresh
820815If mDrawingOutsideUCThen
821- If (mContainerHwnd <>0 )And mSubclassedThen
822- PostMessagemContainerHwnd , WM_INVALIDATE,0 &,0 &
816+ If (UserControl.ContainerHwnd <>0 )And mSubclassedThen
817+ PostMessageUserControl.ContainerHwnd , WM_INVALIDATE,0 &,0 &
823818End If
824819End If
825820 PropertyChanged"Opacity"
@@ -868,8 +863,8 @@ Public Property Let CurvingFactor(ByVal nValue As Integer)
868863 SetCurvingFactor2
869864 Me.Refresh
870865If mDrawingOutsideUCThen
871- If (mContainerHwnd <>0 )And mSubclassedThen
872- PostMessagemContainerHwnd , WM_INVALIDATE,0 &,0 &
866+ If (UserControl.ContainerHwnd <>0 )And mSubclassedThen
867+ PostMessageUserControl.ContainerHwnd , WM_INVALIDATE,0 &,0 &
873868End If
874869End If
875870 PropertyChanged"CurvingFactor"
@@ -967,19 +962,19 @@ Public Property Let UseSubclassing(ByVal nValue As SESubclassingConstants)
967962 pvSubclass
968963If mSubclassedThen
969964If mDrawingOutsideUCThen
970- If (mContainerHwnd <>0 )And mSubclassedThen
971- PostMessagemContainerHwnd , WM_INVALIDATE,0 &,0 &
965+ If (UserControl.ContainerHwnd <>0 )And mSubclassedThen
966+ PostMessageUserControl.ContainerHwnd , WM_INVALIDATE,0 &,0 &
972967End If
973968End If
974969Else
975- If mContainerHwnd <>0 Then
976- PeekMessage iMessage,mContainerHwnd , WM_INVALIDATE, WM_INVALIDATE, PM_REMOVE' remove posted message, if any
970+ If UserControl.ContainerHwnd <>0 Then
971+ PeekMessage iMessage,UserControl.ContainerHwnd , WM_INVALIDATE, WM_INVALIDATE, PM_REMOVE' remove posted message, if any
977972End If
978973End If
979974Else
980975If mSubclassedThen pvUnsubclass
981- If mContainerHwnd <>0 Then
982- PeekMessage iMessage,mContainerHwnd , WM_INVALIDATE, WM_INVALIDATE, PM_REMOVE' remove posted message, if any
976+ If UserControl.ContainerHwnd <>0 Then
977+ PeekMessage iMessage,UserControl.ContainerHwnd , WM_INVALIDATE, WM_INVALIDATE, PM_REMOVE' remove posted message, if any
983978End If
984979End If
985980 PropertyChanged"UseSubclassing"
@@ -1015,8 +1010,7 @@ Private Sub Draw()
10151010Dim iShiftAs Long
10161011Dim iHalfBorderWidthAs Long
10171012
1018- If mGdipToken =0 Then InitGDI
1019- If GdipCreateFromHDC(UserControl.hdc, iGraphics) =0 Then
1013+ If GdipCreateFromHDC(UserControl.hDC, iGraphics) =0 Then
10201014
10211015If mFillStyle = seFSSolidThen
10221016 iFilled =True
@@ -2646,15 +2640,13 @@ Private Function ConvertColor(nColor As Long, nOpacity As Single) As Long
26462640End Function
26472641
26482642Private Sub InitGDI ()
2649- Dim GdipStartupInputAs GDIPlusStartupInput
2650- GdipStartupInput.GdiPlusVersion =1 &
2651- Call GdiplusStartup (mGdipToken, GdipStartupInput,ByVal 0 )
2643+ Dim aInput(0 To 3 )As Long
2644+ If GetModuleHandle("gdiplus" ) =0 Then
2645+ aInput(0 ) =1
2646+ Call GdiplusStartup (0 , aInput(0 ))
2647+ End If
26522648End Sub
26532649
2654- Private Sub TerminateGDI ()
2655- Call GdiplusShutdown (mGdipToken)
2656- mGdipToken =0
2657- End Sub
26582650
26592651Private Property Get SmoothingMode()As Long
26602652If mQuality = seQualityHighThen
@@ -2673,7 +2665,7 @@ End Property
26732665Private Sub pvSubclass ()
26742666Dim iDoAs Boolean
26752667
2676- If mContainerHwnd <>0 Then
2668+ If UserControl.ContainerHwnd <>0 Then
26772669If mUseSubclassing = seSCYesThen
26782670 iDo =True
26792671ElseIf mUseSubclassing = seSCNotInIDEThen
@@ -2686,7 +2678,7 @@ Private Sub pvSubclass()
26862678End If
26872679End If
26882680If iDoThen
2689- Set m_pSubclass = InitSubclassingThunk(mContainerHwnd , InitAddressOfMethod().SubclassProc(0 ,0 ,0 ,0 ,0 ))
2681+ Set m_pSubclass = InitSubclassingThunk(UserControl.ContainerHwnd , InitAddressOfMethod().SubclassProc(0 ,0 ,0 ,0 ,0 ))
26902682 mSubclassed =True
26912683End If
26922684End If