Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.07.01;
Скачать: 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 вся ветка

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

Наверх




Память: 0.47 MB
Время: 0.013 c
15-1180687632
Andy BitOff (ppc)
2007-06-01 12:47
2007.07.01
трафикометр для кпк


2-1181137864
Bora_ru
2007-06-06 17:51
2007.07.01
Имя следующего файла


2-1181323079
novice
2007-06-08 21:17
2007.07.01
Добавление объекта в динамический массив


1-1178164475
Novice
2007-05-03 07:54
2007.07.01
Поиск файлов FindNext, FindFirst


3-1175609549
tytus
2007-04-03 18:12
2007.07.01
TOracleQuery - многострочный SQL