Advertisement
TLama

Untitled

Apr 9th, 2015
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.37 KB | None | 0 0
  1. [Setup]
  2. AppName=My Program
  3. AppVersion=1.5
  4. DefaultDirName={pf}\My Program
  5.  
  6. [Code]
  7. #ifdef UNICODE
  8.   #define AW "W"
  9. #else
  10.   ANSI Inno Setup is not supported for this script (yet?)!
  11. #endif
  12.  
  13. const
  14.   WS_CHILD = $40000000;
  15.   WS_BORDER = $800000;
  16.   WS_VISIBLE = $10000000;
  17.  
  18.   TVS_HASBUTTONS = $0001;
  19.   TVS_HASLINES = $0002;
  20.   TVS_LINESATROOT = $0004;
  21.  
  22.   TVI_LAST = -65534;
  23.   TVIF_TEXT = $0001;
  24.   TV_FIRST = $1100;
  25.   TVM_INSERTITEMW = TV_FIRST + 50;
  26.   TVM_INSERTITEM = TVM_INSERTITEMW;
  27.   WC_TREEVIEW = 'SysTreeView32';
  28.  
  29. type
  30.   HMENU = THandle;
  31.   LPVOID = PAnsiChar;
  32.   WPARAM = UINT_PTR;
  33.   LPARAM = INT_PTR;
  34.   LRESULT = INT_PTR;
  35.   HINSTANCE = THandle;
  36.   HMODULE = HINSTANCE;
  37.   HTREEITEM = THandle;
  38.  
  39.   TTVItem = record
  40.     mask: UINT;
  41.     hItem: HTREEITEM;
  42.     state: UINT;
  43.     stateMask: UINT;
  44.     pszText: string;
  45.     cchTextMax: Integer;
  46.     iImage: Integer;
  47.     iSelectedImage: Integer;
  48.     cChildren: Integer;
  49.     lParam: LPARAM;
  50.   end;
  51.  
  52.   TTVInsertStruct = record
  53.     hParent: HTREEITEM;
  54.     hInsertAfter: HTREEITEM;
  55.     item: TTVItem;
  56.   end;
  57.  
  58. procedure InitCommonControls;
  59.   external 'InitCommonControls@comctl32.dll stdcall';
  60. function GetModuleHandle(lpModuleName: string): HMODULE;
  61.   external 'GetModuleHandle{#AW}@kernel32.dll stdcall';
  62. function CreateWindowEx(dwExStyle: DWORD; lpClassName: string;
  63.   lpWindowName: string; dwStyle: DWORD; X: Integer; Y: Integer;
  64.   nWidth: Integer; nHeight: Integer; hWndParent: HWND; hMenu: HMENU;
  65.   hInstance: HINSTANCE; lpParam: LPVOID): HWND;
  66.   external 'CreateWindowEx{#AW}@user32.dll stdcall';
  67. function DestroyWindow(hWnd: HWND): BOOL;
  68.   external 'DestroyWindow@user32.dll stdcall';
  69. function TreeViewInsertItem(hWnd: HWND; Msg: UINT; wParam: WPARAM;
  70.   lParam: TTVInsertStruct): HTREEITEM;
  71.   external 'SendMessage{#AW}@user32.dll stdcall';
  72.  
  73. var
  74.   TreeHandle: HWND;
  75.   ModuleInst: HMODULE;
  76.   WizardPage: TWizardPage;
  77.  
  78. function TreeViewCreate(Parent: HWND; const Bounds: TRect): HWND;
  79. begin
  80.   Result := CreateWindowEx(0, WC_TREEVIEW, 'Tree View', WS_VISIBLE or WS_CHILD or
  81.     WS_BORDER or TVS_HASLINES or TVS_HASBUTTONS or TVS_LINESATROOT, Bounds.Left,
  82.     Bounds.Top, Bounds.Right - Bounds.Left, Bounds.Bottom - Bounds.Top, Parent, 0,
  83.     ModuleInst, '');
  84.   if Result = 0 then
  85.     MsgBox(SysErrorMessage(DLLGetLastError), mbError, MB_OK);
  86. end;
  87.  
  88. function TreeViewInsert(TreeView: HWND; ParentItem: HTREEITEM; const Text: string): HTREEITEM;
  89. var
  90.   Struct: TTVInsertStruct;
  91. begin
  92.   Struct.hParent := ParentItem;
  93.   Struct.hInsertAfter := TVI_LAST;
  94.   Struct.item.mask := TVIF_TEXT;
  95.   Struct.item.pszText := Text;
  96.   Struct.item.cchTextMax := Length(Text);
  97.   Result := TreeViewInsertItem(TreeView, TVM_INSERTITEM, 0, Struct);
  98. end;
  99.  
  100. procedure InitializeWizard;
  101. var
  102.   Bounds: TRect;
  103.   TreeItem: HTREEITEM;
  104. begin
  105.   InitCommonControls;
  106.   ModuleInst := GetModuleHandle('');
  107.   WizardPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');  
  108.   Bounds.Left := 0;
  109.   Bounds.Top := 0;
  110.   Bounds.Right := WizardPage.SurfaceWidth;
  111.   Bounds.Bottom := WizardPage.SurfaceHeight;
  112.   TreeHandle := TreeViewCreate(WizardPage.Surface.Handle, Bounds);
  113.   TreeViewInsert(TreeHandle, 0, 'Item 1');
  114.   TreeItem := TreeViewInsert(TreeHandle, 0, 'Item 2');
  115.   TreeItem := TreeViewInsert(TreeHandle, TreeItem, 'Subitem 2.1');
  116. end;
  117.  
  118. procedure DeinitializeSetup;
  119. begin
  120.   if TreeHandle <> 0 then
  121.     DestroyWindow(TreeHandle);
  122. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement