Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Program's windows order...

Posted on 1999-06-29
18
Medium Priority
?
206 Views
Last Modified: 2008-02-01
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...
0
Comment
Question by:sharmon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
  • 2
  • +2
18 Comments
 
LVL 1

Expert Comment

by:jdunck
ID: 1520802
 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
0
 
LVL 6

Author Comment

by:sharmon
ID: 1520803
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...
0
 
LVL 1

Expert Comment

by:jdunck
ID: 1520804
Ah.. You mean that you want your program to -always- be on the bottom..
Why show it at all?


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Author Comment

by:sharmon
ID: 1520805
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?
0
 
LVL 2

Expert Comment

by:BeedleGuis
ID: 1520806
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.
0
 
LVL 6

Author Comment

by:sharmon
ID: 1520807
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.
0
 
LVL 2

Accepted Solution

by:
header earned 600 total points
ID: 1520808
If you disable the desktop, you can get rid of having to keep the form maximized.  This will allow the users to switch programs using the taskbar, not Alt-Tab.  This code will keep the user from clicking on any icons on the desktop:


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

Sub EnableDesktop()
On Error Resume Next

Dim lParent As Long
Dim lChild1 As Long
Dim lChild2 As Long

' to enable the desktop
lParent = FindWindow("Progman", vbNullString)
lChild1 = FindWindowEx(lParent, 0, "SHELLDLL_DefView", vbNullString)
lChild2 = FindWindowEx(lChild1, 0, "SysListView32", vbNullString)
Call EnableWindow(lChild2, 5)
End Sub


Sub DisableDesktop()
On Error Resume Next

Dim lParent As Long
Dim lChild1 As Long
Dim lChild2 As Long


' disable the desktop
lParent = FindWindow("Progman", vbNullString)
lChild1 = FindWindowEx(lParent, 0, "SHELLDLL_DefView", vbNullString)
lChild2 = FindWindowEx(lChild1, 0, "SysListView32", vbNullString)
Call EnableWindow(lChild2, 0)
End Sub

However, this won't work if you are using Active Desktop's.
0
 
LVL 6

Author Comment

by:sharmon
ID: 1520809
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....
0
 
LVL 2

Expert Comment

by:header
ID: 1520810
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.
0
 
LVL 2

Expert Comment

by:header
ID: 1520811
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.
0
 
LVL 2

Expert Comment

by:header
ID: 1520812
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.
0
 
LVL 2

Expert Comment

by:header
ID: 1520813
Sorry, I don't know how that got on there three times!!!!!!

A little trigger happy I guess.
0
 
LVL 6

Author Comment

by:sharmon
ID: 1520814
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...
0
 
LVL 2

Expert Comment

by:header
ID: 1520815
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.
0
 
LVL 6

Author Comment

by:sharmon
ID: 1520816
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.....
0
 
LVL 6

Expert Comment

by:setiawan
ID: 1520817
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 :)
0
 
LVL 2

Expert Comment

by:header
ID: 1520818
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?
0
 
LVL 6

Author Comment

by:sharmon
ID: 1520819
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.....
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question