Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Ribbonbar Systembutton
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Ribbonbar Systembutton

 Post Reply Post Reply
Author
Message
JvdH View Drop Down
Groupie
Groupie


Joined: 09 May 2008
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote JvdH Quote  Post ReplyReply Direct Link To This Post Topic: Ribbonbar Systembutton
    Posted: 24 July 2008 at 9:50am
Hi,
 
Is there a way to disable that the app closes when doubleclick on the system button, I cannot find a way to disable that.
 
Thank you :)
Back to Top
Baldur View Drop Down
Senior Member
Senior Member


Joined: 22 November 2006
Location: Germany
Status: Offline
Points: 244
Post Options Post Options   Thanks (0) Thanks(0)   Quote Baldur Quote  Post ReplyReply Direct Link To This Post Posted: 24 July 2008 at 2:31pm

In VB6 use Form_QueryUnload-Event.

Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 24 July 2008 at 3:52pm
I'm not sure if there's an easier way (I'd like to know if there is), but using the QueryUnload event as Baldur suggests doesn't differentiate between double-clicking the system button and clicking the X button. You can test for the position of the mouse cursor and make sure it is not in the SystemButton area though, so something like this works:


Private mobjSysBtn As CommandBarPopup

Private Type POINTAPI
   x As Long
   y As Long
End Type

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32.dll" (ByVal hwnd As Long, ByRef lpPoint As POINTAPI) As Long
Private Declare Function PtInRect Lib "user32.dll" (ByRef lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   Dim udtPoint As POINTAPI
   Dim udtRect As RECT
  
   With udtRect
      mobjSysBtn.GetRect .Left, .Top, .Right, .Bottom   ' Get the position of the SystemButton
   End With
  
   If UnloadMode = vbFormControlMenu Then
      GetCursorPos udtPoint    ' Get the position of the mouse pointer
      ScreenToClient Me.hwnd, udtPoint    ' Convert screen coordinates to coordinates relative to the form with the SystemButton
     
      Cancel = PtInRect(udtRect, udtPoint.x, udtPoint.y)    ' Only cancel unloading if the mouse pointer is not above the SystemButton
   End If
End Sub


A potential problem with this approach is that the program won't close if the pointer is above the SystemButton and the user press Ctrl+F4 (probably a rare circumstance, but definitely a limitation of this approach...I suppose you could perform a check to see if the Ctrl key is down and if so ignore the pointer position).

I'd be happy to be shown an easier way to do this. The only other way I know is to subclass the system button and consume WM_LBUTTONDBLCLK (complicated, but I have an example if you are interested).
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 24 July 2008 at 3:55pm
I should add, make sure to call Set mobjSysBtn = RibbonBar.AddSystemButton() (or equivalent) to assign the SystemButton to the object reference.
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.