File: lclmessageglue.pas

package info (click to toggle)
lazarus 2.0.10%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 219,188 kB
  • sloc: pascal: 1,867,962; xml: 265,716; cpp: 56,595; sh: 3,005; java: 609; makefile: 568; perl: 297; sql: 222; ansic: 137
file content (1166 lines) | stat: -rw-r--r-- 62,976 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
{ $Id: lclmessageglue.pas 57496 2018-03-10 16:32:56Z mattias $ }
{
 *****************************************************************************
 *                              LCLMessageGlue.pas                           *
 *                              ------------------                           *
 *                                                                           *
 *                                                                           *
 *****************************************************************************

 *****************************************************************************
  This file is part of the Lazarus Component Library (LCL)

  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************

 Abstract:
  A Unit to make the passing of messages to the LCL from the different
  widgetsets easier. Your mileage will vary if you try to use these procs
  from within your program.

}
unit LCLMessageGlue;

{$MODE objfpc}{$H+}

interface

uses
  Classes, Forms, LCLClasses, LCLProc, Controls, Messages, LMessages, LCLType;

function DeliverMessage(const Target: TObject; var AMessage): PtrInt;
function SendSimpleMessage(const Target: TControl; Msg: Cardinal): PtrInt;

function LCLSendActivateMsg(const Target: TControl; Active: Word; Minimized: Boolean; ActiveWindow: HWND = 0): PtrInt;
function LCLSendSetFocusMsg(const Target: TControl): PtrInt;
function LCLSendKillFocusMsg(const Target: TControl): PtrInt;
function LCLSendShowWindowMsg(const Target: TControl; Show: Boolean; Status: LPARAM = 0): PtrInt;
function LCLSendSizeMsg(const Target: TControl; Width, Height: Word; SizeType: Longint; FromInterface: Boolean = True): PtrInt;
function LCLSendMoveMsg(const Target: TControl; XPos, YPos: SmallInt; MoveType: PtrInt = Move_Default; FromInterface: Boolean = True): PtrInt;
function LCLSendMouseMoveMsg(const Target: TControl; XPos, YPos: SmallInt; ShiftState: TShiftState = []): PtrInt;
function LCLSendMouseDownMsg(const Target: TControl; XPos, YPos: SmallInt; Button: TMouseButton; ShiftState: TShiftState = []): PtrInt;
function LCLSendMouseUpMsg(const Target: TControl; XPos, YPos: SmallInt; Button: TMouseButton; ShiftState: TShiftState = []): PtrInt;
function LCLSendMouseWheelMsg(const Target: TControl; XPos, YPos, WheelDelta: SmallInt; ShiftState: TShiftState = []): PtrInt;
function LCLSendCaptureChangedMsg(const Target: TControl): PtrInt;
function LCLSendSelectionChangedMsg(const Target: TControl): PtrInt;
function LCLSendDestroyMsg(const Target: TControl): PtrInt;
function LCLSendChangedMsg(const Target: TControl; ItemIndex: WPARAM = 0): PtrInt;
function LCLSendClickedMsg(const Target: TControl): PtrInt;
function LCLSendMouseEnterMsg(const Target: TControl): PtrInt;
function LCLSendMouseLeaveMsg(const Target: TControl): PtrInt;
function LCLSendSetEditableMsg(const Target: TControl): PtrInt;
function LCLSendMoveWordMsg(const Target: TControl): PtrInt;
function LCLSendMovePageMsg(const Target: TControl): PtrInt;
function LCLSendMoveToRowMsg(const Target: TControl): PtrInt;
function LCLSendMoveToColumnMsg(const Target: TControl): PtrInt;
function LCLSendKillCharMsg(const Target: TControl): PtrInt;
function LCLSendKillWordMsg(const Target: TControl): PtrInt;
function LCLSendKillLineMsg(const Target: TControl): PtrInt;
function LCLSendCutToClipboardMsg(const Target: TControl): PtrInt;
function LCLSendCopyToClipboardMsg(const Target: TControl): PtrInt;
function LCLSendPasteFromClipboardMsg(const Target: TControl): PtrInt;
function LCLSendConfigureEventMsg(const Target: TControl): PtrInt;
function LCLSendPaintMsg(const Target: TControl;const  DC: HDC; const PaintStruct: PPaintStruct): PtrInt;
function LCLSendEraseBackgroundMsg(const Target: TWinControl;const  DC: HDC): PtrInt;
function LCLSendKeyDownEvent(const Target: TControl; var CharCode: Word; KeyData: PtrInt; BeforeEvent, IsSysKey: Boolean): PtrInt;
function LCLSendKeyUpEvent(const Target: TControl; var CharCode: Word; KeyData: PtrInt; BeforeEvent, IsSysKey: Boolean): PtrInt;
function LCLSendCharEvent(const Target: TControl; var CharCode: Word; KeyData: PtrInt; BeforeEvent, IsSysKey, ANotifyUserInput: Boolean): PtrInt;
function LCLSendUTF8KeyPress(const Target: TWinControl; AUTF8Char: TUTF8Char; IsSysKey: Boolean): PtrInt;
function LCLSendTimerMsg(const Target: TControl; TimerID: WParam; TimerProc: LParam): PtrInt;
function LCLSendExitMsg(const Target: TControl): PtrInt;
function LCLSendCloseQueryMsg(const Target: TControl): PtrInt;
function LCLSendDragStartMsg(const Target: TControl): PtrInt;
function LCLSendMonthChangedMsg(const Target: TControl): PtrInt;
function LCLSendYearChangedMsg(const Target: TControl): PtrInt;
function LCLSendDayChangedMsg(const Target: TControl): PtrInt;
function LCLSendMouseMultiClickMsg(const Target: TControl; XPos, YPos: SmallInt; Button: TMouseButton; ClickCount: Byte = 2; ShiftState: TShiftState = []): PtrInt;
function LCLSendDrawListItemMsg(const Target: TControl; const DrawListItemStruct: PDrawListItemStruct): PtrInt;
function LCLSendDropDownMsg(const Target: TControl): PtrInt;
function LCLSendCloseUpMsg(const Target: TControl): PtrInt;

