SalTblObjectsFromPoint
SalTblObjectsFromPoint
I'm using Team Developer Version 6.1-SP3r Build 34099. I need to know where ( I am concerned in which row ) the user has clicked with the right button of the mouse on a Child Table Window. I use SAM_ContextMenu message and SalTblObjectsFromPoint. But it seems that the nX and nY coordinates ( wParam, lParam ) are not correct, therefore the funcion always returns FALSE. Is it a bug or I am not properly using the function ?
Thanks
lfonda
Thanks
lfonda
-
- Founder/Site Admin
- Posts: 1188
- Joined: 24 Feb 2017, 09:12
- Location: Gouda, The Netherlands
SalTblObjectsFromPoint
The parameter values need to be recalculated, as described here:
https://wiki.tdcommunity.net/index.php/K ... tor_setups
https://wiki.tdcommunity.net/index.php/K ... tor_setups
Regards,
Dave Rabelink

Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel
Dave Rabelink

Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel
SalTblObjectsFromPoint
Thank you for your reply.
We red the article suggested and tested on a child table window SalTblObjectsFromPoint, rearranging the downloaded application: MultiMonitor_SAM_ContextMenu.apt.
The test has been carried out on a single monitor PC.
Here is a fragment of the function tested:
On SAM_ContextMenu
Call OnSAM_ContextMenu_1( wParam, lParam )
Function: OnSAM_ContextMenu_1
Description:
Returns
Boolean:
Parameters
Number: pnwParam
Number: pnlParam
Static Variables
Local variables
Boolean: bOk
Number: nRow
Number: nFlags
Window Handle: hWndCol
Actions
Set pnwParam = GetPosParam( pnwParam )
Set pnlParam = GetPosParam( pnlParam )
! -------------------------------------------------------------------------------------------------------
Call ScreenToClient( tblTest, pnwParam, pnlParam )
Set bOk = SalTblObjectsFromPoint( tblTest, pnwParam, pnlParam, nRow, hWndCol, nFlags )
Call SalClearField( dfClicked )
If NOT bOk
Set dfClicked = "ERROR"
The receive variables hWndCol and nFlags are always correct, but nRow values TBL_Error, even if we are on a editable cell.
Thanks
lfonda
We red the article suggested and tested on a child table window SalTblObjectsFromPoint, rearranging the downloaded application: MultiMonitor_SAM_ContextMenu.apt.
The test has been carried out on a single monitor PC.
Here is a fragment of the function tested:
On SAM_ContextMenu
Call OnSAM_ContextMenu_1( wParam, lParam )
Function: OnSAM_ContextMenu_1
Description:
Returns
Boolean:
Parameters
Number: pnwParam
Number: pnlParam
Static Variables
Local variables
Boolean: bOk
Number: nRow
Number: nFlags
Window Handle: hWndCol
Actions
Set pnwParam = GetPosParam( pnwParam )
Set pnlParam = GetPosParam( pnlParam )
! -------------------------------------------------------------------------------------------------------
Call ScreenToClient( tblTest, pnwParam, pnlParam )
Set bOk = SalTblObjectsFromPoint( tblTest, pnwParam, pnlParam, nRow, hWndCol, nFlags )
Call SalClearField( dfClicked )
If NOT bOk
Set dfClicked = "ERROR"
The receive variables hWndCol and nFlags are always correct, but nRow values TBL_Error, even if we are on a editable cell.
Thanks
lfonda
SalTblObjectsFromPoint
Since you wrote a test case I would suggest that you zip and attach your test case to a reply to this message thread. Since TD Help for SalTblObjectsFromPoint() says this about the nRow value:
A second thought: You can see that the TD code you pasted into your msg. is all left-justified and is more difficult to read, the correct way -- after pasting -- is to select the code in the edit window, then click the "</>" key just above the field. That causes the Forum editor to preserve the indenting. Something like this I indented the start of your code by hand):
This way it is much more readable, as you can see.
so I am not sure why nRow is invalid. With a test case that fails for you and some info. on how to run the test and how you test it (for example: Where do you right-click the mouse on or over the table window?), then we can better help you understand what the problem is.If nY is over a row then the row number is returned in nRow; otherwise nRow is TBL_Error
A second thought: You can see that the TD code you pasted into your msg. is all left-justified and is more difficult to read, the correct way -- after pasting -- is to select the code in the edit window, then click the "</>" key just above the field. That causes the Forum editor to preserve the indenting. Something like this I indented the start of your code by hand):
Code: Select all
On SAM_ContextMenu
Call OnSAM_ContextMenu_1( wParam, lParam )
Function: OnSAM_ContextMenu_1
Description:
Returns
Boolean:
Parameters
Number: pnwParam
Number: pnlParam
Static Variables
Local variables
Boolean: bOk
Number: nRow
Number: nFlags
Window Handle: hWndCol
Actions
Set pnwParam = GetPosParam( pnwParam )
... and so on
SalTblObjectsFromPoint
Thank you for your reply. I tried to send my test case as attachment, but apt extension is not allowed.
I tested in the debug environment ( not .exe ).
Clicking the mouse right button on table window:
- row header, the message box reported correctly the kind of area.
- row, the message box reported correctly the kind of area, the column, but Row number is always TBL_error ( i.e. 2147423633).
Here is the idented listing of most significant parts:
Hope to have been more exaustive in my reply supplying all the elements you need to find out my problem. Thank you for your hints to display a more readible code.
lfonda
I tested in the debug environment ( not .exe ).
Clicking the mouse right button on table window:
- row header, the message box reported correctly the kind of area.
- row, the message box reported correctly the kind of area, the column, but Row number is always TBL_error ( i.e. 2147423633).
Here is the idented listing of most significant parts:
Code: Select all
Library name: user32.dll
ThreadSafe: No
Function: ScreenToClient
Description:
Export Ordinal: 0
Returns
Boolean: BOOL
Parameters
Window Handle: HWND
structPointer
Receive Number: LONG
Receive Number: LONG
-------------------------------------------------------------------------
Form Window: frmMain
Class:
Property Template:
Class DLL Name:
Title: ContextMenu position issue
Icon File:
Accessories Enabled? No
Visible? Yes
Display Settings
Display Style? Default
Visible at Design time? Yes
Automatically Created at Runtime? Yes
Initial State: Normal
Maximizable? Yes
Minimizable? Yes
Allow Child Docking? No
Docking Orientation: All
System Menu? Yes
Resizable? Yes
Window Location and Size
Left: 1.263"
Top: 0.927"
Width: 8.05"
Width Editable? Yes
Height: 5.643"
Height Editable? Yes
Form Size
Width: Default
Height: Default
Number of Pages: Dynamic
Font Name: Default
Font Size: Default
Font Enhancement: Default
Text Color: Default
Background Color: Default
XAML Style:
Background Brush:
Description:
Named Menus
Menu
Tool Bar
Display Settings
Display Style? Default
Location? Top
Visible? Yes
Size: Default
Size Editable? Yes
Docking Toolbar? No
Toolbar Docking Orientation: Top | Bottom
Font Name: Default
Font Size: Default
Font Enhancement: Default
Text Color: Default
Background Color: Default
Resizable? No
XAML Style:
Background Brush:
Contents
Contents
Data Field: dfClicked
Class Child Ref Key: 0
Class ChildKey: 0
Class:
Property Template:
Class DLL Name:
Data
Maximum Data Length: Default
Data Type: String
Editable? Yes
Display Settings
Window Location and Size
Left: 1.15"
Top: 1.5"
Width: 1.267"
Width Editable? Yes
Height: 0.25"
Height Editable? Yes
Visible? Yes
Border? Yes
Justify: Left
Format: Unformatted
Country: Default
Font Name: Default
Font Size: Default
Font Enhancement: Default
Text Color: Default
Background Color: Default
Input Mask: Unformatted
ToolTip:
XAML Style:
Background Brush:
Text Brush:
Flow Direction: Default
Message Actions
Background Text: bkgd9
Resource Id: 54186
Class Child Ref Key: 0
Class ChildKey: 0
Class:
Window Location and Size
Left: 0.15"
Top: 1.524"
Width: 0.9"
Width Editable? Yes
Height: 0.167"
Height Editable? Yes
Visible? Yes
Justify: Right
Font Name: Default
Font Size: Default
Font Enhancement: Default
Text Color: Default
Background Color: Default
Title: R-Clicked
XAML Style:
Background Brush:
Text Brush:
Flow Direction: Default
Child Table: tblTest
Class Child Ref Key: 0
Class ChildKey: 0
Class:
Property Template:
Class DLL Name:
Display Settings
Window Location and Size
Left: 0.4"
Top: 0.25"
Width: 6.483"
Width Editable? Yes
Height: 1.155"
Height Editable? Yes
Visible? Yes
Font Name: Default
Font Size: Default
Font Enhancement: Default
Text Color: Default
Background Color: Default
View: Table
Allow Row Sizing? No
Lines Per Row: Default
Hide Column Headers? No
Memory Settings
Maximum Rows in Memory: Default
Discardable? Yes
XAML Style:
Summary Bar Enabled? No
Background Brush:
Text Brush:
Contents
Column: col1
Class Child Ref Key: 0
Class ChildKey: 0
Class:
Property Template:
Class DLL Name:
Title: Column 1
Visible? Yes
Editable? Yes
Maximum Data Length: Default
Data Type: String
Justify: Left
Width: Default
Width Editable? Yes
Format: Unformatted
Country: Default
Input Mask: Unformatted
Cell Options
Cell Type? Standard
Multiline Cell? No
Cell DropDownList
Sorted? Yes
Vertical Scroll? Yes
Auto Drop Down? No
Allow Text Editing? Yes
Cell CheckBox
Check Value:
Uncheck Value:
Ignore Case? Yes
ToolTip:
Column Aggregate Type: None
Flow Direction: Default
List Values
Text: pippo
Message Actions
Column: col2
Class Child Ref Key: 0
Class ChildKey: 0
Class:
Property Template:
Class DLL Name:
Title: Column 2
Visible? Yes
Editable? Yes
Maximum Data Length: Default
Data Type: String
Justify: Left
Width: Default
Width Editable? Yes
Format: Unformatted
Country: Default
Input Mask: Unformatted
Cell Options
Cell Type? Standard
Multiline Cell? No
Cell DropDownList
Sorted? Yes
Vertical Scroll? Yes
Auto Drop Down? No
Allow Text Editing? Yes
Cell CheckBox
Check Value:
Uncheck Value:
Ignore Case? Yes
ToolTip:
Column Aggregate Type: None
Flow Direction: Default
List Values
Message Actions
Functions
Window Variables
Message Actions
On SAM_ContextMenu
Call OnSAM_ContextMenu( wParam, lParam )
Functions
Function: OnSAM_ContextMenu
Description:
Returns
Boolean:
Parameters
Number: pnwParam
Number: pnlParam
Static Variables
Local variables
Boolean: bOk
Number: nRow
Number: nFlags
Window Handle: hWndCol
String: sTitle
Actions
Set pnwParam = GetPosParam( pnwParam )
Set pnlParam = GetPosParam( pnlParam )
! -------------------------------------------------------------------------------------------------------
Set bOk = ScreenToClient( tblTest, pnwParam, pnlParam )
Set bOk = SalTblObjectsFromPoint( tblTest, pnwParam, pnlParam, nRow, hWndCol, nFlags )
If NOT bOk
Call SalMessageBox( 'SalTblObjectsFromPoint right click', 'failed', MB_Ok )
If nFlags & TBL_XOverRowHeader
Call SalMessageBox( 'SalTblObjectsFromPoint right click', 'TBL_XOverRowHeader', MB_Ok )
If nFlags & TBL_YOverNormalRows
Call SalTblGetColumnTitle( hWndCol, sTitle, 200 )
Call SalMessageBox( 'SalTblObjectsFromPoint right click nRow = ' || SalNumberToStrX( nRow, 0 ) || ' sTitle = ' || sTitle, 'TBL_YOverNormalRows', MB_Ok )
Return bOk
Function: GetPosParam
Description:
Returns
Number:
Parameters
Number: pnUnsignedParam
Static Variables
Local variables
Actions
If pnUnsignedParam > 32767
Set pnUnsignedParam = pnUnsignedParam - 65536
Return pnUnsignedParam
Window Parameters
Window Variables
Message Actions
lfonda
-
- Founder/Site Admin
- Posts: 1188
- Joined: 24 Feb 2017, 09:12
- Location: Gouda, The Netherlands
SalTblObjectsFromPoint
As Jeff suggested, you have to ZIP your sample and upload the archive as attachment.
Regards,
Dave Rabelink

Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel
Dave Rabelink

Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel
-
- Founder/Site Admin
- Posts: 1188
- Joined: 24 Feb 2017, 09:12
- Location: Gouda, The Netherlands
SalTblObjectsFromPoint
Your code actually works perfectly.
When you click on an area which does not reflect a real populated row, the function
The code you supplied here did not populate any rows in the table, so every call to
I changed your code which inserts a couple of rows to the table. When RClicking an existing row, the row number is being returned correctly.
So, when you click on a non-populated row in the table, you get
When you click on an area which does not reflect a real populated row, the function
SalTblObjectsFromPoint
will return you a nRow having the value TBL_Error
.The code you supplied here did not populate any rows in the table, so every call to
SalTblObjectsFromPoint
will give you nRow = TBL_Error
.I changed your code which inserts a couple of rows to the table. When RClicking an existing row, the row number is being returned correctly.
So, when you click on a non-populated row in the table, you get
nRow = TBL_Error
to indicate you have clicked outside the populated part of the table.You do not have the required permissions to view the files attached to this post.
Regards,
Dave Rabelink

Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel
Dave Rabelink

Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel
SalTblObjectsFromPoint
Of course now it works perfectly. I didn't realize that you have to be on a populated row, otherwise the table window actually has no rows, even if they are painted. The help says 'If nY is over a row then the row number is returned in nRow'. Perhaps it should be clearer: 'If nY is over a populated row'.
Thank you very much.
lfonda
Thank you very much.
lfonda
SalTblObjectsFromPoint
With Dave's suggestion and your test case, I'm glad to read you have it working for you now. And... if I may reply and clarify your statement:
In fact, the error msg. your code receives when I r-click below that 4th/last row in the test can actually be trapped and used in your code that the user isn't r-clicking correctly over a created row in the TW. If there's no warning msg. created to alert the user about this, then the user might continue to try to r-click over a blank area in the TW and wonder why whatever is supposed to happen -- like a popup, context menu -- does not appear.
"Populated" is the word used to describe a table window (TW) when it contains a row or more with data in it. The rows in your test don't have to contain data; the rows just need to 'exist' -- that is -- be created with SalTblInsertRow, as your code does.Perhaps it should be clearer: 'If nY is over a populated row'.
In fact, the error msg. your code receives when I r-click below that 4th/last row in the test can actually be trapped and used in your code that the user isn't r-clicking correctly over a created row in the TW. If there's no warning msg. created to alert the user about this, then the user might continue to try to r-click over a blank area in the TW and wonder why whatever is supposed to happen -- like a popup, context menu -- does not appear.
SalTblObjectsFromPoint
Thank you very much for explanation as TW works and for coding suggestions.
lfonda
lfonda
SalTblObjectsFromPoint
You are welcome, lfonda, I am HTH!
Who is online
Users browsing this forum: [Ccbot] and 0 guests