Einzelnen Beitrag anzeigen

Mark90
(Gast)

n/a Beiträge
 
#3

Re: mit dem Programmname an den Fenstertitel heran kommen?

  Alt 25. Aug 2007, 11:17
Schau dir mal das an! So in der Art wird es gehen.

Delphi-Quellcode:
function GetStatusText(wndWindow: THandle;
  StatusBarClassName: string;
  PanelIndex: Byte): string;
var
  WndStatusBar: THandle;
  StatusBarText: array[0..$FFF] of Char;
begin
  Result := '';
  WndStatusBar := FindWindowEx(wndWindow, 0, PChar(StatusBarClassName), nil);
  if WndStatusBar <> 0 then
  begin
    if PanelIndex = 0 then
      SendMessage(WndStatusBar, WM_GETTEXT, $FFF, Longint(@StatusBarText))
    else
      SendMessage(WndStatusBar, SB_GETTEXT, PanelIndex, Longint(@StatusBarText));
    Result := StrPas(StatusBarText);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  // Read statustext from Internet Explorer
  label1.Caption := GetStatusText(FindWindow('IEFrame', nil), 'msctls_statusbar32', 0);
  // Also works with a TStatusBar
  Label2.Caption := GetStatusText(Form1.Handle, 'TStatusBar', 0);
end;




uses
  CommCtrl, uProcessMemMgr { from Download };


function GetStatusBarText(hStatusBarHandle: HWND; PanelNumber: Integer): string;
var
  PMM: TProcessMemMgr;
  NumberOfPanels, Len: Integer;
  PrcBuf: PChar;
  PartText: string;
begin
  if hStatusBarHandle = 0 then Exit;
  PMM := CreateProcessMemMgrForWnd(hStatusBarHandle);
  try
    NumberOfPanels := SendMessage(hStatusBarHandle, SB_GETPARTS, 0, 0);
    if PanelNumber < NumberOfPanels then
    begin
      Len := LOWORD(SendMessage(hStatusBarHandle, SB_GETTEXTLENGTH, PanelNumber, 0));
      if Len > 0 then
      begin
        PrcBuf := PMM.AllocMem(Len + 1);
        SendMessage(hStatusBarHandle, SB_GETTEXT, PanelNumber, Longint(PrcBuf));
        Result := PMM.ReadStr(PrcBuf);
        PMM.FreeMem(PrcBuf);
      end
      else
      begin
        Result := '';
      end;
    end;
  finally
    PMM.Free;
  end;
end;

// Example to read the statusbar text of the explorer.exe
// Beispiel, um den Statusbar text des explorers auszulesen
procedure TForm1.Timer1Timer(Sender: TObject);
var
  hWindow, hStatusBarHandle: HWND;
begin
  hWindow := FindWindow('ExploreWClass', nil);
  if FensterHandle = 0 then Exit;
  hStatusBarHandle := FindWindowEx(hWindow, 0, 'msctls_statusbar32', nil);
  label1.Caption := GetStatusBarText(hStatusBarHandle, 2);
end;
  Mit Zitat antworten Zitat