Preload ColorRequester options

Just starting out? Need help? Post your questions and find answers here.
fcb
User
User
Posts: 42
Joined: Fri Aug 31, 2012 10:12 pm

Preload ColorRequester options

Post by fcb »

ColorRequester

Is there a way to preload/preset the 16 "Custom colours" options? Any idea where these are stored?
User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Preload ColorRequester options

Post by ChrisR »

You can take a look at this thread Better ColorRequester()
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: Preload ColorRequester options

Post by kenmo »

I also learned from that thread above, and wrote this IncludeFile:
https://github.com/kenmo-pb/includes/bl ... sterEx.pbi

which simplifies it to

Code: Select all

SetColorReqExRecent(Index, Color) ; index 0 through 15

choice = ColorRequesterEx()
User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Preload ColorRequester options

Post by ChrisR »

kenmo wrote: Thu Jan 20, 2022 3:57 am I also learned from that thread above, and wrote this IncludeFile:
https://github.com/kenmo-pb/includes/bl ... sterEx.pbi
Nicely written, as usual, I appreciate :)

In addition, it can be interesting, as I did in my project, to use the last custom colour as a backup point.
It allows to restore, if needed, after trying another colour, to return to the original colour, the one in parameter (ex: Color = ColorRequesterEx(RGB(255, 0, 255), #ColorReq_UseFile, WindowID(0)).
It can be done by adding, in line 135

Code: Select all

  If (Color = #PB_Default)
    Color = __ColorReq_Recent(0)
  Else
    __ColorReq_Recent(15) = Color
  EndIf 

Still impressive the lack of reply from the requester, here or elsewhere :D :twisted:
fcb
User
User
Posts: 42
Joined: Fri Aug 31, 2012 10:12 pm

Re: Preload ColorRequester options

Post by fcb »

Thank you.

So if I understand it correctly the 'ChooseColor' function is actually a windows command that PB has wrapped. And that "Better ColorRequester" uses that command instead of the wrapped PB version ("ColorRequester")?
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: Preload ColorRequester options

Post by kenmo »

Yes you're right, the PureBasic ColorRequester() is internally calling the Windows ChooseColor_() function. And if you want to access Windows' extra options, like the pre-loaded colors, you have to do a little extra work using ChooseColor_() directly (which is what the linked code takes care of)
Post Reply