implementation

type
  TWinControlAccess = class(TWinControl)
  end;

function DeliverMessage(const Target: TObject; var AMessage): PtrInt;
var
  RefCounted: Boolean;
begin
  if Target=nil then DebugLn('[DeliverMessage] Target = nil');
  {$IFDEF VerboseDeliverMessage}
  if  (TLMessage(AMessage).Msg <>LM_MOUSEMOVE)
    and (TLMessage(AMessage).Msg <>LM_PAINT)
    and (TLMessage(AMessage).Msg <>LM_KEYDOWN)
    and (TLMessage(AMessage).Msg <>LM_KEYUP)
    and (TLMessage(AMessage).Msg <> CN_KEYDOWN ) then
    DebugLn('DeliverMessage ',DbgS(Target),
    ' ',TComponent(Target).Name,':',TObject(Target).ClassName,
    ' Message=',GetMessageName(TLMessage(AMessage).Msg));
  {$ENDIF}
  RefCounted := False;
  try
    try
      if Target is TLCLComponent then
      begin
        TLCLComponent(Target).IncLCLRefCount;
        RefCounted := True;
      end;
      if Target is TControl then
        TControl(Target).WindowProc(TLMessage(AMessage))
      else
        Target.Dispatch(TLMessage(AMessage));
    except
      Application.HandleException(nil);
    end;
  finally
    if RefCounted then
      TLCLComponent(Target).DecLCLRefCount;
  end;
  Result := TLMessage(AMessage).Result;
end;

{******************************************************************************
 *                                                                            *
 *  SendSimpleMessage                                                         *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the simple message            *
 *  Msg         : Message type constant                                       *
 *                                                                            *
 ******************************************************************************}
function SendSimpleMessage(const Target: TControl; Msg: Cardinal): PtrInt;
var
  Mess : TLMessage;
begin
  FillChar(Mess,SizeOf(Mess),0);
  Mess.Msg := Msg;
  Result := DeliverMessage(Target,  Mess);
end;


