Please help me to make a form immovable without using the movable property.
Thanks
Printable View
Please help me to make a form immovable without using the movable property.
Thanks
Why without using the MoveAble property?
You could intercept the WM_MOVE commands going to the form using a subclassing tool (see http://www.merrioncomputing.com/Download/index.htm for one called EventVB.dll) but this would be no different than that property.
HTH,
D
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
I believe ithat if you delete the title bar from the form, then you cannot move the form without applying certian tricks. Try it.
Iouri Boutchkine
[email protected]
Another option:
private Declare Function GetSystemMenu Lib "User" (byval hWnd%, byval bRevert%) as Integer
private Declare Function DeleteMenu Lib "user" (byval hMenu%, byval iditem%, byval wflags%) as Integer
private Const SC_SIZE = &HF000
private Const SC_MOVE = &HF010
private Const MF_BYCOMMAND = &H0
Sub Form_Load()
Dim hWnd%, hMenu%, Success%
hWnd% = me.hWnd
hMenu% = GetSystemMenu(hWnd%, 0)
Success% = deletemenu(hMenu%, SC_SIZE, MF_BYCOMMAND)
Success% = deletemenu(hMenu%, SC_MOVE, MF_BYCOMMAND)
End Sub
Deleting the corresponding item from the system menu prevents the action. This code prevents resizing too.
Hi shree,
It is an exellent solution. But I believe you have to use "user32" instead of "user"
Iouri Boutchkine
[email protected]
Oh yes, this is an example from the MSDN, and I forgot to "upgrade"
Excellent but its not working in Windows CE
Iam not finding the getSystemMenu api on windows API
Please help me
Hello Shree,
How will I know what values are to be passed for the second parameter of DeleteMenu.
You have been giving &HF000 and &HF010. How will we know what value should be specified?
Thanks
Harini
The common System menu items are Move, Size and Close, SC_CLOSE is defined as &hF060. If you want to access other items, then you can use MF_BYPOSITION and specify the position number, 0 for the first menu item. Here is the code that will remove Restore and Move from the system menu:
Code:private Declare Function GetSystemMenu Lib "user32" (byval hWnd%, byval bRevert%) as Integer
private Declare Function DeleteMenu Lib "user32" (byval hMenu%, byval iditem%, byval wflags%) as Integer
private Const SC_SIZE = &HF000
private Const SC_MOVE = &HF010
private Const MF_BYCOMMAND = &H0
private Const MF_BYPOSITION = &H400&
Sub Form_Load()
Dim hWnd%, hMenu%, Success%
hWnd% = me.hWnd
hMenu% = GetSystemMenu(hWnd%, 0)
'Success% = DeleteMenu(hMenu%, SC_SIZE, MF_BYCOMMAND)
'Success% = DeleteMenu(hMenu%, SC_MOVE, MF_BYCOMMAND)
Success% = DeleteMenu(hMenu%, 0, MF_BYPOSITION)
Success% = DeleteMenu(hMenu%, 0, MF_BYPOSITION)
End Sub
Note that I use 0 to remove the Move item too, because after Restore is removed, it is the first item in the menu.