Link to home
Start Free TrialLog in
Avatar of sharmon
sharmon

asked on

Program's windows order...

Can I make a window always be the bottom most window?  If not, is there a way to disable CTL-Alt-DEL, the Start Menu, and The Taskbar, but allow users to still use Alt-Tab to cycle through programs.  I have the hWnd of the window I want to be the bottom most window.  It's easy to make it the top windows, but I can't find anything on making it the bottom window.  My program takes control of another program, makes it full screen, disables close, taskbar, Ctl-Alt-Del so that the program is not able to be closed and the user cannot do anything that is not on this program.  The problem is that it is a menu type program and users start other programs from there, if they click back on the menu program it comes to the foreground, hiding the application, with no way to bring it back at this point.  Thanks for any help...
Avatar of jdunck
jdunck

 You could cycle through all of the windows, setting each to topmost, with yours being set first.  This would have the affect of making yours the bottom window.  
  The downside to that is that you would probably have a good deal of screen flicker as the windows are cycled.

  -JDunck
Avatar of sharmon

ASKER

I would also have to watch for every program that was loaded, grab it's hwnd and set that option....I thought of that, not a very good route unless there is something that I don't know there...
Ah.. You mean that you want your program to -always- be on the bottom..
Why show it at all?


Avatar of sharmon

ASKER

Ok, maybe I didn't say it totally correctly, my program only controls another program.  It is hidden...what it does is this:  I have a menu program that has to run at bootup, it's called Zen and is a Novell program.  What I am doing is taking off the close button from Zen, setting it to full screen, taking off all menu items, taking off the Start menu, the Ctl-Alt-Del and the taskbar.  So that Zen is the only thing the user has the choice to use.  Zen is like a menu program and it has choices of programs for the user to run.  My program never enters the picture, it runs in the backgroud, waiting for Zen to load and then makes adjustments to the system and Zen so that the user cannot do anything else.  It works very smoothly, untill a user starts one of the allowed programs from Zen and then clicks back on Zen, then the program they started gets thrown beneath Zen and cannot be accessed because I took off anyway to use the taskmanager, the startmenu and the Taskbar...I have to take those off or the program is useless.  Kinda get what I am saying now?
can't you use the setwindowpos api call setting ZEN to HWND_BOTTOM?  Of coarse, youd have to do this every time another app was started, or you could just make every app started by ZEN a topmost window.
Avatar of sharmon

ASKER

Yes, I could use HWND_BOTTOM but your right, I would have to do it evertime a program was started or they clicked back on Zen.  And I would have to grab the HWND of every program started after ZEN and my program to set it to a topmost window.  Unless there is some easy code to do that, it sure would be a mess in my mind.
ASKER CERTIFIED SOLUTION
Avatar of header
header

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sharmon

ASKER

That will work for the desktop, but what about the icons in the taskbar and the systray...I cannot let them use that nor the start menu...if you have a way to disable the systray, the taskbar icons and the start menu, I'll be very happy.....I really need to finish this up tonight....
To disable the Start Menu:

Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function EnableWindow Lib "User32" (ByVal hWnd As Long, ByVal fEnable As Long) As Long

On Error Resume Next

' to enable the start menu, ctrl+exc
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "Button", ""), 1)

' to disable the start menu, ctrl+exc
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "Button", ""), 0)



To disable the systray, Same as the above only use this statement to turn it off:
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "TrayNotifyWnd", ""), 0)
To turn it back on, just substitute a "1" for the very last param.


As for the taskbar icons, I'm not sure what you are getting at.
To disable the Start Menu:

Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function EnableWindow Lib "User32" (ByVal hWnd As Long, ByVal fEnable As Long) As Long

On Error Resume Next

' to enable the start menu, ctrl+exc
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "Button", ""), 1)

' to disable the start menu, ctrl+exc
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "Button", ""), 0)



To disable the systray, Same as the above only use this statement to turn it off:
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "TrayNotifyWnd", ""), 0)
To turn it back on, just substitute a "1" for the very last param.


