1{
2 /***************************************************************************
3                                   wsproc.pp
4                                   ---------
5                             Widgetset Utility Code
6
7
8 ***************************************************************************/
9
10 *****************************************************************************
11  This file is part of the Lazarus Component Library (LCL)
12
13  See the file COPYING.modifiedLGPL.txt, included in this distribution,
14  for details about the license.
15 *****************************************************************************
16
17  Useful lower level helper functions and classes for implementing widgetsets.
18}
19unit WSProc;
20
21{$mode objfpc}{$H+}
22{$I lcl_defines.inc}
23
24interface
25
26uses
27  LCLClasses, LCLProc, Controls, Menus;
28
29
30function WSCheckReferenceAllocated(const AComponent: TLCLReferenceComponent;
31                                   const AProcName: String): Boolean;
32
33function WSCheckHandleAllocated(const AWincontrol: TWinControl;
34                                const AProcName: String): Boolean;
35
36function WSCheckHandleAllocated(const AMenu: TMenu;
37                                const AProcName: String): Boolean;
38
39implementation
40
41function WSCheckReferenceAllocated(const AComponent: TLCLReferenceComponent;
42  const AProcName: String): Boolean;
43
44  procedure Warn;
45  begin
46    DebugLn('[WARNING] %s called without reference for %s(%s)', [AProcName, AComponent.Name, AComponent.ClassName]);
47  end;
48begin
49  Result := AComponent.ReferenceAllocated;
50  if Result then Exit;
51  Warn;
52end;
53
54function WSCheckHandleAllocated(const AWincontrol: TWinControl;
55  const AProcName: String): Boolean;
56
57  procedure Warn;
58  begin
59    DebugLn('[WARNING] %s called without handle for %s(%s)', [AProcName, AWincontrol.Name, AWincontrol.ClassName]);
60  end;
61begin
62  Result := AWinControl.HandleAllocated;
63  if Result then Exit;
64  Warn;
65end;
66
67function WSCheckHandleAllocated(const AMenu: TMenu;
68                                const AProcName: String): Boolean;
69  procedure Warn;
70  begin
71    DebugLn('[WARNING] %s called without handle for %s(%s)', [AProcName, AMenu.Name, AMenu.ClassName]);
72  end;
73begin
74  Result := AMenu.HandleAllocated;
75  if Result then Exit;
76  Warn;
77end;
78
79
80end.
81