Skip to Content
0
Former Member
Apr 17, 2014 at 04:22 PM

Treeview popup menu in PB12.5 Winforms oddity

46 Views

Migrated a predominantly PFC app from PB 6.5 to PB 12.5 Classic, treeview popup menu did not initially fire because the code was in the rbuttonup event, which no longer fires since PB 7.0 or so. So now we post that event from the treeview rightclicked event, and everything is aces in PB 12.5 Classic.

im_tv.m_table.PopMenu (lw_parent.PointerX() + 5, lw_parent.PointerY() + 10)

In the PB 12.5 Classic PB app, the above code popped up the menu, and the event dynamically triggered by the popup menu object (when a popup item is selected) fired off as coded.

Migrated the app to a winform app in PB 12.5 Classic. The treeview popup menu "pops up", but the events dynamically triggered by the popup menu object (when a popup item is selected) are not firing. After trying to figure out a "logical" reason for this and failing, decided to slap some messageboxes in the code to see if they pop up.

Remember this code (without the messagebox) worked fine in PB 12.5 Classic as a straight up PB app.

im_tv.m_table.PopMenu (lw_parent.PointerX() + 5, lw_parent.PointerY() + 10)

messagebox("After popup menu","")

With this messagebox, the events dynamically triggered by the popup menu object (when a popup item is selected) NOW fire off as coded. Of course the users won't want to have to deal with an extraneous messagebox, so I decided to throw some crap at the wall to see what stuck. Replaced the messagebox with the yield() function. By dumb luck, that seemed to do the trick. Now the events dynamically triggered by the popup menu object (when a popup item is selected) fire off as coded, without the need for additional user interaction.

I'm not entirely confident in this code fix, I don't know why the code wasn't working in the first place, and I don't know why adding the yield() function in there would cause it to work. I would appreciate any thoughts and/experiences/alternative code fixes y'all might have on the matter, I always appreciate logic over "magic".

Thanks and regards,

Todd Oesterreich