De-activating close button 
Author Message
 De-activating close button

Hi,

 I'm trying to find a way to keep a VB app  open at
 al times. Any idea of an API call that sets the
 close button to false.

 OR if possible, on NT, have an icon in the botom
 right of screen next to clock, that is activated
 on double click. Any idea how to place apps in
 this area??

 Thanks
 Gordon

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Fri, 09 Aug 2002 03:00:00 GMT  
 De-activating close button
To remove the close button on the form, the key is to actually remove the
"Close" item from the form's system menu itself.  I'm not sure of the exact
code, but I believe you have to call GetSystemMenu to retrieve the system
menu handle, then call RemoveMenuItem (not sure if that's its name, sorry)
pointing it to the hWnd you just obtained, and remove the last two items on
the menu, (easier with MF_byposition).  Doing the last two items also takes
away the bevel-bar at the bottom of the system menu.  That will then disable
the close button on the form.

As for the Tray Icon, there are a lot of free OCX's to do that, or if you
prefer you could try the ShellNotifyIcon API call, but I haven't used it
before so I'm not sure of it's exact use.

I hope some of this garbled nonsense was of use to you.
Regards,
Alex Clark

Quote:

> Hi,

>  I'm trying to find a way to keep a VB app  open at
>  al times. Any idea of an API call that sets the
>  close button to false.

>  OR if possible, on NT, have an icon in the botom
>  right of screen next to clock, that is activated
>  on double click. Any idea how to place apps in
>  this area??

>  Thanks
>  Gordon

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Fri, 09 Aug 2002 03:00:00 GMT  
 De-activating close button
To remove the close button on the form, the key is to actually remove the
"Close" item from the form's system menu itself.  I'm not sure of the exact
code, but I believe you have to call GetSystemMenu to retrieve the system
menu handle, then call RemoveMenuItem (not sure if that's its name, sorry)
pointing it to the hWnd you just obtained, and remove the last two items on
the menu, (easier with MF_byposition).  Doing the last two items also takes
away the bevel-bar at the bottom of the system menu.  That will then disable
the close button on the form.

As for the Tray Icon, there are a lot of free OCX's to do that, or if you
prefer you could try the ShellNotifyIcon API call, but I haven't used it
before so I'm not sure of it's exact use.

I hope some of this garbled nonsense was of use to you.
Regards,
Alex Clark

Quote:

> Hi,

>  I'm trying to find a way to keep a VB app  open at
>  al times. Any idea of an API call that sets the
>  close button to false.

>  OR if possible, on NT, have an icon in the botom
>  right of screen next to clock, that is activated
>  on double click. Any idea how to place apps in
>  this area??

>  Thanks
>  Gordon

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Fri, 09 Aug 2002 03:00:00 GMT  
 De-activating close button
The following code removes the 'X' close button from a form.

'##General Declaration in module
'Remove close button on forms
Public Const MF_BYPOSITION = &H400
Public Const MF_REMOVE = &H1000

Public Declare Function DrawMenuBar Lib "user32" _
      (ByVal hWnd As Long) As Long

Public Declare Function GetMenuItemCount Lib "user32" _
      (ByVal hMenu As Long) As Long

Public Declare Function GetSystemMenu Lib "user32" _
      (ByVal hWnd As Long, _
       ByVal bRevert As Long) As Long

Public Declare Function RemoveMenu Lib "user32" _
      (ByVal hMenu As Long, _
       ByVal nPosition As Long, _
       ByVal wFlags As Long) As Long '

'# Form load event
   Dim hMenu As Long
   Dim menuItemCount As Long

  'Obtain the handle to the form's system menu
   hMenu = GetSystemMenu(Me.hWnd, 0)

   If hMenu Then

     'Obtain the number of items in the menu
      menuItemCount = GetMenuItemCount(hMenu)

     'Remove the system menu Close menu item.
     'The menu item is 0-based, so the last
     'item on the menu is menuItemCount - 1
      Call RemoveMenu(hMenu, menuItemCount - 1, _
                      MF_REMOVE Or MF_BYPOSITION)

     'Remove the system menu separator line
      Call RemoveMenu(hMenu, menuItemCount - 2, _
                      MF_REMOVE Or MF_BYPOSITION)

     'Force a redraw of the menu. This
     'refreshes the titlebar, dimming the X
      Call DrawMenuBar(Me.hWnd)

   End If

HTH

Simon

Quote:

>Hi,

> I'm trying to find a way to keep a VB app  open at
> al times. Any idea of an API call that sets the
> close button to false.



Sat, 10 Aug 2002 03:00:00 GMT  
 De-activating close button

Quote:

>Hi,

> I'm trying to find a way to keep a VB app  open at
> al times. Any idea of an API call that sets the
> close button to false.

Removing the close button isn't going to do it.  User can end the program from
the Task List, or by right-clicking the program in the TaskBar and selecting
"Close".

Quote:

> OR if possible, on NT, have an icon in the botom
> right of screen next to clock, that is activated
> on double click. Any idea how to place apps in
> this area??

Go to my web page and download TRAYICON.ZIP.

Lee Weiner
weiner AT fuse DOT net
http://home.fuse.net/lweiner



Sat, 10 Aug 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Do I Find or Write the new Form Events (Activated,DeActivated,Closing,Closed)

2. Cannot activate the close current window button in the CRViewer

3. Using WhatsThisMode on command button activates button click procedure

4. Word 2000 - (De)Activating AddIn Object

5. Activate/deactivate screensaver

6. MDIList and Activate Deactivate Events

7. Activated/Deactivate event x setting MDIParent on the child window

8. activate/deactivate events

9. Activate and Deactivate - Weird Problem?!

10. Q: How can I deactivate / activate mouse pointer?

11. Activate and Deactivate event

12. ACTIVATE and DEACTIVATE events

 

 
Powered by phpBB® Forum Software