home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Simple_Mac211504642008.psc / control / chameleonButton.ctl
Text File  |  2002-08-03  |  17KB  |  320 lines

  1. VERSION 5.00
  2. Begin VB.UserControl chameleonButton 
  3.    AutoRedraw      =   -1  'True
  4.    ClientHeight    =   3600
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   4800
  8.    DefaultCancel   =   -1  'True
  9.    PropertyPages   =   "chameleonButton.ctx":0000
  10.    ScaleHeight     =   240
  11.    ScaleMode       =   3  'Pixel
  12.    ScaleWidth      =   320
  13.    ToolboxBitmap   =   "chameleonButton.ctx":0035
  14.    Begin VB.Timer OverTimer 
  15.       Enabled         =   0   'False
  16.       Interval        =   3
  17.       Left            =   0
  18.       Top             =   0
  19.    End
  20. End
  21. Attribute VB_Name = "chameleonButton"
  22. Attribute VB_GlobalNameSpace = False
  23. Attribute VB_Creatable = True
  24. Attribute VB_PredeclaredId = False
  25. Attribute VB_Exposed = False
  26. Option Explicit
  27.  
  28. #Const isOCX = False
  29.  
  30. Private Const cbVersion As String = "2.0.6"
  31.  
  32. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  33. '%             <<< GONCHUKI SYSTEMS >>>               %
  34. '%                                                    %
  35. '%                 CHAMELEON BUTTON                   %
  36. '%         copyright ⌐2001-2002 by gonchuki           %
  37. '%                                                    %
  38. '%  this custom control will emulate the most common  %
  39. '%      command buttons that everyone knows.          %
  40. '%                                                    %
  41. '%  it took me three months to develop this control   %
  42. '% but that was a first step, now eight months after, %
  43. '%  it turned out to be a very professional control.  %
  44. '%                                                    %
  45. '%     ALL THE CODE WAS WRITTEN FROM SCRATCH!!!       %
  46. '%                                                    %
  47. '%   ever wanted to add cool buttons to your app???   %
  48. '%          this is the BEST solution!!!              %
  49. '%                                                    %
  50. '%        Copyright ⌐ 2001-2002 by gonchuki           %
  51. '%                                                    %
  52. '%    Commercial use of this control is FORBIDDEN     %
  53. '%       without explicitly permission from me        %
  54. '%    You can't either use any part of this code      %
  55. '%              without my permission                 %
  56. '%   You can use this code without asking for your    %
  57. '%  personal projects or for freeware, but remember   %
  58. '%           to give credits where its due            %
  59. '%                                                    %
  60. '%  If you are building an OCX version, you MUST set  %
  61. '%      the isOCX constant to true and inlcude the    %
  62. '%          original unmodified about form            %
  63. '%                                                    %
  64. '%            e-mail: gonchuki@yahoo.es               %
  65. '%                                                    %
  66. '%                  MADE IN URUGUAY                   %
  67. '%                                                    %
  68. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  69.  
  70. '######################################################
  71. '#                    UPDTATE LOG                     #
  72. '#  all times are GMT -03:00                          #
  73. '#                                                    #
  74. '# November 9  - 03:00 am                             #
  75. '#              ╖ first release                       #
  76. '#                                                    #
  77. '# November 9  - 05:00 pm                             #
  78. '#              ╖ added ShowFocusRect property        #
  79. '#              ╖ added repaint before triggering the #
  80. '#                click event                         #
  81. '#                                                    #
  82. '# November 9  - 07:20 pm                             #
  83. '#              ╖ fixed the color shifting so it will #
  84. '#                display the correct color and not a #
  85. '#                weird one.                          #
  86. '#              ╖ improved Java button drawing        #
  87. '#              ╖ added custom colors capability      #
  88. '#                now it looks better than ever COOL! #
  89. '#              ╖ improved Flat button drawing        #
  90. '#                                                    #
  91. '# November 13 - 03:40 pm                             #
  92. '#              ╖ fixed the WinXP button colors and   #
  93. '#                styles. Note that as the colors are #
  94. '#                relative to a base, and for this    #
  95. '#                button i made a color work-around,  #
  96. '#                some colors will be un-reachable    #
  97. '#              ╖ added MouseMove event as requested  #
  98. '#                                                    #
  99. '# November 18 - 10:40 am                             #
  100. '#              ╖ translated all the line methods to  #
  101. '#                API calls. It's now faster than     #
  102. '#                ever. It will also decrease the     #
  103. '#                extra size of your exe!!!           #
  104. '#              ╖ improved Win32 button drawing       #
  105. '#              ╖ moved the direct calls to SetPixel  #
  106. '#                to use less inline .hDC calls       #
  107. '#              ╖ fixed KeyDown/KeyUp events so they  #
  108. '#                now act as they should              #
  109. '#                                                    #
  110. '# November 23 - 3:55 pm  (not updating on PSC...)    #
  111. '#              ╖ upgraded version to 1.1             #
  112. '#              ╖ added FontBold, and other similar   #
  113. '#                properties as requested             #
  114. '#              ╖ greatly improved drawing speed by   #
  115. '#                replacing lots of duplicated code   #
  116. '#                with the new-brand function made by #
  117. '#                me: "DrawFrame"                     #
  118. '#              ╖ fixed MouseDown/MouseUp events so   #
  119. '#                they now act as they should         #
  120. '#              ╖ added MousePointer property         #
  121. '#                                                    #
  122. '# December 1  - 10:10 pm                             #
  123. '#              ╖ replaced the RECT types assignment  #
  124. '#                in the resize event with API calls  #
  125. '#                that take 3/4 the time of raw vb    #
  126. '#              ╖ added "use container" to the color  #
  127. '#                schemes                             #
  128. '#              ╖ button now initializes with it's    #
  129. '#                caption set as it's name            #
  130. '#                                                    #
  131. '# December 23 - 2:00 pm                              #
  132. '#              ╖ finally got all the code in API by  #
  133. '#                replacing the Usercontrol.ForeColor #
  134. '#                calls with CreatePen API            #
  135. '#              ╖ added support for wrapping captions #
  136. '#              ╖ changed a bit the XP button gradient#
  137. '#                thanks to Ghuran Kartal for this    #
  138. '#              ╖ added refresh sub to force a button #
  139. '#                redraw.                             #
  140. '#              ╖ MouseIcon property added            #
  141. '#              ╖ MouseOver/MouseOut events added and #
  142. '#                also a ForeOver property is provided#
  143. '#                to change font color on mouse over. #
  144. '#                this also fixed the WinXP button,   #
  145. '#                which design is now perfect.        #
  146. '#              ╖ added FlatHover button style that is#
  147. '#                the real toolbar button.            #
  148. '#                                                    #
  149. '# January 1  - 11:15 am                 year 2002!!! #
  150. '#              ╖ some minor fixes                    #
  151. '#              ╖ new release!!!                      #
  152. '#                                                    #
  153. '# January 5  - 10:15 am                              #
  154. '#              ╖ fixed the memory leaks (only 1% of  #
  155. '#                gdi is lost per 15-20 runs of demo) #
  156. '#              ╖ the font assignment has changed     #
  157. '#              ╖ fixed a very rare and random bug in #
  158. '#                the XP-button. Problem was in the   #
  159. '#                DrawLine sub. Thanks goes to Dennis #
  160. '#                Vanderspek                          #
  161. '#              ╖ changed Mid and LCase to the faster #
  162. '#                Mid$ and LCase$ way                 #
  163. '#                                                    #
  164. '# January 22  - 11:55 pm                             #
  165. '#              ╖ fixed the "not redrawing" bug under #
  166. '#                Win 2K/NT/ME.                       #
  167. '#              ╖ fixed a bug that prevented hot keys #
  168. '#                to work properly                    #
  169. '#              ╖ fixed the font alignment problem    #
  170. '#                many many thanks to Carles P.V.     #
  171. '#                                                    #
  172. '# February 6  - 4:15 pm                              #
  173. '#              ╖ fixed property assignment problems  #
  174. '#              ╖ fixed "Use Container" color scheme  #
  175. '#              ╖ optimized a bit the code            #
  176. '#              ╖ fixed problem with system colors    #
  177. '#              ╖ added SoftBevel prop to allow the   #
  178. '#                buton to be "flatter"               #
  179. '#                                                    #
  180. '# February 8  - 10:15 pm                             #
  181. '#              ╖ fixed click event when user double  #
  182. '#                clicks on the button                #
  183. '#                                                    #
  184. '# February 10 - 2:35 pm                              #
  185. '#              ╖ added Office XP button style        #
  186. '#              ╖ added "DrawCaption" sub for easier  #
  187. '#                caption management                  #
  188. '#              ╖ changed focus rects for flat buttons#
  189. '#              ╖ added "DisableRefresh" sub to allow #
  190. '#                property changes without repainting #
  191. '#                until needed to do so.              #
  192. '#              ╖ added BackOver property             #
  193. '#                                                    #
  194. '# February 11 - 1:15 am                              #
  195. '#              ╖ added primitive support for pictures#
  196. '#              ╖ fixed colors when mouse re-enters   #
  197. '#                button area while holding the mouse #
  198. '#                button.                             #
  199. '#                                                    #
  200. '# February 12 - 4:30 pm                              #
  201. '#              ╖ finished with the picture property! #
  202. '#              ╖ Java focus rect fixed               #
  203. '#              ╖ Office XP style fixed               #
  204. '#              ╖ Changed "ConvertFromSystemColor" sub#
  205. '#                                                    #
  206. '# February 14 - 6:20 pm                              #
  207. '#              ╖ replaced the transparent blitting   #
  208. '#                function with one 10 times better   #
  209. '#              ╖ joined bitmaps & icons drawing      #
  210. '#              ╖ added "UseGreyscale" option         #
  211. '#                                                    #
  212. '# February 18 - 4:30 pm                              #
  213. '#              ╖ added embossed/engraved/shadowed fx #
  214. '#              ╖ added category for each property    #
  215. '#              ╖ added standard property pages       #
  216. '#                                                    #
  217. '# March 3 - 9:10 pm                                  #
  218. '#              ╖ fixed effects for XP styles         #
  219. '#              ╖ added mouseover detection function  #
  220. '#              ╖ some minor adjustments              #
  221. '#                                                    #
  222. '# March 31 - 2:55 am                                 #
  223. '#              ╖ upgraded to version 2.0             #
  224. '#              ╖ added transparent, 3D Hover and     #
  225. '#                oval button types                   #
  226. '#                                                    #
  227. '# April 1 - 9:45 pm                                  #
  228. '#              ╖ fixed transparent button drawing    #
  229. '#                                                    #
  230. '# April 19 - 6:00 pm                                 #
  231. '#              ╖ fixed Ofice XP button colors        #
  232. '#              ╖ added built-in hand cursor          #
  233. '#                                                    #
  234. '# May 11 - 12:40 pm                                  #
  235. '#              ╖ added KDE 2 button style!           #
  236. '#              ╖ slightly optimized Mac button code  #
  237. '#                                                    #
  238. '# May 16 - 7:00 pm                                   #
  239. '#              ╖ added version property              #
  240. '#              ╖ added complilation options for lite #
  241. '#                version (evaluation purpose only)   #
  242. '#              ╖ some optimizations for drawing fx   #
  243. '#                                                    #
  244. '# May 22 - 5:20 pm                                   #
  245. '#              ╖ added some code to make more robust #
  246. '#                the lite version                    #
  247. '#              ╖ added background picture option     #
  248. '#                                                    #
  249. '# June 29 - 4:00 pm                                  #
  250. '#              ╖ added CheckBoxBehaviour option to   #
  251. '#                allow the button behave as one of em#
  252. '#                                                    #
  253. '# July 25 - 11:55 pm                                 #
  254. '#              ╖ slightly optimized code, specially  #
  255. '#                by removing the slow IIf's          #
  256. '#              ╖ corrected default state for KDE2    #
  257. '#                                                    #
  258. '# August 1 - 12:30 pm                                #
  259. '#              ╖ NEW PUBLIC RELEASE!!!    (ver 2.04) #
  260. '#            2:40 pm                           2.05  #
  261. '#              ╖ button was not updating when "value"#
  262. '#                prop was changed by the code. Thanks#
  263. '#                to Steve and uZiGuLa.               #
  264. '#              ╖ fixed drawing for Win32 button while#
  265. '#                being CheckBox and Value = True     #
  266. '#                                                    #
  267. '# August 2 - 11:30 pm                                #
  268. '#              ╖ fixed (i hope) the problem with the #
  269. '#                WinXP disabled picture              #
  270. '#              ╖ fixed the "not redrawing" problem   #
  271. '#                                                    #
  272. '######################################################
  273.  
  274. Private Declare Function SetPixel Lib "gdi32" Alias "SetPixelV" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
  275.  
  276. Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
  277. Private Const COLOR_HIGHLIGHT = 13
  278. Private Const COLOR_BTNFACE = 15
  279. Private Const COLOR_BTNSHADOW = 16
  280. Private Const COLOR_BTNTEXT = 18
  281. Private Const COLOR_BTNHIGHLIGHT = 20
  282. Private Const COLOR_BTNDKSHADOW = 21
  283. Private Const COLOR_BTNLIGHT = 22
  284.  
  285. Private Declare Function OleTranslateColor Lib "oleaut32.dll" (ByVal lOleColor As Long, ByVal lHPalette As Long, lColorRef As Long) As Long
  286. Private Declare Function GetBkColor Lib "gdi32" (ByVal hdc As Long) As Long
  287. Private Declare Function GetTextColor Lib "gdi32" (ByVal hdc As Long) As Long
  288. Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
  289. 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
  290. Private Const DT_CALCRECT = &H400
  291. Private Const DT_WORDBREAK = &H10
  292. Private Const DT_CENTER = &H1 Or DT_WORDBREAK Or &H4
  293.  
  294. Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
  295. Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
  296. Private Declare Function FrameRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
  297. Private Declare Function DrawFocusRect Lib "user32" (ByVal hdc As Long, lpRect As RECT) As Long
  298. 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
  299.  
  300. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  301. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  302.  
  303. Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, lpr thiGcccccccccccccccccccccccccccccccccccccccccccccccccccg
  304. Sole
  305. '#ccccccccccccccccrcGected deuWccccccAs Long, ByVal X2 As Long, ByVal Y2 As Longim
  306. nstre FiUIeclare Func:
  307. Privatbng, lpr thiGcccccccccccccccccccccccccccccccccccccccccccccccccccg
  308. Sole
  309. '#ccccccccccccccccrcGected deuWcccccci5pse Lib "gdaT                                         #
  310. '# November 9  - 0 X As We         #
  311. '#              ╖ added CheckBoxB#
  312. '#                td CheckmvYtccccccccheckBox#
  313. 'dxB#
  314. '#$hoWn DeleteObject Lib "gdi32" (ByVal hObject As Long) As Longd'         mByVal X2 A,wheH     #
  315. '# i
  316. nstre FiUIeclare Func:
  317. Privalrnvranscccccg
  318. SoShoWn ccci5pg
  319. dsccgrivate Declare Funct#
  320. '