Computing.Net > Forums > Programming > VB.net: TopMost=All the time +

VB.net: TopMost=All the time +

Reply to Message Icon

Original Message
Name: etan7501
Date: November 15, 2004 at 14:40:24 Pacific
Subject: VB.net: TopMost=All the time +
OS: n/a
CPU/Ram: n/a
Comment:

I am creating a program for a guest computer at work that limits clients of full use of the computer.
Is there another way besides the TopMost option to allow the program to always stay on top? I have a button that launches Word, but when Word launches my program downsizes and is not full screen anymore.

Last question: I need to be the only that has the privalege to close this prorgam. Is there a way for whoever is trying to close the program to be prompted a password?

Any suggestions would be appreciated.
Nate.


Report Offensive Message For Removal

Response Number 1
Name: livingdecay
Date: November 16, 2004 at 09:55:34 Pacific
Subject: VB.net: TopMost=All the time +
Reply: (edit)

I know in VB6 (dont know anything about .NET) you can use the SetWindowPos API function to set a window to be topmost. It is declared like this:

'Constants:
Private Const HWND_TopMost = -1
Private Const HWND_NoTopMost = -2

' Function Declaration:
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

and implemented like this, on Form_Load event:

SetWindowPos hWnd, HWND_TopMost, 0, 0, 0, 0, &H1 Or &H2

With regards to the password, you can set the form not to have a close button on the title bar, and rather have a button on the form/menu to close the app, and use the InputBox function to prompt for a password.
Something like this like this:

Private Sub cmdClose_Click()
Dim sPassword as string
sPassword = InputBox("Enter the password", "Password")
if sPassword = "123ABC" then
End
else
MsgBox("Incorrect password")
end if
end sub

hope this helps.

Athlon XP 1800+
512Mb DDR266 RAM
Leadtek Geforce 6800
Thermaltake 360W PSU
56X CD-ROM
52x24x52 Samsung CD-RW
20 GB Maxtor HDD
80 GB Hitachi HDD
Gigabyte GA-7DX+ mobo


Report Offensive Follow Up For Removal

Response Number 2
Name: etan7501
Date: November 17, 2004 at 22:01:17 Pacific
Subject: VB.net: TopMost=All the time +
Reply: (edit)

Thanks alot for your time livingdecay. I will try all of this tonight.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: VB.net: TopMost=All the time +

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software