Checkbox for Tree

xiaoxiao2021-03-13  179

Long getWindowlong (HWND HWND, INT NLNDEX); This function gets information about the specified window, and the function is also a 32-bit integer value that specifies the offset bit address in the additional window memory.

parameter:

HWND: Window handle and the window class to which you have an indirect window.

NLndex: Specifies the offset of the value greater than or equal to 0 to obtain. Valid value ranges from 0 to an additional window memory space, for example, if a 12-bit or more than 12 additional type storage space is specified, the index position 8 of the third 32-bit integer should be set. To get any other value, specify one of the following values:

GWL_EXSTYLE; get the expansion window style.

GWL_Style: Get window style.

GWL_WNDPROC: Get the address of the window process, or the handle of the address of the window process. You must call the window process using the GWL_WndProc function.

GWL_HINSTANCE: Get the handle of the application instance.

GWL_HWNDPAAENT: If the parent window exists, get the parent window handle.

GWL_ID: Get window ID.

GWL_USERDATA: Get 32-bit values ​​related to the window. Each window has a 32-bit value used by the application that creates the window.

You can also use the following value when the HWND parameter identifies a dialog:

DWL_DLGPROC: Get the address of the dialog process, or a handle of the address representing the dialog process. You must use the function CallWindowProc to call the dialog process.

DWL_MSGRESULT: Gets the return value of a message processing in the dialog process.

DWL_USER: Get additional information privately available, such as a handle or pointer.

Return Value: If the function is successful, the return value is the desired 32-bit value; if the function fails, the return value is 0. If you want to get more error messages, please call the getLastError function.

From: Hotboys, Time: 2005-03-18 8:44:44, ID: 3017606 long setwindowlong (hwnd hwnd, int nlndex, long dwnewlong); This function changes the properties of the specified window. The function also sets the specified 32-bit value to the specified offset location of the additional storage space of the window.

parameter:

HWND: Window handle and indirectly given the class belonging.

NLndex: Specifies the offset value of the setting greater than or equal to 0. Valid values ​​range from 0 to additional categories of storage spaces: For example, if a 12-bit or more than 12 additional type storage space, it should be set to the third 32-bit integer index 8 . To set any other value, you can specify one of the following values:

GWL_EXISTYLE: Set a new extension style. GWL_Style: Set a new window style.

GWL_WNDPROC: Sets a new address for the window process. GWL_ID: Set a new window identifier.

GWL_HINSTANCE: Sets a new application case handle.

GWL_USERDATA: Sets 32-bit values ​​related to the window. Each window has a 32-bit value used by the application that creates the window.

When the HWND parameter identifies a dialog, you can also use the following value:

DWL_DLGPROC: Sets the new address of the dialog process.

DWL_MSGRESULT: Set the return value of the message processed during the dialog process.

DWL_USER: Sets new additional information privately available, such as a handle or pointer.

DWNEWLONG: Specifies the replacement value.

Return value: If the function is successful, the return value is the original value of the specified 32-bit integer. If the function fails, the return value is 0. To get more error messages, call the getLastError function. If the original value of the 32-bit integer is 0 and the function is successful, the return value is 0, but the function does not clear the last error message, which is difficult to determine if the function is successful. At this time, you should call the CallingSetLastError (0) function before calling SetWindowlong to clear the last error message. This way, if the function fails, it will return 0, and getLastError. Also returns a non-zero value.

Unit unit1;

Interface

Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Imglist, Stdctrls, Comctrls, CommCtrl

type TForm1 = class (TForm) TreeView1: TTreeView; Memo1: TMemo; Button1: TButton; ImageList1: TImageList; procedure FormCreate (Sender: TObject); procedure Button1Click (Sender: TObject); private {Private declarations} public {Public declarations} end ;

Var Form1: TFORM1;

IMPLEMENTATION

{$ R * .dfm}

procedure TForm1.FormCreate (Sender: TObject); const TVS_CHECKBOXES = $ 0100; var s: dword; begin s: = GetWindowLong (treeview1.Handle, GWL_STYLE); s: = s or TVS_CHECKBOXES; SetWindowLong (treeview1.Handle, GWL_STYLE, s) ;

Procedure TForm1.Button1Click (Sender: Tobject); Var i: integer; item: ttvitem; s: string; begin {item.State: = (item.State or $ 1000) and (not $ 2000); did not tick item.State: = (item.State or $ 2000) and (not $ 1000); tick} memo1.text: = '; for i: = 0 to TreeView1.Items.count - 1 do beg Item.mask: = tvif_handle; item.hitem : = TreeView1.items [i] .Item (TreeView_getitem (TreeView1.Handle, Item); if (item.State and $ 2000) = 0 THEN // Unmarkted Else Memo1.Lines.Add ('Father' S ' - ' TreeView1.items.Item [i] .parent.text ' - ' INTOSTR (TreeView1.Items.Item [i] .level) ' layer ' ' TreeView1.Items [i] .text) ; End;

End.

转载请注明原文地址:https://www.9cbs.com/read-129006.html

New Post(0)