As for the taskbar icons, I'm not sure what you are getting at.
To disable the Start Menu:

Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function EnableWindow Lib "User32" (ByVal hWnd As Long, ByVal fEnable As Long) As Long

On Error Resume Next

' to enable the start menu, ctrl+exc
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "Button", ""), 1)

' to disable the start menu, ctrl+exc
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "Button", ""), 0)



To disable the systray, Same as the above only use this statement to turn it off:
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "TrayNotifyWnd", ""), 0)
To turn it back on, just substitute a "1" for the very last param.


As for the taskbar icons, I'm not sure what you are getting at.
Sorry, I don't know how that got on there three times!!!!!!

A little trigger happy I guess.
Avatar of sharmon

ASKER

Ok, those two things will help...and that should have me about wrapped up...if you can tell me how to turn off the toolbars on the taskbar, that will do it for me...that's what I meant by that...I am going to implement the other stuff now and if it goes right and we can figure out how to get rid of that toolbar, we'll be all set and I'll give ya the points...thanks for your help so far...
I was just playing around and found out that this statement will take out the entire taskbar, start menu, tray icons, clock and all (so you might want to try it first, but you can get rid of the three seperate statements I gave you earlier and just use this one):

Call EnableWindow(FindWindowEx(FindWindow("", ""), 0, "Shell_TrayWnd", ""), 0)

Again just substitute the "0" with a "1" as the last param to re-enable.

Are you sure you want to disable all multitasking?  Depending on the situation, this could be very dangerous.  For example, if the user minimizes all of the apps and the taskbar is disabled, they are stuck (not to mention that the start menu is also disabled, leaving them no choice but to do a hard reboot)!  I would suggest leaving the taskbar available and just disabling the start menu and the tray icons, but it's your call.
Avatar of sharmon

ASKER

Everything is working great accept the tool bar is on the taskbar, now all I need to do is disable that toolbar and it's finished....if you figure it out, let me know, if not and I figure it out, I'll still give ya the points....the toolbar allows users to start default programs on it and I cannot allow that....I would just turn them off manually, but it has to be done programmatically because this program is going to be installed on a few hundred clients and I don't want to have to do every single one of them.  Thanks again for all of your help so far.....
To Hide the taskbar
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cY As Long, ByVal wFlags As Long) As Long

' *** Taskbar
Private Const HWND_TOPMOST = -1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_HIDEWINDOW = &H80
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOREPOSITION = &H200
Private Const SWP_NOSIZE = &H1

Public Sub HideTaskBar()
   Dim nTaskBarhWnd        As Long
   nTaskBarhWnd = FindWindow("Shell_traywnd", "")
   If nTaskBarhWnd <> 0 Then Call SetWindowPos(nTaskBarhWnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)    
End Sub

Public Sub ShowTaskBar()
   Dim nTaskBarhWnd        As Long
   nTaskBarhWnd = FindWindow("Shell_traywnd", "")
   If nTaskBarhWnd <> 0 Then Call SetWindowPos(nTaskBarhWnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
End Sub

Hope this help :)
If you are talking about the right-clicking on the taskbar, you can disable it by putting a dword value in the registry here:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer


Call the value "NoTrayContextMenu" and give it a value of 1.

This will disable the right-click menu on the taskbar, to re-enable it just change the value to 0, or delete the value completely.

This requires a reboot for the changes to take effect.


setiawan has a good point, if you are totaly disabling the taskbar, why not just hide it?
Avatar of sharmon

ASKER

I can't disable the taskbar if I need to use it for task switching, I cannot figure out a way to disable ctl-alt-del without disabling alt-tab, so the only way I can do it is to turn off everything on the taskbar but the task switching ability........I have figured out from your examples everything I needed to do and it is all working great now......I would rather hide the taskbar and disable ctl-alt-del and still leave alt-tab available but I can't figure it out.......if you ever figure that out let me know, thanks for all the help.....