Board index » delphi » Q: Disabling and yet not Disabling CheckBoxes.....

Q: Disabling and yet not Disabling CheckBoxes.....

Q:  Can I prevent a user from switching the state of a check box, in
effect disabling it, without causing it to "look" diabled/embossed?

I'm using 2 checkboxes to report the type of data record currently pointed
to.  This "type" is determined from a Code field so these are not DB Aware
Checkboxes as I need to parse the appropriate parts from this Code field
first.  I don't like setting their Enabled field to false as Delphi forces
their text to look embossed.  I want them to in every way look active, but
I don't want the user to be able to change their checked status.

My only idea is to use their OnClick even handler and simply reverse their
state.  I'm looking for a better way.  Any ideas?


-- Jim Burns
   Technology Dynamics
   Pearland, Texas


Re:Q: Disabling and yet not Disabling CheckBoxes.....

>My only idea is to use their OnClick even handler and simply reverse their

I don't think this will work at first glance.  I've noticed that the OnClick event
handler is getting called when the status of the checkbox changes.

Why does this happen?

I placed a simple message box inside the OnClick event handler for the checkbox.  
When the data changes as a result of advancing to the next record, I manually set
the status of the checkboxes based on a Code field, for example: MyCheckBox.Checked
:= True.  Yet, this statement also carries me into the OnClick event handler and I
get to see my message box.  I sure didn't expect this.  What is going on here.  
Should not the OnClick event handler be for just that.... Clicks!!  ?   A code
sample follows the body of this message.

Any comments or clarifications are appreciated.

-- Jim Burns
   Technology Dynamics
   Pearland, Texas


procedure TInventoryApp.DataSourceDataChange(Sender: TObject; Field: TField);
  if ItemCode <> 0      then IsItemCheckBox.Checked := True
  else                       IsItemCheckBox.Checked := False;
  if ContainerCode <> 0 then IsContainerCheckBox.Checked := True
  else                       IsContainerCheckBox.Checked := False;



The procedure below is entered when the checkbox states are changed in the
procedure above.  These are the only two functions at this time that modify or
otherwise play with the Checked property of the checkboxes.


procedure TInventoryApp.IsContainerCheckBoxClick(Sender: TObject);
  {Check Edit Mode}
  if EditSwitchSpdBtn.Down then begin                            {Edit Mode}
    {If this is a new record, create new PICKey.}
    {If this is an existing record, we may need to modify the records PICKey}
    MessageDlg('Edit Mode', mtInformation, [mbOk], 0);

  else begin                                                     {View Mode}
    {Checkboxes should not change}
    MessageDlg('View Mode', mtInformation, [mbOk], 0);



Other Threads