some relative to taskbar
来源:互联网 发布:沙特国王科技大学 知乎 编辑:程序博客网 时间:2024/05/29 18:10
遇到问题,process1 launch process2后,wait, 直至process2 exit, process激活自己。
process1如果不hide自己的主窗口,taskbar(或alt+tab)上会显示process1和process2,而这时点process1又是没反应的,因为其主线程处于wait状态。
所以现在把process1的主窗口hide,这样taskbar上就不回显示,可是新问题又来了,process2结束后,process1的主窗口跑到后台去了。
为了使其主窗口从会前面,调SetForegroundWindow,SetActiveWindow,SetFocus,BringWindowToTop, SetWindowsPos都不行,都只能闪阿闪在任务栏。
调AttachThreadInput就可以了,不过有时还是会不行,且即使在前面了,也会有先显示其他,再显示process1的切换。
理想情况是,process1不hide主窗口,而其又不会在taskbar(alt+tab)上显示,exit process2的时候会自动切换过来,这个能做到吗?
现在发现如果在taskbar上没有icon,进程不会主动切换过来。
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
强制切换:
HWND hCurWnd = NULL;
DWORD lMyID;
DWORD lCurID;
hCurWnd = ::GetForegroundWindow();
lMyID = ::GetCurrentThreadId();
lCurID = ::GetWindowThreadProcessId(hCurWnd, NULL);
::AttachThreadInput( lMyID, lCurID, TRUE);
SetForegroundWindow();
::AttachThreadInput( lMyID, lCurID, FALSE);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
从Win98开始,微软更改了系统代码,一般的SetForegroundWindow只能将
状态栏中应用按钮闪烁,并没有将应用调到最前面。请使用下列函数:
function ForceForegroundWindow(hwnd: THandle): boolean;
const
SPI_GETFOREGROUNDLOCKTIMEOUT = $2000;
SPI_SETFOREGROUNDLOCKTIMEOUT = $2001;
var
timeout: DWORD;
begin
if ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion
> 4)) or
((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
((Win32MajorVersion > 4) or ((Win32MajorVersion = 4) and
(Win32MinorVersion > 0)))) then begin
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, @timeout,
0);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
TObject(0), SPIF_SENDCHANGE);
Result := SetForegroundWindow(hWnd);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
TObject(timeout), SPIF_SENDCHANGE);
end
else
Result := SetForegroundWindow(hWnd);
end; { ForceForegroundWindow }
///////////////////////////////////////////////////////////////////////////////////////////////////////
FROM MSDN
Managing Taskbar Buttons
The Shell creates a button on the taskbar whenever an application creates a window that isn't owned. To ensure that the window button is placed on the taskbar, create an unowned window with the WS_EX_APPWINDOW extended style. To prevent the window button from being placed on the taskbar, create the unowned window with the WS_EX_TOOLWINDOW extended style. As an alternative, you can create a hidden window and make this hidden window the owner of your visible window.
The Shell will remove a window's button from the taskbar only if the window's style supports visible taskbar buttons. If you want to dynamically change a window's style to one that doesn't support visible taskbar buttons, you must hide the window first (by calling ShowWindow with SW_HIDE), change the window style, and then show the window.
The window button typically contains the application icon and title. However, if the application does not contain a system menu, the window button is created without the icon.
If you want your application to get the user's attention when the window is not active, use the FlashWindow function to let the user know that a message is waiting. This function flashes the window button. Once the user clicks the window button to activate the window, your application can display the message.
Modifying the contents of the taskbar
Version 4.71 and later of Shell32.dll adds the capability to modify the contents of the taskbar. From an application, you can now add, remove, and activate taskbar buttons. Activating the item does not activate the window; it shows the item as pressed on the taskbar.
The taskbar modification capabilities are implemented in a COM object (CLSID_TaskbarList) that exposes the ITaskbarList interface (IID_ITaskbarList). You must call the ITaskbarList::HrInit method to initialize the object. You can then use the methods of the ITaskbarList interface to modify the contents of the taskbar.
ITaskbarList2::MarkFullscreenWindow
- some relative to taskbar
- Pin to Taskbar
- Pin To Taskbar
- Pin To Taskbar
- Function is used to Show/Hide the TaskBar
- Move The Taskbar to the Top of Desktop
- A Friently Introduction to the Windows 7 Taskbar Features
- VC++和C#的pin two programs to Taskbar
- some link to learn as3
- some commands related to "find"
- Some tasks to be finished
- Uable to upload some APKs
- relative
- Relative to SQLCE Various Errors Information
- c# Relative Path convert to Absolute Path
- Performance Issue Relative To Temporary Table
- failed to push some refs to git
- 解决failed to push some refs to
- Linux中定期运行程序
- ip,dns,路由表,ARP表形象比喻
- 学习PHP的方法.
- 使用索引的误区之二:使用了 和 != 操作符,导致查询不使用索引
- IE ZOOM
- some relative to taskbar
- 30岁职场精英,遭遇六大职业瓶颈
- 使用索引的误区之三:基于函数的索引
- WM_TABLET_FLICK
- 使用索引的误区之四:空值对索引的影响
- 不从装VS6 MSDN
- 使用索引的误区之五:空值的妙用
- Iterator和listIterator的区别
- 使用索引的误区之六:为所有列都建立索引