{******************************************************************************
 *                                                                            *
 *  LCLSendActivateMsg                                                        *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_ACTIVATE       *
 *  Active      : Set to True.  This is currently ignored                     *
 *  Minimized   : Set to False. This is currently ignored                     *
 *  ActiveWindow: Optional. Pass the handle of the currently or newly         *
 *                active window                                               *
 *                                                                            *
 ******************************************************************************}
function LCLSendActivateMsg(const Target: TControl; Active: Word; Minimized: Boolean; ActiveWindow: HWND = 0): PtrInt;
var
  Mess: TLMActivate;
begin
  Result := 0;
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := LM_ACTIVATE;
  Mess.Active := Active;
  Mess.Minimized := Minimized;
  Mess.ActiveWindow := ActiveWindow;
  Result := DeliverMessage(Target, Mess);
end;


{******************************************************************************
 *                                                                            *
 *  LCLSendSetFocusMessage                                                    *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_SETFOCUS       *
 *                                                                            *
 ******************************************************************************}
function LCLSendSetFocusMsg(const Target: TControl): PtrInt;
begin
  Result:=SendSimpleMessage(Target, LM_SETFOCUS);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendKillFocusMessage                                                   *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_KILLFOCUS      *
 *                                                                            *
 ******************************************************************************}
function LCLSendKillFocusMsg(const Target: TControl): PtrInt;
begin
  Result:=SendSimpleMessage(Target, LM_KILLFOCUS);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendShowWindowMsg                                                      *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_SHOWWINDOW     *
 *  Show        : Set to True if Showing the window False otherwise           *
 *  Status      : Usually zero. Set to non-zero if the message was generated  *
 *                by another window showing or hiding.                        *
 *                                                                            *
 ******************************************************************************}
function LCLSendShowWindowMsg(const Target: TControl; Show: Boolean;
  Status: LPARAM = 0): PtrInt;
var
   Mess : TLMShowWindow;
begin
  FillChar(Mess,SizeOf(Mess),0);
  Mess.Msg := LM_SHOWWINDOW;
  Mess.Show := True;

  Result := DeliverMessage(Target, Mess);
end;

{******************************************************************************
 *                                                                            *
 * LCLSendSizeMsg                                                             *
 *                                                                            *
 * Returns       : 0 to accept the message, non-zero to reject the message    *
 *                                                                            *
 * Params                                                                     *
 *                                                                            *
 * Target        : The Control that will recieve the message LM_SIZE          *
 * Width, Height : The new Width and Height for the control                   *
 * SizeType      : SIZE_RESTORED, SIZE_MINIMIZED, SIZE_MAXIMIZED,...          *
 * FromInterface : True if this message was sent from the widgetset to notify *
 *                 the LCL of a change.  False to make the widgetset change   *
 *                 the size of the control. Default = True                    *
 *                                                                            *
 ******************************************************************************}
function LCLSendSizeMsg(const Target: TControl; Width, Height: Word;
  SizeType: Longint; FromInterface: Boolean = True): PtrInt;
var
  Mess: TLMSize;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := LM_SIZE;
  Mess.Width := Width;
  Mess.Height := Height;
  Mess.SizeType := SizeType;
  if FromInterface then
    Mess.SizeType := Mess.SizeType or Size_SourceIsInterface;
    
  Result := DeliverMessage(Target, Mess);
end;


{******************************************************************************
 *                                                                            *
 * LCLSendMoveMsg                                                             *
 *                                                                            *
 * Returns       : 0 to accept the message, non-zero to reject the message    *
 *                                                                            *
 * Params                                                                     *
 *                                                                            *
 * Target        : The Control that will recieve the message LM_MOVE          *
 * XPos, YPos    : The new Top and Left for the control                       *
 * MoveType      : Move_Default = update, 1 = force RequestAlign              *
 * FromInterface : True if this message was sent from the widgetset to notify *
 *                 the LCL of a change.  False to make the widgetset change   *
 *                 the position of the control. Default = True                *
 *                                                                            *
 ******************************************************************************}
function LCLSendMoveMsg(const Target: TControl; XPos, YPos: SmallInt;
  MoveType: PtrInt = Move_Default; FromInterface: Boolean = True): PtrInt;
