Get a color name from any RGB combination?

G

GS

GS said:
AIUI even in XP still had to register but the difference since Vista
is the UAC must be turned off or permission given. Can be done
manually, or via cmd (without turning off the UAC), or with an
installer subject to the user accepting the prompt that appears. I've
never looked into RegFree and manifest, always meant to! However even
Regfree won't help with Office 64bit, right?

Not for OCXs, but DLLs should still be possible so long as
'LoadLibrary' is available!
Seems for VBA the only solution for the old favourite ocx's is to
roll your own. You mentioned listview, was thinking about adapting
that one day.
It takes a bit more code to implement, but still requires its library
to be registered. This is why I did my initial listbox-based dataform
way back before UAC days and dropped support for mscomctl.ocx. I see,
though, that similar libs ship as DLLs in recent versions of Windows
and so may be worth re-exploring use of the listview!!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
P

Peter T

GS said:
Not for OCXs, but DLLs should still be possible so long as 'LoadLibrary'
is available!

There is a ptrSafe version of LoadLibrary. So are you saying with RegFree
you can use a VB6 aX dll in Office 64 and call it from VBA, as a ComAddin
too?
It takes a bit more code to implement, but still requires its library to
be registered. This is why I did my initial listbox-based dataform way
back before UAC days and dropped support for mscomctl.ocx. I see, though,
that similar libs ship as DLLs in recent versions of Windows and so may be
worth re-exploring use of the listview!!

FWIW the mscomctl treeview has been adapted to VBA, can also use that for a
simple listview that's used for the only reason you can include add an icon
to the item.

Regards,
Peter T
 
G

GS

GS said:
There is a ptrSafe version of LoadLibrary. So are you saying with
RegFree you can use a VB6 aX dll in Office 64 and call it from VBA,
as a ComAddin too?

Not sure about that because I expect the DLL needs to be x64. I don't
have MSO x64 installed and so can't say. Perhaps you can ask Rob Bovey
about this.

Also, Olaf Schmidt provided the reg-free stuff for VBA and so you can
ask him about MSO x64 in the classic VB forums. Note that this would be
'OT'!
FWIW the mscomctl treeview has been adapted to VBA, can also use that
for a simple listview that's used for the only reason you can include
add an icon to the item.

Yes, I've seen that project but not tried it. I don't see how a
treeview can also be used as a listview (or am I misunderstanding you),
but I can do similar as both with my Spread.ocx. Again, though, it
needs to be registered and so is not an option for VBA projects that
need to be reg-free. (My apps are 100% portable and so MUST be
reg-free) Otherwise, I have no issue installing/registering
mscomctl.ocx. (I do plan to investigate using the newer DLL reg-free,
though!)

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
P

Peter T

snip
Not sure about that because I expect the DLL needs to be x64. I don't have
MSO x64 installed and so can't say. Perhaps you can ask Rob Bovey about
this.

But can't compile a dll as 64bit, 32bit only. It's not Win64 that's the
problem but Office64.
Also, Olaf Schmidt provided the reg-free stuff for VBA and so you can ask
him about MSO x64 in the classic VB forums. Note that this would be 'OT'!

Well not OT over there I assume! But I guess this is getting OT here
already.
Yes, I've seen that project but not tried it.

Perhaps you might find the demo file that acts as an extended 'Project
Explorer' handy!
I don't see how a treeview can also be used as a listview (or am I
misunderstanding you), but I can do similar as both with my Spread.ocx.

If the listview only contains a single column it has the same appearance and
in effect functionality as a treeview that has multiple root nodes but no
branches. Only reason to use a listview in such a case is for it's
capability to add icons to items, as can do with a treeview.

Regards,
Peter T
 
G

GS

GS said:
snip

But can't compile a dll as 64bit, 32bit only. It's not Win64 that's
the problem but Office64.

MSOx64 uses VBA7 for both 32/64 bit versions. This is not an issue!

MSOx64 needs x64 DLLs AFAIK! That excludes using VB6 DLLs all
together!!
Well not OT over there I assume! But I guess this is getting OT here
already.
Absolutely!

Perhaps you might find the demo file that acts as an extended
'Project Explorer' handy!


If the listview only contains a single column it has the same
appearance and in effect functionality as a treeview that has
multiple root nodes but no branches. Only reason to use a listview in
such a case is for it's capability to add icons to items, as can do
with a treeview.

Ah! So it's the other way around; using listview as a treeview! I don't
think the icon factor makes this worth the trouble for displaying data
in a VBA userform.

