日志搜索
用户登录
数据载入中,请稍等...
用户公告
数据载入中,请稍等...
时间记忆
数据载入中,请稍等...
最新日志
数据载入中,请稍等...
最新回复
数据载入中,请稍等...
最新留言
数据载入中,请稍等...
统计信息
数据载入中,请稍等...
How do you bring the window of another program int

Instructions:
You can find the handle to a window using the Windows API function FindWindow.

Let's suppose you wish to bring a Microsoft Access window into the foreground:

HWND Handle= ZERO;
Handle= FindWindow("OMAIN",ZERO);
if(Handle)
{

ShowWindow(Handle, SW_MINIMIZE); //

ShowWindow ( Handle, SW_SHOWNORMAL );
SetForegroundWindow(Handle);

}

else
ProgramExecute("C:\\MSOffice.97\\Office\\ACCESS.EXE");

If the window is not found, Microsoft Access is then restarted.

Note on the FindWindow function:

The first parameter is the class of the window.
You can find out the class using a compiler (e.g.: Spy from Visual C++).

The second parameter is the title of the window (title bar). You can specify either one of the two parameters, or both together. In our example the command looks like this:

Handle=FindWindow(NULL,"Microsoft Access -");

If you are searching for the name of the window, then please note that with some programs the title is language-specific and so might not be found in a different language. The class is always independent of the language.

If you know the class of the window, then you can use this procedure for other applications too.

Here you see the names of the window classes for some applications:
 

Application

Class

Microsoft Access

OMAIN

Internet Explorer 4.0

IEFrame

Microsoft Excel 97

XLMAIN

Microsoft Outlook 97

rctrl_renwnd32

Microsoft PowerPoint 97

PP97FrameClass

Microsoft Word 97

OpusApp

MS-DOS Input Prompt

ConsoleWindowClass

Netscape

Afx:400000:b:10008:6:947d03d8

Notepad

Notepad

Paint:

MSPaintApp

Calculator

SciCalc

Windows Explorer

ExploreWClass

SIMATIC Manager

s7tgtopx

WinCC V4.x Control Center

MCPFrameWndClass

WinCC V5.x WinCC Explorer

WinCCExplorerFrameWndClass

WinCC V6.x WinCC Explorer

WinCCExplorerFrameWndClass

WordPad

WordPadClass

Example 1: WinCC V5.x / WinCC V6.x: Bring WinCCExplorer into the foreground

HWND Handle= ZERO;
Handle= FindWindow("WinCCExplorerFrameWndClass",ZERO);
if(Handle)
{
ShowWindow(Handle, SW_MINIMIZE);
// This entry is only necessary in Windows 2000
//(or Windows XP in the case of WinCC V6.x)
ShowWindow ( Handle, SW_SHOWNORMAL );
SetForegroundWindow(Handle);
}

Example 2: WinCC V4: Bring the Control Center into the foreground

HWND Handle= ZERO;
Handle= FindWindow("MCPFrameWndClass",ZERO);
if(Handle)
{

ShowWindow ( Handle, SW_SHOWNORMAL );
SetForegroundWindow(Handle);
}

Keywords:
Programming tips

  • 标签:Programming tips 
  • 发表评论:
    数据载入中,请稍等...
    Copyright © 超音速工作室                                 生活因感动而精彩,理想在创造中放飞
    Powered by Oblog.