var
  Mess: TLMMove;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := LM_MOVE;
  Mess.XPos := XPos;
  Mess.YPos := YPos;
  Mess.MoveType := MoveType;
  if FromInterface then
    Mess.MoveType := Mess.MoveType or Move_SourceIsInterface;
    
  Result := DeliverMessage(Target, Mess);
end;


{******************************************************************************
 *                                                                            *
 * LCLSendMouseMoveMsg                                                        *
 *                                                                            *
 * Returns       : 0 to accept the message, non-zero to reject the message    *
 *                                                                            *
 * Params                                                                     *
 *                                                                            *
 * Target        : The Control that will recieve the message LM_SIZE          *
 * XPos, YPos    : The Mouses X and Y position relative to the control.       *
 * ShiftState    : Modifier keys that are pressed at the time of the event    *
 *                                                                            *
 ******************************************************************************}
function LCLSendMouseMoveMsg(const Target: TControl; XPos, YPos: SmallInt;
  ShiftState: TShiftState = []): PtrInt;
var
  Mess: TLMMouseMove;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := LM_MouseMove;
  Mess.XPos := XPos;
  Mess.YPos := YPos;

  Mess.Keys := ShiftStateToKeys(ShiftState);

  Result := DeliverMessage(Target, Mess);
end;


{******************************************************************************
 *                                                                            *
 * LCLSendMouseDownMsg                                                        *
 *                                                                            *
 * Returns       : 0 to accept the message, non-zero to reject the message    *
 *                                                                            *
 * Params                                                                     *
 *                                                                            *
 * Target        : The Control that will recieve the message LM_xBUTTONDOWN   *
 * XPos, YPos    : The Mouses X and Y position relative to the control.       *
 * Button        : TMouseButton (mbLeft, mbMiddle, mbRight)                   *
 * ShiftState    : Modifier keys that are pressed at the time of the event    *
 *                                                                            *
 ******************************************************************************}
function LCLSendMouseDownMsg(const Target: TControl; XPos, YPos: SmallInt;
  Button: TMouseButton; ShiftState: TShiftState = []): PtrInt;
var
  Mess: TLMMouse;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  case Button of
    mbLeft   : Mess.Msg := LM_LBUTTONDOWN;
    mbMiddle : Mess.Msg := LM_MBUTTONDOWN;
    mbRight  : Mess.Msg := LM_RBUTTONDOWN;
    mbExtra1 : Mess.Msg := LM_XBUTTONDOWN;
    mbExtra2 : Mess.Msg := LM_XBUTTONDOWN;
  end;

  Mess.XPos := XPos;
  Mess.YPos := YPos;

  Mess.Keys := ShiftStateToKeys(ShiftState);

  Result := DeliverMessage(Target, Mess);
end;

{******************************************************************************
 *                                                                            *
 * LCLSendMouseUpMsg                                                          *
 *                                                                            *
 * Returns       : 0 to accept the message, non-zero to reject the message    *
 *                                                                            *
 * Params                                                                     *
 *                                                                            *
 * Target        : The Control that will recieve the message LM_xBUTTONUP     *
 * XPos, YPos    : The Mouses X and Y position relative to the control.       *
 * Button        : TMouseButton (mbLeft, mbMiddle, mbRight)                   *
 * ShiftState    : Modifier keys that are pressed at the time of the event    *
 *                                                                            *
 ******************************************************************************}
function LCLSendMouseUpMsg(const Target: TControl; XPos, YPos: SmallInt;
  Button: TMouseButton; ShiftState: TShiftState): PtrInt;
var
  Mess: TLMMouse;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  case Button of
    mbLeft   : Mess.Msg := LM_LBUTTONUP;
    mbMiddle : Mess.Msg := LM_MBUTTONUP;
    mbRight  : Mess.Msg := LM_RBUTTONUP;
    mbExtra1 : Mess.Msg := LM_XBUTTONUP;
    mbExtra2 : Mess.Msg := LM_XBUTTONUP;
  end;

  Mess.XPos := XPos;
  Mess.YPos := YPos;

  Mess.Keys := ShiftStateToKeys(ShiftState);

  Result := DeliverMessage(Target, Mess);
end;

