Jump to content

Recommended Posts

  • 1 month later...
Posted

If I change the backcolor of the picker button, then I don't see the color rectangle on it anymore. Anyone know how I can GUICtrlSetBkColor on the color picker button without loosing the color rect?

Also the "More" button doesn't do anything for me, can I get rid of that or make it so I can choose more colors?

[size="1"][font="Lucida Console"]My ScriptsTrue multi-threaded ping[/font][/size]

Posted

If I change the backcolor of the picker button, then I don't see the color rectangle on it anymore. Anyone know how I can GUICtrlSetBkColor on the color picker button without loosing the color rect?

Also the "More" button doesn't do anything for me, can I get rid of that or make it so I can choose more colors?

Color Picker behaves just like a normal button. What version of AutoIt you are using and what version of Windows? And please show your code.
Posted

Color Picker behaves just like a normal button. What version of AutoIt you are using and what version of Windows? And please show your code.

I run Windows XP 32-Bit and Windows 7 32-Bit with AutoIt V3.3.

My Script:

$color_picker = _GUIColorPicker_Create('', 220, 174, 40, 23, 0xFF0000, BitOR($CP_FLAG_DEFAULT, $CP_FLAG_CHOOSERBUTTON), $aPalette, 5, 4, 0, '', '')

ColorPicker.au3:

.....
Func _GUIColorPicker_Create($sText, $iLeft, $iTop, $iWidth, $iHeight, $iRGB = 0, $iFlags = -1, $aPalette = 0, $iWidthPalette = -1, $iHeightPalette = -1, $hCursor = 0, $sTitle = '', $sButton = 'Custom...')
    If $iFlags < 0 Then
        $iFlags = $CP_FLAG_DEFAULT
    EndIf
    $sText = StringStripWS($sText, 3)
    $sTitle = StringStripWS($sTitle, 3)
    $sButton = StringStripWS($sButton, 3)
    $iFlags = BitOR($iFlags, 0x0080 * (StringLen($sText) = 0), 0x0100 * (StringLen($sTitle) > 0))
    Local $ID = GUICtrlCreateButton($sText, $iLeft, $iTop, $iWidth, $iHeight)
    GUICtrlSetBkColor(-1,0x000000)
.....

This is what it looks like with the backcolor changed

post-50351-12647818170966_thumb.gif

And this is if I don't change the backcolor

post-50351-12647819305174_thumb.gif

[size="1"][font="Lucida Console"]My ScriptsTrue multi-threaded ping[/font][/size]

  • 1 month later...
  • 6 months later...
  • 1 month later...
Posted

i am getting an error everytime using your demo script...

#Include <ColorPicker.au3>

Opt('MustDeclareVars', 1)

Global $hForm, $Msg, $Label, $Picker

$hForm = GUICreate('Color Picker', 179, 100)
$Label = GUICtrlCreateLabel('', 5, 5, 90, 90, $SS_SUNKEN)
GUICtrlSetBkColor(-1, 0xFF6600)

; Create Picker
$Picker = _GUIColorPicker_Create('Color...', 102, 70, 70, 23, 0xFF6600, BitOR($CP_FLAG_DEFAULT, $CP_FLAG_TIP))

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Picker
            GUICtrlSetBkColor($Label, _GUIColorPicker_GetColor($Picker))
    EndSwitch
WEnd

D:\_Autoit Scripts\ColorPicker.au3(792,33) : WARNING: $ccData possibly not declared/created yet

$ccData[9] = $cpId[$ID][14]

~~~~~~~~~~~~~~~~~~~~~~~~~~~^

D:\_Autoit Scripts\ColorPicker.au3(945,55) : ERROR: CC_WM_COMMAND(): undefined function.

Call('CC_WM_COMMAND', $hWnd, $iMsg, $wParam, $lParam)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

D:\_Autoit Scripts\ColorPicker.au3(1005,67) : ERROR: CC_WM_SETCURSOR(): undefined function.

$Result = Call('CC_WM_SETCURSOR', $hWnd, $iMsg, $wParam, $lParam)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

