Window usage tips series of articles-collaboration between windows (medium)

Source: Internet
Author: User

Variable or function call between different windows

You can apply variables or functions in other windows in the form of a window name plus a delimiter and a variable. For example, you can use w_data.is_title to reference the instance variable is_title in the w_parm window. You can use other values or assign values to a referenced variable as long as the definition of the variable permits these operations (For details, refer to the previous sections ).

In fact, this is not advocated in programming. The degree of interconnection between modules is called coupling. Program Design advocates creating low-coupling modules so that interfaces between modules are simple and programs are easy to maintain. Directly referencing variables between different windows is the highest degree of coupling (known as content coupling) and should be avoided as much as possible.

The same format is used to access window functions between different windows.

Although not, programming is quite convenient in some cases. For example, when retrieving data in the data window, you can display the retrieval progress in a small window and cancel the retrieval at any time. Assume that w_cancel is displayed in the small window when dw_1, the data window of w_data is searched. The programming process is as follows:

(1) define instance variables in the w_data window:

Boolean ib_cancel_open

(2) In the window w_data Open event:

Dw_1.SetTransObject (SQLCA)

(3) In the RetrieveStart event of the data window control dw_1 of the window w_data:

Ib_cancet_open = true // indicates that the window w_cancel has been opened.

Open (w_cancel)

(4) In the RetrieveRow event of the data window control dw_1 of the window w_data:

This. ScrollNextRow () // scroll to the newly Retrieved Data row

If IsValid (w_cancel) Then // If w_cancel is not disabled

// Display the number of records that have been retrieved on the st_count static text control in the w_cancel window

W_cancel.st_count.Text = String (This. RowCount ())

End If

 

If ib_cancel_open = False Then Return 1 // Stop Retrieval

(5) In the RetrieveEnd event of the data window control dw_1 of the window w_data:

If ib_cancel_open Then

Ib_cancel_open = False

End If

 

Close (w_cancel)

(6) In the clicked event where the w_cancel button in the window is canceled:

Parent. parentwindow (). triggerevent ("cancel_requested ")

(7) In the window w_data's Custom Event cancel_requested:

Ib_cancel_open = false

In the above program, when the data window in the window w_data starts to search, the small window w_cancel displays and keeps refreshing the number of retrieved records, in w_cancel, you can click "cancel" to terminate the search at any time. In this program, the content of the st_count control in the w_cancel of the w_data data window dw_1 is directly modified in the retrieverow event, so the two windows are content-coupled.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.