是其它程序的标题栏,只隐藏任务栏上的标题,但不隐藏程序窗口即不使用ShowWindow,如何实现?谢谢

解决方案 »

  1.   

    program Project1;uses
      Forms, Windows,
      Unit1 in 'Unit1.pas' {Form1};{$R *.res}begin
      Application.Initialize;
      SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end.
      

  2.   

    隐藏任务管理器在任务栏上的标题栏:
    OperateButtonInTaskbar('Windows 任务管理器', otHide)uses CommCtrl;type
      TOperationType = (otHide = 1, otShow = 0, otDelete = 2);function OperateButtonInTaskbar(const ACaption: string; AOperation:
      TOperationType = otHide): Boolean;
    type
      PTBButtonEx = ^TTBButtonEx;
      TTBButtonEx = packed record
        Button: TTBButton;
        Caption: array[0..MAXBYTE-1] of Char;
      end;
    var
      TaskbarHandle: HWND;
      PID, ProcessHandle, NumberOfBytesRead: Cardinal;
      AllocatedMem: PTBButtonEx;
      ButtonInfo: TTBButtonEx;
      I, CaptionLength: Integer;
    begin
      Result := False;  TaskbarHandle := FindWindow('Shell_TrayWnd', nil);
      TaskbarHandle := FindWindowEx(TaskbarHandle, 0, 'ReBarWindow32', nil);
      TaskbarHandle := FindWindowEx(TaskbarHandle, 0, 'MSTaskSwWClass', nil);
      TaskbarHandle := FindWindowEx(TaskbarHandle, 0, 'ToolbarWindow32', nil);
      if TaskbarHandle = 0 then Exit;  GetWindowThreadProcessId(TaskbarHandle, PID);
      ProcessHandle := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ, False,
        PID);
      if ProcessHandle = 0 then Exit;
      AllocatedMem := VirtualAllocEx(ProcessHandle, nil, SizeOf(TTBButtonEx),
        MEM_COMMIT, PAGE_READWRITE);
      if AllocatedMem = nil then Exit;  for I := 0 to SendMessage(TaskbarHandle, TB_BUTTONCOUNT, 0, 0)-1 do
      begin
        if SendMessage(TaskbarHandle, TB_GETBUTTON, I, Integer(AllocatedMem)) = 0
          then Exit;
        if not ReadProcessMemory(ProcessHandle, AllocatedMem, @ButtonInfo,
          SizeOf(TTBButton), NumberOfBytesRead) then Exit;
        CaptionLength := SendMessage(TaskbarHandle, TB_GETBUTTONTEXT,
          ButtonInfo.Button.idCommand, Integer(@AllocatedMem^.Caption));
        if CaptionLength = -1 then Exit;
        if not ReadProcessMemory(ProcessHandle, @AllocatedMem^.Caption,
          @ButtonInfo.Caption, SizeOf(ButtonInfo.Caption), NumberOfBytesRead) then Exit;
        if ButtonInfo.Caption = ACaption then
        begin
          if AOperation = otDelete then
            Result := BOOL(SendMessage(TaskbarHandle, TB_DELETEBUTTON, I, 0))
          else
            Result := BOOL(SendMessage(TaskbarHandle, TB_HIDEBUTTON,
              ButtonInfo.Button.idCommand, Ord(AOperation)));
          SendMessage(TaskbarHandle, TB_AUTOSIZE, 0, 0);
          Break
        end
      end;  VirtualFreeEx(ProcessHandle, AllocatedMem, 0, MEM_RELEASE);
      CloseHandle(ProcessHandle);
    end;
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      hOthers: THandle;
    begin
      hOthers := FindWindow('360se5_Frame', nil);
      if hOthers = 0 then
        ShowMessage('not found!')
      else
        SetWindowText(hOthers, '');
    end;