Максимизация приложения Delphi (VCL) извне с использованием Windows APIC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 Максимизация приложения Delphi (VCL) извне с использованием Windows API

Сообщение Anonymous »


I try to start another application that is written in Delphi in my C# application using this code:

Process process = new Process(); process.StartInfo.FileName="app.exe"; process.Start(); It happens that users minimize that another app. So, sometimes I want to bring that window from the minimized state to maximized state, and show on top of my C# application. When I try to maximize it, using Windows API calls:

ShowWindow(process.MainWindowHandle, SW_MAXIMIZED); -- SW_MAXIMIZED=3 It shows me a black screen instead of application:
Изображение


I guess it's due to how VCL applications works. I have tried different approaches (SW_RESTORE, SW_SHOW), then tried to SetForeGroundWindow (also didn't help - it only works when window is not minimized).

What's more, after maximizing it with ShowWindowprogramatically, I can still maximize that external app window from the taskbar manually, and it works. Also when I minimize manually the window, a black window minimizes as well.

If I close that black window, the external Delphi application is being closed too.

After some time wasted today, I found out that sending alt+tab using SendKeys class worked. However, that's a very naive, and I don't accept it as a solution, since user could have any other window opened before (not only an external application), so then that another window will be on top.

Any ideas how to deal with that, or what is actually happening?

I tried to dig in VCL documentation, but I couldn't find proper explanation about what is happening.


Источник: https://stackoverflow.com/questions/779 ... indows-api
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»