App crashes if disabling Named TB btn over Dynalib

Report TD 5.x and 6.x bugs and possible workarounds.
a_sivababu
India
Posts: 505
Joined: 10 Mar 2017, 08:46
Location: Chennai,India

App crashes if disabling Named TB btn over Dynalib

Post by a_sivababu » 21 May 2014, 17:29

Dear Gupta Team,
We are passing Named toolbar handle into APD through user defined events. The application is crashing if I use the SalTBdisableItem(). However, It works If i try to use another Named toolbar function such as SalTbSetItemText().

I have tried couple of other ways too but application crashes.

Attached is the sample application without commenting SalTbSetItemText(). The application changes the text to "Dynamic".

The SalTBDisableItem() is currently commented and uncommenting this function will lead into application crashes.

This is tested in TD 6.2 SP1 in Windows 7 and Windows 8 with SQL Server 2008 R2

Three files are attached. LIB.APL, Sam.APT ( build this as APD) and Main.APT ( run this application to check)

Please let us know if there is any work around to resolve.

Thanks.

Regards,
Siva A.
You do not have the required permissions to view the files attached to this post.

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3522
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: App crashes if disabling Named TB btn over Dynalib

Post by Dave Rabelink » 22 May 2014, 06:50

Hi Siva,

Yes, I have a workaround for you.

Basically, you pass the current context (within the main application) to the dynalib which is used there to execute specific code within the main application.

So at Main side, you pass the window handle AND the context as message to the dynalib:

Code: Select all

On SAM_TabChange
   ! Pass current context as wParam
   Call SalSendMsg ( hWndForms[lParam], AM_Activate, SalHStringToNumber( SalContextCurrent(  ) ) , SalWindowHandleToNumber(hWndTBCRUD) )
Then at dynalib side:

Code: Select all

On AM_Activate
   ! wParam = context
   ! lParam = window handle
   Call OnActivate( SalNumberToHString( wParam ), SalNumberToWindowHandle (lParam) )

Function: OnActivate
   ! Create evaluation string
   Set sWindowHandle = SalNumberToStrX( SalWindowHandleToNumber( hWndTBCRUD ), 0 ) 
   Set sIndex = SalNumberToStrX( 0, 0 )
   Set sEval = "SalTBDisableItem( SalNumberToWindowHandle( " || sWindowHandle || " ), " || sIndex || " )"
   !
   Call SalCompileAndEvaluate( sEval, nError, nErrorPos, nNumber, sString, dtDate, hWndWindow, TRUE, psContext )

It is clearly a bug that the windowhandle can not be used on SalTBDisableItem in a dynalib context.
I have seen some other Sal functions fail, like here. This trick solves those issues.

Attached the change source:
NamedTB_Workaround.zip
You do not have the required permissions to view the files attached to this post.
Regards,
Dave Rabelink

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

a_sivababu
India
Posts: 505
Joined: 10 Mar 2017, 08:46
Location: Chennai,India

Re: App crashes if disabling Named TB btn over Dynalib

Post by a_sivababu » 22 May 2014, 10:29

Dear Dave,
Thanks a lot for your response and I have tested this and it works fine as per expectation. I am wondering or afraid about how many SAL functions are like that.

One more thing,
This is working fine in win32 architecture but I tried to test this in WPF Desktop but no effect.

I would require to do this since my end state of my product is going to be in XBAP browser.

Thank you once again.

and it would be great if you could share SAL functions which will create problems.

thanks

Regards,
Siva A

Return to “Bug Reports”

Who is online

Users browsing this forum: [Ccbot] and 1 guest