Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Additional Controls/TColorBox    [ Add a report in this area ]  
Report #:  35845   Status: Closed
TColorBox.Selected is lost between Create and Form.Show
Project:  Delphi Build #:  10.0.2445.40105
Version:    10.0 Submitted By:   matthias muntwiler
Report Type:  Minor failure / Design problem Date Reported:  10/28/2006 8:43:21 PM
Severity:    Commonly encountered problem Last Updated: 1/9/2010 12:03:40 AM
Platform:    All platforms Internal Tracking #:  
Resolution: Cannot Reproduce (Resolution Comments) Resolved in Build: : Update 2
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
TColorBox does not pass the value of its Selected property to the window control, if Selected is set after creation of the object and before creation of the window control.

from debugging i find that
- PopulateList is called during creation
- Selected is set while the box has no handle
- CreateWnd does not set the item index of the newly created

thus the assignment to Selected is lost.
Steps to Reproduce:
1) create a new application with a main form
1) create a another form for a modal dialog
2) add a TColorBox to the dialog
3) include cbIncludeDefault, cbCustomColor in Style
4) add code to create and show to the parent form. before ShowModal, assign an arbitrary color to ColorBox1.Selected
5) run the application and open the modal form

the apparently selected color is the default color, and not the one assigned in step 4.

Workarounds
create an OnShow handler and toggle the Style property forth and back, e.g.

ColorBox.Style := ColorBox.Style + [cbIncludeNone];
ColorBox.Style := ColorBox.Style - [cbIncludeNone];
Attachment
35845.zip
Comments

Sebastian Modersohn at 10/29/2006 1:43:16 AM -
I have attached a test-case which I created following your steps. This works fine here using BDS 2006 Update 2!
Judging from your build number it seems you don't have Update 2 installed?

Server Response from: ETNACODE01