Author Topic: _AllocColor() limit  (Read 2939 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
_AllocColor() limit
« on: June 19, 2015, 05:57:35 PM »

 
_AllocColor() documentation says there is a 255 color limit.
Maybe there used to be, but I can allocate over 300 colors now.
What is the real limit?
Is there a limit anymore?
Is it really necessary to call _FreeColor()?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6884
  • Hero Points: 530
Re: _AllocColor() limit
« Reply #1 on: June 19, 2015, 10:02:00 PM »
The limit is definitely not 256. I think it's an unsigned short. I'm not looking at the source at the moment.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6884
  • Hero Points: 530
Re: _AllocColor() limit
« Reply #2 on: June 20, 2015, 01:45:35 AM »
It's fine to allocate a color and keep it until you exit SlickEdit. This is a very common usage. You probably don't need to use _FreeColor() unless you are allocating one heck of a lot of colors with no limit and no reuse.

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: _AllocColor() limit
« Reply #3 on: June 22, 2015, 03:27:56 AM »
Cool....I was just wondering. I'd like some colors, but I don't need hundreds.


I imagine that this limit probably dates from long ago - maybe from when you had a 256 color (or less!) palette to work with on Windows.




Two more questions ...


Given the color index, how can I query the RGB value?


What are the "special" color constants?
0x80000008 and 0x80000005 are used often and seem to be related to the default bk and fg colors.
But there are some others, 0x80000022 seems to be one of the most common.


Are these defined someplace?


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6884
  • Hero Points: 530
Re: _AllocColor() limit
« Reply #4 on: June 22, 2015, 01:41:00 PM »
Use _default_color(ColorIndex) to query the RBG colors. The special color constants make it easier to specify default background and foreground colors for whatever the control is.

0x80000008   Default background for that control
0x80000005   Default foreground for that control
0x80000022   Default dialog background color