Вниз
Скачать: CL | DM;

Handleи кнопка ToolButton   Найти похожие ветки 

 
Ламонов Олег   (2007-04-29 10:52) [0]

Уважаемые мастера.
Скажите, можно ли,имея, handle окна нажать на
кпопку ToolButton?
Использую процедуру, но она работает только на обчных кнопках.
Спасибо.

function EnumChildProc(Wnd: hWnd; SL: TStrings): BOOL; stdcall;
var
 szFull: array[0..MAX_PATH] of Char; //Buffer for window caption
begin
 Result := Wnd <> 0;
 if Result then
 begin
   GetWindowText(Wnd, szFull, SizeOf(szFull)); // put window text in buffer
   if (Pos(SL[0], StrPas(szFull)) > 0) // Test for text
     and (SL.IndexOfObject(TObject(Wnd)) < 0) // Test for duplicate handles
     then SL.AddObject(StrPas(szFull), TObject(Wnd)); // Add item to list
   EnumChildWindows(Wnd, @EnumChildProc, Longint(SL)); //Recurse into child windows
 end;
end;

function ClickButton(ParentWindow: Hwnd; ButtonCaption: string): Boolean;
var
 SL: TStringList;
 H:  hWnd;
begin
 SL := TStringList.Create;
 try

   SL.AddObject(ButtonCaption, nil); // First item in list is text to find
   EnumChildWindows(ParentWindow, @EnumChildProc, Longint(SL));
   H := 0;
   case SL.Count of
     1: ShowMessage("Окно не найдено !");
     2: H := hWnd(SL.Objects[1]);
     else
       ShowMessage("Текст определен !");
   end;
 finally
   SL.Free;
 end;
 Result := H <> 0;
 if Result then
 PostMessage(H, BM_CLICK, 0, 0);
end;


 
begin...end ©   (2007-04-29 11:07) [1]

У ToolButton"ов нет handle. Нажать такую кнопку можно, послав ToolBar"у, на котором она находится, сообщение TB_PRESSBUTTON.



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

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.013 c
1-1177854375
tormoz
2007-04-29 17:46
2007.07.01
Сервис и реализация событий "наружу"


15-1180774671
@!!ex_
2007-06-02 12:57
2007.07.01
Ну и за что бан?


2-1181320090
Bullfrog
2007-06-08 20:28
2007.07.01
Создание, редактирование отчета


2-1181198499
Solbon
2007-06-07 10:41
2007.07.01
Системный журнал


4-1169546579
Просто зашел
2007-01-23 13:02
2007.07.01
Запрет запуска




   Наверх