Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Setup]
- AppName=My Program
- AppVersion=1.5
- DefaultDirName={pf}\My Program
- [Code]
- #ifdef UNICODE
- #define AW "W"
- #else
- ANSI Inno Setup is not supported for this script (yet?)!
- #endif
- const
- WS_CHILD = $40000000;
- WS_BORDER = $800000;
- WS_VISIBLE = $10000000;
- TVS_HASBUTTONS = $0001;
- TVS_HASLINES = $0002;
- TVS_LINESATROOT = $0004;
- TVI_LAST = -65534;
- TVIF_TEXT = $0001;
- TV_FIRST = $1100;
- TVM_INSERTITEMW = TV_FIRST + 50;
- TVM_INSERTITEM = TVM_INSERTITEMW;
- WC_TREEVIEW = 'SysTreeView32';
- type
- HMENU = THandle;
- LPVOID = PAnsiChar;
- WPARAM = UINT_PTR;
- LPARAM = INT_PTR;
- LRESULT = INT_PTR;
- HINSTANCE = THandle;
- HMODULE = HINSTANCE;
- HTREEITEM = THandle;
- TTVItem = record
- mask: UINT;
- hItem: HTREEITEM;
- state: UINT;
- stateMask: UINT;
- pszText: string;
- cchTextMax: Integer;
- iImage: Integer;
- iSelectedImage: Integer;
- cChildren: Integer;
- lParam: LPARAM;
- end;
- TTVInsertStruct = record
- hParent: HTREEITEM;
- hInsertAfter: HTREEITEM;
- item: TTVItem;
- end;
- procedure InitCommonControls;
- external 'InitCommonControls@comctl32.dll stdcall';
- function GetModuleHandle(lpModuleName: string): HMODULE;
- external 'GetModuleHandle{#AW}@kernel32.dll stdcall';
- function CreateWindowEx(dwExStyle: DWORD; lpClassName: string;
- lpWindowName: string; dwStyle: DWORD; X: Integer; Y: Integer;
- nWidth: Integer; nHeight: Integer; hWndParent: HWND; hMenu: HMENU;
- hInstance: HINSTANCE; lpParam: LPVOID): HWND;
- external 'CreateWindowEx{#AW}@user32.dll stdcall';
- function DestroyWindow(hWnd: HWND): BOOL;
- external 'DestroyWindow@user32.dll stdcall';
- function TreeViewInsertItem(hWnd: HWND; Msg: UINT; wParam: WPARAM;
- lParam: TTVInsertStruct): HTREEITEM;
- external 'SendMessage{#AW}@user32.dll stdcall';
- var
- TreeHandle: HWND;
- ModuleInst: HMODULE;
- WizardPage: TWizardPage;
- function TreeViewCreate(Parent: HWND; const Bounds: TRect): HWND;
- begin
- Result := CreateWindowEx(0, WC_TREEVIEW, 'Tree View', WS_VISIBLE or WS_CHILD or
- WS_BORDER or TVS_HASLINES or TVS_HASBUTTONS or TVS_LINESATROOT, Bounds.Left,
- Bounds.Top, Bounds.Right - Bounds.Left, Bounds.Bottom - Bounds.Top, Parent, 0,
- ModuleInst, '');
- if Result = 0 then
- MsgBox(SysErrorMessage(DLLGetLastError), mbError, MB_OK);
- end;
- function TreeViewInsert(TreeView: HWND; ParentItem: HTREEITEM; const Text: string): HTREEITEM;
- var
- Struct: TTVInsertStruct;
- begin
- Struct.hParent := ParentItem;
- Struct.hInsertAfter := TVI_LAST;
- Struct.item.mask := TVIF_TEXT;
- Struct.item.pszText := Text;
- Struct.item.cchTextMax := Length(Text);
- Result := TreeViewInsertItem(TreeView, TVM_INSERTITEM, 0, Struct);
- end;
- procedure InitializeWizard;
- var
- Bounds: TRect;
- TreeItem: HTREEITEM;
- begin
- InitCommonControls;
- ModuleInst := GetModuleHandle('');
- WizardPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
- Bounds.Left := 0;
- Bounds.Top := 0;
- Bounds.Right := WizardPage.SurfaceWidth;
- Bounds.Bottom := WizardPage.SurfaceHeight;
- TreeHandle := TreeViewCreate(WizardPage.Surface.Handle, Bounds);
- TreeViewInsert(TreeHandle, 0, 'Item 1');
- TreeItem := TreeViewInsert(TreeHandle, 0, 'Item 2');
- TreeItem := TreeViewInsert(TreeHandle, TreeItem, 'Subitem 2.1');
- end;
- procedure DeinitializeSetup;
- begin
- if TreeHandle <> 0 then
- DestroyWindow(TreeHandle);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement