Greenu Sharma
June 22nd, 2001, 05:21 AM
Please help me to make a form immovable without using the movable property.
Thanks
Thanks
|
Click to See Complete Forum and Search --> : Making the Form immovable Greenu Sharma June 22nd, 2001, 05:21 AM Please help me to make a form immovable without using the movable property. Thanks Clearcode June 22nd, 2001, 05:47 AM 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 Iouri June 22nd, 2001, 07:09 AM 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 iouri@hotsheet.com shree June 22nd, 2001, 08:47 AM 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. Iouri June 22nd, 2001, 10:12 AM Hi shree, It is an exellent solution. But I believe you have to use "user32" instead of "user" Iouri Boutchkine iouri@hotsheet.com shree June 22nd, 2001, 10:15 AM Oh yes, this is an example from the MSDN, and I forgot to "upgrade" Greenu Sharma June 23rd, 2001, 12:36 AM Excellent but its not working in Windows CE Iam not finding the getSystemMenu api on windows API Please help me Harini June 29th, 2001, 12:44 PM 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 shree June 30th, 2001, 04:18 AM 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: 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. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |