Print Page | Close Window

Detecting R-Click prior to _FocusChanging

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=18112
Printed Date: 16 September 2024 at 7:26pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Detecting R-Click prior to _FocusChanging
Posted By: bryanu
Subject: Detecting R-Click prior to _FocusChanging
Date Posted: 23 March 2011 at 4:34pm
Hello,

I am using the report control to show a list of available reports, as the user clicks on a report or uses the Up/Down arrows, I show the details of the report selected.

However, I want the user to be able to R-Click the report and have a Pop-Up menu appear WITHOUT changing the Focus of the row that was R-Clicked.  It appears that the _FocusChanging event is fired before the _MouseDown or the _RowRClick event.

What I am trying to accomplish is the user to only be able to change the selected Row when the Left Mouse button is used or the arrow keys change the current selection, and show a Pop-Up menu when right clicked.

Any suggestions????

Regards,




-------------
Suite Pro v16.3.1

Visual Basic 6.0 ENT sp6

Windows 8.1



Replies:
Posted By: jpbro
Date Posted: 23 March 2011 at 8:42pm
I just tried a ReportControl with the following:


Private Sub Form_Load()
   With Me.ReportControl1
      .Columns.Add .Columns.Count, "Test", 100, True
     
      With .Records.Add
         .AddItem 1
      End With
      With .Records.Add
         .AddItem 1
      End With
      With .Records.Add
         .AddItem 1
      End With
      With .Records.Add
         .AddItem 1
      End With
      With .Records.Add
         .AddItem 1
      End With
      With .Records.Add
         .AddItem 1
      End With
      With .Records.Add
         .AddItem 1
      End With
      With .Records.Add
         .AddItem 1
      End With
      With .Records.Add
         .AddItem 1
      End With
      With .Records.Add
         .AddItem 1
      End With
      With .Records.Add
         .AddItem 1
      End With
     
      .Populate
   End With
End Sub


And right-clicking doesn't change the focus for me, so it seems that your desired behaviour is the default behaviour.

Unless I've misunderstood your requirements?


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: Xander75
Date Posted: 24 March 2011 at 6:47am
@jpbro

I tried your code but I too had the FocusChanging event firing, which is the default behaviour of the ReportControl.

@bryanu

I have uploaded a code example that allows you to only change the row focus on left click or up/down arrow keys, clicking with the right mouse button will no longer change the row focus.

uploads/2960/Prevent_Right_Mouse_Click.rar - uploads/2960/Prevent_Right_Mouse_Click.rar


-------------
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)


Posted By: jpbro
Date Posted: 24 March 2011 at 7:02am
Hmm, strange - my FocusChanging event does fire when I right-click (using the code I provided), but the focus doesn't actually change!




-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: Xander75
Date Posted: 24 March 2011 at 7:05am
Very strange indeed, my FocusChanging event fired also but the row focus also changed.

Maybe you have a default setting on the ReportControl which is the solution to this afterall!

The code I uploaded is a workaround using the GetAsyncKeyState API.


-------------
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)


Posted By: jpbro
Date Posted: 24 March 2011 at 7:12am
One note about using GetAsyncKeystate with VK_L/RBUTTON to test for the mouse button state is that you should also use a GetSystemMetrics check to make sure the buttons haven't been swapped by left handed users:


Option Explicit

Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const SM_SWAPBUTTON = 23
Private Const VK_LBUTTON = &H1
Private Const VK_RBUTTON = &H2

Private Function RightButtonDown() As Boolean
Dim l_Button As Long

If GetSystemMetrics(SM_SWAPBUTTON) Then
   l_Button = VK_LBUTTON
Else
   l_Button = VK_RBUTTON
End If

RightButtonDown = GetAsyncKeyState(l_Button)
End Function


I'll investigate my settings a bit more to see why the focus isn't changing...


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: Xander75
Date Posted: 24 March 2011 at 7:14am
Nice catch on the use of GetSystemMetric to check for the swapped mouse buttons!

Must admit I never did think of that!


-------------
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)


Posted By: Aaron
Date Posted: 25 March 2011 at 2:40am
Originally posted by jpbro jpbro wrote:

Hmm, strange - my FocusChanging event does fire when I right-click (using the code I provided), but the focus doesn't actually change!


 
Hi,
 
Just for the record, I used same code as Jason and focus does change as well.
 
What worries me more is the fact, when rightclicking last row (if not entirely visible) RC scrolls one row down to make that row visible and focus changes a second time.
 
To reproduce:
  • Set height of RC (in IDE) to 1695
  • Run sample
  • Rightclick last row
  • See? focus is on row after the one you rightclicked and FocusChange event fires two times as well
Thanks
  


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: Xander75
Date Posted: 25 March 2011 at 4:30am
@Aaron

I tried this out and you're right, it does set focus to the row after the one you right click on.

Looks like a bug to me!


-------------
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)


Posted By: ABuenger
Date Posted: 25 March 2011 at 8:06am
Originally posted by Aaron Aaron wrote:

 To reproduce:
  • Set height of RC (in IDE) to 1695
  • Run sample
  • Rightclick last row
  • See? focus is on row after the one you rightclicked and FocusChange event fires two times as well


Thanks, will be fixed today.



-------------
Codejock support


Posted By: jpbro
Date Posted: 25 March 2011 at 8:58am
Any idea why my focus isn't changing even though FocusChanging event fires?  In fact FocusChanging seems to fire twice (once on rbuttondown, once on rbuttonup) even though there is no visible change to focus.

Maybe something to do with Windows 2000?

Here's a video: http://www.statslog.com/rcrc.avi - http://www.statslog.com/rcrc.avi


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: Xander75
Date Posted: 25 March 2011 at 9:10am
@jpbro

I have no idea why your focus is not changing maybe one for CJ Wink, however I did notice the FocusChanging event being fired on both the mousedown and mouseup events. This might be how the issue that Aaron described above is being caused, as the row changes focus on mousedown then once the row focus moved down it the fired again on mouseup this then focused on the next row down.


-------------
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)


Posted By: SuperMario
Date Posted: 25 March 2011 at 9:30am
Originally posted by jpbro jpbro wrote:

Any idea why my focus isn't changing even though FocusChanging event fires?  In fact FocusChanging seems to fire twice (once on rbuttondown, once on rbuttonup) even though there is no visible change to focus.

Maybe something to do with Windows 2000?

Here's a video: http://www.statslog.com/rcrc.avi - http://www.statslog.com/rcrc.avi


There was a bug in 15.0.1 that was fixed in 15.0.2.  I see in your sig that 15.0.1 is used.

"Fixed bug in SetFocusedRow where the row would not become selected"


Posted By: jpbro
Date Posted: 25 March 2011 at 12:35pm
Thanks SuperMario, that would explain it ;)

I didn't move to 15.0.2 because of the reported problems about slowness that I saw in the forum. Since it's not a big issue to me about the right-click, I'll wait for 15.0.3.




-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: ABuenger
Date Posted: 25 March 2011 at 12:40pm
Hi,

I've reviewed the code changes of the report control. Selection on right-click has been introduced in 13.3 to allow dragging on right-click. Unfortunately the row will always become selected, even if dragging on right-click is disabled.

I'll add several properties that allow to define the behaviour of the report control:

SetFocus = True | False
SetSelection = True | False
EnsureVisible = True | False
StartDrag = True | False
ShowContextMenu = True | False

I'll also add default sets to reproduce the different behaviours of the Office products (Outlook, Excel).

Andre



-------------
Codejock support


Posted By: bryanu
Date Posted: 25 March 2011 at 4:49pm
Hey Guys,
 
I appreciate the help in this matter, I have it up and running now with your help.
 
Looks like the first bug I have ever uncovered in a CJ product ;)
 
Sounds like it's being addressed.
 
Regards,
 
 


-------------
Suite Pro v16.3.1

Visual Basic 6.0 ENT sp6

Windows 8.1


Posted By: ABuenger
Date Posted: 28 March 2011 at 8:08pm
Originally posted by Aaron Aaron wrote:

What worries me more is the fact, when rightclicking last row (if not entirely visible) RC scrolls one row down to make that row visible and focus changes a second time.


Fixed for 15.0.3.

@Aaron: You can test the scheme "Codejock default". If you select "Codejock 15.0.2" you'll even see the old bug. I'll also add the 13.x versions. 15.0.2 also did not select subitems on right-click, which I've changed for 15.0.3. When upgrading the report control the behavior can always be reverted with a single line of code:

wndReportControl.Behavior.Scheme = xtpReportBehaviorCodejock1502


@bryanu: I've implemented customizable behavior for 15.0.3. Please download the updated sample and let me know if the scheme "custom" works for you. It's a customized Outlook scheme. Right click a group row to see the behavior. You might also want to try the Outlook scheme, focus is only temporarily set to the row if you right-click it.




Download sample:

uploads/1755/ReportSample.zip - uploads/1755/ReportSample.zip





-------------
Codejock support


Posted By: McKloony
Date Posted: 29 March 2011 at 1:20am
Do you know, the release date of the official 15.0.3 ?

-------------
Product: Xtreme SuitePro (ActiveX) 16.2.5

Platform: XP / Windows 7

Language: Visual Basic 6.0 SP6


Posted By: SuperMario
Date Posted: 29 March 2011 at 11:03am
We don't have a date at this time.

http://www.codejock.com/corporate/release-date-policy.asp



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net