{******************************************************************************
 *                                                                            *
 * LCLSendMouseWheelMsg                                                       *
 *                                                                            *
 * Returns       : 0 to accept the message, non-zero to reject the message    *
 *                                                                            *
 * Params                                                                     *
 *                                                                            *
 * Target        : The Control that will recieve the message LM_xBUTTONUP     *
 * XPos, YPos    : The Mouses X and Y position relative to the control.       *
 * WheelDelta    : -1 for Up, 1 for Down                                      *
 * ShiftState    : Modifier keys that are pressed at the time of the event    *
 *                                                                            *
 ******************************************************************************}
function LCLSendMouseWheelMsg(const Target: TControl; XPos, YPos,
  WheelDelta: SmallInt; ShiftState: TShiftState): PtrInt;
var
  Mess: TLMMouseEvent;
begin
  FillChar(Mess, SizeOf(Mess), 0);

  Mess.Msg := LM_MOUSEWHEEL;
  Mess.X := XPos;
  Mess.Y := YPos;
  Mess.WheelDelta := WheelDelta;
  Mess.State := ShiftState;

  Result := DeliverMessage(Target, Mess);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendCaptureChangedMsg                                                  *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_CAPTURECHANGED *
 *                                                                            *
 ******************************************************************************}
function LCLSendCaptureChangedMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_CAPTURECHANGED);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendSelectionChangedMsg                                                *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_SELCHANGE      *
 *                                                                            *
 ******************************************************************************}
function LCLSendSelectionChangedMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_SELCHANGE);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendSelectionChangedMsg                                                *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_DESTROY        *
 *                                                                            *
 ******************************************************************************}
function LCLSendDestroyMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_DESTROY);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendChangedMsg                                                         *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_CHANGED        *
 *  ItemIndex   : Only used by Listviews and CheckBoxes. The Index of         *
 *                the Item that has changed.                                  *
 *                                                                            *
 ******************************************************************************}
function LCLSendChangedMsg(const Target: TControl; ItemIndex: WPARAM = 0): PtrInt;
var
  Mess: TLMessage;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := LM_CHANGED;
  Mess.WParam := ItemIndex;
  Result := DeliverMessage(Target, Mess);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendClickedMsg                                                         *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_CLICKED        *
 *                                                                            *
 ******************************************************************************}
function LCLSendClickedMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_CLICKED);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendMouseEnterMsg                                                      *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message CM_MOUSEENTER     *
 *                                                                            *
 ******************************************************************************}
function LCLSendMouseEnterMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, CM_MOUSEENTER);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendMouseLeaveMsg                                                      *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message CM_MOUSELEAVE     *
 *                                                                            *
 *                                                                            *
 ******************************************************************************}
function LCLSendMouseLeaveMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, CM_MOUSELEAVE);
end;


{******************************************************************************
 *                                                                            *
 *  LCLSendSetEditableMsg                                                     *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_SETEDITABLE    *
 *                                                                            *
 *  Not used by the LCL                                                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendSetEditableMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_SETEDITABLE);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendMoveWordMsg                                                        *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_MOVEWORD       *
 *                                                                            *
 *  Not used by the LCL                                                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendMoveWordMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_MOVEWORD);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendMovePageMsg                                                        *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_MOVEPAGE       *
 *                                                                            *
 *  Not used by the LCL                                                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendMovePageMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_MOVEPAGE);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendMoveToRowMsg                                                       *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_MOVETOROW      *
 *                                                                            *
 *  Not used by the LCL                                                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendMoveToRowMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_MOVETOROW);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendMoveToColumnMsg                                                    *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_MOVETOCOLUMN   *
 *                                                                            *
 *  Not used by the LCL                                                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendMoveToColumnMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_MOVETOCOLUMN);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendKillCharMsg                                                        *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_KILLCHAR       *
 *                                                                            *
 *  Not used by the LCL                                                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendKillCharMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_KILLCHAR);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendKillWordMsg                                                        *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_KILLWORD       *
 *                                                                            *
 *  Not used by the LCL                                                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendKillWordMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_KILLWORD);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendKillLineMsg                                                        *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_KILLLINE       *
 *                                                                            *
 *  Not used by the LCL                                                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendKillLineMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_KILLLINE);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendCutToClipboardMsg                                                  *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_CUT            *
 *                                                                            *
 ******************************************************************************}
function LCLSendCutToClipboardMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_CUT);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendCopyToClipboardMsg                                                 *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_COPY           *
 *                                                                            *
 ******************************************************************************}
function LCLSendCopyToClipboardMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_COPY);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendPasteFromClipboardMsg                                              *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_COPY           *
 *                                                                            *
 ******************************************************************************}
function LCLSendPasteFromClipboardMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_PASTE);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendConfigureEventMsg                                                  *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_CONFIGUREEVENT *
 *                                                                            *
 *  Not used by the LCL                                                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendConfigureEventMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_CONFIGUREEVENT);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendPaintMsg                                                           *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_PAINT          *
 *  DC          : This is the Device Context                                  *
 *  PaintStruct : PaintStruct                                                 *
 *                                                                            *
 ******************************************************************************}
function LCLSendPaintMsg(const Target: TControl;const  DC: HDC; const PaintStruct: PPaintStruct): PtrInt;
var
  Mess: TLMPaint;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := LM_PAINT;
  Mess.DC := DC;
  Mess.PaintStruct := PaintStruct;
  
  Result := DeliverMessage(Target, Mess);
end;

function LCLSendEraseBackgroundMsg(const Target: TWinControl; const DC: HDC): PtrInt;
var
  Mess: TLMEraseBkgnd;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := LM_ERASEBKGND;
  Mess.DC := DC;

  Include(TWinControlAccess(Target).FWinControlFlags, wcfEraseBackground);
  Result := DeliverMessage(Target, Mess);
  Exclude(TWinControlAccess(Target).FWinControlFlags, wcfEraseBackground);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendKeyDownEvent                                                       *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message xx_xxKEYDOWN      *
 *  CharCode    : This is the VK Key code. Check if this has changed after    *
 *                sending the message.                                        *
 *  KeyData     : Bitwise or'ed combination of the KF_xxxx constants.         *
 *  BeforeEvent : True if we are sending the message before the widgetset     *
 *                has handled the keystroke. False otherwise                  *
 *  IsSysKey    : True if the Alt Key was also pressed.                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendKeyDownEvent(const Target: TControl; var CharCode: Word;
  KeyData: PtrInt; BeforeEvent, IsSysKey: Boolean): PtrInt;
var
  Mess: TLMKeyDown;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  if BeforeEvent then begin
    if IsSysKey then
      Mess.Msg := CN_SYSKEYDOWN
    else Mess.Msg := CN_KEYDOWN;
  end
  else begin
    if IsSysKey then
      Mess.Msg := LM_SYSKEYDOWN
    else Mess.Msg := LM_KEYDOWN;
  end;
  Mess.CharCode := CharCode;
  Mess.KeyData := KeyData;
  Result := DeliverMessage(Target, Mess);
  CharCode := Mess.CharCode;
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendKeyUpEvent                                                         *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message xx_xxKEYUP        *
 *  CharCode    : This is the VK Key code. Check if this has changed after    *
 *                sending the message.                                        *
 *  KeyData     : Bitwise or'ed combination of the KF_xxxx constants.         *
 *  BeforeEvent : True if we are sending the message before the widgetset     *
 *                has handled the keystroke. False otherwise.                 *
 *  IsSysKey    : True if the Alt Key was also pressed.                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendKeyUpEvent(const Target: TControl; var CharCode: Word;
  KeyData: PtrInt; BeforeEvent, IsSysKey: Boolean): PtrInt;
var
  Mess: TLMKeyUp;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  if BeforeEvent then begin
    if IsSysKey then
      Mess.Msg := CN_SYSKEYUP
    else Mess.Msg := CN_KEYUP;
  end
  else begin
    if IsSysKey then
      Mess.Msg := LM_SYSKEYUP
    else Mess.Msg := LM_KEYUP;
  end;
  Mess.CharCode := CharCode;
  Mess.KeyData := KeyData;
  Result := DeliverMessage(Target, Mess);
  CharCode := Mess.CharCode;
end;

function LCLSendCharEvent(const Target: TControl; var CharCode: Word;
  KeyData: PtrInt; BeforeEvent, IsSysKey, ANotifyUserInput: Boolean): PtrInt;
var
  Mess: TLMChar;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  if BeforeEvent then begin
    if IsSysKey then
      Mess.Msg := CN_SYSCHAR
    else Mess.Msg := CN_CHAR;
  end
  else begin
    if IsSysKey then
      Mess.Msg := LM_SYSCHAR
    else Mess.Msg := LM_CHAR;
  end;
  Mess.CharCode := CharCode;
  Mess.KeyData := KeyData;
  Result := DeliverMessage(Target, Mess);
  CharCode := Mess.CharCode;

  if ANotifyUserInput then NotifyApplicationUserInput(Target, Mess.Msg);
end;

function LCLSendUTF8KeyPress(const Target: TWinControl; AUTF8Char: TUTF8Char;
  IsSysKey: Boolean): PtrInt;
begin
  {if not IsControlKey then}
  Target.IntfUTF8KeyPress(AUTF8Char, 1, IsSysKey);
  Result := 1;
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendTimerMsg                                                           *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to allow the message to   *
 *                continue to process.                                        *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_TIMER          *
 *  TimerID     : ID of the timer.                                            *
 *  TimerProc   : The procedure to call.                                      *
 *                                                                            *
 ******************************************************************************}
function LCLSendTimerMsg(const Target: TControl; TimerID: WParam;
  TimerProc: LParam): PtrInt;
var
  Mess: TLMessage;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := LM_TIMER;
  Mess.WParam := TimerID;
  Mess.LParam := TimerProc;
  Result:=DeliverMessage(Target, Mess);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendExitMsg                                                            *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_EXIT           *
 *                                                                            *
 *  Not used by the LCL                                                       *
 *                                                                            *
 ******************************************************************************}
function LCLSendExitMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_EXIT);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendCloseQueryMsg                                                      *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_CLOSEQUERY     *
 *                                                                            *
 ******************************************************************************}
function LCLSendCloseQueryMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_CLOSEQUERY);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendDragStartMsg                                                       *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_DRAGSTART      *
 *                                                                            *
 ******************************************************************************}
function LCLSendDragStartMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_DRAGSTART);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendMonthChangedMsg                                                    *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_MONTHCHANGED   *
 *                                                                            *
 ******************************************************************************}
function LCLSendMonthChangedMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_MONTHCHANGED);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendYearChangedMsg                                                     *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_YEARCHANGED    *
 *                                                                            *
 ******************************************************************************}
function LCLSendYearChangedMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_YEARCHANGED);
end;

{******************************************************************************
 *                                                                            *
 *  LCLSendDayChangedMsg                                                      *
 *                                                                            *
 *  Returns     : 0 to accept the message, non-zero to reject the message     *
 *                                                                            *
 *  Params                                                                    *
 *                                                                            *
 *  Target      : The Control that will recieve the message LM_DAYCHANGED     *
 *                                                                            *
 ******************************************************************************}
function LCLSendDayChangedMsg(const Target: TControl): PtrInt;
begin
  Result := SendSimpleMessage(Target, LM_DAYCHANGED);
end;

{******************************************************************************
 *                                                                            *
 * LCLSendMouseMultiClickMsg                                                  *
 *                                                                            *
 * Returns       : 0 to accept the message, non-zero to reject the message    *
 *                                                                            *
 * Params                                                                     *
 *                                                                            *
 * Target        : The Control that will recieve the message LM_xBUTTONxxxCLK *
 * XPos, YPos    : The Mouses X and Y position relative to the control.       *
 * Button        : TMouseButton (mbLeft, mbMiddle, mbRight)                   *
 * ClickCount    : 2 = LM_xBUTTONDBLCLK, 3 = LM_xBUTTONTRIPLECLK,             *
 *                 4 = LM_xBUTTONQUADCLK                                      *
 * ShiftState    : Modifier keys that are pressed at the time of the event    *
 *                                                                            *
 ******************************************************************************}
function LCLSendMouseMultiClickMsg(const Target: TControl; XPos, YPos: SmallInt;
  Button: TMouseButton; ClickCount: Byte = 2; ShiftState: TShiftState = []): PtrInt;