Please have a look at my listbox-based example when I'm done with it.
Though Charlotte's usage only includes 4 fields of data, it can handle
as many fields as a listbox max ColumnCount. This should be more than
ample for a database solution that's flat-table text file based, and
uses standard VB file I/O functions. IMO, that's as simple as it gets
for working with smaller amounts of data. If it does grow large it can
be easily 'dumped' into a SQLite db file and worked with via ADODB.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
P

Peter T

GS said:
Ah! So it's the other way around; using listview as a treeview! I don't
think the icon factor makes this worth the trouble for displaying data in
a VBA userform.

No, use a treeview to resemble a listview, albeit for the limited purpose I
described (and can't use aX/ocx controls)
Please have a look at my listbox-based example when I'm done with it.
Though Charlotte's usage only includes 4 fields of data, it can handle as
many fields as a listbox max ColumnCount. This should be more than ample
for a database solution that's flat-table text file based, and uses
standard VB file I/O functions. IMO, that's as simple as it gets for
working with smaller amounts of data. If it does grow large it can be
easily 'dumped' into a SQLite db file and worked with via ADODB.

Can you point me to where it is (or again if as I assume it's linked
somewhere in this long thread!)

Regards,
Peter T
 
G

GS

GS said:
No, use a treeview to resemble a listview, albeit for the limited
purpose I described (and can't use aX/ocx controls)


Can you point me to where it is (or again if as I assume it's linked
somewhere in this long thread!)

I'll be posting a download link (in this thread) for Charlotte *when
I'm done with it*! (As I said, I couldn't find my original project so
I'm redoing it from scratch)

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
C

Charlotte E.

Wow, I'd really started something here, haven't I? :)

Really looking forward to your solution...
....the solution I'm trying to implement is to look up the individual RGB
values, within the function itself - not 'smart' or pretty, but it is as
fast as my skills will take me :)


Thanks for all your inputs ans suggestions.

CE


GS said:
I'll be posting a download link (in this thread) for Charlotte *when I'm
done with it*! (As I said, I couldn't find my original project so I'm
redoing it from scratch)

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
G

GS

What's important is that your solutions meets your needs!

Since I don't have a need for this, I decided to make a generic utility
named "Color Name Manager" that has the following features:

allows you to add, edit, remove, and rename color name data;
uses a comma delimited text file as its data storage;
manages data with standard VB file I/O functions and arrays;
is dialog based;
creates its own menuitem;
has task specific context management for user action controls;
has a simple help system;
finds RGB values for a given name;
finds (existing) names for RGB values;

It's an XLS with its 'IsAddin' property set True so it's hidden when
open, but could be saved as XLA if desired. On first startup it
notifies user of menuitem location in both early/late versions. Also,
the VBA project (2 userforms, 2 modules) is accessible for modifying.

I still have the Rename feature to finish plus write the Help text.
Sorry it's taking longer than initially expected, but I seem to have
discarded my initial listbox based data form sample and so had to start
from scratch!<g> I'll keep pluging away at it between other obligations
so it gets done sooner than later, and 'off my plate' for now. Perhaps
we can swap projects<g>?

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
P

Peter T

GS said:
What's important is that your solutions meets your needs!

Since I don't have a need for this, I decided to make a generic utility
named "Color Name Manager" that has the following features:

allows you to add, edit, remove, and rename color name data;
uses a comma delimited text file as its data storage;
manages data with standard VB file I/O functions and arrays;
is dialog based;
creates its own menuitem;
has task specific context management for user action controls;
has a simple help system;
finds RGB values for a given name;
finds (existing) names for RGB values;

Wow, all that for a simple colour match algorithm, and you said I added too
much fluff! <vbg>

Charlotte, if all you want to do is get the name of the colour that best
matches your RGB see the example I included in my second post in this
thread. It does exactly that using a simple "linear" calculation and
replicates the javascript demo you referred to. It should be straightforward
to adapt to your requirements.

Regards,
Peter T
 
G

GS

Wow, all that for a simple colour match algorithm, and you said I
added too much fluff! <vbg>

It's not a simple colour match algorithm!
The development of this utility was inspired by your explanation of the
time/effort you put into your project!

There's no 'fluff' in my project; it just reflects its name in terms of
features which fit what the name implies. It's being released as a
'finished product' and so requires the effort necessary to that, IMO!
It also writes the data to a worksheet named range and so can be used
in a lookup formula if desired.

