powerbuilder triggerevent example

Lets suppose that we have a window with two datawindow in it dw_1, dw_2 and two push buttons pb_1 pb_2.

pb_2 clicked event contains the following code
x1 = 1
dw_2.show()
dw_2.setfocus()


pb_1 clicked event contains the following code
x1 = 2
pb_2.triggerevent(clicked!)
messagebox("hi", string(x1))

my problem is that when i press pb1 button  pb2 clicked event is fired (x1 = 1) but dw_2 is receiving focus after the execution of messagebox command and not before it as i expected. Can i bypass this problem somehow (possibly with another technique)? i know than i can use a
responsed window containing dw_2 instead. i am interested in another solution if possible.


basilhs_sAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MarkPTXCommented:
Here's a trick we use to delay a messagebox. Create a new function in you n_appmanager:

of_postmessage return long  with 2 arguments:
string as_title
string as_msg

long ll_rc

ll_rc = MessageBox(as_title, as_msg)

Return ll_rc


Then in your code use this:

gnv_app.Post of_PostMessage('hi', String(x1))

Since you are posting this, there is no way to capture the return from the function so you cannot use this trick if you need to know which button they clicked but for OK messages, this works nicely.


You can also write a similar function if you are using the MESSAGES table and the inv_error.of_Message function. If you are, I can send you that function as well.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sandeep_patelCommented:
I am sure your datawindow is getting focus first, but you are displaying message immediately after that and hence focus is now on message box and once you close message box, it goes back to datawindow.

Write messagebox('','focus') in getfocus event of dw_2 and you will see that it's getting a focus before or not.

Regards,
Sandeep
0
basilhs_sAuthor Commented:
i used the messagebox to show that dw_2 receive the focus after the completion of pb1 clicked event.
0
basilhs_sAuthor Commented:
thanks very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.