Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Post  Topic: Динамическое создание формы в DLL 
Author Message
Dec



PostPosted: Wed Jun 06, 2007 11:13    Post subject: Reply with quote

Мой код, может быть пригодится
Code:

type
  TWinArray = array of THandle;

function TdecFSRoot.ExecuteProperties(AMainWin: Cardinal; ARemoteName: PAnsiChar): Integer;
var
  NotTC: boolean;
  Thr: THandle;
  WinArray: TWinArray;

  function DoDisableWindow(Window: HWnd; Data: Longint): Bool; stdcall;
  begin
    if IsWindowVisible(Window) and IsWindowEnabled(Window) then
    begin
      SetLength(WinArray, Length(WinArray) + 1);
      WinArray[Length(WinArray) - 1] := Window;
      EnableWindow(Window, False);
    end;
    Result := True;
  end;

  procedure EnableTaskWindows;
  var i: integer;
  begin
    for i := 0 to Length(WinArray) - 1 do
      if IsWindow(WinArray[i]) then EnableWindow(WinArray[i], True);
    SetLength(WinArray, 0);
  end;

  procedure DisableTaskWindows(AThread: THandle);
  begin
    try
      EnumThreadWindows(AThread, @DoDisableWindow, 0);
    except
      EnableTaskWindows;
      raise;
    end;
  end;

begin
  if not HaveProperties then
    begin
      Result := FS_EXEC_YOURSELF;
      exit;
    end;
  try
    if decGetClassName(AMainWin) <> 'TTOTAL_CMD' then
      begin
        NotTC := true;
        Thr := GetWindowThreadProcessId(AMainWin);
        SetLength(WinArray, 0);
        DisableTaskWindows(Thr);
      end
    else
      NotTC := false;
    try
      ShowProperties(AMainWin);
      Result := FS_EXEC_OK;
    finally
      if NotTC then
        EnableTaskWindows;
    end;
  except
    Result := FS_EXEC_ERROR;
  end;
end;

procedure TdecFSClipboardRoot.ShowProperties(AMainWin: Cardinal);
var AboutForm: TAboutForm2;
begin
  Application.Handle := AMainWin;
  AboutForm := TAboutForm2.Create(Application);
  try
    AboutForm.ShowModal(IniFile);
  finally
    AboutForm.Free;
    Application.Handle := 0;
  end;
end;
View user's profile Send private message


Powered by phpBB © 2001, 2005 phpBB Group