Mirror

List all app's ctrls & menus in a TTreeView (Views: 107)

{\*\pnseclvl2\pnucltr\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}
{\*\pnseclvl3\pndec\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}
{\*\pnseclvl4\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{)}}}
{\*\pnseclvl5\pndec\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}
{\*\pnseclvl6\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}
{\*\pnseclvl7\pnlcrm\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}
{\*\pnseclvl8\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}
{\*\pnseclvl9\pndec\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}
\endnhere\sectdefaultcl{\footer \pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs22\cf0\i Delphi Knowledge Base (http://dkb.kastu.lt)}}
{\pard\wpparprot{\ql\li195\fi0\ri0\sb0\sl\sa0 \plain\f10\fs22\cf0\b Title: List all app's ctrls & menus in a TTreeView?\par
\wpparprot\ql\li195\fi0\ri0\sb0\sl\sa0 \plain\f10\fs22\cf0\b Author: Martin Gamulin\par
\wpparprot\ql\li195\fi0\ri0\sb0\sl\sa0 \plain\f10\fs22\cf0\b Product: Delphi 6.x (or higher)\par
\wpparprot\ql\li195\fi0\ri0\sb0\sl\sa0 \plain\f10\fs22\cf0\b Post Date: 10/07/2002\par
\wpparprot\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f10\fs22\cf0\b \par
\wpparprot\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f10\fs22\cf0\b\shad Problem/Question/Abstract:\par
\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f1\fs22\cf0\shad \par
}{\*\wptable}{\pard\trowd\trgaph0\trleft0\clvertalc\cellx10772\cellx42\cellx42\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\clbrdrl\brdrs\brdrw0\brsp40\clshdng0\clcbpat16\clcfpat12\cellx42\intbl{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f2\fs24\cf0 How to list all app's ctrls & menus in a TTreeView?\cell}\row
}\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f1\fs22\cf0\shad \par
\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f1\fs22\cf0\b\shad Answer:\par
\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f1\fs22\cf0\shad \par
{\brdrl\brdrs\brdrw0\brsp40\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b uses\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   ComCtrls, Menus, Classes, Forms, Controls, Windows, Messages;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0 \par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b function\plain\f6\fs20\cf0  GetControlCaption(Control: TWinControl): ShortString;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf11\i // Slightly modified version of Twister's Tip\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf11\i //\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf11\i // function GetCaptionAtPoint(pt: TPoint): string;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf11\i //\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b var\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   TextLength: Integer;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   Text: PChar;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b if\plain\f6\fs20\cf0  \plain\f6\fs20\cf0\b not\plain\f6\fs20\cf0  Boolean(Control.Handle) \plain\f6\fs20\cf0\b then\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     Exit;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0 \par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   Result := Control.Name; \plain\f6\fs20\cf11\i // if Control doesn't have Caption\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf11\i // Control.Name is returned\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0 \par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   TextLength := SendMessage(Control.Handle, WM_GETTEXTLENGTH, \plain\f6\fs20\cf11 0\plain\f6\fs20\cf0 , \plain\f6\fs20\cf11 0\plain\f6\fs20\cf0 );\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b if\plain\f6\fs20\cf0  TextLength \plain\f6\fs20\cf11 0\plain\f6\fs20\cf0  \plain\f6\fs20\cf0\b then\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     GetMem(Text, TextLength + \plain\f6\fs20\cf11 1\plain\f6\fs20\cf0 );\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     SendMessage(Control.Handle, WM_GETTEXT, TextLength + \plain\f6\fs20\cf11 1\plain\f6\fs20\cf0 , Integer(Text));\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     Result := Text;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     FreeMem(Text);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0 \par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf11\i // function GetCaptionAtPoint(pt: TPoint): ShortString;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf11\i // begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf11\i // Result:= GetControlCaption(FindVCLWindow(pt));\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf11\i // end;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0 \par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b procedure\plain\f6\fs20\cf0  FindAllMenuItems(AppTree: TTreeView; MenuItem: TMenuItem; Parent:\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   TTreeNode);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b var\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   loop: Integer;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   Node: TTreeNode;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   mItem: TMenuItem;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   Name: ShortString;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b for\plain\f6\fs20\cf0  loop := \plain\f6\fs20\cf11 0\plain\f6\fs20\cf0  \plain\f6\fs20\cf0\b to\plain\f6\fs20\cf0  MenuItem.Count - \plain\f6\fs20\cf11 1\plain\f6\fs20\cf0  \plain\f6\fs20\cf0\b do\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     mItem := MenuItem.Items[loop];\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     Name := mItem.Caption;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     Node := AppTree.Items.AddChildObject(Parent, Name, mItem);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     \plain\f6\fs20\cf0\b if\plain\f6\fs20\cf0  mItem.Count \plain\f6\fs20\cf11 0\plain\f6\fs20\cf0  \plain\f6\fs20\cf0\b then\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0       findAllMenuItems(AppTree, mItem, Node);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0 \par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b procedure\plain\f6\fs20\cf0  FindAllControls(AppTree: TTreeView; Comp: TComponent; Parent: TTreeNode);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b var\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   Child: TComponent;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   loop, start, Index: Integer;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   Name: ShortString;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   Node, Mnode: TTreeNode;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   start := \plain\f6\fs20\cf11 0\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b if\plain\f6\fs20\cf0  Comp \plain\f6\fs20\cf0\b is\plain\f6\fs20\cf0  TApplication \plain\f6\fs20\cf0\b then\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     \plain\f6\fs20\cf11\i // Parent:= AppTree.Items.AddObjectFirst(Parent, 'Application', nil);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     \plain\f6\fs20\cf11\i // if you want to see the root ('Application') uncomment\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     start := \plain\f6\fs20\cf11 1\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0 \par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b for\plain\f6\fs20\cf0  loop := start \plain\f6\fs20\cf0\b to\plain\f6\fs20\cf0  Comp.ComponentCount - \plain\f6\fs20\cf11 1\plain\f6\fs20\cf0  \plain\f6\fs20\cf0\b do\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     Child := Comp.Components[loop];\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     Name := Child.Name;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0 \par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     \plain\f6\fs20\cf0\b if\plain\f6\fs20\cf0  Child \plain\f6\fs20\cf0\b is\plain\f6\fs20\cf0  TControl \plain\f6\fs20\cf0\b then\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     \plain\f6\fs20\cf0\b begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0       \plain\f6\fs20\cf0\b if\plain\f6\fs20\cf0  Child \plain\f6\fs20\cf0\b is\plain\f6\fs20\cf0  TWinControl \plain\f6\fs20\cf0\b then\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0       \plain\f6\fs20\cf0\b begin\plain\f6\fs20\cf0  \plain\f6\fs20\cf11\i // does Child have Caption property??\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0         Name := GetControlCaption(TWinControl(Child));\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0       \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0       Node := AppTree.Items.AddChildObject(Parent, Name, Child);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0       \plain\f6\fs20\cf0\b if\plain\f6\fs20\cf0  Child.ComponentCount \plain\f6\fs20\cf11 0\plain\f6\fs20\cf0  \plain\f6\fs20\cf0\b then\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0         FindAllControls(AppTree, Child, Node);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0 \par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     \plain\f6\fs20\cf0\b if\plain\f6\fs20\cf0  Child \plain\f6\fs20\cf0\b is\plain\f6\fs20\cf0  TMenu \plain\f6\fs20\cf0\b then\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     \plain\f6\fs20\cf0\b begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0       Node := AppTree.Items.AddChildObject(Parent, Name, Child);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0       \plain\f6\fs20\cf0\b for\plain\f6\fs20\cf0  Index := \plain\f6\fs20\cf11 0\plain\f6\fs20\cf0  \plain\f6\fs20\cf0\b to\plain\f6\fs20\cf0  TMenu(Child).Items.Count - \plain\f6\fs20\cf11 1\plain\f6\fs20\cf0  \plain\f6\fs20\cf0\b do\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0       \plain\f6\fs20\cf0\b begin\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0         Mnode := AppTree.Items.AddChildObject(Node, TMenu(Child).Items[Index].Caption,\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0           TMenu(Child).Items[Index]);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0         FindAllMenuItems(AppTree, TMenu(Child).Items[Index], Mnode);\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0       \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0     \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0   \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;\par
\shading0\cbpat16\cfpat12\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f6\fs20\cf0\b end\plain\f6\fs20\cf0 ;}}}
}

<< Back to main page