Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
; shlw_colors.wbt #DefineFunction shlwRGBToHLS(rgb) r = ItemExtract(1,rgb,"|") g = ItemExtract(2,rgb,"|") b = ItemExtract(3,rgb,"|") ;rgb = (b << 8 + g) << 8 + r ; incorrect! rgb = (b*256*256 + g*256 + r) ; make a COLORREF bb = BinaryAlloc(6) BinaryEodSet(bb,6) pwH = IntControl(42,bb,0,0,0) + 0 pwL = IntControl(42,bb,0,0,0) + 2 pwS = IntControl(42,bb,0,0,0) + 4 DllCall(StrCat(DirWindows(1),"shlwapi.dll"), void:"ColorRGBToHLS", long:rgb, long:pwH, long:pwL, long:pwS) arr = ArrDimension(3) arr[0] = BinaryPeek2(bb,0) ; H arr[1] = BinaryPeek2(bb,2) ; L arr[2] = BinaryPeek2(bb,4) ; S BinaryFree(bb) Return arr #EndFunction #DefineFunction shlwHLSToRGB(hls) h = hls[0] l = hls[1] s = hls[2] rgb = DllCall(StrCat(DirWindows(1),"shlwapi.dll"), long:"ColorHLSToRGB", word:h, word:l, word:s) ;; incorrect! ;r = rgb & 255 ;g = rgb >> 8 & 255 ;b = rgb >> 16 & 255 ; decode the COLORREF r = rgb & 255 g = (rgb & (255 * 256)) / 256 b = (rgb & (255 * 256 * 256)) / (256 * 256) rgb = StrCat(r,"|",g,"|",b) Return rgb #EndFunction #DefineFunction shlwAdjustLuma(rgb,n,flag) ;n is ; Luminance in units of 0.1 percent of the total range. For ; example, a value of n = 50 corresponds to 5 percent of the ; maximum luminance. ;fScale is ; If fScale is set to TRUE, n specifies how much to increment ; or decrement the current luminance. If fScale is set to FALSE, ; n specifies the absolute luminance. r = ItemExtract(1,rgb,"|") g = ItemExtract(2,rgb,"|") b = ItemExtract(3,rgb,"|") rgb = (b*256*256 + g*256 + r) ; make a COLORREF rgb = DllCall(StrCat(DirWindows(1),"shlwapi.dll"), long:"ColorAdjustLuma", long:rgb, long:n, long:flag) ; decode the COLORREF r = rgb & 255 g = (rgb & (255 * 256)) / 256 b = (rgb & (255 * 256 * 256)) / (256 * 256) rgb = StrCat(r,"|",g,"|",b) Return rgb #EndFunction ;if fileroot(strlower(intcontrol(1004,0,0,0,0)))!="shlw_colors" then return #DefineSubRoutine ExampleProc(DialogHandle, EventCode, ControlNum, Res4, Res5) Switch( EventCode) Case 0 DialogProcOptions(DialogHandle, 1, 80) ; timer events lum = 0 Return -2 Case 1 lum = lum - 25 If lum < -300 Then lum = 0 rgb = "224|12|17" ; start with a nice color: "Artery Red" rgb = shlwAdjustLuma(rgb,lum,0) DialogProcOptions(DialogHandle, 1001, rgb) ; set the color ; ; rotating hue ; rgb = DialogProcOptions(DialogHandle, 1001, -1) ; get the color ; aHLS = shlwRGBToHLS(rgb) ; convert to HLS ; aHLS[0] = aHLS[0] + 3 ; incrememt the hue ; rgb = shlwHLSToRGB(aHLS) ; convert back to RGB ; DialogProcOptions(DialogHandle, 1001, rgb) ; set the color Return -2 EndSwitch #EndSubRoutine MyDialogFormat=`WWWDLGED,6.1` MyDialogCaption=`Nice vascular red, throbbing` MyDialogX=073 MyDialogY=070 MyDialogWidth=344 MyDialogHeight=182 MyDialogNumControls=002 MyDialogProcedure=`ExampleProc` MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`DEFAULT,187|173|168` MyDialogConfig=4513660 MyDialog001=`091,161,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`217,161,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ButtonPushed=Dialog("MyDialog") Exit
Article ID: W15910
File Created: 2004:03:30:15:41:42
Last Updated: 2004:03:30:15:41:42