Author Topic: Check and Radio box has both Onchange and OnClick, what's the difference?  (Read 303 times)


  • Hero Member
  • *****
  • Posts: 5851
There seems to be a problem with these two as I work between Laz and the other guy's product.

Here, both the Onclick and OnChange are identical in operation, software change or user change.

 So, I decided to look at Dephi's docs if that really matters here, to find I can't connect to their Wiki for some reason, server not responding, and I don't feel like booting up the PC with D on it atm.

 Anyways, I find it ironic that things like this have gone on unchecked, excused the punt, but shouldn't there at least be a MODIFIED property in there to indicate if the changes made are via software or user to make things easier?

 I know all about nullifying the event and then reinstating it, but that is just a stupid step. also, one could simply use the TAG property prior to setting it via software to indicate the operation.
  Shouldn't these controls have the MODIFIED property in it which gets cleared upon entry of the control and cleared when software is making changes to the state, one can examine this property while in one of the events and currently do exactly the same thing. User changes would set this property and keep it as is when the focus leaves the control for later inspection.

The only true wisdom is knowing you know nothing


  • Hero Member
  • *****
  • Posts: 5851
Re: Check and Radio box has both Onchange and OnClick, what's the difference?
« Reply #1 on: September 11, 2023, 04:45:53 am »
This is a Test jig source file to look at..

It's not perfect because I also found that the checkbox still receives keyboard focus when on another control like a Tbutton but it does not generate the keyboard messages. I think this is a little messed up.
But anyways, you can see what I am talking about here.
Btw, I had to use Down events instead of up events because it seems the LCL widget is one operation behind.
Code: Pascal  [Select][+][-]
  2. unit Unit1;
  4. {$mode objfpc}{$H+}
  6. interface
  8. uses
  9.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,Lmessages,lclType;
  11. type
  12. TCheckBox = Class(StdCtrls.TCheckBox)
  13.   Public
  14.   MODIFIED:Boolean;
  15.   Procedure WndProc(Var Msg:TLMessage); Override;
  17. end;
  19.   { TForm1 }
  21.   TForm1 = class(TForm)
  22.     Button1: TButton;
  23.     CheckBox1: TCheckBox;
  24.     CheckBox2: TCheckBox;
  25.     procedure Button1Click(Sender: TObject);
  26.     procedure CheckBox1Click(Sender: TObject);
  27.   private
  29.   public
  31.   end;
  33. var
  34.   Form1: TForm1;
  36. implementation
  38. {$R *.lfm}
  39. Procedure TCheckBox.WndPRoc(Var Msg:TLmessage);
  40. Begin
  41.   Case Msg.Msg Of
  43.     Begin
  44.      Modified := True;
  45.     end;
  46.   LM_SETFOCUS:Begin
  47.              Modified := False;
  48.            End;
  49.   LM_KEYDOWN:IF Msg.WParam=VK_SPACE THen Modified := true;
  50.   end;
  51.  Inherited;
  52. end;
  54. { TForm1 }
  56. procedure TForm1.CheckBox1Click(Sender: TObject);
  57. begin
  58.   If CheckBox1.MODIFIED Then beep;
  59.   CheckBox1.Modified := false;
  60. end;
  62. procedure TForm1.Button1Click(Sender: TObject);
  63. begin
  64.   checkBox1.Checked := not CheckBox1.Checked;
  65. end;
  67. end.
The only true wisdom is knowing you know nothing


TinyPortal © 2005-2018