Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.08.07;
Скачать: CL | DM;

Вниз

TreeView с ChekBox оми.   Найти похожие ветки 

 
Punch   (2005-07-18 17:41) [0]

Подскажите компонент.


 
begin...end ©   (2005-07-18 17:44) [1]

Таким компонентом может являться стандартный TreeView. Добавьте к стилю его окна значение TVS_CHECKBOXES.


 
Юрий Зотов ©   (2005-07-18 17:56) [2]

> Punch   (18.07.05 17:41)

TTreeView.

uses
 CommCtrl;

procedure TForm1.FormCreate(Sender: TObject);
begin
 with TreeView1 do
   SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) or TVS_CHECKBOXES)
end;


 
Fay ©   (2005-07-18 17:58) [3]

2 Юрий Зотов ©   (18.07.05 17:56) [2]
А виндо точно не будет перестраиваться?


 
Юрий Зотов ©   (2005-07-18 18:06) [4]

> Fay ©   (18.07.05 17:58) [3]

???


 
Fay ©   (2005-07-18 19:07) [5]

2 Юрий Зотов ©   (18.07.05 18:06) [4]
Возможен повторный вызов CreateWindow? У всяких TEdit-ов это происходит частенько.


 
Юрий Зотов ©   (2005-07-18 20:21) [6]

> Fay ©   (18.07.05 19:07) [5]

Возможен, если в коде будут меняться какие-то свойства дерева, требующие пересоздания окна. Если верить коду VCL (и если я ничего в нем не прозевал), то это свойства Ctl3D и BorderStyle.


 
Fay ©   (2005-07-18 21:14) [7]

2 Юрий Зотов ©   (18.07.05 20:21) [6]
Видимо, надо писать наследника.


 
Юрий Зотов ©   (2005-07-18 21:25) [8]

> Fay ©   (18.07.05 21:14) [7]

Кто умеет писать компоненты - да. Кто не очень - проще использовать StateImages.


 
Punch   (2005-07-19 14:43) [9]

Скажите, как узнать состояние (checked или unchecked) у узла?


 
Fay ©   (2005-07-19 18:39) [10]

Working with state image indexes
There is often confusion about how to set and retrieve the state image index in a tree-view control. The following examples demonstrate the proper method for setting and retrieving the state image index. The examples assume that there are only two state image indexes in the tree-view control, unchecked and checked. If your application contains more than two, these functions will need to be modified to handle that case.

The following example function illustrates how to set an item"s check state.

BOOL TreeView_SetCheckState(HWND hwndTreeView, HTREEITEM hItem, BOOL fCheck)
{
   TVITEM tvItem;

   tvItem.mask = TVIF_HANDLE | TVIF_STATE;
   tvItem.hItem = hItem;
   tvItem.stateMask = TVIS_STATEIMAGEMASK;

   /*Image 1 in the tree-view check box image list is the
   unchecked box. Image 2 is the checked box.*/
   
   tvItem.state = INDEXTOSTATEIMAGEMASK((fCheck ? 2 : 1));

   return TreeView_SetItem(hwndTreeView, &tvItem);
}

The following example function illustrates how to retrieve an item"s check state.

BOOL TreeView_GetCheckState(HWND hwndTreeView, HTREEITEM hItem)
{
   TVITEM tvItem;

   // Prepare to receive the desired information.
   tvItem.mask = TVIF_HANDLE | TVIF_STATE;
   tvItem.hItem = hItem;
   tvItem.stateMask = TVIS_STATEIMAGEMASK;

   // Request the information.
   TreeView_GetItem(hwndTreeView, &tvItem);

   // Return zero if it"s not checked, or nonzero otherwise.
   return ((BOOL)(tvItem.state >> 12) -1);
}



Страницы: 1 вся ветка

Текущий архив: 2005.08.07;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.064 c
6-1114019313
Jetus
2005-04-20 21:48
2005.08.07
Блокировка файла от удаления по FTP


4-1118400248
Андрей Жук
2005-06-10 14:44
2005.08.07
Я чего-то не понимаю?


9-1113998028
Comrade
2005-04-20 15:53
2005.08.07
Как "забобахать" мегопростую игр


10-1098692414
Саша
2004-10-25 12:20
2005.08.07
Как открыть докуммент Excel, не запуская сам Excel


1-1121710721
APXi
2005-07-18 22:18
2005.08.07
При создании дочерней MDI формы метод ShowModal не работает!