Fórum Forçar abertura de janela já aberta no windows #370485
15/05/2009
0
eu preciso saber como eu posso maximizar ou ativar um programa que já esteja aberto no windows?
por exemplo:
No clique de um botão, eu verifico se o programa IBExpert já está aberto no windows. Caso esteja aberto e eu não esteja nele, ele abre como se eu tivesse clicado nele na barra de tarefas.
[vaza]
Curtir tópico
+ 0Posts
15/05/2009
Diegotiemann
{
MutexHandle := CreateMutex(nil, TRUE, ´Gestor RETTA :: Suínos´);
if MutexHandle <> 0 then
begin
if GetLastError = ERROR_ALREADY_EXISTS then
begin
application.MessageBox(´Gestor RETTA :: Suínos já está em execução em outra janela!´,´ Aviso´, MB_ICONQUESTION);
CloseHandle(MutexHandle);
hwind:=0;
repeat
hwind:=Windows.FindWindowEx(0,hwind,´TApplication´,´Gestor RETTA :: Suínos´);
until (hwind<>Application.Handle);
if (hwind<>0) then
begin
Windows.ShowWindow(hwind,SW_SHOWNORMAL);
Windows.SetForegroundWindow(hwind);
Windows.CloseHandle(hwind);
end;
Halt;
end
end; }Gostei + 0
15/05/2009
[vaza]
no caso ´Gestor RETTA :: Suínos´ seria o título do meu programa, correto?
É que esta retornando um erro. como esta no meu programa:
procedure TForm1.Button1Click(Sender: TObject);
[b:4ceb8f0e5b]var
MutexHandle, hwind: THandle;
begin
MutexHandle := CreateMutex(nil, TRUE, ´IBConsole´);
if MutexHandle <> 0 then
begin
if GetLastError = ERROR_ALREADY_EXISTS then
begin
application.MessageBox(´IBConsole já está em execução em outra janela!´,´ Aviso´, MB_ICONQUESTION);
CloseHandle(MutexHandle);
hwind:=0;
repeat
hwind:=Windows.FindWindowEx(0,hwind,´TApplication´,´IBConsole´);
until (hwind<>Application.Handle);
if (hwind<>0) then
begin
Windows.ShowWindow(hwind,SW_SHOWNORMAL);
Windows.SetForegroundWindow(hwind);
Windows.CloseHandle(hwind);
end;
Halt;
end;
end;
[/b:4ceb8f0e5b]
end;
Gostei + 0
15/05/2009
[vaza]
Esta aberto?
Então da o foco nele. Como se eu estivesse usando o IBConsole ou como se ele estivesse minimizado e eu cliquei no icone dele na barra de ferramentas do windows e ele abriu.
Gostei + 0
15/05/2009
[vaza]
dexei apenas isso:
procedure TForm1.Button3Click(Sender: TObject);
var
MutexHandle, hwind: THandle;
begin
MutexHandle := CreateMutex(nil, TRUE, ´IBConsole´);
if MutexHandle <> 0 then
begin
hwind:=0;
repeat
hwind:=Windows.FindWindow(nil,´IBConsole´);
until (hwind<>Application.Handle);
if (hwind<>0) then
begin
Windows.ShowWindow(hwind,SW_SHOWMAXIMIZED);
Windows.SetForegroundWindow(hwind);
Halt;
end
end;
end;
Vlw ai por tudo :)
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)