PDA

Click to See Complete Forum and Search --> : Color in a ComboBox?


Andrew Herrmann
Dec 29th, 1999, 10:35 PM
Is it possible to assign different colors to the different items in a combo box?

Thanks

Aaron Young
Dec 29th, 1999, 10:50 PM
It is if you use Subclassing with the Windows API, for examples, check out my previous answers for a Colored Combobox (http://www.vb-world.net/ubb/Forum1/HTML/012246.html) and a Colored Listbox (http://www.vb-world.net/ubb/Forum1/HTML/009153.html).

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com

Andrew Herrmann
Dec 30th, 1999, 12:06 AM
The colors work ok, but when I unload, I get a "vb 6 has performed an illegal operation".

I have the following lines in my unload event:

'Release the SubClassing, Very Import to Prevent Crashing!
Call SetWindowLong(hwnd, GWL_WNDPROC, lPrevWndProc)

Any ideas?



[This message has been edited by Andrew Herrmann (edited 12-30-1999).]

Aaron Young
Dec 30th, 1999, 12:18 AM
When Subclassing you need to make sure you close the Form properly, don't just hit Stop on the VB Navigation Bar, otherwise the Subclassing Release Code Never Executes causing the GPF.

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com



[This message has been edited by Aaron Young (edited 12-30-1999).]

Andrew Herrmann
Dec 30th, 1999, 01:34 AM
I have a button on my form which when pressed does the following:

unload me

I've verified that my unload event is being triggered (by placing a msgbox inside of it).

Is there a different way that I should be doing this?

Aaron Young
Dec 30th, 1999, 01:53 AM
Did you copy and Paste the Code I posted Exactly, maybe you declared lPrevWndProc Privately and are using a Zero value, when Removing the Subclassing.

If you create a new project, add a Combobox and set the Startup Object to Sub Main and Paste the Code I posted Exactly, it will work.

If you can't get it to work, post your code and I'll take a look.

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com