Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Any clickable component with backgroundColor support?



  • Please log in to reply
4 replies to this topic
Azevedo
  • Members
  • 179 posts
  • Last active: Nov 04 2015 04:37 PM
  • Joined: 07 Mar 2012

Hi,

I have this colorpick situation:

 

clipboard20151028170950.png

 

The idea is, the user click those squares and I call a function / label that picks up a color.

The only component I found that will allow this background color to be set is the progress bar:

        Gui, Preferences:Add, Text, x30 y180, Highlight colors:
        Gui, Preferences:Add, Text, x150 y180, Search:
        Gui, Preferences:Add, Progress,  x+5 y175 w20 h20 Backgroundff0000
        Gui, Preferences:Add, Text, x+32 y180, New items:
        Gui, Preferences:Add, Progress,  x+5 y175 w20 h20 Background00ff00
        Gui, Preferences:Add, Text, x+32 y180, Non-collection:
        Gui, Preferences:Add, Progress,  x+5 y175 w20 h20 Background0000ff

The problem is I cannot link the click event of a Progress component to a label (like gMyLabel).

Which component could I use that is "clickable" and I can set the background color?



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

I would use an image. I think it can be a pixel large and you can resize it if you just want a solid color with minimal file size.

 

But there are some advanced GUI tricks you could do, so, someone with more knowledge might step in with a good way to do it. I remember reading about a colored TreeView, not sure about other controls.



noname
  • Members
  • 650 posts
  • Last active:
  • Joined: 12 Nov 2011

Exaskryz suggestion of using a picture is the most straightforward way i guess,you could use a hbitmap created insitu like Skan showed some time ago.

see  http://autohotkey.co...ows-7/?p=352926

 

The new beta ahk version supports hbitmaps but  now you can use the sendmessage to the picture handle.I only tried it on 32bit winXP.

Gui, Preferences:Add, Text, x30 y180, Highlight colors:
Gui, Preferences:Add, Text, x150 y180, Search:
Gui, Preferences:Add, Picture,  x+5 y175 w20 h20 0xE vPic1 gSearch hwndhPic1
Gui, Preferences:Add, Text, x+32 y180, New items:
Gui, Preferences:Add, Picture,  x+5 y175 w20 h20 0xE vPic2 gItems hwndhPic2
Gui, Preferences:Add, Text, x+32 y180, Non-collection:
Gui, Preferences:Add, Picture,  x+5 y175 w20 h20 0xE vPic3 gNon-collection hwndhPic3

colors:=["0000ff","00ff00","ff0000"]  ;BGR format
loop 3
SendMessage, 0x172,0, hbmfromColor(20,20,colors[A_Index]),,% "ahk_id " hPic%A_Index%

Gui, Preferences:show
return


Search:
msgbox search
return

Items:
msgbox new items
return

Non-collection:
msgbox non-collection
return




hbmfromColor(w,h,color)
{
hex=
(join
424D3A000000000000003600000028000000010000000100000001
0020000000000000000000C40E0000C40E00000000000000000000
)
hex .=color "FF"
VarSetCapacity( BMP,(cLen:=StrLen(hex)//2))
Loop %cLen%
   NumPut("0x" SubStr(hex,2*a_index-1,2),BMP,a_index-1,"char")
hBMP := DllCall( "CreateDIBitmap", UInt,hDC, UInt,(bmiHAddr:=&BMP+14)
,UInt,(CBM_INIT:=6), UInt,&BMP+NumGet(BMP,10), UInt,&BMP+14, UInt,(DIB_PAL_COLORS:=1) )
return DllCall("CopyImage",UInt, hBMP,UInt,0,Int,w,Int,h, UInt,0)
}





winXP  and ahk unicode


lblb
  • Members
  • 120 posts
  • Last active: Dec 02 2015 08:05 AM
  • Joined: 22 May 2012
✓  Best Answer

Maybe something like this?

#SingleInstance, force

Gui, Preferences:Add, Text, x30 y180 gHighlight, Highlight colors:
Gui, Preferences:Add, Text, x150 y180, Search:
Gui, Preferences:Add, Progress,  x+5 y175 w20 h20 Backgroundff0000 hwndRedPRogress
Gui, Preferences:Add, Text, x+32 y180, New items:
Gui, Preferences:Add, Progress,  x+5 y175 w20 h20 Background00ff00
Gui, Preferences:Add, Text, x+32 y180, Non-collection:
Gui, Preferences:Add, Progress,  x+5 y175 w20 h20 Background0000ff hwndBlueProgress

OnMessage(0x0201, "WM_LBUTTONDOWN")
global RedPRogress, BlueProgress

Gui, Preferences: Show
Return


WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) {
    If (hwnd = RedProgress)
        Msgbox, Red
    If (hwnd = BlueProgress)
        Msgbox, Blue
    }


Highlight:
Msgbox, Clicked Highlight colors
Return


Azevedo
  • Members
  • 179 posts
  • Last active: Nov 04 2015 04:37 PM
  • Joined: 07 Mar 2012

Thanks everyone!

 

I used OnMessage(0x0201, "WM_LBUTTONDOWN")

Then I came back here to post the solution and I found lblb have already written.

 

Thanks everyone