Solved

poerbuilder cancel query

Posted on 2009-04-08
2
477 Views
Last Modified: 2013-12-26
i want to make the combination of keys shift+f1 to act as cancel-query keystroke. if it is pressed it should break the query that is being executed and return control to the main program.

How can i do it?

since i am new to powerbuilder i would appreciate the answer to be as clear as possible

0
Comment
Question by:basilhs_s
2 Comments
 
LVL 18

Accepted Solution

by:
diasroshan earned 500 total points
ID: 24104736
Hi,

I am assuming u r retrieving the query in a datawindow.
dwcontrol.DBCancel ( ) is wat ur looking for.
Check PB Help for DBCancel.

You would need to use datawindow events RetrieveStart and RetrieveRow

Below is the PB Help example for DBCancel which is pretty detailed.

In this example, the menu bar for an MDI application has menu items for starting and canceling a retrieval. When the user cancels the retrieval, a user function calls DBCancel and sets a boolean instance variable to Get/SetSeriesStyle and Get/SetDataStyle. The RetrieveStart and RetrieveRow events check this variable and return the appropriate value.
In this hypothetical application, the user starts a retrieval by selecting Retrieve from a menu. The script for the Retrieve menu item calls a user function for the window:

w_async1.wf_retrieve()

The wf_retrieve function sets the Async DBParm for asynchronous processing and starts the retrieval. Because Async is set to 1, the user can select the Cancel menu item at any time, even before the first row is retrieved. (In your own application, you would include error handling to make sure Retrieve returned successfully.)

long rc
ib_cancel = false
SQLCA.DBParm = 'Async = 1'
rc = dw_1.Retrieve()

The user can stop the retrieval by selecting Cancel from the menu. The script for the Cancel menu item reads:

w_async1.wf_cancel()

The user function wf_cancel for the window w_async1 calls DBCancel and sets a flag indicating that the retrieval is canceled. Other events for the DataWindow will check this flag and abort the retrieval too. The variable ib_cancel is an instance variable for the window:

ib_cancel = true
dw_1.DBCancel()

Scripts for the RetrieveStart and RetrieveRow events both check the ib_cancel instance variable and, if it is true, stop the retrieval by returning a value of 1. In order to cancel the retrieval, some code or comment in the script for the RetrieveRow event is required:

IF ib_cancel = true THEN
        RETURN 1
END IF

//Example ends here

As far as using a combination of Shift + F1 goes,
to keep it simple, if ur using a menu, u can have a menu item and assign the shortcut key property of that menu item to Shift + F1 and keep it invisible if u want.

Else,
Check PB Help for KeyDown event (DataWindows)
u will have to create a new event in ur Datawindow with event id pbm_dwnkey
say ue_keydnw
Now,
IF keyflags = 1 THEN
      If key = KeyF1! Then      
                    //ur code here
                end if
End If

Cheers,
Rosh
0
 

Author Closing Comment

by:basilhs_s
ID: 31568410
perfect analysis for a novice to powerbuilder like me. thanks
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now