How to make a form unmoveable in VB4? 
Author Message
 How to make a form unmoveable in VB4?

Hello,
How can I prevent users form moving a not maximized form when they try
to drag it to another place???
Thanks in advance...



Mon, 21 Feb 2000 03:00:00 GMT  
 How to make a form unmoveable in VB4?



Quote:
> Hello,
> How can I prevent users form moving a not maximized form when they try
> to drag it to another place???
> Thanks in advance...

Declare the following in a Module

Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal
nPosition As Long, ByVal wFlags As Long) As Long
Global Const SC_SIZE = &HF000&
Global Const SC_MOVE = &HF010&
Global Const SC_MINIMIZE = &HF020&
Global Const SC_MAXIMIZE = &HF030&
Global Const SC_NEXTWINDOW = &HF040&
Global Const SC_PREVWINDOW = &HF050&
Global Const SC_CLOSE = &HF060&
Global Const SC_VSCROLL = &HF070&
Global Const SC_HSCROLL = &HF080&
Global Const SC_MOU{*filter*}U = &HF090&
Global Const SC_KEYMENU = &HF100&
Global Const SC_ARRANGE = &HF110&
Global Const SC_RESTORE = &HF120&
Global Const SC_TASKLIST = &HF130&
Global Const SC_SCREENSAVE = &HF140&
Global Const SC_HOTKEY = &HF150&
Global Const SC_DEFAULT = &HF160&
Global Const SC_MONITORPOWER = &HF170&
Global Const SC_CONTEXTHELP = &HF180&
Global Const SC_SEPARATOR = &HF00F&
Global Const MF_BYCOMMAND = &H0&

Then write a Procedure like this

Sub Secure_Frame(X_Frame As Form)
    Dim X_I As Long
    Dim X_HMenu As Long

    X_HMenu = GetSystemMenu(X_Frame.hwnd, &H0&)
    X_I = DeleteMenu(X_HMenu, SC_SIZE, MF_BYCOMMAND)

   Rem This is the code to make the frame unmoveable
    X_I = DeleteMenu(X_HMenu, SC_MOVE, MF_BYCOMMAND)

    X_I = DeleteMenu(X_HMenu, SC_MINIMIZE, MF_BYCOMMAND)
    X_I = DeleteMenu(X_HMenu, SC_MAXIMIZE, MF_BYCOMMAND)
    X_I = DeleteMenu(X_HMenu, SC_NEXTWINDOW, MF_BYCOMMAND)
    X_I = DeleteMenu(X_HMenu, SC_PREVWINDOW, MF_BYCOMMAND)
    X_I = DeleteMenu(X_HMenu, SC_CLOSE, MF_BYCOMMAND)
End Sub

And now you can secure your Frame by calling the function in the
load-Section of your program with

    Call Secure_Frame(Me)



Sat, 26 Feb 2000 03:00:00 GMT  
 How to make a form unmoveable in VB4?



Quote:
> Hello,
> How can I prevent users form moving a not maximized form when they try
> to drag it to another place???
> Thanks in advance...

Declare the following in a Module

Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal
nPosition As Long, ByVal wFlags As Long) As Long
Global Const SC_SIZE = &HF000&
Global Const SC_MOVE = &HF010&
Global Const SC_MINIMIZE = &HF020&
Global Const SC_MAXIMIZE = &HF030&
Global Const SC_NEXTWINDOW = &HF040&
Global Const SC_PREVWINDOW = &HF050&
Global Const SC_CLOSE = &HF060&
Global Const SC_VSCROLL = &HF070&
Global Const SC_HSCROLL = &HF080&
Global Const SC_MOU{*filter*}U = &HF090&
Global Const SC_KEYMENU = &HF100&
Global Const SC_ARRANGE = &HF110&
Global Const SC_RESTORE = &HF120&
Global Const SC_TASKLIST = &HF130&
Global Const SC_SCREENSAVE = &HF140&
Global Const SC_HOTKEY = &HF150&
Global Const SC_DEFAULT = &HF160&
Global Const SC_MONITORPOWER = &HF170&
Global Const SC_CONTEXTHELP = &HF180&
Global Const SC_SEPARATOR = &HF00F&
Global Const MF_BYCOMMAND = &H0&

Then write a Procedure like this

Sub Secure_Frame(X_Frame As Form)
    Dim X_I As Long
    Dim X_HMenu As Long

    X_HMenu = GetSystemMenu(X_Frame.hwnd, &H0&)
    X_I = DeleteMenu(X_HMenu, SC_SIZE, MF_BYCOMMAND)

   Rem This is the code to make the frame unmoveable
    X_I = DeleteMenu(X_HMenu, SC_MOVE, MF_BYCOMMAND)

    X_I = DeleteMenu(X_HMenu, SC_MINIMIZE, MF_BYCOMMAND)
    X_I = DeleteMenu(X_HMenu, SC_MAXIMIZE, MF_BYCOMMAND)
    X_I = DeleteMenu(X_HMenu, SC_NEXTWINDOW, MF_BYCOMMAND)
    X_I = DeleteMenu(X_HMenu, SC_PREVWINDOW, MF_BYCOMMAND)
    X_I = DeleteMenu(X_HMenu, SC_CLOSE, MF_BYCOMMAND)
End Sub

And now you can secure your Frame by calling the function in the
load-Section of your program with

    Call Secure_Frame(Me)



Sat, 26 Feb 2000 03:00:00 GMT  
 How to make a form unmoveable in VB4?

 Hi vandendriessche ,

You can simply use mouse_up event to set the form back to original position.

Form_MouseUp(......)
    me.top=OldTop
    me.left=OldLeft
end sub

goo luck

zack gao

************************

Quote:
>Hello,
>How can I prevent users form moving a not maximized form when they try
>to drag it to another place???
>Thanks in advance...



Sun, 27 Feb 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. HELP!-How to create unmoveable forms?

2. how set a form unmoveable

3. Making a form system Modal in vb4.0

4. VB4: Making Page Setup form

5. Making the Form invisible but making the controls seen

6. Making a form a child form of an MDI form

7. Making a form a child form of an MDI form

8. Some Help Verr much Appreciated (Modal Dialog and unmoveable windows )

9. How to make image unmoveable in listview control?

10. visible=true/Form.Show makes Form.Location change!

11. Making a Form the Active Form

12. Making a form pop-up form a button

 

 
Powered by phpBB® Forum Software