|
-
Jun 18th, 2000, 09:03 AM
#1
Thread Starter
Lively Member
I want to make a ver. 1.1 of my app and with the up-date (and others) I want it to satay always on top. so it wont go under any other windows. so all the questions I want to know are how can I center the program in the screen, how can I make it always on top, and how can I make it so you cant move it to another area on the screen.
And if your wondering if I am just asking you all these questions for you to do the work, i'm not, i'm only 11 and I'm learning form these codes and I have to buy a book as soon as i get more money. So please help out.
Timbudtwo
I have no life, only one with computers.
VB 6.0 Enterprise Edition
[hr]
-
Jun 18th, 2000, 09:28 AM
#2
Stayontop:
[/code]
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
Public Const HWND_TOPMOST = -1
Public Const HWND_TOP = 0
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const flags = SWP_NOMOVE Or SWP_NOSIZE
Sub StayOnTop(TheForm As Form)
SetWinOnTop = SetWindowPos(TheForm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, Flags)
End Sub
Use: Stayontop Me
[/code]
Center Form:
[/code]
Public Sub CenterForm(frmForm As Form)
With frmForm
.Left = (Screen.Width - .Width) / 2
.Top = (Screen.Height - .Height) / 2
End With
End Sub
Use: CenterForm Me
[/code]
This is just an example with any coordinates (form cannot be moved past the sides nor the top):
[/code]
f Me.Left < 700 Then Me.Left = 0
If Me.Left > 8500 Then Me.Left = Screen.Width - Width
If Me.Top < 700 Then Me.Top = 0
[/code]
-
Jun 18th, 2000, 09:28 AM
#3
put this in a module
Code:
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
Global Const conHwndTopmost = -1
Global Const conSwpNoActivate = &H10
Global Const conSwpShowWindow = &H40
Public Sub FormOnTop(hWindow As Long, bTopMost As Boolean)
' Example: Call FormOnTop(me.hWnd, True)
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
wFlags = SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW Or SWP_NOACTIVATE
Select Case bTopMost
Case True
Placement = HWND_TOPMOST
Case False
Placement = HWND_NOTOPMOST
End Select
SetWindowPos hWindow, Placement, 0, 0, 0, 0, wFlags
End Sub
thats to keep it on top...
do this to make it in the center
during design time, set the start up position to 3 - center screen.
and for the moveable/not moveable question
set the form property "Movable" to False.
Simple
-
Jun 18th, 2000, 10:05 AM
#4
Thread Starter
Lively Member
every time...
every time I use this function
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
it says "invalid inside procedure"
I have vb. 4.0 if thats the prob but how can I fix it?
And none of the other functions work.
[Edited by timbudtwo on 06-18-2000 at 11:09 PM]
Timbudtwo
I have no life, only one with computers.
VB 6.0 Enterprise Edition
[hr]
-
Jun 18th, 2000, 10:32 AM
#5
Thread Starter
Lively Member
I don't have a...
I don't have a moveable opetion on mine. I have vb 4 so there are some differences. I'm 11 so don't go to hard on me.
Timbudtwo
I have no life, only one with computers.
VB 6.0 Enterprise Edition
[hr]
-
Jun 19th, 2000, 01:00 AM
#6
I don't have a moveable option either. I have no idea what Dennis is talking about.
Put the declarations and the centerform and stayontop codes in a module also.
-
Jun 19th, 2000, 02:02 AM
#7
Addicted Member
Moveable Property
Hi guys,
There is certainly a Moveable Property for Forms in VB6, I can't say if this is not included in earlier versions, because I haven't used any of them.
GRAHAM
-
Jun 19th, 2000, 03:01 AM
#8
Thread Starter
Lively Member
...
first off, I was wondering if there is a 1 line code to not be able to move it and a 3 line code to make is so it's always on top. How can you also disable ctrl+alt+delete?
Timbudtwo
I have no life, only one with computers.
VB 6.0 Enterprise Edition
[hr]
-
Jun 19th, 2000, 03:14 AM
#9
To disable Ctrl+Alt+Del, use the SystemParametersInfo API.
Code for module
Code:
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Sub DisableCtrlAltDelete(bDisabled As Boolean)
Dim X As Long
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
Now put this in the Load event of the Form.
Code:
Private Sub Form_Load()
'disable CtrlAltDel
Call DisableCtrlAltDelete(True)
End Sub
-
Jun 19th, 2000, 03:17 AM
#10
Thread Starter
Lively Member
This is the 3rd time...
I've told you before, I can't use this function
(ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
It says invalid inside function. It won't work. is there any other way?
the
Private Sub Form_Load()
'disable CtrlAltDel
Call DisableCtrlAltDelete(True)
End Sub
function doesn't work either.
[Edited by timbudtwo on 06-19-2000 at 04:21 PM]
Timbudtwo
I have no life, only one with computers.
VB 6.0 Enterprise Edition
[hr]
-
Jun 19th, 2000, 03:33 AM
#11
put the "Declare Function..... etc.." in a .bas module, and maybe in vb4 you have to specify the scope... do this
Public Delcare Function.....etc...
sorry about the moveable thing... I did not know you were using VB4.
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
|