-
April 30th, 2008, 12:15 AM
#1
a window that stays topmost
How can i create a window that stays topmost and don't loose focus with ALT+TAB or by any other process lunch like Task Manager?
I can create a fullscreen topmost window but unable to keep it topmost. For example, ALT+TAB brings up the taskbar and if I start Task Manager, the Task Manager window becomes the topmost window. I want to prevent loosing focus of my fullscreen window and don't want any other window to pop up.
Thanks.
~Donotalo()
-
April 30th, 2008, 12:58 AM
#2
Re: a window that stays topmost
You can try using the WS_EX_TOPMOST style in the CreateWindowEx function.
More info here http://msdn.microsoft.com/en-us/libr...80(VS.85).aspx .
-
April 30th, 2008, 05:08 AM
#3
Re: a window that stays topmost
My window is using this style. But then if I press ALT+TAB, the task bar is shown which is not desirable. From the task bar I can activate Task Manager. In my computer, the option Always on top is activated for Task Manager. So activating Task Manager brings it on my window. This is also undesirable. Any solution to prevent them?
~Donotalo()
-
April 30th, 2008, 05:24 AM
#4
Re: a window that stays topmost
Try using SetWindowPos API with HWND_TOPMOST.
-
April 30th, 2008, 10:50 AM
#5
Re: a window that stays topmost
Why are you trying to do this?
Please explain the usecase.
-
April 30th, 2008, 11:42 PM
#6
Re: a window that stays topmost
Code:
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindowEx( WS_EX_TOPMOST,
szWindowClass,
szTitle,
WS_MAXIMIZE | WS_POPUP,
0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
// hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
// CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 100, 100, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
// ShowWindow(hWnd, nCmdShow);
// UpdateWindow(hWnd);
return TRUE;
}
doesn't work as i wanted. pressing windows key brings up the taskbar and start menu. from there task manager can be opened. pressing Ctrl+Alt+Delete also brings up the task manager on the top of my window. i think i need to handle those keys such that they will be consumed by my program. i didn't program, but i know one way - hooking a dll. is there any other way?
usecase:
my program will be one of the startup process. so after logging in, it will not allow any other program to be foreground program. it will ask for a password. a valid password will close the window. believe it or not, sometimes i feel that i need such a software. there may be such software available freely to use, but i want to build my own. i'm a basic win32 programmer. i want to learn such advanced features of the api.
thanks for your time.
~Donotalo()
-
May 2nd, 2008, 08:07 AM
#7
Re: a window that stays topmost
Originally Posted by Donotalo
usecase:
my program will be one of the startup process. so after logging in, it will not allow any other program to be foreground program. it will ask for a password. a valid password will close the window.
If your window imitates the appearance of the login dialog box that's the perfect tool to steal passwords. This is not a hacker forum.
-
May 3rd, 2008, 12:04 AM
#8
Re: a window that stays topmost
Originally Posted by srelu
If your window imitates the appearance of the login dialog box that's the perfect tool to steal passwords. This is not a hacker forum.
The password will be set by the user and it doesn't have to be windows password. Besides, this the program I need for my personal use. I've no intention to distribute it right now.
I said before that I've learnt the basics of windows programming. I'm trying to learn some advanced features. Whenever I got stuck I post it in a forum. Whenever I ask something advanced to learn, I got stuck with this kind of reply. I wonder what is the way to learn advanced features of something like this.
~Donotalo()
-
May 3rd, 2008, 05:21 AM
#9
Re: a window that stays topmost
So you are trying to implement a login window. In that case checkout GINA.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|