D:\_Autoit Scripts\Test.au3 - 2 error(s), 1 warning(s)

  • 2 weeks later...
  • 1 year later...
Posted (edited)

hi guy

i have big questions about example 2

so i had modify the example2 for my big script-program

the logic of my program consist: program call function , whitout cicle of while

in one of this function (i call by menu ) i writed this

Func _Report()

$zc=1

GUIDelete("GEST")

$Form1 = GUICreate("GEST -- Report & Grafici", 1075, 675, 150, 4, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))

$Tempoeffettivo = _DateTimeFormat(_NowCalc(), 2)

$REPtempo = StringSplit($Tempoeffettivo, "/")

$REPdata2 = $REPtempo[3] & "/" & $REPtempo[2] & "/" & $REPtempo[1]

If $REPtempo[2] = "01" Then

$REPanno = $REPtempo[3] - 1

$REPtempo[2] = 12

$REPdata = $REPanno & "/" & $REPtempo[2] & "/01"

EndIf

$tempoREP = _Date_Time_GetLocalTime()

$TempoeffettivoREP = _Date_Time_SystemTimeToDateTimeStr($tempoREP) ; tempo chiamata

$Group1 = GUICtrlCreateGroup("Report Fat Vend VS Fat Acq", 16, 24, 217, 201)

$Button1 = GUICtrlCreateButton("Genera Report", 136, 192, 83, 25, 0)

$Label2 = GUICtrlCreateLabel("Data Fattura di Partenza", 32, 62, 119, 17)

$Date1 = GUICtrlCreateDate($REPdata, 32, 88, 186, 21, $DTS_SHORTDATEFORMAT) ;data afttura partenza

$Label1 = GUICtrlCreateLabel("Data Fattura di Arrivo", 32, 128, 104, 17)

$Date2 = GUICtrlCreateDate($TempoeffettivoREP, 32, 153, 186, 21, $DTS_SHORTDATEFORMAT) ;data fattura arrivo

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group2 = GUICtrlCreateGroup("Report Giacenza Magazzino", 16, 233, 217, 201)

$Button2 = GUICtrlCreateButton("Genera Report", 136, 401, 83, 25, 0)

$Label3 = GUICtrlCreateLabel("Data di Partenza", 32, 271, 86, 17)

$date3 = GUICtrlCreateDate($REPdata, 32, 297, 186, 21, $DTS_SHORTDATEFORMAT) ;data afttura partenza

$Label4 = GUICtrlCreateLabel("Data di Arrivo", 32, 337, 68, 17)

$date4 = GUICtrlCreateDate($TempoeffettivoREP, 32, 362, 186, 21, $DTS_SHORTDATEFORMAT) ;data fattura arrivo

$Group3 = GUICtrlCreateGroup("Grafici", 240, 24, 625, 625)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group4 = GUICtrlCreateGroup("Filtri", 872, 24, 193, 625)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group5 = GUICtrlCreateGroup("Propietà del Grafico", 10, 446, 225, 203)

;$Checkbox1 = GUICtrlCreateCheckbox("Scritte orizzontali", 24, 472, 97, 17)

;$Button3 = GUICtrlCreateButton("Applica", 144, 616, 75, 21, 0)

$Picker1 = _GUIColorPicker_Create('Colore 1° Linea', 24, 496, 83, 21, "", BitOR($CP_FLAG_DEFAULT, $CP_FLAG_CHOOSERBUTTON), 0, -1, -1, $hCursor, 'Tavola colori')

$Picker2 = _GUIColorPicker_Create('Colore 2° Linea', 24, 524, 83, 21, "", BitOR($CP_FLAG_DEFAULT, $CP_FLAG_CHOOSERBUTTON), 0, -1, -1, $hCursor, 'Tavola colori')

$Picker3 = _GUIColorPicker_Create('Colore 3° Linea', 24, 551, 83, 21, "", BitOR($CP_FLAG_DEFAULT, $CP_FLAG_CHOOSERBUTTON), 0, -1, -1, $hCursor, 'Tavola colori')

$Picker4 = _GUIColorPicker_Create('Colore 4° Linea', 24, 578, 83, 21, "", BitOR($CP_FLAG_DEFAULT, $CP_FLAG_CHOOSERBUTTON), 0, -1, -1, $hCursor, 'Tavola colori')

$linee = _FileCountLines(@ScriptDir & "configcolor_line_graph.ini")

$key=1

Do

$varColor[$key] = IniRead(@ScriptDir & "configcolor_line_graph.ini", "colori", "key" & $key, "NotFound")

$key=$key+1

until $key=$linee

$Label5 = GUICtrlCreateLabel("", 147, 496, 36, 17,$SS_SUNKEN)

GUICtrlSetBkColor(-1, $varColor[1])

GUICtrlSetTip(-1, $varColor[2])

$Label6 = GUICtrlCreateLabel("", 147, 527, 36, 17,$SS_SUNKEN)

GUICtrlSetBkColor(-1, $varColor[3])

GUICtrlSetTip(-1, $varColor[4])

$Label7 = GUICtrlCreateLabel("", 147, 555, 36, 17,$SS_SUNKEN)

GUICtrlSetBkColor(-1, $varColor[5])

GUICtrlSetTip(-1, $varColor[6])

$Label8 = GUICtrlCreateLabel("", 147, 581, 36, 17,$SS_SUNKEN)

GUICtrlSetBkColor(-1, $varColor[7])

GUICtrlSetTip(-1, $varColor[8])

GUICtrlCreateGroup("", -99, -99, 1, 1)

_MenuFile()

GUISetState(@SW_SHOW)

GUICtrlSetOnEvent($Button1, "_genera_report")

GUICtrlSetOnEvent($Button2, "_genera_report_Mgazzino")

;GUICtrlSetOnEvent($Button3, "_applica_Propieta_graf")

GUICtrlSetOnEvent($Picker1, "_piccer1")

GUICtrlSetOnEvent($Picker2, "_piccer2")

GUICtrlSetOnEvent($Picker3, "_piccer3")

GUICtrlSetOnEvent($Picker4, "_piccer4")

$hInstance = _WinAPI_LoadLibrary(@SystemDir & 'mspaint.exe')

$hCursor = DllCall('user32.dll', 'ptr', 'LoadCursor', 'ptr', $hInstance, 'dword', 1204)

$hCursor = $hCursor[0]

_WinAPI_FreeLibrary($hInstance)

; Free cursor

DllCall('user32.dll', 'int', 'DestroyCursor', 'ptr', $hCursor)

; Create custom (4 x 5) color palette

Dim $aPalette[20] = _

[0xFFFFFF, 0x000000, 0xC0C0C0, 0x808080, _

0xFF0000, 0x800000, 0xFFFF00, 0x808000, _

0x00FF00, 0x008000, 0x00FFFF, 0x008080, _

0x0000FF, 0x000080, 0xFF00FF, 0x800080, _

0xC0DCC0, 0xA6CAF0, 0xFFFBF0, 0xA0A0A4]

_xml_creator()

$oChart1 = _CreateFusionChart("FCF_MSLine.swf", @ScriptDir & "Dati_DittareportgraficiExample1.xml", 250, 38, 600, 300)

$oChart2 = _CreateFusionChart("FCF_MSColumn3D.swf", @ScriptDir & "Dati_DittareportgraficiExample1.xml", 250, 338, 600, 300)

EndFunc ;==>_Report

and in second function i writed this

func _piccer4()

$Data = _GUIColorPicker_GetColor($Picker4, 1)

$hexcolor =( "0x"&Hex($Data[0], 6) )

$hexcolor1=( "'"&Hex($Data[0], 6)&"'" )

GUICtrlDelete($Label8)

$Label8 = GUICtrlCreateLabel("", 147, 581, 36, 17,$SS_SUNKEN)

GUICtrlSetBkColor(-1, $hexcolor)

GUICtrlSetTip(-1, $hexcolor1)

$codcolor=StringRight($hexcolor,6)

_FileWriteToLine(@ScriptDir & "configcolor_line_graph.ini",8, "key7=0x"&$codcolor,1)

_FileWriteToLine(@ScriptDir & "configcolor_line_graph.ini",9, "key8='"&$codcolor&"'",1)