What do you think a "Color Name *Manager*" utility should do?<g>

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
G

GS

Just curious, Peter, about where you are located having used this
spelling...

colour

...as I'm located in eastern Ontario, Canada but I use/speak enUS!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
P

Peter T

GS said:
It's not a simple colour match algorithm!

Sorry I misunderstood, read it as all intended as a solution for Charlotte's
Q
What do you think a "Color Name *Manager*" utility should do?<g>

There's no simple answer because it depends on peoples' objectives, and with
colour match would probably be diverse. But like anything as a minimum a
means to input and store data, input the query, process, and output, all
with a suitable UI.

There could be more than one list of colours, typically they range from as
few as 40 to 1000+ colours. Maybe provide links to samples.

A sheet is ideal for colours because you can store all the various
attributes (RGB, Hex, HSL, name, etc) in cells and display each colour (in
2003 coloured shapes as cells can only display 56 colours). Or for display
only could also show each colour in a form in a variety of ways and retrieve
from elsewhere.

Input the colour to match, consider how, or maybe a coloured pixel 'picked'
from the screen.

Output the matched colour, its name and specs, to the form, perhaps to the
clipboard too.

As I mentioned my old app included a colour match utility as a small feature
of a much larger range of colour related stuff.

Regards,
Peter T
 
P

Peter T

GS said:
Just curious, Peter, about where you are located having used this
spelling...

colour

..as I'm located in eastern Ontario, Canada but I use/speak enUS!

UK, ie English-English!
 
G

GS

There's no simple answer because it depends on peoples' objectives,
and with colour match would probably be diverse. But like anything as
a minimum a means to input and store data, input the query, process,
and output, all with a suitable UI.

And so is why I'm putting all the effort into it as a finished product!
There could be more than one list of colours, typically they range
from as few as 40 to 1000+ colours. Maybe provide links to samples.

A sheet is ideal for colours because you can store all the various
attributes (RGB, Hex, HSL, name, etc) in cells and display each
colour (in 2003 coloured shapes as cells can only display 56
colours). Or for display only could also show each colour in a form
in a variety of ways and retrieve from elsewhere.

It's just displaying RGB as BackColor of a label. The code verifies if
a new entry (or edited listitem) already has the RGB values OR name
entered.

I found this was a needed feature since Charlotte's link color names
list has, for example, both "Aqua" and "Cyan" with the same RGB values.
Thus I've 'removed' "Cyan" for now since it's a standard color. (the
list should only have non-standard names to start with, IMO, leaving
inclusions up to the end user)

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
P

Peter T

GS said:
I found this was a needed feature since Charlotte's link color names list
has, for example, both "Aqua" and "Cyan" with the same RGB values. Thus
I've 'removed' "Cyan" for now since it's a standard color. (the list
should only have non-standard names to start with, IMO, leaving inclusions
up to the end user)

Why only non standard names, isn't that for the user to decide. If there are
duplicates maybe return both, eg return "Aqua = Cyan". Indeed it's not
unusual for colour lists to include 2+ names that refer to the same RGB, and
in the case of this list there are are many duplicates besides cyan.
 
P

Peter T

GS said:
Nice! How do you like living in the midst of all that UK history?

Old!

Only kidding, I appreciate having a sense of history around. Not always
though, I arrived once in one particular country in the middle of troubles
and asked a local to explain the background, and was told "need to go back
3500 years and work forwards to begin to understand..." it took a long time!
(too OT for here)
 
G

GS

GS said:
Why only non standard names, isn't that for the user to decide. If
there are duplicates maybe return both, eg return "Aqua = Cyan".
Indeed it's not unusual for colour lists to include 2+ names that
refer to the same RGB, and in the case of this list there are are
many duplicates besides cyan.

As you say, it's up to the user to decide. I'm talking about the
initial startup list I provide with the utility. *I prefer* to not
include standard colors already in the standard palette. Thus users can
add them if they want them included in the db, and/or
edit/remove/rename existing colors to their liking! The intent is to
supply a 'starter list' only. (I'm just treating it as 'dummy
data'!<g>)

The reason is that we all see the standard colors differently, so how
Red appears to me doesn't necessarily match how it appears to you.
Custom named RGB values are already how that respective color appears
someone else, not necessarily how it appears to the user of this
utility(IMO).

I haven't deliberately looked for other duplicates because that's not
on my agenda. This I'm leaving up to the user! If a matching name
and/or RGB is encountered the user is notified and prompted for how
they want to handle their input values when adding/editing data.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top