Disabled Top Right Close button in form 
Author Message
 Disabled Top Right Close button in form

How can i disabled Top Right close button in a form with api?




Sat, 16 Sep 2000 03:00:00 GMT  
 Disabled Top Right Close button in form

Use:

Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,
ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long)
As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal
nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As
Long

Sub Command_Click()
  Dim hMenu As Long
  Dim MenuItems As Long
  Dim r As Long
  Const MF_REMOVE = &H1000&
  Const MF_BYPOSITION = &H400&
  hMenu = GetSystemMenu(F.hwnd, 0)
  MenuItems = GetMenuItemCount(hMenu)
 'remove the system menu separator line
  r = RemoveMenu(hMenu, MenuItems - 1, MF_REMOVE Or MF_BYPOSITION)
 'remove the system menu Close menu item
  r = RemoveMenu(hMenu, MenuItems - 2, MF_REMOVE Or MF_BYPOSITION)
 'force a redraw of the menu,
 'this also refreshes the caption, dimming the X
  r = DrawMenuBar(F.hwnd)
End Sub

Good luck.
Vladimir.

Quote:

>How can i disabled Top Right close button in a form with api?





Sun, 17 Sep 2000 03:00:00 GMT  
 Disabled Top Right Close button in form

I did what you suggested but it did not work...
Can you send a working example ?
Guy Cohen



Quote:
> Use:

> Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,
> ByVal bRevert As Long) As Long
> Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As
Long)
> As Long
> Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long,
ByVal
> nPosition As Long, ByVal wFlags As Long) As Long
> Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As
> Long

> Sub Command_Click()
>   Dim hMenu As Long
>   Dim MenuItems As Long
>   Dim r As Long
>   Const MF_REMOVE = &H1000&
>   Const MF_BYPOSITION = &H400&
>   hMenu = GetSystemMenu(F.hwnd, 0)
>   MenuItems = GetMenuItemCount(hMenu)
>  'remove the system menu separator line
>   r = RemoveMenu(hMenu, MenuItems - 1, MF_REMOVE Or MF_BYPOSITION)
>  'remove the system menu Close menu item
>   r = RemoveMenu(hMenu, MenuItems - 2, MF_REMOVE Or MF_BYPOSITION)
>  'force a redraw of the menu,
>  'this also refreshes the caption, dimming the X
>   r = DrawMenuBar(F.hwnd)
> End Sub

> Good luck.
> Vladimir.


> >How can i disabled Top Right close button in a form with api?





Sun, 17 Sep 2000 03:00:00 GMT  
 Disabled Top Right Close button in form

But it did work when it was in Form_Load
Guy Cohen



Sun, 17 Sep 2000 03:00:00 GMT  
 Disabled Top Right Close button in form

Well it did not work yesterday.
Maybe my VB was not filling good ???
Guy Cohen



Mon, 18 Sep 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How to Disable the Close Button (X) at top right of screen

2. disabling the x button at the top right corner of a form

3. disabling the x button at the top right corner

4. disable close button without disabling make small button

5. disable the right mouse button when a form is running

6. disabled the close button in a form

7. How to disable close button on form?

8. Disabling a Forms close button

9. Disable Close Button on MDI Child Form? VB5

10. Disabling Min, Max, and Close buttons on MDI form

11. Disable the Close (X) button on the forms

12. Disable close button in a form

 

 
Powered by phpBB® Forum Software