msgbox(64,"Info","Inserimento Colore Avvenuto")

EndFunc

if i use one time go perfectly but if i refresh a gui (because use other menu) , the program stop take a _GUIColorPicker_GetColor , give me only the last value

why ?? ;)

Edited by Melba23
  • Moderators
Posted

faustf,

In future when you post code please use Code tags - put [autoit] before and [/autoit] after your posted code. :)

I tried to add them to the post above but the forum is not allowing me to do so - must be the new (downgrade)update. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • 1 month later...
  • 8 months later...
Posted (edited)

Hi - I am creating my button with _GUIColorPicker_Create() with $iFlags set to $CP_FLAG_CHOOSERBUTTON - and it is working great.

However, can I skip the dropdown "palette" that shows the swatches and directly go to the "More..." Windows Color Picker when the button is clicked on? Thanks.

Edited by robertcollier4
  • Moderators
Posted

robertcollier4,

If all you want is the Windows dialog, then use the standard _ChooseColor UDF - look in the Help file for more details and an example. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • 6 months later...
Posted

Hi Yashied,

im traying to use the colorpicker with events.

it works perfectly when using it as in the examples.

using events like follows , top working

_________________________________________________

; my form , and controls

;now creating the botton color picker

 $PickerMessageBackground = _GUIColorPicker_Create("  ", 336, 78, 44, 22,$BC_PickerMessageBackground, BitOR($CP_FLAG_DEFAULT, $CP_FLAG_CHOOSERBUTTON), 0, -1, -1, $hCursor, 'Simple Text')


GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

 While 1
  If $fFlag = True  Then
   $fFlag = False
   GUISetState(@SW_HIDE,$Gui)
   GUIDelete($Gui)
   ExitLoop
  EndIf

_________________

in  "WM_COMMAND" i have all the actions  (ex.)

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)  ; Handle WM_COMMAND messages 
Switch $iwParam
  Case $PickerMessageBackground
    $Data = _GUIColorPicker_GetColor($PickerMessageBackground, 1)
    If $Data[1] = '' Then
       $Data[1] = 'Custom'
    EndIf
    GUICtrlSetBkColor($T_MessageFont,"0x" & Hex($Data[0], 6) )
    GUICtrlSetState($buttonApply,$GUI_ENABLE)
  EndSwitch
endfunc

something with the registration

you put in the  "colorPicker.au3"  the following comments. but i having difficulties to understand what its means

#Region Initialization

; IMPORTANT! If you register the following window messages in your code, you should call handlers from this library until
; you return from your handlers, otherwise the Clor Picker controls will not work properly. For example:
;
; Func MY_WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam)
;     Local $Result = CP_WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam)
;     If Not $Result Then
;         Return 0
;     EndIf
;     ...
;     Return $GUI_RUNDEFMSG
; EndFunc   ;==>MY_WM_SETCURSOR

GUIRegisterMsg($CP_WM_ACTIVATE, 'CP_WM_ACTIVATE')
GUIRegisterMsg($CP_WM_COMMAND, 'CP_WM_COMMAND')
GUIRegisterMsg($CP_WM_MOUSEWHEEL, 'CP_WM_MOUSEWHEEL')
GUIRegisterMsg($CP_WM_SETCURSOR, 'CP_WM_SETCURSOR')

#EndRegion Initialization

any help  is apreciated .

thanks in advance!!

P.s.

Cool stuff , thanks for sharing.

  • Moderators
Posted

Marcelos,

When you register a message handler, you overwrite any previous registration. So if you register a handler for any of the messages used within this UDF AFTER the UDF has registered the message, the UDF will no longer have its function called when the message is received. Similarly, if your handler is registered BEFORE the UDF, your handler will not work as it is replaced by the UDF version. :(

The usual way to get round this (I do exactly the same in all my UDFs which require handlers) is to ask the user to call the relevant UDF handler function INSIDE the user's own handler. That way the user handler is run when the message is received and the UDF function is run at that point as well. In the commented section you posted, you can see that the UDF function CP_WM_SETCURSOR is being called from within the user handler. Clear now? :)

Do ask again if not. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...