Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2003.01.30;
Скачать: [xml.tar.bz2];

Вниз

показать окно ранее запущенной программы   Найти похожие ветки 

 
Alexsc   (2002-12-16 12:48) [0]

Уважаемые мастера, подскажите пожалуйста как показать окно ранее запущенной программы (узнать ее хэндл и отобразить по кнопке ее поверх работающей программы)
Заранее спасибо


 
Danlicha   (2002-12-16 12:51) [1]

В инете таких примеров как грязи. Тут тоже недавно было.


 
Danlicha   (2002-12-16 12:53) [2]

Минуту назад...


 
Alexsc   (2002-12-16 13:52) [3]

Не нашел, а можно ссылку на тему, пожалуйста


 
Danlicha   (2002-12-16 14:00) [4]

http://delphi.mastak.ru/cgi-bin/faq.pl?look=1&id=988619824&n=15 но есть и ещё.


 
alexsc   (2002-12-16 14:09) [5]

Да, нет. Мне нужно найти другую программу (не мою) NEWPROG.EXE и из моей программы показать ее (открыть поверх всех окон) по кнопке в моей программе.


 
Danlicha   (2002-12-16 14:14) [6]

Ну так там же этот кусок есть, какая в принципе разниза, свой экземпляр поверх ставить, или нет.

Нужно, имхо, вызывать SetForegroundWindow. Ей подставлять хандлер окна программы, который можно добыть с помощью FindWindow, которой в качестве параметров нужно передать заголовок окна и/или имя класса. Последнее можно узнать с помощью MS Spy++, например.


 
alexsc   (2002-12-16 15:23) [7]

Спасибо все отдично получается, но только если программа не свернута а открыта (активна за основным окном), в противном случае с основной формы пропадает активность, а к другой не переходит. Ответьте пожалуйста!


 
Danlicha   (2002-12-16 15:27) [8]

А вот тут хрен знает. Вроде в НТ нужно получать привилегии. Гланьте в Win32 SDK. Вот вырезка на SetForegroundWindow:

SetForegroundWindow Function

----------------------------------------------------

The SetForegroundWindow function puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user. The system assigns a slightly higher priority to the thread that created the foreground window than it does to other threads.

Syntax

BOOL SetForegroundWindow( HWND hWnd
);
Parameters

hWnd
[in] Handle to the window that should be activated and brought to the foreground.
Return Value

If the window was brought to the foreground, the return value is nonzero.

If the window was not brought to the foreground, the return value is zero.




Remarks

The foreground window is the window at the top of the Z-Order. It is the window that the user is working with. In a preemptive multitasking environment, you should generally let the user control which window is the foreground window.

Windows 98/Me: The system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:


The process is the foreground process.
The process was started by the foreground process.
The process received the last input event.
There is no foreground process.
The foreground process is being debugged.
The foreground is not locked (see LockSetForegroundWindow).
The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
Windows 2000/XP: No menus are active.

With this change, an application cannot force a window to the foreground while the user is working with another window. Instead, Foreground and Background Windows will activate the window (see SetActiveWindow) and call the function to notify the user. However, on Microsoft® Windows® 98 and Windows Millennium Edition (Windows Me), if a nonforeground thread calls SetForegroundWindow and passes the handle of a window that was not created by the calling thread, the window is not flashed on the taskbar. To have SetForegroundWindow behave the same as it did on Windows 95 and Microsoft Windows NT® 4.0, change the foreground lock timeout value when the application is installed. This can be done from the setup or installation application with the following function call:

SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID)0, SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);

This method allows SetForegroundWindow on Windows 98/Windows Me and Windows 2000/Windows XP to behave the same as Windows 95 and Windows NT 4.0, respectively, for all applications. The setup application should warn the user that this is being done so that the user isn"t surprised by the changed behavior. On Windows Windows 2000 and Windows XP, the call fails unless the calling thread can change the foreground window, so this must be called from a setup or patch application. For more information, see Foreground and Background Windows.

A process that can set the foreground window can enable another process to set the foreground window by calling the AllowSetForegroundWindow function. The process specified by dwProcessId loses the ability to set the foreground window the next time the user generates input, unless the input is directed at that process, or the next time a process calls AllowSetForegroundWindow, unless that process is specified.

The foreground process can disable calls to SetForegroundWindow by calling the LockSetForegroundWindow function.

Function Information

Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Included in Windows 95, Windows NT 3.1

See Also

Windows Overview, AllowSetForegroundWindow, FlashWindowEx, GetForegroundWindow, LockSetForegroundWindow, SetActiveWindow

------------------------------------------------------------

© 2002 Microsoft Corporation. All rights reserved.


 
alexsc   (2002-12-16 15:47) [9]

Спасибо за ответ буду разбираться. Удачи



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2003.01.30;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.009 c
7-97044
lavish
2002-11-17 20:26
2003.01.30
Виртуальный диск


3-96519
AVovik
2003-01-14 15:34
2003.01.30
Кто знает откуда берется эта messag


9-96502
Some0ne.
2002-07-27 00:16
2003.01.30
Управление мышой


1-96814
beginer_
2003-01-20 11:01
2003.01.30
Как запустить программу и дождаться её завершения?


9-96507
Сирожа
2002-08-07 00:08
2003.01.30
DirectX





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский