1. Erick Siliezar
  2. PowerBuilder
  3. Wednesday, 24 August 2022 15:21 PM UTC

Hi everyone, I'm using this code to verify if a checkbox was clicked in a treeview. My code is working fine in X32 environment but when I compile same code in X64 bit the function to set ib_stateclick variable is not working. For some reason the validation cannot detect the item was clicked. As a result the code in the clicked event is not executed 

Any idea about this issue? Should I use a different validation in X64?

Web recommendation: https://stackoverflow.com/questions/22978768/treeview-checkboxes-how-to-i-get-the-checked-value 

Reference

FUNCTION long HitMsg( long hWindow, uint uMsg, long wParam,  REF OS_TVHITTESTINFO lParam ) LIBRARY "user32.dll"  ALIAS FOR "SendMessageA;Ansi"

Public:
Constant uint TVM_HITTEST = 4369
Constant uint TVHT_ONITEMSTATEICON = 64

 

Mousemove event

OS_TVHITTESTINFO lstr_tvhittest

// Get Information on whether the State Icon has been clicked.
lstr_tvhittest.str_pt.l_x = UnitsToPixels( xpos, XUnitsToPixels! )
lstr_tvhittest.str_pt.l_y = UnitsToPixels( ypos, YUnitsToPixels! )

// Send message to retrieve handle to item pointed by mouse.
HitMsg( il_handle, TVM_HITTEST, 0, lstr_tvhittest )

// Set the flag if we are over a state checkbox.
IF lstr_tvhittest.l_hItem <> 0 THEN
       ib_stateclick = ( lstr_tvhittest.l_flags = TVHT_ONITEMSTATEICON )
END IF

Clicked event

IF ib_stateclick THEN
    // MY CODE
END IF

Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 24 August 2022 17:01 PM UTC
  2. PowerBuilder
  3. # 1

Make sure your structures are defined like this:

POINT
  long x
  long y

TVHITTESTINFO
  point pt
  ulong flags
  longptr hItem

Make sure your external function declaration is like this:

Function long HitMsg(longptr hWnd, ulong Msg, longptr wParam,
       Ref TVHITTESTINFO lParam) Library "user32.dll" Alias For "SendMessageW"

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 24 August 2022 16:58 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Erick - 

Here is how I would code the External Function Declaration so that it works in either 32-bit or 64-bit:

FUNCTION Longptr HitMsg ( &
   Longptr hWnd, &
   ULong   Msg, &
   Longptr wParam, &
   Longptr lParam &
   ) LIBRARY "user32.dll" ALIAS FOR "SendMessageW"

In case you are not familiar with it, the PowerBuilder Longptr datatype is a 4-byte integer in a 32-bit process and an 8-byte integer in a 64-bit process, allowing it to be used in both without having to code and use separate declarations for each bitness.

Windows handles (such as the first argument, "hWnd") also should be defined this way, as they too expand from 32-bits in a a 32-bit process into a 64-bit value in a 64-bit process.

HTH, John

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 24 August 2022 15:35 PM UTC
  2. PowerBuilder
  3. # 3

64-bit app cannot call 32-bit DLL and the data type Long might need to be handled as LongLong or LongPtr.  

You cannot simply recompile a 32-bit app as 64-bit.  You need to go through code migration process and rewrite somethings. 

Please refer to the 64-bit migration guide: https://docs.appeon.com/pb2022/migrating_32bit_applications_to_64bit/index.html

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 24 August 2022 15:35 PM UTC
  2. PowerBuilder
  3. # 4

Hi Erick;

   Basically, your code has issues for sure. For example:

  1. HitMsg => SendMessageW
  2. Handles should be LongPTR
  3. il_handle => lp_handle

HTH

Regards ... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.