var
  Mess: TLMMouse;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := LM_UNKNOWN;
  case ClickCount of
    2:
    case Button of
      mbLeft   : Mess.Msg := LM_LBUTTONDBLCLK;
      mbMiddle : Mess.Msg := LM_MBUTTONDBLCLK;
      mbRight  : Mess.Msg := LM_RBUTTONDBLCLK;
      mbExtra1 : Mess.Msg := LM_XBUTTONDBLCLK;
      mbExtra2 : Mess.Msg := LM_XBUTTONDBLCLK;
    end;
    3:
    case Button of
      mbLeft   : Mess.Msg := LM_LBUTTONTRIPLECLK;
      mbMiddle : Mess.Msg := LM_MBUTTONTRIPLECLK;
      mbRight  : Mess.Msg := LM_RBUTTONTRIPLECLK;
      mbExtra1 : Mess.Msg := LM_XBUTTONTRIPLECLK;
      mbExtra2 : Mess.Msg := LM_XBUTTONTRIPLECLK;
    end;
    4:
    case Button of
      mbLeft   : Mess.Msg := LM_LBUTTONQUADCLK;
      mbMiddle : Mess.Msg := LM_MBUTTONQUADCLK;
      mbRight  : Mess.Msg := LM_RBUTTONQUADCLK;
      mbExtra1 : Mess.Msg := LM_XBUTTONQUADCLK;
      mbExtra2 : Mess.Msg := LM_XBUTTONQUADCLK;
    end;
  end;
    
  Mess.XPos := XPos;
  Mess.YPos := YPos;

  Mess.Keys := ShiftStateToKeys(ShiftState);

  Result := DeliverMessage(Target, Mess);
end;

{******************************************************************************
 *                                                                            *
 * LCLSendDrawListItemMsg                                                     *
 *                                                                            *
 * Returns       : 0 to accept the message, non-zero to reject the message    *
 *                                                                            *
 * Params                                                                     *
 *                                                                            *
 * Target        : The Control that will recieve the message LM_DRAWLISTITEM  *
 * DrawListItemStruct : Pointer to a TDrawListItemStruct                      *
 *                                                                            *
 ******************************************************************************}
function LCLSendDrawListItemMsg(const Target: TControl; const DrawListItemStruct: PDrawListItemStruct): PtrInt;
var
  Mess: TLMDrawListItem;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := LM_DRAWLISTITEM;
  Mess.DrawListItemStruct := DrawListItemStruct;

  Result := DeliverMessage(Target, Mess);
end;

{******************************************************************************
 *                                                                            *
 * LCLSendDropDownMsg                                                         *
 *                                                                            *
 * Returns       : 0 to accept the message, non-zero to reject the message    *
 *                                                                            *
 * Params                                                                     *
 *                                                                            *
 * Target        : The Control that will recieve the message CN_Command       *
 *                                                                            *
 * Used to notify a combo that the combobox is popping down                   *
 *                                                                            *
 ******************************************************************************}
function LCLSendDropDownMsg(const Target: TControl): PtrInt;
var
  Mess : TLMCommand;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := CN_Command;
  Mess.NotifyCode := CBN_DROPDOWN;

  Result := DeliverMessage(Target, Mess);
end;

function LCLSendCloseUpMsg(const Target: TControl): PtrInt;
var
  Mess : TLMCommand;
begin
  FillChar(Mess, SizeOf(Mess), 0);
  Mess.Msg := CN_Command;
  Mess.NotifyCode := CBN_CLOSEUP;

  Result := DeliverMessage(Target, Mess);
end;


// Remove these lines as you implement the function

{
  LM_ACTIVATEITEM    // NOT USED
  LM_FOCUS           // NOT USED
  LM_SIZEALLOCATE    // NOT USED
  LM_CHECKRESIZE     // NOT USED
  LM_SHOW            // NOT USED
  LM_MOVERESIZE      // NOT USED
  LM_DRAW            // NOT USED
  LM_MOUSEBTNPRESS   // NOT USED
  LM_MOUSEBTNRELEASE // NOT USED
}


end.