Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Button in einer anderen anwendung enablen (https://www.delphipraxis.net/21802-button-einer-anderen-anwendung-enablen.html)

Meflin 8. Mai 2004 12:50


Button in einer anderen anwendung enablen
 
Hi,
kann man (z.B. per SendMessage) den button oder auch andere controls enablen, falls diese disabled sind?

*MFG*

toms 8. Mai 2004 12:54

Re: Button in einer anderen anwendung enablen
 
Delphi-Quellcode:
  EnableWindow(Handle_des_Buttons, True);

Meflin 8. Mai 2004 12:57

Re: Button in einer anderen anwendung enablen
 
und false würde das teil disablen nehme ich an. bleibt noch die frage wie ich ein buttonhandle bekomme...

toms 8. Mai 2004 12:59

Re: Button in einer anderen anwendung enablen
 
Delphi-Quellcode:
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 EnableButton(ParentWindow: Hwnd; ButtonCaption: string; Enabled: Boolean): 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('Window text not found.');
      2: H := hWnd(SL.Objects[1]);
      else
        ShowMessage('Ambiguous text detected.');
    end;
  finally
    SL.Free;
  end;
  Result := H <> 0;
  if Result then
    EnableWindow(H, Enabled);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  EnableButton(HANDLE_DES_FENSTERS {z.B FindWindow Suchen},'OK', True);
end;

Meflin 8. Mai 2004 13:02

Re: Button in einer anderen anwendung enablen
 
merci beaucoup!


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:03 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz