Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - Detecting R-Click prior to _FocusChanging
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Detecting R-Click prior to _FocusChanging

 Post Reply Post Reply
Author
Message
bryanu View Drop Down
Groupie
Groupie
Avatar

Joined: 19 February 2007
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote bryanu Quote  Post ReplyReply Direct Link To This Post Topic: Detecting R-Click prior to _FocusChanging
    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
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: 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

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

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post 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
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)
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 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

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

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post 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)
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 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

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

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post 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....
Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post 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
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: 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
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

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

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post 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


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"
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: 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

Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
bryanu View Drop Down
Groupie
Groupie
Avatar

Joined: 19 February 2007
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote bryanu Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post 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



Codejock support
Back to Top
McKloony View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 January 2007
Location: Germany
Status: Offline
Points: 340
Post Options Post Options   Thanks (0) Thanks(0)   Quote McKloony Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post 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
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.422 seconds.