Collection PowerBuilder Tips & Tricks. Get From The Internet
Tips 1: Changing DataWindow object by code methods
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | //==================================================================== // Changing DataWindow object by code methods //==================================================================== String error_syntaxfromSQL, error_create String new_sql, new_syntax new_sql = 'SELECT emp_data.emp_id, emp_data.emp_name from emp_data WHERE emp_data.emp_salary > 10000' new_syntax = SQLCA.SyntaxFromSQL (new_sql, 'Style (Type = Form)', error_syntaxfromSQL) If Len (error_syntaxfromSQL) > 0 Then // Display errors mle_sfs.Text = error_syntaxfromSQL Else // Generate new DataWindow dw_new.Create (new_syntax, error_create) If Len (error_create) > 0 Then mle_create.Text = error_create End If End If dw_new.SetTransObject (SQLCA) dw_new.Retrieve () |
Tips 2: Open dynamic window approach
1 2 3 4 5 6 7 8 9 10 11 12 | //==================================================================== // Open dynamic window approach: //==================================================================== window newarray [3] String win [3] Int i win [1] = "w_employee" win [2] = "w_customer" win [3] = "w_sales" For i = 1 To 3 Open (newarray [i], win [i]) Next |
Tips 3: Displays a consistent style with the Windows operating system About dialog. First, the following statement external function:
1 2 3 4 5 | //==================================================================== // Displays a consistent style with the Windows operating system About dialog. First, the following statement external function: //==================================================================== Function Int ShellAboutA (ULong al_hWnd, String as_szApp, String as_szOtherStuff, ULong hIcon) Library "shell32" ShellAboutA (Handle (Parent), "About ... # ferryman studio", "Welcome to the ferryman studio", 0) |
Tips 4: How COLUMN display style between EDIT, DDDW, DDLB switch between
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | //==================================================================== // How COLUMN display style between EDIT, DDDW, DDLB switch between: //==================================================================== //(1) Is switched To the DDDW: dw_1.Modify ("# 1.dddw.Name = 'dddw_jg'") dw_1.Modify ("# 1.dddw.DisplayColumn = 'name_jg'") dw_1.Modify ("# 1.dddw.DataColumn = 'id_jg'") //(2) switch To DDLB: dw_1.Modify ("# 1.ddlb.case = 'any'") dw_1.Object. # 1.Values = "red ~ t1 / white ~ t2" //(3) switch To the EDIT: dw_1.Modify ("# 1.edit.case = 'any'") dw_1.Modify ("# 1.edit.") //(4) Get the current Style: dw_1.Describe ("# 1.Edit.Style") //(5) If Not enough, you may have To Do the following: dw_1.Modify ("# 1.dddw.Name = ''") |
Tips 5: Few records you want to print selected in the dw_1
1 2 3 4 5 6 7 8 9 10 11 12 13 | //==================================================================== // Few records you want to print selected in the dw_1 //==================================================================== Long ll_pos dataStore lds_ds lds_ds = Create dataStore lds_ds.DataObject = dw_1.DataObject For ll_pos = 1 To dw_1.RowCount () If dw_1.IsSelected (ll_pos) Then dw_1.RowsCopy (ll_pos, ll_pos, Primary!, lds_ds, lds_ds.RowCount () + 1, Primary!) End If Next lds_ds.Print () |
Tips 6: Achieved when the cycle is terminated by clicking the button loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //==================================================================== // Achieved when the cycle is terminated by clicking the button loop //==================================================================== Integer n // sb_interrupt is shared variables sb_interrupt = False For n = 1 To 3000 Yield () Value If sb_interrupt Then // sb_interrupt modifications to true in the "Cancel" button in the Clicked event MessageBox ("I quit", "You're bad!") sb_interrupt = False Exit Else // other processing, display the current value of n in a single line editor sle_1.Text = String (n) End If Next |
Tips 7: SQL statement calling convention
1 2 3 4 5 6 7 | //==================================================================== // SQL statement calling convention //==================================================================== Integer li_customer_id = 1 String ls_city_code = '501' Prepare SQLSA From "DELETE bb_customer_info_t WHERE city_code = AND customer_id = "; Execute SQLSA Using: ls_city_code,: li_customer_id; |
Tips 8: Modify function by modifying multiple tables simultaneously
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | //==================================================================== // Modify function by modifying multiple tables simultaneously //==================================================================== //1, a new Data window d_grid_dep_emp, its Select statement Select department.dept_id, department.dept_name, employee.emp_id, employee.emp_fname, employee.emp_lname From department, employee Where employee.dept_id = department.dept_id; //2, Set the data window d_grid_dep_emp properties of the column taborder to non-zero value; //And click On the menu Rows - > Update //properties, Set This Data window Allow Updates, Table To Update To department, Updateable Columns Of //department.dept_id, department.dept_name. //3, Update the Data window button In the window Clicked Event scripting: Long ll_rtn // Modify Department table (Department table in step 2 is set to be updated) ll_rtn = dw_1.Update (True, False) If ll_rtn = 1 Then // Close modifications to the Department table dw_1.Modify ("department_dept_name.Update = 'No'") dw_1.Modify ("department_dept_id.Update = 'No'") dw_1.Modify ("department_dept_id.Key = 'No'") // Set the Employee table into a new table can be modified dw_1.Modify ("DataWindow.Table.UpdateTable = 'employee'") dw_1.Modify ("employee_emp_id.Update = 'Yes'") dw_1.Modify ("employee_emp_fname.Update = 'Yes'") dw_1.Modify ("employee_emp_lname.Update = 'Yes'") dw_1.Modify ("employee_emp_id.Key = 'Yes'") // Modify the Employee table ll_rtn = dw_1.Update () If ll_rtn = 1 Then Commit Using SQLCA; dw_1.Retrieve () MessageBox ('message', 'updated successfully!') Else Rollback Using SQLCA; MessageBox ('message', 'update failed!') End If // Reset modify flag dw_1.Modify ("department_dept_name.Update = 'Yes'") dw_1.Modify ("department_dept_id.Update = 'Yes'") dw_1.Modify ("department_dept_id.Key = 'Yes'") dw_1.Modify ("DataWindow.Table.UpdateTable = 'department'") dw_1.Modify ("employee_emp_id.Update = 'No'") dw_1.Modify ("employee_emp_fname.Update = 'No'") dw_1.Modify ("employee_emp_lname.Update = 'No'") dw_1.Modify ("employee_emp_id.Key = 'No'") Else Rollback Using SQLCA; MessageBox ('message', 'update failed!') End If // Above functions can be made a function call can be when necessary. |
Tips 9: Click Edit marquee in which the content
GetFocus Event Write code: This.SelectText (1, Len (This.Text)). Save Running, Do Not Get what we want Effect. Think Of an alternative approach: To pbm_bnclicked For the Event ID, Create a single-line EDIT box custom Event ue_clicked,
code Is: This.SelectText (1, Len (This.Text)),
code GetFocus Event changed: This.Post Event ue_clicked (). After the Save operation, the Effect came out!
Tips 10: How to get the number of characters in the string
1 2 3 4 5 6 7 8 9 10 | //==================================================================== // How to get the number of characters in the string //==================================================================== For i = 1 To Len (aString) ls_ch = Mid (aString, i, 1) If Asc (ls_ch) > = 128 Then // Chinese characters li_num ++ i = i + 1 End If Next |
Tips 11: Finally, li_num is the number of characters
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | //==================================================================== // Finally, li_num is the number of characters //==================================================================== // DW supports double-click the title to sort String ls_old_sort, ls_column, ls_name, ls_criteria Char lc_sort If Right (dwo.Name, 2) = '_t' Then // made whether the column header name ls_column = Left (dwo.Name, Len (String (dwo.Name)) - 2) ls_old_sort = This.Describe ("Datawindow.Table.sort") If ls_column = Left (ls_old_sort, Len (ls_old_sort) - 2) Then lc_sort = Right (ls_old_sort, 1) If lc_sort = 'A' Then lc_sort = 'D' Else lc_sort = 'A' End If This.SetSort (ls_column + "" + lc_sort) Else ls_criteria = ls_column + "A" This.SetSort (ls_criteria) End If This.Sort () End If |
Tips 12: DW support press Ctrl or Shift-click to select more than Line
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | //==================================================================== // DW support press Ctrl or Shift-click to select more than Line //==================================================================== Int il_last_row // il_last_row for instance variables, recording the last click Int li_current_row // current click OK Int li_row // intermediate variables // Not choose to return If row = 0 Then Return Else li_current_row = row End If If KeyDown (keyshift!) Then // press the SHIFT key If il_last_row = 0 Then This.SelectRow (row, True) il_last_row = li_current_row Else This.SelectRow (0, False) If li_current_row > il_last_row Then For li_row = il_last_row To li_current_row This.SelectRow (li_row, True) End For Else For li_row = il_last_row To li_current_row Step -1 This.SelectRow (li_row, True) End For End If End If Else // SHIFT key pressed il_last_row = li_current_row If KeyDown (keycontrol!) Then // press the CTRL key If This.IsSelected (li_current_row) Then This.SelectRow (li_current_row, False) Else This.SelectRow (li_current_row, True) End If Else // no CTRL key or SHIFT key is pressed This.SelectRow (0, False) This.SelectRow (li_current_row, True) End If End If End If End If |
Tips 13: DW queries change conditional statements
1 2 3 4 5 6 7 8 9 10 11 12 | //==================================================================== // DW queries change conditional statements //==================================================================== String ls_select, ls_filter ls_select = dw_1.GetSQLSelect () ls_select = Mid (ls_select, 1, Pos (Upper (ls_select), 'FROM') +30) ls_filter = "WHERE service_kind =" + vi_service_kind + "ORDER BY FEE_ID ASC" ls_select = ls_select + ls_filter dw_1.Reset () dw_1.SetTransObject (SQLCA) dw_1.SetSQLSelect (ls_select) dw_1.Retrieve () |
Tips 14: Datawindow: Tips to save data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //==================================================================== // data window: Tips to save data //==================================================================== //CloseQuery Event // data window: Tips to save data dw_1.AcceptText () If dw_1.ModifiedCount () + dw_1.DeletedCount () > 0 Then Choose Case MessageBox ("Operation Tips", "data has been changed, whether to save ", Question!, YesNoCancel!, 1) Case 1 cb_save.TriggerEvent (Clicked!) Case 2 Return 0 // do nothing directly to Close Case 3 Return 1 // not run Close Event, to maintain the original case End Choose End If |
Tips 15: Select to delete records
1 2 3 4 5 6 7 | //==================================================================== // Tip: Select to delete records //==================================================================== If dw_2.GetSelectedRow (0) = 0 Then MessageBox ("message", "Please select the record to be deleted!") Return End If |
Tips 16: Sorted by a field
1 2 3 4 5 6 7 8 9 10 | //==================================================================== // Sorted by a field //==================================================================== If dwo.Name = "fee_id_t" Then This.SetSort ("fee_id a") This.Sort () ElseIf dwo.Name = "fee_position_t" Then This.SetSort ("fee_position a, fee_id a") This.Sort () End If |
Tips 17: Control DATAWINDOW in the number of rows displayed per page
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //==================================================================== // Control DATAWINDOW in the number of rows displayed per page //==================================================================== //an increase In Datawindow a computational domain, named: ceil_page, the computational domain must be placed Detail section, Expression enter Ceiling (GetRow () / 25) 25 25 Rows per page said, it can be a parameter. //2, grouping, Select the menu Rows \ Create Group, Select ceil_page By ceil_page grouping, And Select new page On Group Break (meaning began To change when a new Set Of pages). //3, This computational domain Is Set To Hide (In the properties page Expression pages written In the Visible attributes 0). //4, Fill an empty Line: Write the following code In the Open Event Of the window: Long li_count, li_i li_count = dw_1.Retrieve () If Mod (li_count, 25) <> 0 Then For li_i = 1 To 25 - Mod (li_count, 25) dw_1.InsertRow (0) Next End If |
Tips 18: How to achieve data window data automatically wrap
1) Open the Datawindow Object In the Datawindow Painter.
2) Double-click the mouse On a column In the need To Set up Automatic fold Line, bounced off the properties window For This column.
3) Select the Position tab, Select AutoSize Height checkbox.
4) Select the EDIT tab And Uncheck Auto Horz Scroll checkbox.
5) click the OK button To Save your changes.
6) points Detail Band (ie Write Long belt Detail gray), And click the Right mouse button And Select properties … menu Item.
7) Select the AutoSize Height checkbox.
8) click the OK button To Save your changes.
9) Save the Datawindow.
Note: the characters together (With no punctuation Or spaces), the System will be considered as a word, does Not automatically wrap,
English Is also True …… DW window wrap If there are characters, Then it will be necessary To wrap the intermediate spaces, otherwise how To Set up will Not work. For example, you
If you want To fold In the First 20 Rows, you First determine whether it Is the First 20 characters, If Not To put a Space After the First 20, If the characters In the
the First 19 spaces. determine whether the characters In the ASCII code can use it To determine whether it Is greater than 127.
Tips 19: By conditions on color-coded data in a row
1 | Case (cj when Is > = 90 Then RGB (255,0,0) when Is < 60 Then RGB (0,255,0) Else RGB (0,0,255))) |
Tips 20: PB simultaneously connect to multiple databases, such as connecting SQLServer2000 and Oracle8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | //==================================================================== // PB simultaneously connect to multiple databases, such as connecting SQLServer2000 and Oracle8 //==================================================================== String ls_startupfile ls_startupfile = 'db.ini' SQLCA.DBMS = ProfileString (ls_startupfile, "database", "dbms", "") SQLCA.Database = ProfileString (ls_startupfile, "database", "database", "") SQLCA.UserID = ProfileString (ls_startupfile, "database", "userid", "") SQLCA.DBPass = ProfileString (ls_startupfile, "database", "dbpass", "") SQLCA.LogID = ProfileString (ls_startupfile, "database", "logid", "") SQLCA.LogPass = ProfileString (ls_startupfile, "database", "LogPassWord", "") SQLCA.ServerName = ProfileString (ls_startupfile, "database", "servername", "") SQLCA.DBParm = ProfileString (ls_startupfile, "database", "dbparm", "") remote_trans = Create Transaction remote_trans.DBMS = ProfileString (ls_startupfile, "Database_remote", "dbms", "") remote_trans.Database = ProfileString (ls_startupfile, "Database_remote", "database", "") remote_trans.UserID = ProfileString (ls_startupfile, "database_remote", "userid", "") remote_trans.DBPass = ProfileString (ls_startupfile, "database_remote", "dbpass", "") remote_trans.LogID = ProfileString (ls_startupfile, "database_remote", "logid", "") remote_trans.LogPass = ProfileString (ls_startupfile, "database_remote", "LogPassWord", "") remote_trans.ServerName = ProfileString (ls_startupfile, "database_remote", "servername", "") remote_trans.DBParm = ProfileString (ls_startupfile, "database_remote", "dbparm", "") // Attached db.ini [Database] DBMS = MSS Microsoft SQL Server 6.X Database = his UserID = DatabasePassword = ServerName = . LogID = sa Lock = Prompt = 0 computer = '11 ' ocx = 0 use0 = 's hospital management' cfprint = '1' [Database_remote] DBMS = "O84 Oracle8 / 8i (8.x.4 +)" ServerName = "oracle8" LogID = "dba" Database = zx UserID = DatabasePassword = Lock = Prompt = 0 computer = '11 ' ocx = 0 cfprint = '1' |
Tips 21: Connection Oracle8i and 9i of
1 2 3 4 5 6 7 8 9 | //==================================================================== // Connection Oracle8i and 9i of //==================================================================== SQLCA.DBMS = "O84 Oracle8 / 8i (8.x.4 +)" SQLCA.LogPass = "test" SQLCA.ServerName = "myora" SQLCA.LogID = "test" SQLCA.AutoCommit = False SQLCA.DBParm = "TableCriteria = ', test,' 'TABLE' ',' 'VIEW' ''" |
Tips 22: Retrieving data rows in a row plus
1 2 3 4 5 6 7 8 9 10 11 12 | //==================================================================== // Retrieving data rows in a row plus //==================================================================== dataWindowChild dwc dw_service.GetChild ('svcid', dwc) dwc.SetTransObject (SQLCA) dwc.Retrieve () dwc.InsertRow (1) dwc.SetItem (1, 'svcid', '00') dwc.SetItem (1, 'svcname', 'does not distinguish between') dw_service.SetTransObject (SQLCA) dw_service.Retrieve () |
Tips 23: DataWindow, press the enter key to achieve tab function (in Enter event data window)
1 2 3 4 5 | //==================================================================== // DataWindow, press the enter key to achieve tab function (in Enter event data window) //==================================================================== Send (Handle (This), 256,9, Long (0,0)) Return 1 |
Tips 24: send usage: Send (handle, message #, lowword, long)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | //==================================================================== // send usage: Send (handle, message #, lowword, long) //==================================================================== // This statement scrolls the window w_emp up one page: Send (Handle (w_emp), 277, 2, 0) // Both of the following statements click the CommandButton cb_OK: Send (Handle (Parent), 273, 0, Handle (cb_OK)) cb_OK.TriggerEvent (Clicked!) // minimizes the DataWindow: Send (Handle (dw_1), 274, 61472, 0) // maximizes the DataWindow: Send (Handle (dw_1), 274, 61488, 0) // returns the DataWindow to its normal, defined size: Send (Handle (dw_1), 274, 61728, 0) |
Tips 25: Reset search statement data window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | //==================================================================== // Reset search statement data window //==================================================================== ls_accept_city = gs_citycode ld_beg_date = DateTime (Date (em_assign_beg_date.Text), Time ('00: 00: 00 ')) ld_end_date = DateTime (Date (em_assign_end_date.Text), Time ('23: 59: 59 ')) ls_where = "WHERE b.assign_date> =: id_begin_date "+& "And b.assign_date <= : id_end_date "+& "And a.register_number = b.register_number "+& "And a.accept_city = : is_accept_city "+& "And a.action = 6 And current_action = 1 And status In (1, -1) " ls_sql = dw_wp.Describe ("DataWindow.Table.Select") If Pos (ls_sql, 'WHERE') <> 0 Then ls_sql = Mid (ls_sql, 1, Pos (ls_sql, 'WHERE') - 1) End If ls_sql = 'DataWindow.Table.Select = "' + ls_sql + ls_where + '"' ls_err_info = dw_wp.Modify (ls_sql) If ls_err_info <> "" Then MessageBox ('message', 'inquiry unusual, please verify' + ls_err_info) Return End If af_connect () dw_wp.SetTransObject (SQLCA) dw_wp.Retrieve (ld_beg_date, ld_end_date, ls_accept_city) af_disconnect () |
Tips 26: PB standard sql statement calling
1 2 3 4 5 6 7 8 9 10 11 12 | //==================================================================== // PB standard sql statement calling //==================================================================== ls_sql = "select road_name from bb_data_wide_bus_temp_t where register_number = '" + ls_register_number + "'" Declare cur_get Dynamic Cursor For SQLSA; Prepare SQLSA From: ls_sql; Open Dynamic cur_get; Fetch cur_get Into: ls_value; If SQLCA.SQLCode <> 0 Then MessageBox ('operational information', 'extraction failed!', exclamation!) End If Close cur_get; |
Tips 27: PB standard cycle call sql statement
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | //==================================================================== // PB standard cycle call sql statement //==================================================================== Declare cur_sql Dynamic Cursor For SQLSA; Prepare SQLSA From: ls_sql; Open Dynamic cur_sql; Do While SQLCA.SQLCode = 0 Fetch cur_sql Into: ls_register_number,: ls_complete_note; ll_sqlcode = SQLCA.SQLCode If ll_sqlcode < 0 Then Close cur_sql; af_disconnect () MessageBox ('error', 'Wrong number retrieved accepted!', StopSign!) Return ElseIf ll_sqlcode = 100 Then Exit End If ddlb_register_number.AddItem (Trim (ls_register_number + '|' + ls_complete_note)) Loop Close cur_sql; |
Tips 28: Generic Script window open event
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | //==================================================================== // Generic Script window open event //==================================================================== // Home window centered af_center_window (This) // Connect to the database af_connect () // Define variables dataWindowChild dwc // Get City Code drop-down list and value dw_city_code.GetChild ('city_code', dwc) dwc.SetTransObject (SQLCA) dwc.Retrieve (gs_citycode, gi_citylevel) dw_city_code.SetTransObject (SQLCA) dw_city_code.Retrieve () dw_city_code.SetItem (1, 'city_code', dwc.GetItemString (1, 'city_code')) is_city_code = dw_city_code.GetItemString (dw_city_code.GetRow (), 'city_code') // Get business type drop-down list and value dw_service_kind.GetChild ('service_kind', dwc) dwc.SetTransObject (SQLCA) dwc.Retrieve () dw_service_kind.SetTransObject (SQLCA) dw_service_kind.Retrieve () dw_service_kind.SetItem (1, 'service_kind', 10) ii_service_kind = dw_service_kind.GetItemNumber (dw_service_kind.GetRow (), 'service_kind') // Access applications drop-down list and values matter dw_apply_event.GetChild ('apply_event', dwc) dwc.SetTransObject (SQLCA) dwc.Retrieve (ii_service_kind) dw_apply_event.SetTransObject (SQLCA) dw_apply_event.Retrieve () dw_apply_event.SetItem (1, 'apply_event', dwc.GetItemNumber (1, 'apply_event')) ii_apply_event = dw_apply_event.GetItemNumber (dw_apply_event.GetRow (), 'apply_event') // Stimulate inquiry events cb_query.TriggerEvent (Clicked!) // Disconnect the database af_disconnect () |
Tips 29: Query button Generic Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | //==================================================================== // Query button Generic Script //==================================================================== // Connect to the database af_connect () // Define variables dataWindowChild dwc // retrieving data dw_1 dw_1.SetTransObject (SQLCA) dw_1.Retrieve (ii_service_kind) // retrieving data dw_2 Int li_row, li_row_temp dw_2.GetChild ('action', dwc) dwc.SetTransObject (SQLCA) dwc.Retrieve (ii_service_kind) dw_2.SetRowFocusIndicator (hand!) dw_2.SetTransObject (SQLCA) li_row_temp = dw_2.Retrieve (ii_apply_event, ii_service_kind, is_city_code) dw_2.ScrollToRow (li_row_temp) // If you do not retrieve the data into a blank line, the data on filter String ls_filter Int li_action If li_row_temp = 0 Then dw_2.InsertRow (0) Else For li_row = 1 To dw_2.RowCount () li_action = dw_2.GetItemNumber (li_row, 'action') ls_filter = 'action <>' + String (li_action) dw_1.SetFilter (ls_filter) dw_1.Filter () Next End If // Disconnect the database af_disconnect () |
Tips 30: Add button Generic Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | //==================================================================== // Add button Generic Script //==================================================================== // Variable definitions Int li_step, li_action, li_auto_status, li_row // Confirm the selection to increase the record If dw_1.GetSelectedRow (0) = 0 Then MessageBox ('prompt', 'Please select the record you want to add!', exclamation!) Return End If // Removed to increase the information li_step = dw_2.GetItemNumber (dw_2.GetRow (), 'step') li_action = dw_1.GetItemNumber (dw_1.GetSelectedRow (0), 'action') li_auto_status = dw_1.GetItemNumber (dw_1.GetSelectedRow (0), 'auto_status') // Add information li_row = dw_2.InsertRow (0) dw_2.SetItem (li_row, 'step', li_step) dw_2.SetItem (li_row, 'action', li_action) dw_2.SetItem (li_row, 'auto_status', li_auto_status) dw_2.ScrollToRow (li_row) |
Tips 31: Delete button Generic Script
1 2 3 4 5 6 7 8 9 10 11 | //==================================================================== // Delete button Generic Script //==================================================================== // First confirmation before deleting If dw_2.GetRow () = 0 Then MessageBox ('prompt', 'Please select the record to be deleted!', exclamation!) Return Else If MessageBox ("message", "really want to delete the specified record ", Question!, YesNo!, 2) = 2 Then Return dw_2.DeleteRow (dw_2.GetRow ()) End If |
Tips 32: Save button Generic Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | //==================================================================== // Save button Generic Script //==================================================================== // Connect to the database af_connect () // Define variables String ls_city_code, ls_error Int li_service_kind, li_apply_event, li_row, li_step dataWindowChild dwc // Detect whether the data changes dw_2.AcceptText () If dw_2.ModifiedCount () + dw_2.DeletedCount () = 0 Then MessageBox ("Operation Tips", "data does not change, no need to save!", exclamation!) Return End If // Detects whether empty or zero dw_2.SetSort ('step a') dw_2.Sort () For li_row = 1 To dw_2.RowCount () li_step = dw_2.GetItemNumber (li_row, 'step') If IsNull (li_step) Or li_step = 0 Then MessageBox ('operating tips', 'step can not be blank or zero, please re-enter!', exclamation!) dw_2.SetRow (li_row) Return End If Next // Save dw_2.SetTransObject (SQLCA) If dw_2.Update () = 1 Then Commit; MessageBox ("message", "saved successfully!") dw_2.ScrollToRow (dw_2.RowCount ()) Else ls_error = SQLCA.SQLErrText Rollback; MessageBox ("message", "Save Failed!" + Char (13) + ls_error, StopSign!) Return End If // Disconnect the database af_disconnect () |
Tips 33: Print button Generic Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | //==================================================================== // Print button Generic Script //==================================================================== If dw_1.RowCount () > 0 Then If PrintSetup () = -1 Then MessageBox ('message', 'printer settings wrong!', exclamation!) Return Else If dw_1.Print (True) = 1 Then // can cancel the print dialog box is displayed MessageBox ('prompt', "print success! ") Else MessageBox ('prompt', "Print fail! ", StopSign!) End If End If Else MessageBox ('prompt', "no data can be printed, please check the data! ", exclamation!) Return End If |
Tips 34: Export button Generic Script
1 2 3 4 5 6 7 8 9 10 | //==================================================================== // Export button Generic Script //==================================================================== If dw_1.RowCount () <= 0 Then MessageBox ('message', 'no data can be exported, please check!', exclamation!) Return End If If dw_1.SaveAs ('', Text!, True) = 1 Then MessageBox ('message', 'export success!') End If |
Tips 35: Import button Generic Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | //==================================================================== // Import button Generic Script //==================================================================== // Variable definitions String ls_pathfile, ls_file, ls_title, ls_ext, ls_filter Int li_pos, li_fileid Long ll_buffer // Variable assignment ls_title = "Please select the data file." ls_ext = "txt" ls_filter = "text files (* .txt), *. txt, all files (*. *), *. *" li_fileid = GetFileOpenName (ls_title, ls_pathfile, ls_file, ls_ext, ls_filter) If (li_fileid = 0 Or ls_file = "") Then Return End If sle_file_name.Text = ls_pathfile cb_OK.Enabled = True |
Tips 36: Exit button Generic Script
1 2 3 4 | //==================================================================== // Exit button Generic Script //==================================================================== Close (Parent) Or CloseWithReturn (Parent, ReturnValue) |
Tips 37: Generic script calling process
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | //==================================================================== // Generic script calling process //==================================================================== If dw_wp.RowCount () <= 0 Then Return // Variable definitions String ls_sql, ls_err_info String ls_register_number, ls_accept_city, ls_department, ls_oper_person Integer li_err_code, li_apply_event // Variable assignment ls_register_number = dw_wp.GetItemString (1, 'register_number') ls_accept_city = gs_citycode li_apply_event = dw_wp.GetItemNumber (1, 'apply_event') ls_department = gl_dealerid ls_oper_person = gs_workerid // Connect to the database af_connect () // Call with number cancellation process ls_sql = "execute bb_pstn_assign_no_repeal_p ( , , , , )" Declare proc_assign_no_repeal Dynamic Cursor For SQLSA; Prepare SQLSA From: ls_sql; Open Dynamic proc_assign_no_repeal Using: ls_register_number,: ls_accept_city,: li_apply_event,: ls_department,: ls_oper_person; If SQLCA.SQLCode = -1 Then ls_err_info = SQLCA.SQLErrText Close proc_assign_no_repeal; Rollback; MessageBox ("Error Message 1", "execution exception!" + ls_err_info, StopSign!) af_disconnect () Return End If Fetch proc_assign_no_repeal Into: li_err_code,: ls_err_info; If li_err_code < 0 Then Close proc_assign_no_repeal; Rollback; MessageBox ("Error message 2", "execution exception!" + ls_err_info, StopSign!) af_disconnect () Return End If Close proc_assign_no_repeal; Commit; // Disconnect the database af_disconnect () // Withdrawals after the success of the print work orders dw_wp.Print () |
Tips 38: PB some controls Chinese display problems
If PB’s ListView can not properly display Chinese, you should set the ListView’s FontCharSet property Into Other types. the Export ListView Where the Object Into the Source code. Find ListView definition section In the Source code, which will FontCharSet property Into DefaultCharSet! If Other controls PB corresponding phenomenon also occurs when the same adjustments To its FontCharSet properties. General Speaking For Simplified Chinese fonts In Chinese WINDOWS environment should be Set To DefaultCharSet !. Display Chinese Control In Question it’s FontChatSet property forcibly set to DefaultCharSet! Should be no problem. Or change the font !!!
Tips 39: Data type conversion
Conversion Between numeric types automatically By the System, usually converted To high-level accuracy based On the operator To participate In operations.
Precision numeric types From high To low priority as follows:
Double ← Real ← Decimal ← UnsignedLong, Long ← UnsignedInteger
String To numeric Type Conversion functions:
Integer (str), Long (str), Real (str), Double (str), Dec (str)
numeric To String Conversion Function Is:
String (Number, Format), Number Is Any numeric Type, Format After Format Conversion instructions can usually be omitted.
Tips 40: Pronouns
This: This representative Of the window, the user Object, menu, Application Object Or Control itself, which represents the Object being To whom To Write Event handlers.
Parent: Parent refers To the window Where the current Control.
ParentWindow: ParentWindow representative runtime menu window Where the pronoun used only In the Event handler menu.
Super: when writing a Control sub-objects Or Object, the child Object can Call the Parent Object’s event handler, the program can directly use the Name Of the Parent Object To Call them, can also be used To refer To Super pronouns. For example, when you want To Call the Parent Object’s Clicked event handler, sub-objects can be written: Call Super :: Clicked
Tips 41: System of five predefined global variables
SQLCA, sqlda, SQLSA, Error, Message
Tips 42: Relationship in PowerBuilder and RGB color values between the values as follows:
Color = R * 256 * 256 + G * 256 + b
Tips 43: There are fourteen kinds of standard data types
Blob binary large Object, used To store large amounts Of Data, such as images, large Text, etc., such as: Blob {100} ib_test // length 100
Boolean Boolean, Boolean variable has only two possible Values : True Or False
Char Or Character, a single ASCII Character
Date Date, including the Year (1000-3000), Month (01-12), 1999 (01-31)
DateTime Data Type DateTime Date And Time, only For Database Access
Dec Or Decimal, signed Decimal Number, maximum 18 Precision, such as: Dec {2} ld_test // 2-bit precision
Double floating-point Number With Sign, 15 significant digits
Int Or Integer, 16-bit signed Integer
Long 32-bit signed Integer
Real signed floating Point Precision 6
String String Type, ASCII characters used To store an arbitrary Length Of 0 To 60,000 (16 environments), 32 environment Length Limited only By the capacity Of the System. when the program writes directly To the String, use single quotation marks (‘) or double quotes (“) to enclose the string the Default Value Is an empty String (“”)
Time 24-Hour Time, including the Hour (00 To 23), points (00 To 59), Second (00 To 59) And the Second Decimal place (up To six), Range From 00:00:00 To 23:59: 59: 999999
UInt Or UnsignedInteger, UnsignedInt, 16-bit unsigned Integer ranging From 0 To 65,535
ULong Or UnsignedLong, 32-bit unsigned Integer ranging From 0 To 4,294,976,295
Any Type Of Any variable In Order To know the Type Of stored Data, you can use the Function ClassName ()
Tips 44: How pictures will be stored into the database
define a Bolb variable lb_file, the file Read lb_file, With insertblob Or UpdateBlob On OK
Tips 45: Variable scope
Global Variables: the entire Application can Access, its scope Is the entire Application
Instance Variables: the Object Is associated With, only be used For the Object Instance Variables defined In the Event handler Or Function Of the Object.
Instance Variables when it Is associated With an Object created Is opened, when it Is closed To disappear
Shared Variables: a Static variable, which means Not only share when it opened again After the Object Is closed Object variable remains closed Value, But also means keeping multiple instances Of the same Value With the same Name In a Class Shared Variables
Local Variables: the use Of its Event handler Or Function described In its scope Is Limited To the description Of its program segment, Any segment Of the program Places can Access Local Variables, But Other programs can Access This section block Local Variables. After Running the program, enter when a program segment, the System automatically allocates memory For Local Variables, when you Exit the program segment, the memory Of Local Variables Is released.
Tips 46: exit, continue, return
1.Exit (Exit Loop): Do … Loop And For … Next Loop statement, when we wanted To quit In the middle Of the cycle when the Exit statement, Control procedures go To the statement After the Loop, In the Case Of nested loops, Exit statement To Exit the current Level circulation, But Not All cycles.
2.Continue (continued circulation): In the body Of the Loop Do … Loop And For … Next statement, After encountering Continue statement, After the End Of the cycle does Not Execute Continue statement All statements before, And began a new Round Of circulation.
3.Return statement: Return Control To the user Or the calling Function Places. (when the termination Of the Application you want To Run, use the Halt statement), the Immediate termination Of the Event processing execution Of the program Or Function, the Control Is returned To the calling program when the Return statement at the Event handler And a user action triggers the Event After the treatment program, the implementation Of the Return statement, which immediately terminates the execution Of the Event handler And waits For the user’s next operation when the program when calling a Function Or Event handler, After executing the Return statement, which immediately terminates execution Event handler Or Function, And To Control Is returned To the calling program.
4.Halt {Close} statement: Halt statement Is used To terminate the Application To Run when Halt Close statement With no Options, the statement immediately terminate Running applications.; when Halt statement With Close option, After execution To the statement, the Application To Execute the Application Object Close Event handler, And Then re-terminate the Application.
Tips 47: DataWindow Buffer
Primary buffer, Filter buffer, Delete buffer, original buffer when we Read the Data From the Database, All Data will be placed In the main buffer (Primary buffer), And will put a Copy Of the original Buffer (original buffer) within In the Data window we can see the Data the main buffer (Primary buffer) within Any Data processing are also doing the main buffer For Data processing, But remember, no matter what we Do the Data In the buffer zone Of Any treatment, Unless we Run the Update () Function, no changes To the Data In the buffer, For the back-end Database without Any Effect.
Tips 48: How to generate a fixed-length front plus zero digits, for example: 12 generation “00012” 1234 generation “01234.” The method is simple:
1 | String (ll_number, "00000") |
Tips 49: row represents the number of rows, col represents the field name, val represents the value
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | //==================================================================== // row represents the number of rows, col represents the field name, val represents the value //==================================================================== dw_1.SetItem (row, 'col', val) dw_1.getItemX (row, 'col') // single read data faster than dot notation dw_1.Object.Data // read multi-function pen notation faster data dw_1.Object.Data [1] dw_1.Object.Data [1,2] dwc.Object.Data [1,1] dw_1.Object.Data [1,1,2,2] dw_1.Object.col [1] dw_1.Object.col.current dw_2.Object.Data = dw_1.Object.Data dw_2.Object.Data = dw_1.Object.Data.Select // Example 1 (only executed once) String ls_name [] ls_name = dw_1.Object.col.current // all data read column col // Example 2 (have to implement dw_1.rowCount () times) String ls_name [] For li_row = dw_1.RowCount () To 1 Step -1 ls_name [li_row] = dw_1.GetItemString (li_row, 'col') Next |
Tips 50: Read data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | //==================================================================== // Read data //==================================================================== Retrieve () > // = 1 the actual number of data read from the database = 0 // can not find any qualified data = -1 // Read data failed // Increase data dw_1.InsertRow (row) dw_1.InsertRow (0) // to last a // Delete data: primary => delete!! dw_1.DeleteRow (row) dw_1.DeleteRow (0) // delete all current data rows // Filtering data: primary => filter!! dw_1.SetFilter ('kind <1000') dw_1.Filter () // Data sorting dw_1.SetSort ('kind d') dw_1.Sort () // Data Clear dw_1.Reset () // remove the data from all of the buffer, but does not have any effect on the data in the database // Data calculation dw_1.RowCount () dw_1.FilteredCount () dw_1.DeletedCount () sum dw_1.ModifiedCount () // calculate all rows state DataModified! or NewModified!'s // Data Status notModified! dataModified! new! // rows only newModified! // rows only // Data copy dw_1.RowsCopy (startRow, endRow, sourceBuffer!, destDW, beforeRow, destBuffer!) dw_1.RowsCopy (dw_1.GetRow (), dw_1.RowCount (), Primary!, dw_2,1, Primary!) // Data movement dw_1.RowsMove (startRow, endRow, sourceBuffer!, destDW, beforeRow, destBuffer!) dw_1.RowsMove (1, dw_1.DeletedCount (), Delete!, dw_1,1, Primary!) // Data rolling dw_1.ScrollToRow (row) // dw parameter dwo.Name // describe () function ll_color = dw_1.Describe ('dataWindow.color') // ll_color = dw_1.dataWindow.color ll_color = dw_1.Describe ('kind_t.color') // ll_color = dw_1.kind_t.color // modify () function dw_1.Modify ("dataWindow.color = '255'") dw_1.Modify ("kind_t.color = '255'") dw_1.Modify ("kind_t.color = '0 ~ tif (kind> 1000,255,0)'") // ~ t 0 is the default value for the previous // Operating external data FileExists () FileRead () FileLength () FileClose () FileSeek () FileOpen () FileWrite () // Dbf format file, or text file tab key segment fields directly introduced in the data window buffer ImportFile (Filename, startRow, endRow, startCol, endCol, dwStartCol) |
Tips 51: How to Grid-based datawindow into Tabular type
Export Data window Into .srd file, use Notepad To Open the processing = 1 Into processing = 0
Tips 52: Yield () function
Yield () Is a Function Not used To PowerBuilder. However, a large Loop In the process, If the user wants To perform half By clicking a button Or menu To Exit, Then it must use To Yield () Function, otherwise the program will complete the entire cycle will be executed After Respond To the click Event Of the button Or menu. the Yield () Function In the middle Of the Loop body. So Find that during the execution Of the Loop has something new Pieces Of messages In the Message queue And returned immediately To Respond.
Tips 53: sqlca.SQLCode
when Using Embedded SQL For each SQL command you should Run a Check once the Transaction Object attributes SQLCode, rather than wait Until All SQL command has finished Running And Then go Run a Check Transaction Object SQLCode properties. when the Function we use the Data provided By the window, the Do you want To remember To Check SQLCode To determine whether the Run was successful. But To every Function In accordance With the Value Of the Return Run To determine whether To Run Success.
1 2 3 4 5 6 7 8 9 10 | Update tab_test Set col1 = 'test' if sqlca.sqlCode = -1 then Rollback Using SQLCA; If SQLCA.SQLCode = -1 Then MessageBox ('error', 'Connection failed!') End If MessageBox ('error', 'Connection failed!') Else Commit Using SQLCA; End If |
Tips 54: To ensure the Success Of the Data stored
1 2 3 4 5 6 7 8 9 | //==================================================================== // To ensure the Success Of the Data stored //==================================================================== If dw_1.Update () = -1 Then Rollback Using SQLCA; MessageBox ("Warning!", "Data save failed!") Else Commit Using SQLCA; End If |
Tips 55: In PB how to open a file (such as .txt, .doc), just like in Explorer, double-click to open the file the same
1 2 3 4 5 6 7 | //a: you can By API Function To achieve. //In Global External functions are defined In the Application: Function Long ShellExecuteA (ULong hwnd, String lpOperation, String lpFile, String lpParameters, String lpDirectory, Long nShowCmd) Library "shell32.dll" //Call as follows: String ls_null SetNull (ls_null) ShellExecuteA (Handle (Parent), ls_null, "c: \ doc \ hello.txt", ls_null, ls_null, 1) |
Tips 56: Insert a row after a default value to the default value but do not modify, CloseQuery event does not excite method
1 2 3 4 5 6 7 | //==================================================================== // Insert a row after a default value to the default value but do not modify, CloseQuery event does not excite method //==================================================================== Long l1_Row l1_Row = dw_1, InsertRow (dw_1, GetRow ()) dw_1.SetItem (l1_Row, "discount_pct", 0,10) dw_1.SetItemStatus (l1_Row, 0, Primary!, new!) |
Tips 57: Value of a column with a data window is retrieved based on the value of another column (on itemchanged event in DW)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | //==================================================================== // Value of a column with a data window is retrieved based on the value of another column (on itemchanged event in DW) //==================================================================== dataWindowChild dwc //Field Name If dwo.Name = "vw_type_type1" Then // Province s_type1 = Data //Field Name This.GetChild ("vw_type_type2", dwc) // County This.SetItem (This.GetRow (), "vw_type_type2", "") This.SetItem (This.GetRow (), "vw_type_type3", "") This.SetItem (This.GetRow (), "type", i_null) s_sql = "Select distinct type2 From vw_type Where type1_code =" + "'" + s_type1 + "'" // dynamically generated SQL statements dwc.SetTransObject (SQLCA) dwc.SetSQLSelect (s_sql) dwc.Retrieve () End If |
Tips 58: Dynamic DataWindow
1 2 3 4 5 6 7 8 | //==================================================================== // Dynamic DataWindow //==================================================================== //Datawindow Object Syntax: ls_syntax = SQLCA.SyntaxFromSQL ('select kind, name from tab_t', 'style (type = tabular)', ls_err1) dw_1.Create (ls_syntax, ls_err2) dw_1.SetTransObject (SQLCA) dw_1.Retrieve () |
Tips 59: Read multiple rows of data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | //==================================================================== // Read multiple rows of data //==================================================================== //1 shows a Cursor With a Declare; (Post without checking SQLCode property, To use a semicolon To End the statement.) //2 Open the Cursor Using the Open statement; //3 use the Fetch statement reads a Line Of Data; //4 processing Data; //5 To determine whether All Of the Data has been Read, repeat steps 3 To 5 when Not reading; //6. Close statement To Close the Cursor. Int Emp_num String Emp_name Declare Emp_cur Cursor For Select employee.emp_number, employee.Emp_name From employee; Open Emp_cur; Fetch Emp_cur Into: Emp_num,: Emp_name; If SQLCA.SQLCode = -1 Then Rollback; MessageBox ('', '') Return End If Close Emp_cursor; |
Tips 60: Dynamic SQL (There are four types)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | //==================================================================== // Dynamic SQL (There are four types) //==================================================================== // 1. Neither input parameters, and no result set String Mysql Mysql = "CREATE TABLE Employee" & + "(emp_id integer not null," & + "dept_id integer not null," & + "emp_fname char (10) not null," & + "emp_lname char (20) not null)" Execute Immediate: Mysql Using SQLCA; // 2. Has input parameters, but no result set Int Emp_id_var = 56 Prepare SQLSA From "DELETE FROM employee WHERE emp_id = "; Execute SQLSA Using: Emp_id_var; // 3. Already know the parameters and result set when compiling the column (cursor or stored procedure) Int Emp_id_var String Emp_state_var = "Beijing", Sqlstatement Sqlstatament = "SELECT emp_id FROM employee WHERE emp_state = " Declare my_cursor Dynamic Cursor For SQLSA; Prepare SQLSA From: Sqlstatement; Open Dynamic my_cursor Using: Emp_state_var; Fetch my_cursor Into: Emp_id_var; If SQLCA.SQLCode = -1 Then Rollback; MessageBox ('', '') Return End If Close my_cursor; // Or Int Emp_id_var String Emp_state_var = "Beijing", Proc, ls_error, ls_prompt Proc = "execute bb_pstn_complete_wp_p ( )" Declare my_cursor Dynamic Cursor For SQLSA; Prepare SQLSA From: Proc; Open Dynamic my_cursor Using: Emp_state_var; If SQLCA.SQLCode = -1 Then ls_error = SQLCA.SQLErrText Rollback; MessageBox ('message', 'process execution failed!' + Char (13) + ls_error) End If Fetch my_cursor Into: Emp_id_var; If li_flag = -1 Then Rollback; MessageBox ('message', 'process execution failed!' + Char (13) + ls_prompt) End If Close my_cursor; // 4. Development program fashion do not know the parameters and result sets String Stringvar, Sqlstatement Int Intvar Sqlstatement = "SELECT emp_id FROM employee" Prepare SQLSA From: Sqlstatement; Describe SQLSA Into sqlda; Declare my_cursor Dynamic Cursor For SQLSA; Open Dynamic my_cursor Using Descriptor sqlda; Fetch my_cursor Using Descriptor sqlda; // When the FETCH statement is executed successfully, the dynamic description area SQLDA contains the first row of the result set data can be obtained repeatedly execute the FETCH statement // Rest of the data. SQLDA.NumOutputs contains a number of output parameters. SQLDA.OutParmType array contains the data of the parameters // Example TypeInteger !, or TypeString! Etc., use CHOOSE CASE statement calling for different output parameters of different types of objects // Function to get the value of the corresponding parameter. Choose Case sqlda.OutParmType [1] Case TypeString! Stringvar = GetDynamicString (sqlda, 1) Case TypeInteger! Intvar = GetDynamicNumber (sqlda, 1) End Choose Close my_cursor; // In addition to the DECLARE statement, executed after all other statements should check SQLCode property transaction object, in order to determine whether the current SQL statement execution Successful. |
Tips 61: Get the display value of the pull-down data window
1 2 3 4 | //==================================================================== // Get the display value of the pull-down data window //==================================================================== ls_value = dw_1.Describe ("Evaluate ('LookupDisplay (column_name)'," + String (row_number) + ")") |
Tips 62: Previous column method of fixing the datawindow, for example, the first column called “id”, fixed the column and started to show from the second half of the next column:
1 2 3 4 5 6 | //==================================================================== // Previous column method of fixing the datawindow, for example, the first column called "id", fixed the column and started to show from the second half of the next column: //==================================================================== dw_1.HSplitScroll = True dw_1.Object.Datawindow.HorizontalScrollSplit = dw_1.Object.ID.Width dw_1.Object.Datawindow.HorizontalScrollPosition2 = dw_1.Object.ID.Width |
Tips 63: Print data window last one approach
1 2 3 4 5 6 7 | //==================================================================== // Print data window last one approach: //==================================================================== String ls_pagecount ls_pagecount = dw_1.Describe ("Evaluate ('PageCount ()', 0)") dw_1.Object.Datawindow.Print.page.Range = "'"+ ls_PageCount +"'" dw_1.Print () |
Tips 64: When the edit box to get focus automatically selected content
1 2 3 4 | //==================================================================== // When the edit box to get focus automatically selected content: //==================================================================== This.SelectText (1, Len (sle_1.Text)) |
Tips 65: If more than 23 this month, will be the 1st time is set for next month, otherwise take the current time
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | //==================================================================== // If more than 23 this month, will be the 1st time is set for next month, otherwise take the current time //==================================================================== // Method 1: If Day (Today ()) > 23 Then If Month (Today ()) + 1 > 12 Then This.Text = Left (String (Today (), 'yyyy-mm-dd'), 5) + '01-01' Else This.Text = String (Date (Year (Today ()), Month (Today ()) + 1,1)) End If Else This.Text = String (Today ()) End If // Method 2: dateld_temp = Today () If Day (ld_temp) > 23 Then ld_temp = Date (Year (RelativeDate (ld_temp, 10)), Month (RelativeDate (ld_temp, 10)), 1) sle_1.Text = String (ld_temp) |
Tips 66: Allows the user to modify the newly added records, and the records retrieved are not allowed to modify.
1 2 | //Open the properties listed In the Expressions, input conditions In protect the discriminant: if (isRowNew (), 0,1) |
Tips 67: Ole object, such as when using the communication with the Word, how to avoid multiple Word and other programs to start
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //==================================================================== // Ole object, such as when using the communication with the Word, how to avoid multiple Word and other programs to start: //==================================================================== OLEObject ole_object ole_object = Create OLEObject li_ret = ole_object.ConnectToObject ("", "word.application") If li_ret <> 0 Then // If Word is not open, then New. li_ret = ole_object.ConnectToNewObject ("word.application") If li_ret <> 0 Then MessageBox ('OLE Error', 'OLE unable to connect Error Number:!' + String (li_ret)) Return End If ole_object.Visible = True End If |
Tips 68: Call screen protection method in PowerBuilder
1 2 3 4 | //==================================================================== // Call screen protection method in PB: //==================================================================== Send (Handle (This), 274,61760,0) |
Tips 69: Get path when the program is running
1 2 3 4 5 6 7 8 9 10 11 | //==================================================================== // Get path when the program is running //==================================================================== // External functions declared in the global: Function ULong GetModuleFileNameA (Long hinstModule, Ref String lpszPath, ULong cchPath) Library "kernel32.dll" // Program path is stored in the variable ls_AppPath String ls_AppPath Int li_ret ls_AppPath = Space (128) li_ret = GetModuleFileNameA (Handle (GetApplication ()), ls_AppPath, 128) // To compile into an executable file .exe available, otherwise get is the path of pb60.exe or PB050.exe of Powerbuilder. |
Tips 70: Editing style columns dynamically set in the program for the pull-down data window (DropDownDataWindow)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | //==================================================================== // Editing style columns dynamically set in the program for the pull-down data window (DropDownDataWindow) //==================================================================== // Assumptions set as department number "department_id", associated sub-data window for "d_dddw_dep", // Display as a department name "dept_name", data as department number "dept_id", achieved as follows: dw_1.Modify ("department_id.DDDW.Name = d_dddw_dep") dw_1.Modify ("department_id.DDDW.DisplayColumn = 'dept_name'") dw_1.Modify ("department_id.DDDW.DataColumn = 'dept_id'") // Or: dw_1.Object.department_id.dddw.Name = "d_dddw_dep" dw_1.Object.department_id.dddw.DisplayColumn = "dept_name" dw_1.Object.department_id.dddw.DataColumn = "dept_id" // Note: PowerBuilder has a small tool DWSyntax (program called: dwsyn60.exe), provides access to and modification of the data window, //The syntax of the attribute value // columns, etc., of the programming is very helpful. These scripts can be found in DWSyntax. |
Tips 71: Incremental search function realization
1 2 3 4 5 6 7 8 9 10 11 12 13 | //==================================================================== // Incremental search function realization //==================================================================== // 1. Line editor for user-defined event ue_enchange, ID events is: pbm_enchange. This event can respond to keyboard input. // 2. Write the following script in a single-line editor ue_enchange event: Long ll_found_row String ls_find ls_find = "string (id) like" + "'" + This.Text + "%'" // search conditions (left part of the single-line text editor equivalent) ll_found_row = dw_1.Find (ls_find, 1, dw_name.RowCount ()) // find qualified OK If ll_found_row <= 0 Then Return dw_1.ScrollToRow (ll_found_row) // scroll to match the line dw_1.SelectRow (0, False) dw_1.SelectRow (ll_found_row, True) // will highlight matching lines |
Tips 72: How in the program written for the database BLOB
1 2 3 4 5 6 7 8 9 10 | //==================================================================== // How in the program written for the database BLOB //==================================================================== //And database-related: to SQLANYWAY example: //General use UPDATEBLOB And SELECTBLOB two SQL statement to achieve. //Build a Table TABLE1, a field is ID, And the other is BLOB, SelectBlob Blob From TABLE1 Where ID = 'xx'; UpdateBlob Set Blob = : BLB_X From TABLE1 Where ID = 'yy'; //deleted when you Delete ID Is 'mm' records can be, Is To Insert a new ID as 'mm' records, And Then writes the Data With UpdateBlob //Table. Other Databases may reference manual, the command above Is Not very different! |
Tips 73: How to remove content DDDW the Display Column of
1 2 3 4 5 | //==================================================================== // How to remove content DDDW the Display Column of. //==================================================================== dw_1.Describe ("Evaluate ('lookupdisplay (column_name)', 1)") // column_name = column name, 'a' represents the first row; look at Help the Describe |
Tips 74: Shielded window ALT + F4 keys
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //==================================================================== // Shielded window ALT + F4 keys //==================================================================== // Method one: 1 add the following code In SystemKey Event window: If KeyDown (KeyF4!) Then Message.Processed = True End If 2 add the following code In CloseQuery Event window: Long ll_ret If KeyDown (KeyF4!) Then ll_ret = 1 End If Return ll_ret // Method two: //build a Instance Variables In your True Then Close the program assigns a Value judgment that CloseQuery, such as False Then Return 1 |
Tips 75: How to achieve in PB delay
1 2 3 4 5 | //==================================================================== // How to achieve in PB delay: //==================================================================== Subroutine Sleep (Long dwMilliseconds) Library "kernel32.dll" //Delay Of one Second Is called: Sleep (1000) // milliseconds. |
Tips 76 : With the following expression can be obtained in a certain group recorded line number:
1 2 3 4 | //==================================================================== // With the following expression can be obtained in a certain group recorded line number: //==================================================================== GetRow () - First (GetRow () For Group 1) +1 |
Tips 77: Call the API function steps
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | //==================================================================== // Call the API function steps: //==================================================================== //1, In the appropriate Position statement functions, such as WINDOWS, the Application, UserObject inside, //defined In the Local External Function Or Global External Function, as playing sounds: Function Boolean sndPlaySoundA (String SoundName, UInt Flags) Library "WINMM.DLL" Function UInt waveOutGetNumDevs () Library "WINMM.DLL" //you can also Create a UserObject, centralized declared common API And localization functions, such as the definition Of user objects u_external_function: //Declare Local External Function (define external function): Function Boolean sndPlaySoundA (String SoundName, UInt Flags) Library "WINMM.DLL" Function UInt waveOutGetNumDevs () Library "WINMM.DLL" //Declare User Object Function (user-defined object function): uf_play_sound (String as_wave_name, Integer ai_option) //Function as follows: // Parameters: as_wave_name: wav file name ai_option: synchronous or asynchronous (1/0) UInt lui_numdevs lui_numdevs = WaveOutGetNumDevs () If lui_numdevs > 0 Then sndPlaySoundA (as_wave_name, ai_option) Return 1 Else Return -1 End If //2, the definition of an entity called In the program And call its function: u_external_function iu_external_function iu_external_function = Create u_external_function iu_external_function.uf_play_sound ('c: \ windows \ media \ ding.wav', 1) //Try, if you have a sound card, you will hear a "ding" sound. Other API functions are treated as such. |
Tips 78: GRID format data under the window, according to the actual situation of each row to control the background
1 2 3 4 5 6 7 8 | //==================================================================== // GRID format data under the window, according to the actual situation of each row to control the background //==================================================================== // Adjust the properties of the color detail the expression on it, such as: If (currentrow () = GetRow (), RGB (255,240,194), If (Mod (GetRow (), 2) = 1, RGB (255,254,249), RGB (247,247,239))) // Expression rgb (255,240,194) as a yellow, rgb (255,254,249) as a pale white, rgb (247,247,239) as a pale yellow. // CurrentRow () to get the data window to get the input focus current line number. // GetRow () returns the data window corresponding with the current line number. |
Tips 79: Achieve the data window of a column / row is displayed as a specified color
1 2 3 4 5 6 7 8 | //==================================================================== // Achieve the data window of a column / row is displayed as a specified color //==================================================================== // If you meet the conditions, displays a gray background, otherwise white; //This method can also Set the font color of the column: Where "column_name" as the column name. dw_1.Object.column_name.background.Color = "16777215 ~ tif (fromid = 'string', rgb (192,192,192), rgb (255,255,255))" //May also have a line color: dw_1.Object.Datawindow.detail.Color = "16777215 ~ tif (fromid = 'string', rgb (192,192,192), rgb (255,255,255))" |
Tips 80: In the data window How to hide a computing unit
Set In its properties \ expression \ visible property “IF (1 = 2,1,0)” on it.
Tips 81: Hyperlink
1 2 3 4 5 6 7 | //==================================================================== // Hyperlink //==================================================================== Inet linet_base GetContextService ("Internet", linet_base) linet_base.HyperLinkToURL ('https://pblib.com/') Destroy (linet_base) |
Tips 82: get value of the expression
1 2 3 4 5 6 7 8 9 10 11 12 13 | // ================================================ =========================== // Function: Returns the value of the expression // Parameters: string thestr calculation expression, such as 2 * (3 + 5) // Return value: string retVal calculated value of the expression, such as 2 * (3 + 5) result is 16 // If it is an incorrect expression, returns false. // ================================================ =========================== String retVal dataStore lds_evaluate lds_evaluate = Create dataStore lds_evaluate.Create ('release 8; ~ r ~ ntable ()') retVal = lds_evaluate.Describe ("evaluate ('" + thestr + "', 1)") Destroy lds_evaluate Return retVal |
Tips 83: Commonly used API functions by example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | //==================================================================== // Commonly used API functions by example //==================================================================== //1. How to make PB window always on top (Always On Top) //By SetWindowPos function to display the level of the window changes to HWND-TOPMOST, you can make the specified window will never be another window cover //Cover, this function is declared as: //Function Long SetWindowPos (Long hwnd, Long ord, Long x, Long y, Long dx, Long dy, Long uflag) Library "user32" //Parameter 1 to be the top-level display window handle parameter 2 to specify the display level, parameter 7 as an additional option, the remaining parameters specify the window position And //Size, can be ignored. Add the following function In Open Or Activate event window to call: SetWindowPos (Handle (This), - 1,0,0,0,0,3) //parameter 2 To take -1 indicates the topmost Display window, take 1 represents the lowest Level In the Display; //If we take one Last parameter, indicating that the window size remains //variable, indicating the holder 2 To take the same Position, And therefore, take 3 ( = 1 + 2) indicates the size And Position remain unchanged, 0, it indicates the size Of the window, And //Position Is changed To the specified Value. //2. how To Get the disc drive In PB //you can Get the drive through GetDriveType Function (eg: floppy drive, hard disk, CD-ROM, network mapped Drives, etc.) information, the Function //declared as: Function UInt GetDriveTypeA (String drive) Library "kernel32.dll" //parameters For a drive letter (such as "C:"), the Return Value: 1 means unknown, 2 floppy drive, Three said the Local hard drive, 4 represents a network drive, //5 shows the optical drive. therefore, the following code can Get the disc drive: For i = Asc ('D') To Asc ('Z') // Enumerate all possible CDROM drive If GetDriveTypeA (Char (i) + ":") = 5 Then // If you find CDROM MessageBox ("CDROM", Char (i) + ":") // Display disc drive Exit // exit list End If Next //3. how To Get directory information In PB //Get the current directory. you can Get the current directory By GetCurrentDirectory Function, which Is declared as: Function ULong GetCurrentDirectoryA (ULong buflen, Ref String dir) Library "kernel32.dll" //parameter 2 To receive the current directory Character buffer, Ref must be added In front Of said Address references; //parameter 1 To Length specified Character buffer. //Call the Procedure as follows: String curdir curdir = Space (256) // Opened up space for character buffer memory GetCurrentDirectoryA (256, curdir) MessageBox ("Current Directory", curdir) //Get WINDOWS And System directories. GetWindowsDirectory And GetSystemDirectory To use two functions, Subject To the following statement: Function UInt GetWindowsDirectoryA (Ref String dir, UInt buflen) Library "kernel32.dll" Function UInt GetSystemDirectoryA (Ref String dir, UInt buflen) Library "kernel32.dll" //4. how In the PB off the current user, shut down the computer, Restart the computer //ExitWindowsEx Function can be achieved By These Three functions, First make the following statement: Function Long ExitWindowsEx (Long uflag, Long nouse) Library "user32.dll" //parameter 2 remains unused, it Is advisable 0; //take 0 parameters one can Log off the current user, you can take a turn off the computer, take the two can Restart the computer, And its Value //Plus 4 represents the forced End "not responding" process. //5. Control program Run By the Run (referred To Run program) //In the PB programming, some programs can be Run Using Run (). For example, the user presses the F1, you Run a chm file. Run the program But can Not //PB coordination With the main program, If the user presses a Number Of F1, will launch multiple instances Run the program, the main program exits, Run the program remains //operation. you can use the following functions To Enable them To coordinate work: Function ULong FindWindowA (ULong ClassName, String windowname) Library "user32.dll" Function Long SetParent (Long childwin, Long parentwin) Library "user32.dll" make Run the program Run only one Instance Of Handle = FindWindowA (nul, wtitle) // Look for Run program is already running, wtitle title Run program If Handle > 0 Then Return // If you are already running on return Run ("C: \ Program Files \ Joint \ Joint.chm") // Otherwise run Run program //when ⑵PB main Exit, Run program also closed Handle = FindWindowA (nul, wtitle) SetParent (Handle, Handle (w-main)) // Make Run PB main program window becomes a child window //6. Mapping a network drive //To program the remote host's resources mapped to a local drive, you can use the following function: //Function Long WNetAddConnectionA (String path, String pwd, String drv) Library "mpr.dll" //the following code can share Files On a remote host Alexander My Documents folder Is mapped To the Local J disk: WNetAddConnectionA ("\\ Alexander \ My Documents", "", "J:") // parameter 2 to access password //it acts To perform at the DOS Prompt: Net use J: file: // alexandermy / Documents //7. Show Or Hide the WINDOWS taskbar //To Show Or Hide the taskbar, it must First Get the window Handle. taskbar Is a Special window, its window Class as follows: //Shell-TrayWnd, no Title, it can only be used FindWindowEx Function To Get its Handle: Function Long FindWindowEx (Long ph, Long ch, Ref String cn, Ref String wn) Library 'user32' Function Long ShowWindow (Long hwnd, Long nCmdShow) Library 'user32' //use ShowWindow To Show Or Hide the window, its Second parameter Is 0 To Hide For five, said Display: Handle = FindWindowEx (0,0, "Shell-TrayWnd", wn) // wn empty string ShowWindow (Handle, 0) // hide the taskbar //8. how Long file names To short file Name //GetShortPathName Function through Long file names can be converted To 8.3 Format, which Is declared as: Function Long GetShortPathNameA (String lf, Ref String sf, Long buflen) Library 'kernel32' //parameter 1 For Long file names, parameter 2 To Save short file Name buffer, the buffer Length parameter 3. For example: GetShortPathNameA ("C: \ My Documents \ PowerBuilder programming practices .Doc", sf, 256) // sf = Space (256) //9. how To achieve the Delay In PB //Delay Function Is useful, Although PB Is Not provided, But can be extended By the win32 Sleep Function: Function Long Sleep (Long ms) Library "kernel32" //Call: Sleep (1000) // delay one second //10. how To play music In PB //PB did Not provide Any multimedia Function, To play music only through the win32 API PlaySound To achieve: Function Long PlaySound (String Filename, Int Mod, Int Flags) Library "winmm.dll" //Wav file Name parameter 1, parameter 2 must be 0, parameter 3 To take a background player said, taking eight said Loop, So take 9 ( = 1 + 8) In the background Loop. //11, Access To the WINDOWS System directory //First, the following statement External Function: //Function UInt GetWindowsDirectoryA (Ref String dirtext, UInt textlen) Library "KERNEL32.DLL" //Script follows: String ls_WinPath ls_WinPath = Space (128) GetWindowsDirectoryA (ls_WinPath, 128) //12, play AVI Files //First, Declare External functions as follows: //Function ULong SendMessageA (ULong hwnd, ULong wMsg, ULong wParam, String lParam) Library "user32.dll" //External user-defined Object uo_comctl_animate, DLL Name filled comctl32.DLL, Class names Fill sysanimate32. //user Object Instance Variables are defined as follows constants: Constant Private Long WM_USER = 1024 Constant Private Long AviFileComp = 101 Constant Private Long AviSearch = 102 Constant Private Long AviFileCopy = 103 Constant Private Long AviDownload = 104 Constant Private Long AviPrinting = 105 Constant Private Long ACM_OPEN = WM_USER + 100 Constant Private Long ACM_PLAY = WM_USER + 101 Constant Private Long ACM_STOP = WM_USER + 102 Function (play AVI Files) define the user Object: of_playavi (Readonly String as_avifilename) Returns Long SendMessagea (Handle (This), ACM_OPEN, 0, as_avifilename) Return Send (Handle (This), ACM_PLAY, -1, 4294901760) And functions (Stop playing): of_stopplay () Returns Long Return Send (Handle (This), ACM_STOP, 0, 0) //Next, Create the user Object uo_test In the window, calling uo_test.of_playavi ("xxx.avi") //And uo_test.of_stopplay () To play And Stop a file named "xxx.avi" Of AVI. //13. Limit the Application runs only once //. Declare External functions as follows: //Function Boolean ShowWindow (ULong winhandle, & Int wincommand) Library "user32" //Function Boolean BringWindowToTop (ULong hwnd) & Library "user32" Function Long FindWindowA (ULong winhandle, & String wintitle) Library "user32" //Creating a window 'w_test'. the Title Is Set To "Test Window". //add the following code In the Application's Open event: Long ll_winhandle ll_winhandle = FindWindowA (0, "Test Window") If ll_winhandle > 0 Then BringWindowToTop (ll_winhandle) ShowWindow (ll_winhandle, 5) Return End If Open (w_test) //14 will be converted To Long file names short file Name //Declare external functions as follows: Function Long GetShortPathNameA (String lpLong, Ref String lpShort, Long lBuff) Library 'kernel32' //Defined functions f_Convert (string as_long), the function code is as follows: String ls_Buffer Long ll_RC ls_Buffer = Space (255) ll_RC = GetShortPathNameA (as_Long, ls_Buffer, 255) Return ls_Buffer |
Tips 84: PB of SHELL command
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | /* 1 command: rundll32.exe shell32.DLL, Control_RunDLL Function: Display Control Panel 2 command: rundll32.exe shell32.DLL, Control_RunDLL Access.cpl ,, 1 Function: Display "Control Panel -> Accessibility Options -> Keyboard" option WINDOWS 3 command: rundll32.exe shell32.DLL, Control_RunDLL Access.cpl ,, 2 Function: Display "Control Panel -> Accessibility Options -> Sound" option WINDOWS 4 command: rundll32.exe shell32.DLL, Control_RunDLL Access.cpl ,, 3 Function: Display "Control Panel -> Accessibility Options -> Display" option WINDOWS 5 command: rundll32.exe shell32.DLL, Control_RunDLL Access.cpl ,, 4 Function: Display "Control Panel -> Accessibility Options -> Mouse" option WINDOWS 6 command: rundll32.exe shell32.DLL, Control_RunDLL Access.cpl ,, 5 Function: Display "Control Panel -> Accessibility Options -> General" option WINDOWS 7 command: rundll32.exe shell32.DLL, Control_RunDLL sysdm.cpl // 1 Function: Performs "Control Panel -> Add New Hardware" wizard. 8 command: rundll32.exe shell32.DLL, SHHelpShortcuts_RunDLL AddPrinter Function: Performs "Control Panel -> Add New Printer" wizard. 9 command: rundll32.exe shell32.DLL, Control_RunDLL appwiz.cpl ,, 1 Function: Display "Control Panel -> Add / Remove Programs -> Install / Uninstall" Panel. 10. command: rundll32.exe shell32.DLL, Control_RunDLL appwiz.cpl ,, 2 Function: Display "Control Panel -> Add / Remove Programs -> Install Windows" Panel. 11 command: rundll32.exe shell32.DLL, Control_RunDLL appwiz.cpl ,, 3 Function: Display "Control Panel -> Add / Remove Programs -> Startup Disk" Panel. 12 command: rundll32.exe syncui.DLL, Briefcase_Create Function: Create a new "My Briefcase" On the desktop. 13 command: rundll32.exe diskcopy.DLL, DiskCopyRunDll Function: Display Copy floppy WINDOWS 14 command: rundll32.exe apwiz.cpl, NewLinkHere% 1 Function: Display "Create Shortcut" dialog box, created a Shortcut To the Location determined By the% 1 parameter. 15. command: rundll32.exe shell32.DLL, Control_RunDLL timedate.cpl ,, 0 Function: Display the "Date and Time" option window. 16. command: rundll32.exe shell32.DLL, Control_RunDLL timedate.cpl ,, 1 Function: Display "Time Zone" option window. 17 command: rundll32.exe rnaui.DLL, RnaDial [a dial-up connection Name] Function: Display a dial-up connection dial window. If you have dial-up connection, it shows the current connection status window. 18. command: rundll32.exe rnaui.DLL, RnaWizard Function: Display "New Connection" wizard window. 19. command: rundll32.exe shell32.DLL, Control_RunDLL desk.cpl ,, 0 Function: Display the "Display Properties -> Background" option window. 20. command: rundll32.exe shell32.DLL, Control_RunDLL desk.cpl ,, 1 Function: Display the "Display Properties -> Screen Saver" option window. 21. command: rundll32.exe shell32.DLL, Control_RunDLL desk.cpl ,, 2 Function: Display the "Display Properties -> Appearance" option window. 22. command: rundll32.exe shell32.DLL, Control_RunDLL desk.cpl ,, 3 Function: Display shows "Display Properties -> Properties" option window. 23. command: rundll32.exe shell32.DLL, SHHelpShortcuts_RunDLL FontsFolder Function: Display the WINDOWS "Fonts" folder. 24. command: rundll32.exe shell32.DLL, Control_RunDLL main.cpl // 3 Function: the same Display the WINDOWS "Fonts" folder. 25. command: rundll32.exe shell32.DLL, SHformatDrive Function: Display formatted floppy disk dialog. 26. command: rundll32.exe shell32.DLL, Control_RunDLL joy.cpl ,, 0 Function: Display "Control Panel -> Game Controllers -> General" option window. 27. command: rundll32.exe shell32.DLL, Control_RunDLL joy.cpl ,, 1 Function: Display "Control Panel -> Game Controllers -> Advanced" Options window. 28. command: rundll32.exe mshtml.DLL, PrintHTML (HTML document) Function: Print an HTML document. 29. command: rundll32.exe shell32.DLL, Control_RunDLL mlcfg32.cpl Function: Display the Microsoft Exchange General Options window. 30. command: rundll32.exe shell32.DLL, Control_RunDLL main.cpl // 0 Function: Display "Control Panel -> Mouse" option. 31. command: rundll32.exe shell32.DLL, Control_RunDLL main.cpl // 1 Function: Display "Control Panel -> Keyboard Properties -> Speed " option window. 32. command: rundll32.exe shell32.DLL, Control_RunDLL main.cpl // 1,, 1 Function: Display "Control Panel -> Keyboard Properties -> Language" option window. 33. command: rundll32.exe shell32.DLL, Control_RunDLL main.cpl // 2 Function: Display WINDOWS "Printers" folder. 34. command: rundll32.exe shell32.DLL, Control_RunDLL main.cpl // 3 Function: Display WINDOWS "Fonts" folder. 35. command: rundll32.exe shell32.DLL, Control_RunDLL main.cpl // 4 Function: Display "Control Panel -> Input Method Properties -> Input Method" option window. 36. command: rundll32.exe shell32.DLL, Control_RunDLL modem.cpl ,, add Function: perform "Add New Modem" wizard. 37. command: rundll32.exe shell32.DLL, Control_RunDLL mmsys.cpl ,, 0 Function: Display "Control Panel -> Multimedia Properties -> Audio" property page. 38. command: rundll32.exe shell32.DLL, Control_RunDLL mmsys.cpl ,, 1 Function: Display "Control Panel -> Multimedia Properties -> Video" property page. 39. command: rundll32.exe shell32.DLL, Control_RunDLL mmsys.cpl ,, 2 Function: Display "Control Panel -> Multimedia Properties -> MIDI" property page. 40. command: rundll32.exe shell32.DLL, Control_RunDLL mmsys.cpl ,, 3 Function: Display "Control Panel -> Multimedia Properties -> CD Music" property page. 41. command: rundll32.exe shell32.DLL, Control_RunDLL mmsys.cpl ,, 4 Function: Display "Control Panel -> Multimedia Properties -> Device" property page. 42. command: rundll32.exe shell32.DLL, Control_RunDLL mmsys.cpl // 1 Function: Display "Control Panel -> Sound" option window. 43. command: rundll32.exe shell32.DLL, Control_RunDLL netcpl.cpl Function: Display "Control Panel -> Network" option window. 44. command: rundll32.exe shell32.DLL, Control_RunDLL odbccp32.cpl Function: Display odbc32 Data management Options window. 45. command: rundll32.exe shell32.DLL, OpenAs_RunDLL {drive: \ path \ Filename} Function: Display the specified file (drive: \ path \ Filename) Of the "Open" dialog box. 46. command: rundll32.exe shell32.DLL, Control_RunDLL Password.cpl Function: Display "Control Panel -> Password" option window. 47. command: rundll32.exe shell32.DLL, Control_RunDLL powercfg.cpl Function: Display "Control Panel -> Power Management Properties" option window. 48. command: rundll32.exe shell32.DLL, SHHelpShortcuts_RunDLL PrintersFolder Function: Display WINDOWS "Printers" folder. (With rundll32.exe shell32.DLL, Control_RunDLL main.cpl // 2) 49. command: rundll32.exe shell32.DLL, Control_RunDLL intl.cpl ,, 0 Function: Display "Control Panel -> Regional Settings Properties -> Regional Settings" option window. 50. command: rundll32.exe shell32.DLL, Control_RunDLL intl.cpl ,, 1 Function: Display "Control Panel -> Regional Settings Properties -> Digital" option window. 51. command: rundll32.exe shell32.DLL, Control_RunDLL intl.cpl ,, 2 Function: Display "Control Panel -> Regional Settings Properties -> Currency" option window. 52. command: rundll32.exe shell32.DLL, Control_RunDLL intl.cpl ,, 3 Function: Display "Control Panel -> Regional Settings Properties -> Time" option window. 53. command: rundll32.exe shell32.DLL, Control_RunDLL intl.cpl ,, 4 Function: Display "Control Panel -> Regional Settings Properties -> Date" option window. 54. command: rundll32.exe desk.cpl, InstallScreenSaver [screen Saver file Name] Function: the screen Saver file specified settings For WINDOWS screensavers, screen Saver And Display properties window. 55. command: rundll32.exe shell32.DLL, Control_RunDLL sysdm.cpl ,, 0 Function: Display "Control Panel -> System Properties -> Traditional" properties window. 56. command: rundll32.exe shell32.DLL, Control_RunDLL sysdm.cpl ,, 1 Function: Display "Control Panel -> System Properties -> Device Manager" properties window. 57. command: rundll32.exe shell32.DLL, Control_RunDLL sysdm.cpl ,, 2 Function: Display "Control Panel -> System Properties -> Hardware Profiles" properties window. 58. command: rundll32.exe shell32.DLL, Control_RunDLL sysdm.cpl ,, 3 Function: Display "Control Panel -> System Properties -> Performance" properties window. 59. command: rundll32.exe user.exe, restartwindows Function: forced To Close All programs And Restart the machine. 60. command: rundll32.exe user.exe, exitwindows Function: forced To Close All programs And shut down. 61. command: rundll32.exe shell32.DLL, Control_RunDLL telephon.cpl Function: Display "Dialing Properties" option window. . 62. command: rundll32.exe shell32.DLL, Control_RunDLL themes.cpl Function: Display "Desktop Themes" option Panel. */ |
Tips 85: PB key code constants described
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | //==================================================================== // PB key code constants described //==================================================================== /* vbKeyLButton 1 Left mouse button vbKeyRButton 2 Right vbKeyCancel 3 Cancel button vbKeyMButton 4 middle mouse button vbKeyBack 8 BACKSPACE Key vbKeyTab 9 tab Key vbKeyClear 12 Clear Key vbKeyReturn 13 enter Key vbKeyShift 16 SHIFT Key vbKeyControl 17 CTRL Key vbKeyMenu 18 menu Key vbKeyPause 19 PAUSE Key vbKeyCapital 20 CAPS Lock Key vbKeyEscape 27 ESC Key vbKeySpace 32 SPACEBAR Key vbKeyPageUp 33 PageUp Key vbKeyPageDown 34 PageDown Key vbKeyEnd 35 End Key vbKeyHome 36 HOME Key vbKeyLeft 37 Left ARROW Key vbKeyUp 38 up ARROW Key vbKeyRight 39 Right ARROW Key vbKeyDown 40 down ARROW Key vbKeySelect 41 Select Key vbKeyPrint 42 Print screen Key vbKeyExecute 43 Execute Key vbKeySnapshot 44 SNAP SHOT button vbKeyInser 45 INS Key vbKeyDelete 46 DEL Key vbKeyHelp 47 HELP Key vbKeyNumlock 144 NUM Lock Key // A key to the Z key and its corresponding ASCII code value Constant Value description vbKeyA 65 a Key vbKeyB 66 b Key vbKeyC 67 C bond vbKeyD 68 D Key vbKeyE 69 E Key vbKeyF 70 F Key vbKeyG 71 G keys vbKeyH 72 H bond vbKeyI 73 i bond vbKeyJ 74 J Key vbKeyK 75 K keys vbKeyL 76 L Key vbKeyM 77 M bond vbKeyN 78 n bond vbKeyO 79 O bond vbKeyP 80 P Key vbKeyQ 81 Q Key vbKeyR 82 R Key vbKeyS 83 s bond vbKeyT 84 T Key vbKeyU 85 U Key vbKeyV 86 V Key vbKeyW 87 W Key vbKeyX 88 X Key vbKeyY 89 Y bond vbKeyZ 90 Z Key // 0 key to 9 keys to their corresponding ASCII code value Constant Value description vbKey0 48 0 Key vbKey1 49 1 Key vbKey2 50 2 keys vbKey3 51 3 keys vbKey4 52 4 Key vbKey5 53 5 keys vbKey6 54 6 Key vbKey7 55 7 Key vbKey8 56 8 Key vbKey9 57 9 Key // Key on the numeric keypad Constant Value description vbKeyNumpad0 96 0 Key vbKeyNumpad1 97 1 Key vbKeyNumpad2 98 2 keys vbKeyNumpad3 99 3 keys vbKeyNumpad4 100 4 Key vbKeyNumpad5 101 5 keys vbKeyNumpad6 102 6 Key vbKeyNumpad7 103 7 Key vbKeyNumpad8 104 8 Key vbKeyNumpad9 105 9 Key vbKeyMultiply 106 multiplication Sign (*) Key vbKeyAdd 107 Plus Sign (+) button vbKeySeparator 108 enter Key (On the numeric keypad) vbKeySubtract 109 minus (-) keys vbKeyDecimal 110 Decimal (.) Key vbKeyDivide 111 division Sign (/) Key // Function keys Constant Value description vbKeyF1 112 F1 Key vbKeyF2 113 F2 Key vbKeyF3 114 F3 Key vbKeyF4 115 F4 Key vbKeyF5 116 F5 Key vbKeyF6 117 F6 Key vbKeyF7 118 F7 Key vbKeyF8 119 F8 Key vbKeyF9 120 F9 Key vbKeyF10 121 F10 Key vbKeyF11 122 F11 Key vbKeyF12 123 F12 Key vbKeyF13 124 F13 Key vbKeyF14 125 F14 Key vbKeyF15 126 F15 Key vbKeyF16 127 F16 Key */ |
Tips 86: PowerBuilder system tables
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | //==================================================================== // PowerBuilder system tables //==================================================================== /* PBCatTbl Database Table PBCatCol Database Columns PBCatFmt Display Format PBCatVld validation rules PBCatEdt editing Style // PBCatTbl pbt_tnam Table Name SQL Server Object ID PBt_tid Table (only For SQL Server) owner pbt_ownr Table pbd_fhgt Data font Height, In PowerBuilder units In pbd_fwgt Data font stroke thickness (400 = normal, 700 = Bold) pbd_fitl Italic font Is bit (Y = YES, n = no) whether the font Is underlined pbd_funl Data (Y = YES, n = no) pbd_fchr Data font Character ji (0 = ANSI, 2 = Symbol, 255 = OEM) pbd_fptc Character Spacing And font Data Series, obtained By adding the two constants Pitch (0 = Default, 1 = Fixed, 2 = variable) Family (0 = Do Not care, 16 = Roman, 32 = Swiss, 48 = Modern, 64 = Scrit, 80 = Decorative) pbd_ffce Data font glyph pbh_fhgt Title font Height, In PowerBuilder units In pbh_ fwgt Title font stroke thickness (400 = normal, 700 = Bold) pbh_fitl Title font Is italicized bits (Y = YES, n = no) are pbh_funl Title font Is underlined (Y = YES, n = no) pbh_fchr Title font Character Set (0 = ANSI, 2 = Symbol, 255 = OEM) pbh_fptc Title Character Spacing And font Family, By two constants obtained By adding Pitch (0 = Default, 1 = Fixed, 2 = Varible) Family (0 = Do Not care, 16 = Roman, 32 = Swiss, 48 = Modern, 64 = Scrit, 80 = Decorative) pbh_ffce Title font glyphs pbl_fhgt Label font Height, In PowerBuilder units In pbl_ fwgt Label font stroke thickness (400 = normal, 700 = Bold) pbl_fitl Label Italic font Is bit (Y = YES, n = no) are pbl_funl Label font Underline (Y = YES, n = no) pbl_fchr Label font Character Set (0 = ANSI, 2 = Symbol, 255 = OEM) pbl_fptc Label font Character Spacing And Series, the Number obtained By adding the two Pitch (0 = Default, 1 = Fixed, 2 = Varible) Family (0 = Do Not care, 16 = Roman, 32 = Swiss, 48 = Modern, 64 = Scrit, 80 = Decorative) pbl_ffce Label font glyphs Notes pbt_cmnt Table // PBCatCol pbc_tnam Table Name SQL Server Object ID pbc_tid Table owner pbc_ownr Table pbc_cnam column Name pbc_cid SQL ServerColumn ID pbc_labl Label pbc_lpos Label Position (23 = Left, 24 = Right) pbc_hdr Title pbc_hpos Title Position (23 = Left, 24 = Right side, 25 = center) pbc_jtfy Alignment (23 = Left, 24 = Right) pbc_mask Display Name Format pbc_case Case (26 = Actual, 27 = Upper, 28 = Lower) pbc_hght column Height pbc_wdth column Width Name pbc_ptrn effective rules pbc_bmap bitmap / picture (Y = YES, n = no) pbc_init initial Value Note pbc_cmnt column pbc_tag (reserved) // PBCatFmt pbf_name Display Name Format pbf_frmt Display Format pbf_type what Type Of Data Format used In pbf_cntr concurrent usage flag // PBCatVld Name pbv_name validity Of the Rule pbv_frmt validation rules pbv_type role In the Type Of Data validation rules pbv_cntr concurrent usage flag pbv_msg validation Error messages // PBCatEdt pbe_name editorial Style Name pbe_edit Format String pbe_type editorial Style Type: 85 = checkbox, 86 = RadioButton, 87 = DropDownListBox 88 = DropDownDataWindow, 89 = EDIT, 90 = EDIT Mask pbe_cntr Modify the Number Of counters pbe_seqn Type PNCatEdt standard For editing multiple lines need To specify the Line sequential pbe_flag editing Style logo pbe_work additional domain */ |
Tips 87: In the datawindow after which press the Enter key, the focus moves to the back of the field, such as from the last movement, then automatically jump to the next line
1 2 3 4 | //==================================================================== // In the datawindow after which press the Enter key, the focus moves to the back of the field, such as from the last movement, then automatically jump to the next line //==================================================================== Send (Handle (This), 256,9, Long (0,0)) |
Tips 88: Window among the enter event
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | //==================================================================== // Window among the enter event! In datawindow events which create a custom event ue_enter, in even_id among paste "pbm_dwnprocessenter" //==================================================================== Long ll_row, ll_RowCount Integer li_col, li_colcount li_col = dw_1.GetColumn () li_colcount = Long (Describe (dw_1, "datawindow.column.count")) If li_col = li_colcount Then ll_row = dw_1.GetRow () ll_RowCount = dw_1.RowCount () If ll_row = ll_RowCount Then ll_row = dw_1.InsertRow (0) dw_1.SetRedraw (False) ScrollToRow (dw_1, ll_row) SetRow (dw_1, ll_row) SetColumn (dw_1,1) dw_1.SetRedraw (True) dw_1.SetFocus () dw_1.Modify ("datawindow.horizontalscrollposition = 1") Return 1 End If End If Send (Handle (This), 256,9, Long (0,0)) Return 1 |
Tips 89 : How in the program for datawindow plus computational domain or line
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //==================================================================== // How in the program for datawindow plus computational domain or line //==================================================================== // The following procedure plus a computational domain sum (dept_id for all) String ls_modrow dw_1.Modify ("DataWindow.summary.Height = 64") ls_modrow = 'Create compute (band = summary font.charset = "0" font.face = "MS Sans Serif" font.family = "2" font.height = "- 8" font.pitch = "2" font.weight = "400" background.mode = "1" background.color = "536870912" color = "0" x = "9" y = "4" height = "52" width = "297" format = "[general]" expression = "sum (dept_id for all)" alignment = "1" border = "0" crosstab.repeat = no) ~ r ~ n ' dw_1.Modify (ls_modrow) // The following procedures add a line String ls_line dw_1.Modify ("DataWindow.detail.Height = 332") ls_line = 'Create line (band = detail background.mode = "2" background.color = "16777215" pen.style = "0" pen.width = "5" pen.color = "0" x1 = "37" y1 = "320" x2 = "1458" y2 = "316") ~ r ~ n ' dw_1.Modify (ls_line) dw_1.SetTransObject (SQLCA) dw_1.Retrieve () |
Tips 90: A window redraw the screen in the middle of the function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //==================================================================== // A window redraw the screen in the middle of the function: //==================================================================== f_wincenter (windowname) environment lenv Long ll_height, ll_width If GetEnvironment (lenv) = -1 Then MessageBox ("error", "get screen message error!") Else ll_height = PixelsToUnits (lenv.ScreenHeight, Ypixelstounits!) ll_width = PixelsToUnits (lenv.ScreenWidth, xpixelstounits!) awin.Y = (ll_height - awin.Height) / 2 - 200 awin.X = (ll_width - awin.Width) / 2 Return 0 // successful return 0 End If Return 1 |
Tips 91: How to get the path of the current application
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //==================================================================== // How to get the path of the current application //==================================================================== Function unit getmodulefilenamea (ULong hmodule, Ref String lpfilename, ULong nsize) Library "kernel32.dll" String ls_Buffer = Space (255) Int i If getmodulefilenamea (Handle (GetApplication ()), ls_Buffer, 255) = 0 Then SetNull (ls_Buffer) Else Do While Pos (ls_Buffer, "", i + 1) > 0 i = Pos (ls_Buffer, "", i + 1) Loop ls_Buffer = Left (ls_Buffer, i) If Right (ls_Buffer, 1) <> "" Then ls_Buffer = ls_Buffer + "" End If Return ls_Buffer |
Tips 92: Get the current name of the computer
1 2 3 4 5 6 7 8 | //==================================================================== // Get the current name of the computer //==================================================================== Function Boolean GetComputerNameA (Ref String cname, Ref Long nbuf) Library "kernel32.dll" String ls_computername = Space (512) Long ll_buffer = 512 Getcomputernamea (ls_computername, ll_buffer) Return ls_computername |
Tips 93: Get the current path
1 2 3 4 5 6 7 8 9 10 11 12 | //==================================================================== // Get the current path //==================================================================== Function ULong GetCurrentDirectoryA (ULong nBufferLength, Ref String lpBuffer) Library "kernel32.DLL" String ls_Buffer ls_Buffer = Space (255) If getcurrentdirectorya (255, ls_Buffer) = 0 Then SetNull (ls_Buffer) Else If Right (ls_Buffer, 1) <> "1" Then ls_Buffer = ls_Buffer + "" End If Return ls_Buffer |
Tips 94: How to configure an ODBC data source code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | //==================================================================== // How to configure an ODBC data source code //==================================================================== //ODBC Is automatically created based On the WINDOWS registry direct writes To achieve steps: //First, Create a Function: gf_create_odbc (String as_odbc_name, String as_odbc_type, String as_path) String ls_key, ls_key1 ls_key = 'HKEY_CURRENT_USER \ Software \ ODBC \ ODBC.INI \' + as_odbc_name ls_key1 = 'HKEY_CURRENT_USER \ Software \ ODBC \ ODBC.INI \ ODBC Data Sources' If as_odbc_type = 'DBF' Then RegistrySet (ls_key, 'Driver', "C: \ WINDOWS \ SYSTEM \ PBDBF12.DLL") RegistrySet (ls_key, 'Description', "automatically generates ODBC '") RegistrySet (ls_key, 'Database', as_path) RegistrySet (ls_key, 'CreateType', "FoxPro25") RegistrySet (ls_key, 'Locking', "RECORD") RegistrySet (ls_key, 'LockCompatibility', "Fox") RegistrySet (ls_key, 'FileOpenCache', "1") RegistrySet (ls_key, 'CacheSize', "4") RegistrySet (ls_key, 'DataFileExtension', "DBF") RegistrySet (ls_key, 'IntlSort', "C: 0") RegistrySet (ls_key, 'UseLongNames', "1") RegistrySet (ls_key, 'UseLongQualifiers', "1") RegistrySet (ls_key, 'ApplicationUsingThreads', "1") RegistrySet (ls_key1, as_odbc_name, "PB INTERSOLV OEM 3.01 32-BIT dBASEFile (* .dbf)") End If If as_odbc_type = 'SQLANY' Then RegistrySet (ls_key, 'Driver', as_path + "WOD50T.DLL") RegistrySet (ls_key, 'Description', "automatically generates ODBC '") RegistrySet (ls_key, 'UID', "DBA") RegistrySet (ls_key, 'PWD', "SQL") RegistrySet (ls_key, 'Start', as_path + 'dbeng50') RegistrySet (ls_key, 'DatabaseFile', as_path + as_odbc_name + '. DB') RegistrySet (ls_key, 'DatabaseName', as_odbc_name) RegistrySet (ls_key, 'AutoStop', "Yes") RegistrySet (ls_key1, as_odbc_name, "Sybase SQL Anywhere 5.0") End If If as_odbc_type = 'FOXPRO' Then RegistrySet (ls_key, 'DefaultDir', as_path) RegistrySet (ls_key, 'Description', as_odbc_name + "automatic ODBC '") RegistrySet (ls_key, 'Driver', 'C: \ WINDOWS \ SYSTEM \ odbcjt32.dll') RegistrySet (ls_key, 'DriverId', ReguLong!, 280) RegistrySet (ls_key, 'FIL', "FoxPro 2.0") RegistrySet (ls_key, 'SafeTransactions', ReguLong!, 0) RegistrySet (ls_key, 'UID', "") RegistrySet (ls_key + '\ Engines \ Xbase', 'CollatingSequence', 'ASCII') RegistrySet (ls_key + '\ Engines \ Xbase', 'Deleted', ReguLong!, 1) RegistrySet (ls_key + '\ Engines \ Xbase', 'ImplicitCommitSync', 'Yes') RegistrySet (ls_key + '\ Engines \ Xbase', 'PageTimeout', ReguLong!, 600) RegistrySet (ls_key + '\ Engines \ Xbase', 'Statistics', ReguLong!, 0) RegistrySet (ls_key + '\ Engines \ Xbase', 'Threads', ReguLong!, 3) RegistrySet (ls_key + '\ Engines \ Xbase', 'UserCommitSync', 'Yes') RegistrySet (ls_key1, s_dbfname, "Microsoft FoxPro Driver (* .dbf)") End If //Second, before the establishment Of the First To Create the ODBC connection information, such as String ls_dbfname = "c: \ Foxprow \ Database" gf_create_odbc ('TestDBF', 'FOXPRO', ls_dbfname) SQLCA.DBMS = "ODBC" SQLCA.AutoCommit = False SQLCA.Database = 'TestDBF' SQLCA.DBParm = "ConnectString = 'DSN = TestDBF'" Connect Using SQLCA; If SQLCA.SQLCode <> 1 Then MessageBox ('error', 'Unable to connect to database files developed! (' + ls_dbfname + ')', StopSign!) Halt Close; End If //Third, remove the ODBC settings; //Create a Public Function gf_erase_odbc (String as_odbc_name) //through the above steps, you Do Not through ODBC tool In Control Panel To Set up. //you may consider the following improvements: //an increase ODBC Create parameter setting Function; //2, an ODBC own Set Of tools that can operate within the System; //3, ODBC Driver can be assigned To a specific directory Or file. |
Tips 95: How to build such a function it
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | //==================================================================== // How to build such a function it //==================================================================== /* First two excellent DropDownListBox, when Select one Of the Item, And another DropDownListBox Display the corresponding First Select the content item. For example, a display name of each center, when you Select the name of one of the center, And the other displays the corresponding center The names of All sectors. (1) dropdownDW better with generation parameters (2) I just realized. Tables can be built: Mobile Brand Table: MOBILE phone model Table: MOBILEMODEL In dw of itemfocuschanged write the following code: */ Long ll_model ll_model = dw_edit.GetItemNumber (dw_edit.GetRow (), 'mob_id') If dwo.Name = 'model_id' And Not IsNull (ll_model) Then dataWindowChild idwc_model dw_edit.GetChild ("model_id", idwc_model) idwc_model.SetTransObject (SQLCA) idwc_model.Retrieve () // Idwc_model.Setfilter ("model_id =" + string (ll_model)) idwc_model.SetFilter ("mob_id =" + String (ll_model)) idwc_model.Filter () End If |
Tips 96: Grid window in which, in a column does not allow editing a column allows editing
With the following method, you can Not very convenient, what they want it
Method one:
In the DataWindow, Between the column And the column when Using the Tab key to move, is based on the DataWindow Tb Values For each column is Set to be moved.
When a column of Tab is 0, this column can Not be edited, so that users can Not add, Delete, change And other operations. It can be a column of Values Tab is Set to 0,
This column is Set to allow non-editable.
Follows (Set columnname For the DataWindow column name to be Set to non-editable):
dw_1.setorder (“columnname”, 0)
Or modify data In the script window with the following statement:
dw_1.modify (: columnname.tabsequence = 0 “)
Or dw_1.modify (“#” + string (number) + “. Tabsequence = 0”)
The advantage of this method is easy to realize, the drawback is Not allowed to move the column. Grid-style DataWindow that must Not checked
column moving, otherwise it will cause confusion when you press the tab key sequence.
Method two:
You can View the edit column properties In the properties View style style. To Set a column can Not be edited In the column edi style = “edit” In
Select the Display only;
Or Script window With the following statement be Modified:
DW + 1.Modify (“columnname.edit. displayonly = Yes)
Or dw_1.Modify (“#” + String (Number) + “. Edit.displayonly = Yes”)
If the column back To editable In the EDIT Style Of the column = “edit”, And Uncheck Display only;
Or Script used In window
Modify the following statement:
dw_1.Modify (“columnname.edit.displayonly = No”)
This method Is very simple, But also does Not allow the column To Move.
Method three:
Datawindow With the Clicked Event Of the method can be implemented To protect the column. If a column can Not be changed, you can Set R otect = 0. Namely:
dw_1.Modify (“columnname.protect = 0”)
Or dw_1.Modify (“#” + String (Number) + “. Protect = 0”)
To the column To be changed, Set protect = 1, Namely:
dw_1.Modify (: columnname.protect = 1 “)
Or dw_1.Modify (“#” + String (Number) + “. Protect = 1”)
This method does Not affect the tab Key To Move, users can pull the column, But also In the Application process To decide which column can be edited, which column Is Not edited.
Tips 97: Data Sheet d_query have a data column id, set to DropDownDW format and linked to another data table d_info (id, name).
1 2 3 4 5 6 7 8 | //==================================================================== // Data Sheet d_query have a data column id, set to DropDownDW format and linked to another data table d_info (id, name). //==================================================================== //Data Is displayed when the program Is Running So the Value Name, And dw_1.GetItemString (1, 'id') / dw_1.Object.Date (1,1) //the resulting Data Is ID Value. But Now i want the Name Of Values , there Is no simple way dw_object.Describe ("evaluate ('LookUpDisplay (" column Name ")'," + String (Line Number) + ")") //you Is: dw_1.Describe ("evaluate ('LookUpDisplay (id)', 1)") |
Tips 98: Window within w_gcde, into a DW_1, how to get the contents inside yuonghu_id column dw_1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | //==================================================================== // Window within w_gcde, into a DW_1, how to get the contents inside yuonghu_id column dw_1 //==================================================================== Long lng_column_count Integer i String str_column [] // column name String str_column_text [] // text name // Get the total number of columns in the data window lng_column_count = Long (dw_1.Describe ("DataWindow.Column.Count")) // Cycle in order to read For i = 1 To lng_column_count str_column [i] = dw_1.Describe ("#" + String (i) + ". name") str_column_text [i] = dw_1.Describe (str_column [i] + "_t.text") Next |
Tips 99: Save the report to excel table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | //==================================================================== // Save the report to excel table //==================================================================== String fpath, fname Int f_s Boolean lb_exist f_s = GetFileSaveName ("Please select the file name to be saved", fpath, fname, "txt", "Text File (* .txt), *. txt, Excel (*. xls), *. xls") lb_exist = FileExists (fpath) If f_s <> 1 Then Return ElseIf lb_exist Then Choose Case MessageBox ("Save", "OK to over write file:" + fname, Question !, OKCancel!) Case 1 dw_1.SaveAs (fname, Text !, True) MessageBox ("successful coverage", "successful overwrite the file" + fname) Case Else MessageBox ("warning", "File not saved successfully.") Return End Choose Else dw_1.SaveAs (fname, Text !, True) End If |
Tips 100: PB in how to write data to EXCEL table has a fixed format
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | //==================================================================== // PB in how to write data to EXCEL table has a fixed format //==================================================================== Int i, Handle, n Handle = OpenChannel ("Excel", 'book1.xls') If Handle < 0 Then MessageBox ('prompt', 'Please open EXCLE program! and open BOOK1.XLS, and empty the table!') Return End If SetRemote ('r1c1', 'customer arrears analysis table', Handle) SetRemote ('r2c5', 'Statistics Date:' + is_rq1 + 'to' + is_rq2, Handle) SetRemote ('r3c1', 'rank', Handle) SetRemote ('r3c2', 'client code', Handle) SetRemote ('r3c3', 'Customer Name', Handle) SetRemote ('r3c4', 'total receivables', Handle) SetRemote ('r3c5', 'total arrears', Handle) SetRemote ('r3c6', 'ratio', Handle) SetRemote ('r3c7', tab_1.tabpage_1.dw_1.Object.no1_t.Text, Handle) SetRemote ('r3c8', tab_1.tabpage_1.dw_1.Object.no2_t.Text, Handle) SetRemote ('r3c9', tab_1.tabpage_1.dw_1.Object.no3_t.Text, Handle) SetRemote ('r3c10', tab_1.tabpage_1.dw_1.Object.no4_t.Text, Handle) SetRemote ('r3c11', tab_1.tabpage_1.dw_1.Object.no5_t.Text, Handle) For i = 1 To tab_1.tabpage_1.dw_1.RowCount () SetRemote ("r" + String (i + 3) + 'c1', String (i), Handle) SetRemote ("r" + String (i + 3) + 'c2', tab_1.tabpage_1.dw_1.GetItemString (i, 'khbm'), Handle) SetRemote ("r" + String (i + 3) + 'c3', tab_1.tabpage_1.dw_1.GetItemString (i, 'khmc'), Handle) SetRemote ("r" + String (i + 3) + 'c4', String (tab_1.tabpage_1.dw_1.GetItemDecimal (i, 'ys')), Handle) SetRemote ("r" + String (i + 3) + 'c5', String (tab_1.tabpage_1.dw_1.GetItemDecimal (i, 'qf')), Handle) SetRemote ("r" + String (i + 3) + 'c6', String (tab_1.tabpage_1.dw_1.GetItemDecimal (i, 'bl')), Handle) SetRemote ("r" + String (i + 3) + 'c7', String (tab_1.tabpage_1.dw_1.GetItemDecimal (i, 'no1')), Handle) SetRemote ("r" + String (i + 3) + 'c8', String (tab_1.tabpage_1.dw_1.GetItemDecimal (i, 'no2')), Handle) SetRemote ("r" + String (i + 3) + 'c9', String (tab_1.tabpage_1.dw_1.GetItemDecimal (i, 'no3')), Handle) SetRemote ("r" + String (i + 3) + 'c10', String (tab_1.tabpage_1.dw_1.GetItemDecimal (i, 'no4')), Handle) SetRemote ("r" + String (i + 3) + 'c11', String (tab_1.tabpage_1.dw_1.GetItemDecimal (i, 'no5')), Handle) Next CloseChannel (Handle) MessageBox ('prompt', 'save finished!') |
Tips 101: Save the data window for generic functions excel (decision wonderful)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | //==================================================================== // Save the data window for generic functions excel (decision wonderful) //==================================================================== // Function name: gf_dw2excel // Scope: public // Description: The window to pass the data to EXCEL table, there are 26 columns limit (generally been good enough) // Parameters: // [Value] datawindow adw_data need to save the data window // [Value] string as_reptitle table title // Return value: LONG // Author: xiaolihua Date: 2003-05-20 // Modified: DoItNow Date: 2003.06.06 Constant Integer ppLayoutBlank = 12 Pointer oldpointer OLEObject ole_object ole_object = Create OLEObject String s_english = "ABCDEFGHIJKMNLOPQRSTUVWXYZ" Integer li_ret ////////////////////////////////////////////////// ////////////////// // // ================================================ ==================== // Script - gf_dw2excel (datawindow adw_data, string as_reptitle) // [Reason]: Since then the case has been opened EXCEL, and sometimes when using the OLE connection error, so instead // OLE directly connected to the new application. // ------------------------------------------------ -------------------- // [MODIFIED By]: DoItNow Date: 2003.06.06 // ================================================ ==================== // li_ret = ole_object.ConnectToObject ("", "Excel.Application") // IF li_ret <> 0 THEN // // If Excel is not open, then New. li_ret = ole_object.ConnectToNewObject ("Excel.Application") If li_ret <> 0 Then MessageBox ('open error', '! Unable to connect EXCEL EXCEL has been installed the wrong number: ' + String (li_ret)) Return 0 End If ole_object.Visible = False // ole application service is displayed // END IF // ------- MODIFIED END --------------------------------------- ---------- ////////////////////////////////////////////////// //////////////////// oldpointer = SetPointer (HourGlass!) ole_object.Workbooks.add Long ll_colnum, ll_rownum String ls_value String ls_objects, ls_obj, ls_objs [], ls_objtag [], ls_width [] Long ll_pos, ll_len, ll_num = 0 the Number Of Rows // Excel table for the number of rows of data window +2 ll_rownum = adw_data.RowCount () + 2 String ls_colname Integer i, J Dec ld_width ll_colnum = Long (adw_data.Object.Datawindow.column.Count) // obtain total field ls_objtag [1] = "number" SetNull (ls_width [1]) i = 1 For ll_num = 1 To ll_colnum If adw_data.Describe ("#" + String (ll_num) + ". Visible") = "1" Then // column does not show signs of nun_Visible i = i + 1 ls_obj = adw_data.Describe ("#" + String (ll_num) + ". name") // actually stored value field name ls_objs [i] = ls_obj ls_objtag [i] = adw_data.Describe (ls_obj + "_t.text") // display the value of the field name ls_width [i] = adw_data.Describe (ls_obj + '.width') // width of each column End If Next ll_colnum = i // number of columns in the table // Generated total title ole_object.Cells (1,1) .Value = as_reptitle ole_object.Range ('A1'). Select ole_object.Selection.font.size = 24 ole_object.Selection.HorizontalAlignment = 3 ole_object.Range ('A1:' + Mid (s_english, ll_colnum, 1) + '1'). Select ole_object.Range ('A1:' + Mid (s_english, ll_colnum, 1) + '1') Merge. // Set the title bar For i = 1 To ll_colnum ls_value = ls_objtag [i] ole_object.Cells (2, i) .Value = ls_value If IsNull (ls_width [i]) Then ld_width = 12 Else ld_width = Dec (ls_width [i]) / 35 // why devided by 35 End If ole_object.Columns (i) .ColumnWidth = ld_width ole_object.Columns (i) .HorizontalAlignment = 3 ole_object.Columns (i) .Borders.LineStyle = 1 ole_object.Columns (i) .font.Bold = True Next // Tim filling actual data to EXCEL String column_name, ls_coltype For i = 3 To ll_rownum ole_object.Cells (i, 1) .font.Bold = False ole_object.Cells (i, 1) .Value = i - 2 For J = 2 To ll_colnum column_name = ls_objs [J] If adw_data.Describe (column_name + '.type') = 'column' Then ls_value = adw_data.Describe ("Evaluate ('LookupDisplay (" + column_name + ")'," + String (i - 2) + ")") End If If adw_data.Describe (column_name + '.type') = 'compute' Then ls_value = adw_data.Describe ("Evaluate ('" + adw_data.Describe (column_name +' .expression ') + "'," + String (i - 2) + ")") End If ls_coltype = adw_data.Describe (column_name + '. coltype') If Pos (Upper (ls_coltype), "CHAR") > 0 Then // for character data processing ole_object.Cells (i, J) .NumberFormat = "//" End If ole_object.Cells (i, J) .font.Bold = False ole_object.Cells (i, J) .Value = ls_value Next Next ////////////////////////////////////////////////// ////////////////// // // ================================================ ==================== // Script - gf_dw2excel (datawindow adw_data, string as_reptitle) // [Reason]: EXCEL file saved in PB // ------------------------------------------------ -------------------- // [MODIFIED By]: DoItNow Date: 2003.05.28 // ================================================ ==================== String sFileName, sFile Integer Value Value = GetFileSaveName ("Save As", sFileName, sFile, "xls", "Excel Files (* .xls), *. xls") If Value = 1 Then ole_object.ActiveWorkbook.SaveAs (sFileName) ole_object.Displayalerts = False // close saved when you exit EXCEL Tips ole_object.Quit () // exit EXCEL Else MessageBox ("Error", "Save file error, manually save") ole_object.Visible = True // display ole Apps End If // ------- MODIFIED END --------------------------------------- ---------- ////////////////////////////////////////////////// //////////////////// SetPointer (oldpointer) ole_object.DisconnectObject () Destroy ole_object Return 1 |
Tips 102: value of the expression
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //==================================================================== // Nine lines of code to achieve the expression evaluates! //==================================================================== // Function: Returns the value of the expression // Parameters: string thestr calculation expression, such as 2 * (3 + 5) // Return value: string retVal calculated value of the expression, such as 2 * (3 + 5) result is 16 // If it is an incorrect expression, returns false. // ================================================ =========================== String retVal dataStore lds_evaluate lds_evaluate = Create dataStore lds_evaluate.Create ('release 10; ~ r ~ ntable ()') retVal = lds_evaluate.Describe ("evaluate ('" + thestr + "', 1)") Destroy lds_evaluate Return retVal |
Tips 103: String into an array
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //==================================================================== // String into an array //==================================================================== Long lPosEnd, lPosStart = 1, lSeparatorLen, lCounter = 1 If UpperBound (sOutputArray) > 0 Then sOutputArray = {""} lSeparatorLen = Len (sSeparator) lPosEnd = Pos (sString, sSeparator, 1) Do While lPosEnd > 0 sOutputArray [lCounter] = Mid (sString, lPosStart, lPosEnd - lPosStart) lPosStart = lPosEnd + lSeparatorLen lPosEnd = Pos (sString, sSeparator, lPosStart) lCounter ++ Loop sOutputArray [lCounter] = Right (sString, Len (sString) - lPosStart + 1) Return lCounter |
Tips 104: PB in the TreeView control using techniques (sweep blind)
PowerBuilder TreeView Control In a tree tour, similar To the WINDOWS Explorer, which Is characterized By tree-level information items were Structure, can Show more clearly the main, a breakdown Of the relationship, the operation Is very convenient. it can be used In conjunction With the Datawindow Application, a provide information classification System, one To provide specific information To achieve even beads Pitt together wonderful Effect. it Is especially suitable For multi-level classification Of information seized Faso, Is a multi-level menu can Not be more than Like, its manifestations By the program designers And the majority Of users In many Application software can see her heroic.
In PowerBuilder, Application TreeView Control Is much more complex than the Other controls, somewhat at a loss when you are new To it often. However, If the mechanism To figure out If it, it Is Not hard To grasp things. here i combine Changbai company books classification And retrieval Instance, the TreeView use controls, And we explore. First, the Application Of the General steps TreeView Control
1, the establishment Of an Application, And Set a good interface With the Database, which Is a prerequisite For the operation Of the Database.
2, built an Application window W_1 In the Application, adding Datawindow Control Object named dw_3 And dw_4 two On And one In the Name TreeView Object TV_1’s.
3, Modify dw_3 property
General: the Datawindow Object Datawindow called DW_date Fill In the Name Of an existing (Note: it Datawindow Control Object Is different), For spanning tree View Item, Set its Visible items are Not Visible.
4, Modify dw_4 property
General: the Datawindow Object Datawindow Object Name To Fill an existing named DW_TS For Display Check out the specific content.
5, edited TV_1 properties
TreeView tree View Item can Not be directly edited, the program must be written In the Script.
picture: picture Name added In Four different icons To represent the tree View Of two levels (one, two), two kinds Of State (Not Selected, Selected).
General: can be Selected depending On whether the Application settings, including:
Delete Items: whether to allow the operation to Delete entries.
Disable PragDrog: drag And drop operation is allowed entry.
Edit Labels: whether to allow the operation to change entries, click the title entries. Show Buttons: whether to display the entries put Buttons, there is shown the relative expansion And contraction.
Hide Selection: when the control loses focus, the selected item is displayed with high brightness.
Show Line: whether Between entries plus one vertical bar.
Lines At Root: All entries In the root zone is connected By a vertical bar.
Indentation: the child entries shrink relative to the right schedule parent entries.
6, The Script writing TV_1
Here is the key to the TreeView control is difficult.
Two, TreeView control information form And Create
Tree View item TreeViewItem TreeView control is the basic unit of information, And generates a tree View items are generally two ways, one is Mr. Cheng root layer View item, And then dynamically generate lower View items In the application, the other is the tree View of All time And a. Each of the two methods There are advantages, chosen according to the specific circumstances, the latter method is used In this example.
1, the main properties of the tree View item TreeViewItem
Label: String type, display information tree View item.
Data: Any type, the internal value tree View item.
Level: Integer type, tree View item level In the tree View.
Children: Boolean type, which determines whether the next level (as shown In the title).
PictureIndex: Integer type, when used In the non-selected icons In the icon queue number.
SelectedPictureIndex: Integer type, when used By the selected number of icons In the icon queue.
2, the functions used to generate entries TreeViewItem
InsertItemFirst (): will be added as the first item
InsertItemLast (): will join the item as the last one
InsertItem (): will join the item Into the back of the specified items
InsertItemSort (): the Order placement.
3, TreeView common event
Constructor: This event is triggered when the control is created, can be constructed here TreeViewItem.
Click: Click TreeViewItem item, Execute the query process.
Double Click: Double-click the TreeViewItem item, Execute the query process.
ItemPopulate event: This event when entries For the first time launched a TreeViewItem Trigger, while the system will Trigger the
TreeViewItem item handle handle passed over By the arguments. It is mainly used to generate the underlying information item corresponding item. Mainly used For the first Ways.
Third, the event code A tree View control TV_1 the constructor event code wanqi 1999.6.28
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | Integer li_rowcount, li_row String li_current_dn, li_last_dn, li_current_ei, li_last_ei // Declare instance variables of two tree view treeviewitem itvi_level_one, itvi_level_two // long ii_h_l_one // long ii_h_l_two dw_3.SetTransObject (SQLCA) // dw_3 For implicit Data window, there are Data spanning tree li_rowcount = dw_3.Retrieve () // Rows dw_3.SetSort ("lb, pm") dw_3.Sort () // Spanning all levels of the tree view item view For li_row = 1 To li_rowcount li_current_dn = dw_3.Object.lb [li_row] // DW_3 object "LB category" li_current_ei = dw_3.Object.pm [li_row] // DW_3 object "PM Name" If IsNull (li_current_ei) Then li_current_ei = "" End If If li_current_dn <> li_last_dn Then // IF LB does not repeat with the primary view item // Set a tree view item itvi_level_one.Label = dw_3.Object.lb [li_row] // View displays information items itvi_level_one.Level = 1 // level itvi_level_one.Data = li_current_dn // View items inside information itvi_level_one.PictureIndex = 1 No. When the Icon Is Not Selected // used itvi_level_one.SelectedPictureIndex = 3 // Icon used when selected number itvi_level_one.Children = (li_current_ei <> '') // Is there under a tree view ii_h_l_one = This.InsertItemLast (0, itvi_level_one) // The item was added to one end of a tree End If // Set two tree view item If li_current_dn <> li_last_ei Then If li_current_ei <> '' Then itvi_level_two.Label = dw_3.Object.pm [li_row] itvi_level_two.Level = 2 itvi_level_two.Data = li_current_dn itvi_level_two.PictureIndex = 2 itvi_level_two.SelectedPictureIndex = 4 itvi_level_two.Data = li_current_ei itvi_level_two.Children = False ii_h_l_two = This.InsertItemLast (ii_h_l_one, itvi_level_two) // The item was added to the two trees in the last one End If End If li_last_dn = li_current_dn // located relatively items li_last_ei = li_current_ei Next 2, Clicked Event code tv_1 controls String s1 treeviewitem ii This.GetItem (Handle, ii) s1 = String (ii.Label) Choose Case ii.Level Case 1 // Filter category dw_4.SetFilter ("lb = '" + s1 + "'") dw_4.Filter () Case 2 dw_4.SetFilter ("pm = '" + s1 + "'") dw_4.Filter () // Filtering title End Choose |
Tips 105: Lowercase to uppercase Amount Amount
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | //==================================================================== // Lowercase to uppercase Amount Amount //==================================================================== String CN_NUM [10] = {"zero", "one", "two", "three", "market", "Mrs.", "Miss", "seven", "eight", "Nine"} // capital 0-9 String CN_CARRY [19] = {"minute", "corner", "", "dollars", "pick up", "Bai", "1,000", "000", "pick up", "Bai", "1,000" "100 million", "pick up", "Bai", "1,000", "000", "pick up", "Bai", "1,000"} String ls_pos, ls_number, ls_rc Integer li_for, li_len Boolean lb_zero = False // whether to allow the next one appears zero ls_number = String (Number, "0.00") li_len = Len (ls_number) For li_for = 1 To li_len ls_pos = Mid (ls_number, li_for, 1) If ls_pos = "-" Then ls_rc + = "negative" Continue End If If ls_pos = '.' Then Continue If ls_pos <> "0" Then ls_rc + = CN_NUM [Integer (ls_pos) + 1] + CN_CARRY [li_len - li_for + 1] ElseIf Mod (li_len - li_for - 3,4) = 0 Then If Right (ls_rc, 2) = CN_NUM [1] Then ls_rc = Left (ls_rc, Len (ls_rc) - 2) ls_rc + = CN_CARRY [li_len - li_for + 1] + CN_NUM [Integer (ls_pos) + 1] ElseIf lb_zero Then ls_rc + = CN_NUM [Integer (ls_pos) + 1] End If lb_zero = ls_pos <> "0" Next If Right (ls_rc, 2) = CN_NUM [1] Then ls_rc = Left (ls_rc, Len (ls_rc) - 2) Return ls_rc |
Tips 106: Pb in custom printed pages long
In the case of continuous paper to print the data window, you need to customize the printed pages long, In Order to ensure the correct printer paper feed without human intervention,
Continuous printing. In PB shall call external functions to customize the length of the paper, more cumbersome. This paper presents a direct printer Control method is simple to achieve page-long Set.
First, prior knowledge
Communication Computer And printer Using the ASCII code, which includes the standard ASCII code printable characters And non-printing characters (control codes), The printer uses control code to customize the printer. Most printer instructions use control codes escape sequence code as the first of its instruction sequence.
Here are a few instruction code sequence used In this article:
Set the line spacing (line spacing) 8-inch
ASCII code ESC 0
Decimal 2748
Set In units of pages long
ASCII code ESC C n
Decimal 27 67 n
Where n is the number of lines per page range (1-127)
Two, PB control the transmission And custom-page code of realization
In PB to achieve By sending control codes to the printer function Printsend (printjobnumber, string, {zerochar}).
The parameters are defined as follows:
printjobnumber: By printjob () Function Returns the Number Of Print jobs;
String: Control String, use the ASCII code;
zerochar: used To Replace String Of digits 0;
because Of the String, 0-terminated String, If String contains 0, you need To use Other characters To represent 0, parameters that Do This zerochar Purposes Set, when the PB To the printer transmits a Control String To Replace the Character zerochar converted To 0. here Is the complete program specific custom pages Long Print Data window (Length Of 2.75 inches custom page):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Long ll_job dw_print.Reset () ll_job = PrintOpen () If ll_job = -1 Then MessageBox (gs_title, "printer not ready") Return End If // 8-inch custom spacing PrintSend (ll_job, Char (27) + Char (48)) // Setting page length 22 lines PrintSend (ll_job, Char (27) + Char (67) + Char (22)) PrintDataWindow (ll_job, dw_print) PrintClose (ll_job) //Line 22 Is a narrow Line just one-third Of a page Long continuous paper, many bills are Not the problem In This paper .win2000, My program Run well. |
Tips 107: pb some experience and skills
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | //==================================================================== // pb some experience and skills //==================================================================== /* 1.RGB Function formula: Color Values = (65536 * Blue) + (256 * green) + (Red) 2 controls draggable: Send (Handle (This), 274,61458,0) 3 how To use the drop-down drop down sub-program Control Data window And away Modify Or directly By Using dw_1.Object.col1.dddw.ShowList = True 4 search parameters And some Do Not need To pass the pass%. 5 how To shield the mouse wheel To Trigger events In the Control Of Other Write If Message.Number = 522 Then Return 1 6 To Get the Syntax Of the Data window: String ls_dwsyntax ls_dwsyntax = dw_1.Describe ("datawindow.syntax") 7 To Get the Data In each column And window Title: */ Long ll_count, i String ls_value, ls_colname ll_colnum = Long (dw_1.Object.Datawindow.column.Count) For i = 1 To ll_colnum // Get the name of the title head ls_colname = dw_1.Describe ('#' + String (i) + ".name") + "_t" ls_value = dw_1.Describe (ls_colname + ".text") Next /* 8 dynamically Set the initial Value In the program: ex: dw_control.Object.columnname.initial = 'xxxx' 9 how To achieve without Using Select DISTINCT Delete duplicate Rows In the Datawindow SQL Syntax: at First you want To Display a column To Sort Of unique Values : "city A", And Then add the following Filter String: "City <> city [-1] or GetRow () = 1" 10. how To change the font Color column, This column Is To remind the user To make changes: In the Color attribute column, enter the following Expression If (column_name <> column_name.original, RGB (255, 0, 0), RGB (0, 0, 0)). In This condition, If This column has changed, Is displayed In Red font, otherwise Display black font. This Expression Is mainly used column_name <> column_name.original compare the current Value Of the column And the original Columns are the same To achieve the purpose Of judgment. 11 written Clicked Or DoubleClicked Event Data window On annotations // solve some unexpected bug! */ |
Tips 108: Datawindow to achieve a combination of field
Now assume that the customer’s province, city, address, zip code were stored in a different field, they are Province, City, Address, PC. we want To Get “Zip + State + City + address” Format, such as: “(214001) Renmin Road, Wuxi City, Jiangsu Province 1.” specific implementation as follows:
1, In the Position you want To Display To add a calculated field (Compute Field)
2, In which the Expression column Write “‘(‘ + PC + ‘)’ + Province + City + Address”
3 click OK To finish. it Is Not easy. need To remind everyone that the computational domain can only be used To Display, you can Not Modify it, because it does Not tab property, can Not Get the focus.
Tips 109: Technical Data automatically refresh the window
when we Write, such as inventory, sales And Other applications, always want the program To be able To dynamically auto-refresh inventory Or sales, For example, every 1 Second refresh. To achieve This Function as Long as we use the Time Interval Of the Data window properties (Timer Interval), when the Value Is 0 Data window Is Not refreshed, If you want the Data window To refresh frequency every Second, So Long as the Value Is Set 1000, that Is 1000 milliseconds. we can also add functionality To the Application flashing alarms. take inventory For Instance, the Most common Is when the stock reaches certain goods when a minimum inventory program should be able To automatically determine And Display a warning Color, usually Red. at This Point, we simply use the above the method Then requires the flashing On the Field, such as stocks, In which the Color properties Of the corresponding Write statement. the following code To achieve “When an item of inventory is less than 20, the program displays a warning in red blinking”
If (Store_Num < 20, & If Mod (Second (Now ()), 2) <> 0, & // once per second, even red, odd-numbered display white, i.e. background
RGB (255, 255, 255), RGB (255, 0, 0))
Tips 110: How to find the listed conditions for Datetime data types used in the DataWindow
1 2 3 4 5 6 7 8 9 | //==================================================================== // How to find the listed conditions for Datetime data types used in the DataWindow //==================================================================== //1. use when you want To Find a Date condition Is a Constant Expression as follows: ls_find = "datetime_col = DateTime ('1/1/1999')" //2. the following Expression uses the Date the Conditions when you are looking For Is a variable: ls_find = "datetime_col = DateTime ('" + ls_Date + "')" //3. use when you want To Find the Date Of the Conditions Is a DateTime Data Type the following Expression: ls_find = "datetime_col = DateTime ('" + String (ldt_DateTime) + "')" |
Tips 111: Realize how not to use SELECT DISTINCT delete duplicate rows in the DataWindow SQL syntax
1 2 3 4 | // Realize how not to use SELECT DISTINCT delete duplicate rows in the DataWindow SQL syntax //==================================================================== //at First you want To Display a column To Sort Of unique Values : "city A", And Then add the following Filter String: "City <> city [-1] or GetRow () = 1" |
Tips 112: How to display line numbers in each group, respectively, in the form of packets of the DataWindow
1 2 3 4 5 6 | //==================================================================== // How to display line numbers in each group, respectively, in the form of packets of the DataWindow //==================================================================== //when we Datawindow Display Line numbers For each Line, you can simply put an Expression Of GetRow () computed column. //But For grouping Datawindow, To Show the Line Number In each Group, you should use the Expression For GetRow () - First (GetRow () For Group 1) computed column + 1. |
Tips 113: How to change the font color column, this column is to remind the user to make changes
1 2 3 4 5 6 7 | //==================================================================== // How to change the font color column, this column is to remind the user to make changes //==================================================================== //In the Color attribute column, enter the following Expression If (column_name <> column_name.original, RGB (255, 0, 0), RGB (0, 0, 0)). //In This condition, If This column has changed, Is displayed In Red font, otherwise Display black font. This Expression Is mainly used //column_name <> column_name.original compare the current Value Of the column And the original Columns are the same To achieve the purpose Of judgment. |
Tips 114: In the data window, remove the line, but do not filter or delete operation
RowsDiscard () Function To Do This, it Is removed To perform work In the Data window, But it can Not be removed In the row Is deleted Or Any Save the Modified nature.
Tips 115: How DataWindow display multiple lines in the Footer Band data is displayed in the first line of the current and the last line number
1 2 3 4 5 6 7 8 9 | //==================================================================== // How DataWindow display multiple lines in the Footer Band data is displayed in the first line of the current and the last line number //==================================================================== //we look at two Expressions calculated Columns: If (GetRow () = First (GetRow () For page), 1, 0) // 1 for the first row of the current page If (GetRow () <> 1 And GetRow () = Last (GetRow () For page), 1, 0) // 1 as the last line of the current page //By seen above, Set the following computed column Expression In the Footer Band: 'Rows' + String (First (GetRow () For page)) + 'to' + String (Last (GetRow () For page)) + 'are displayed'. //can achieve This functionality. |
Tips 116: Window Center
1 2 3 4 | //==================================================================== // Window Center: //==================================================================== Function Long shCenterWindow (Long hwnd) Library "Pbvm60.dll" |
Tips 117: Opens the specified Web page using IE
1 2 3 4 | //==================================================================== // Opens the specified Web page using IE: //==================================================================== Function Long shRunDefltBrower (String sellrl) Library "Pbvm60.dll" |
Tips 118: How to obtain the value of the data window computational domain!
1 2 3 4 5 6 | //==================================================================== // How to obtain the value of the data window computational domain! //==================================================================== //em_data.Text = dw_1.GetDataValue (compute_1) Is Not enough, how To Write //Answer: a Name, Then the same Value as the Field! named In the Name attribute In compute_1 em_date.Text = dw_1.Object.compute_1 [dw_1.GetRow ()] |
Tips 119: grid-style DataWindow how to automatically wrap
1, Open the Datawindow In the Datawindow Painter;
2, In the column To be Set To automatically wrap, Double-click the mouse properties window bounce This column;
3, Select the Position tab, Select AutoSize Height checkbox;
4, Select the EDIT tab, And Uncheck Auto Horz Scroll checkbox;
5, click the OK button To Save your changes;
6, points Detail Band (ie written Detail gray Long belt), click the Right mouse button And Select properties … menu Item;
7, Select AutoSize Height checkbox;
8, click the OK button To Save your changes;
9, Save Datawindow. Height property still Write a column Expression: If (Len (Trim (file_name)) / 18 > 1, Ceiling (Len (Trim (file_name)) / 18) * 24,18) how many characters On the fold Line
Tips 120: 12 with a written statement about the date function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | //==================================================================== // [12 with a written statement about the date function] //==================================================================== //can be directly assigned To a variable, Not written In functional form. another Function Is suitable For PB6.5, a Character occupies two bytes, If used //Please Modify more than the Actual situation pb8.0 // A Zodiac. (Year parameters: int ls_year return parameters: string): Mid (Fill ('Rat Ox Tiger Rabbit snakes Horse Sheep Monkey Jigou pig', 48), (Mod (ls_year -1900,12) +13) * 2 -1,2) // 2 attribution (Year parameters: int ls_year return parameters: string).: Mid (Fill ('B, CD Wuji Gengxin Jen-kuei', 40), (Mod (ls_year -1924,10) +11) * 2 -1,2) + Mid (Fill ('Zichou Mao Yin Chen Si Wu did not Shenyou Xu Hai' , 48), (Mod (ls_year -1924,12) +13) * 2 -1,2) // 3 constellation. (Date parameters: date ls_date return parameters: string): Mid ("Capricorn Aquarius Pisces Aries Taurus Gemini Cancer Leo Virgo Libra Scorpio Sagittarius Capricorn", (Month (ls_Date) + Sign (Sign (Day (ls_Date) - (19 + Integer (Mid ('102123444423', Month (ls_Date), 1)))) + 1)) * 4 3,4) + 'seat' // 4 judgment leap year. (Year parameters: int ls_year return parameters: int 0 = average year, 1 = leap year): Abs (Sign (Mod (Sign (Mod (Abs (ls_year), 4)) + Sign (Mod (Abs (ls_year), 100)) + Sign (Mod (Abs (ls_year), 400)), 2)) -1 ) // 5 days a month (date parameters: date ls_date return parameters: int).: Integer (28 + Integer (Mid ('3' + String (Abs (Sign (Mod (Sign (Mod (Abs (Year (ls_Date)), 4)) + Sign (Mod (Abs (Year (ls_Date)), 100) ) + Sign (Mod (Abs (Year (ls_Date)), 400)), 2)) -1)) + '3232332323', Month (ls_Date), 1))) // 6 date of the last day of a month. (Date parameters: date ls_date return parameters: date): Date (Year (ls_Date), Month (ls_Date), Integer (28 + Integer (Mid ('3' + String (Abs (Sign (Mod (Sign (Mod (Abs (Year (ls_Date)), 4)) + Sign (Mod (Abs (Year (ls_Date)), 100)) + Sign (Mod (Abs (Year (ls_Date)), 400)), 2)) -1)) + '3232332323', Month (ls_Date), 1)) )) // 7 the last day of a month seeking another date (date parameters: date ls_date return parameters: date): a.RelativeDate (Date (Year (ls_Date) + Sign (Month (ls_Date) -12) + 1, Mod (Month (ls_Date) +1,13) + Abs (Sign (Mod (Month (ls_Date) +1,13) ) -1), 1) - 1) b.RelativeDate (Date (Year (ls_Date) + Integer (Month (ls_Date) / 12), Mod (Month (ls_Date), 12) +1,1), - 1) // 8 seeking another few days a month. (Date parameters: date ls_date return parameters: int): a.Day (RelativeDate (Date (Year (ls_Date) + Sign (Month (ls_Date) -12) + 1, Mod (Month (ls_Date) +1,13) + Abs (Sign (Mod (Month (ls_Date) +1, 13)) -1), 1) - 1)), b.Day (RelativeDate (Date (Year (ls_Date) + Integer (Month (ls_Date) / 12), Mod (Month (ls_Date), 12) +1,1), - 1)) // 9 a certain day of the week - with the PB system function DayName. (Date parameters: date ls_date return parameters: string): 'Week' + Mid ('day one hundred twenty-three thousand four hundred fifty-six', (Mod (Year (ls_Date) -1 + Int ((Year (ls_Date) -1) / 4) - Int ((Year (ls_Date) -1) / 100) + Int ((Year (ls_Date) -1) / 400) + DaysAfter (Date (Year (ls_Date), 1,1), ls_Date) +1,7) +1) * 2 -1,2) // 10 seeking several months apart after a relative date (the date parameters: date ls_date apart month (desirable negative): int ls_add_month return parameters: date): Date (Year (ls_Date) + Int ((Month (ls_Date) + ls_add_month) / 13), Long (Mid (Fill ('010203040506070809101112', 48), (Mod (Month (ls_Date) + ls_add_month -1,12) +13 ) * 2 -1,2)), Day (ls_Date) -Integer (Right (Left (String (Day (RelativeDate (Date (Year (ls_Date) + Int ((Month (ls_Date) + ls_add_month) / 13) + Sign (Long (Mid (Fill ('010203040506070809101112', 48), (Mod (Month (ls_Date) + ls_add_month -1,12) +13) * 2 -1,2)) -12) + 1, Mod (Long (Mid (Fill ('010203040506070809101112', 48), (Mod (Month (ls_Date) + ls_add_month -1,12) +13) * 2 -1,2)) + 1,13) + Abs (Sign (Mod (Long (Mid (Fill ('010203040506070809101112', 48), (Mod (Month (ls_Date) + ls_add_month -1,12) +13) * 2 -1,2)) + 1,13)) -1), 1), - 1) ) -Day (ls_Date), '00') + '00000', 5), 3)) / 100) // 11 weeks of the year in which demand a certain date. (Date parameters: date ls_date return parameters: int): // a. weeks starting date for Sunday // a1 Abs (Int (- ((DaysAfter (RelativeDate (Date (Year (ls_Date), 1,1), -Mod (Year (ls_Date) -1 + Int ((Year (ls_Date) -1) / 4) - Int ((Year (ls_Date) -1) / 100) + Int ((Year (ls_Date) -1) / 400) + 1,7) +1), ls_Date) +1) / 7))) // a2 (using DayNumber function) Abs (Int (- ((DaysAfter (RelativeDate (Date (Year (ls_Date), 1,1), -DayNumber (Date (Year (ls_Date), 1,1)) + 1), ls_Date) +1) / 7) )) // b. weeks before the date Monday // b1 Abs (Int (- ((DaysAfter (RelativeDate (Date (Year (ls_Date), 1,1), -Integer (Mid ('6012345', Mod (Year (ls_Date) -1 + Int ((Year (ls_Date) -1 ) / 4) - Int ((Year (ls_Date) -1) / 100) + Int ((Year (ls_Date) -1) / 400) + 1,7), 1))), ls_Date) +1) / 7 ))) // b2 (using DayNumber function) Abs (Int (- ((DaysAfter (RelativeDate (Date (Year (ls_Date), 1,1), -Integer (Mid ('6012345', DayNumber (Date (Year (ls_Date), 1,1)), 1)) ), ls_Date) +1) / 7))) // 12 seeking a date relative to the past few weeks in which a certain date. (Date parameters: date ls_date_1 (requires a certain date), ls_date_2 (past a certain date) return parameters: int): // Note: ls_date_1> ls_date_2 // a. weeks starting date for Sunday // a1 Abs (Int (- ((DaysAfter (RelativeDate (ls_date_2, -Mod (Year (ls_date_2) -1 + Int ((Year (ls_date_2) -1) / 4) - Int ((Year (ls_date_2) -1) / 100) + Int ((Year (ls_date_2) -1) / 400) + DaysAfter (Date (Year (ls_date_2), 1,1), ls_date_2) + 1,7) +1), ls_date_1) +1) / 7))) // a2 (using DayNumber function) Abs (Int (- ((DaysAfter (RelativeDate (ls_date_2, -DayNumber (ls_date_2) +1), ls_date_1) +1) / 7))) // b. weeks before the date Monday // b1 Abs (Int (- ((DaysAfter (RelativeDate (ls_date_2, -Integer (Mid ('6012345', Mod (Year (ls_date_2) -1 + Int ((Year (ls_date_2) -1) / 4) - Int ((Year (ls_date_2) -1) / 100) + Int ((Year (ls_date_2) -1) / 400) + DaysAfter (Date (Year (ls_date_2), 1,1), ls_date_2) + 1,7), 1))), ls_date_1) +1) / 7))) // b2 (using DayNumber function) Abs (Int (- ((DaysAfter (RelativeDate (ls_date_2, -Integer (Mid ('6012345', DayNumber (ls_date_2), 1))), ls_date_1) +1) / 7))) |
Tips 121: pb pure function analog Explorer window, click the mouse in action dynamic data sorting and display the sort arrow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | //==================================================================== // pb pure function analog Explorer window, click the mouse in action dynamic data sorting and display the sort arrow //==================================================================== // Function name: f_dwsort (datawindow fdw_dw, dwobject fdwo_dwo) return none // Description: for analog Explorer click action dynamic sorting in the data window, and display the sort arrow // Invoke rules: In the data window controls clicked written f_dwsort (this, dwo)! // Parameters: fdw_dw datawindow // Fdwo_dwo dwobject // Return Value: None String ls_clicked_pos, ls_col, ls_format, ls_tag Long ll_pos String ls_text, ls_column [] Int li_i ls_clicked_pos = fdwo_dwo.Name ll_pos = Pos (ls_clicked_pos, '_ t') If ll_pos > 0 Then // Set the sort ls_col = Left (ls_clicked_pos, ll_pos -1) ls_tag = fdwo_dwo.Tag If ls_tag = ls_col + "A" Then fdwo_dwo.Tag = ls_col + "D" ls_format = ls_col + "A" ElseIf ls_tag = ls_col + "D" Then fdwo_dwo.Tag = ls_col + "A" ls_format = ls_col + "D" Else fdwo_dwo.Tag = ls_col + "D" ls_format = ls_col + "A" End If // Set column headers For li_i = 1 To Long (fdw_dw.Object.Datawindow.column.Count) ls_column [li_i] = fdw_dw.Describe ("#" + String (li_i) + ".Name") // get column names ls_text = fdw_dw.Describe (ls_column [li_i] + "_t.text") If Right (ls_text, 2) = "▽" Or Right (ls_text, 2) = "△" Then ls_text = Left (ls_text, Len (ls_text) - 2) End If fdw_dw.Modify (ls_column [li_i] + "_t.text = '" + ls_text + "'") Next ls_text = fdw_dw.Describe (ls_clicked_pos + ".text") If Right (ls_text, 2) = "▽" Or Right (ls_text, 2) = "△" Then ls_text = Left (ls_text, Len (ls_text) - 2) End If If Right (ls_format, 1) = 'A' Then fdw_dw.Modify (ls_clicked_pos + ".text = '" + ls_text + "△'") ElseIf Right (ls_format, 1) = 'D' Then fdw_dw.Modify (ls_clicked_pos + ".text = '" + ls_text + "▽'") End If fdw_dw.SetSort (ls_format) fdw_dw.Sort () End If |
Tips 122: pb in the first character of a string of characters to take a function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | //==================================================================== // pb in the first character of a string of characters to take a function zhoukan (Collection) //==================================================================== //Today saw the First Character Of a Fetch Function xuejun characters, And Try a little, feeling very good, Not exclusive, come To share With you: $ PBExportHeader $ uf_getfirstletter.srf $ PBExportComments $ Return For a given String Of characters String initials, xuejun, 19990821 Global Type uf_getfirstletter From function_object End Type Forward Prototypes Global Function String uf_getfirstletter (String as_inputstring) End Prototypes Global Function String uf_getfirstletter (String as_inputstring); // Function name: uf_GetFirstLetter // Used to: Returns the given string of characters string initials, that consonant strings // Input Arguments: as_InputString - string, string given kanji // Return Value: ls_ReturnString - String, given the string of consonants string characters, all lowercase // Notice: 1. the validity of this method is based on the national standard kanji characters Reservoir bit encoding, this encoding systems do not meet this function is invalid! // 2 If the Chinese character string containing non-Kanji characters, such as graphic symbols or ASCII code, then these non-kanji characters will remain unchanged. // Sample: ls_rtn = uf_GetFirstLetter ("People's Republic of China") // Ls_rtn will be: zhrmghg // Scripts: Start area code Char lc_FirstLetter [23] // store GB a different pronunciation of the corresponding Chinese character pronunciation String ls_ch // temporary unit String ls_SecondSecTable // store all GB two Chinese pronunciation Returns the String String ls_ReturnStr // Start area code Integer li_SecPosValue [23] // store GB a different pronunciation of Chinese characters Integer i, J Integer li_SectorCode // Kanji area code Integer li_PositionCode // Chinese-bit code Integer li_SecPosCode // Kanji area code Integer li_offset // two character offsets // Set initial value li_SecPosValue [] = {1601,1637,1833,2078,2274,2302,2433,2594,2787,3106,3212,3472,3635,3722,3730,3858,4027,4086,4390,4558,4684,4925,5249 } lc_FirstLetter [] = {"A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M "," N "," O "," P "," Q "," R "," S "," T "," W "," X "," Y "," Z "} ls_SecondSecTable = "CJWGNSPGCGNE [Y [BTYYZDXYKYGT [JNNJQMBSGZSCYJSYY [PGKBZGY [YWJKGKLJYWKPJQHY [W [DZLSGMRYPYWWCCKZNKYYGTTNJJNYKKZYTCJNMCYLQLYPYQFQRPZSLWBTGKJFYXJWZLTBNCXJJJJTXDTTSQZYCDXXHGCK [PHFFSS [YBGXLPPBYLL [HLXS [ZM [JHSOJNGHDZQYKLGJHSGQZHXQGKEZZWYSCSCJXYEYXADZPMDSSMZJZQJYZC [J [WQJBYZPXGZNZCPWHKXHQKMWFBPBYDTJZZKQHYLYGXFPTYJYYZPSZLFCHMQSHGMXXSXJ [[DCSBBQBEFSJYHXWGZKPYLQBGLDLCCTNMAYDDKSSNGYCSGXLYZAYBNPTSDKDYLHGYMYLCXPY [JNDQJWXQXFYYFJLEJPZRXCCQWQQSBNKYMGPLBMJRQCFLNYMYQMSQYRBCJTHZTQFRXQHXMJJCJLXQGJMSHZKBSWYEMYLTXFSYDSWLYCJQXSJNQBSCTYHBFTDCYZDJWYGHQFRXWCKQKXEBPTLPXJZSRMEBWHJLBJSLYYSMDXLCLQKXLHXJRZJMFQHXHWYWSBHTRXXGLHQHFNM [YKLDYXZPYLGG [MTCFPAJJZYLJTYANJGBJPLQGDZYQYAXBKYSECJSZNSLYZHSXLZCGHPXZHZNYTDSBCJKDLZAYFMYDLEBBGQYZKXGLDNDNYSKJSHDLYXBCGHXYPKDJMMZNGMMCLGWZSZXZJFZNMLZZTHCSYDBDLLSCDDNLKJYKJSYCJLKWHQASDKNHCSGANHDAASHTCPLCPQYBSDMPJLPZJOQLCDHJJYSPRCHN [NNLHLYYQYHWZPTCZGWWMZFFJQQQQYXACLBHKDJXDGMMYDJXZLLSYGXGKJRYWZWYCLZMSSJZLDBYD [FCXYHLXCHYZJQ [[QAGMNYXPFRKSSBJLYXYSYGLNSCMHZWWMNZJJLXXHCHSY [[TTXRYCYXBYHCSMXJSZNPWGPXXTAYBGAJCXLY [DCCWZOCWKCCSBNHCPDYZNFCYYTYCKXKYBSQKKYTQQXFCWCHCYKELZQBSQYJQCCLMTHSYWHMKTLKJLYCXWHEQQHTQH [PQ [QSCFYMNDMGBWHWLGSLLYSDLMLXPTHMJHWLJZYHZJXHTXJLHXRSWLWZJCBXMHZQXSDZPMGFCSGLSXYMJSHXPJXWMYQKSMYPLRTHBXFTPMHYXLCHLHLZYLXGSSSSTCLSLDCLRPBHZHXYYFHB [GDMYCNQQWLQHJJ [YWJZYEJJDHPBLQXTQKWHLCHQXAGTLXLJXMSL [HTZKZJECXJCJNMFBY [SFYWYBJZGNYSDZSQYRSLJPCLPWXSDWEJBJCBCNAYTWGMPAPCLYQPCLZXSBNMSGGFNZJJBZSFZYNDXHPLQKZCZWALSBCCJX [YZGWKYPSGXFZFCDKHJGXDLQFSGDSLQWZKXTMHSBGZMJZRGLYJBPMLMSXLZJQQHZYJCZYDJWBMYKLDDPMJEGXYHYLXHLQYQHKYCWCJMYYXNATJHYCCXZPCQLBZWWYTWBQCMLPMYRJCCCXFPZNZZLJPLXXYZTZLGDLDCKLYRZZGQTGJHHGJLJAXFGFJZSLCFDQZLCLGJDJCSNZLLJPJQDCCLCJXMYZFTSXGCGSBRZXJQQCTZHGYQTJQQLZXJYLYLBCYAMCSTYLPDJBYREGKLZYZHLYSZQLZNWCZCLLWJQJJJKDGJZOLBBZPPGLGHTGZXYGHZMYCNQSYCYHBHGXKAMTXYXNBSKYZZGJZLQJDFCJXDYGJQJJPMGWGJJJPKQSBGBMMCJSSCLPQPDXCDYYKY [CJDDYYGYWRHJRTGZNYQLDKLJSZZGZQZJGDYKSHPZMTLCPWNJAFYZDJCNMWESCYGLBTZCGMSSLLYXQSXSBSJSBBSGGHFJLYPMZJNLYYWDQSHZXTYYWHMZYHYWDBXBTLMSYYYFSXJC [DXXLHJHF [SXZQHFZMZCZTQCXZXRTTDJHNNYZQQMNQDMMG [YDXMJGDHCDYZBFFALLZTDLTFXMXQZDNGWQDBDCZJDXBZGSQQDDJCMBKZFFXMKDMDSYYSZCMLJDSYNSBRSKMKMPCKLGDBQTFZSWTFGGLYPLLJZHGJ [GYPZLTCSMCNBTJBQFKTHBYZGKPBBYMTDSSXTBNPDKLEYCJNYDDYKZDDHQHSDZSCTARLLTKZLGECLLKJLQJAQNBDKKGHPJTZQKSECSHALQFMMGJNLYJBBTMLYZXDCJPLDLPCQDHZYCBZSCZBZMSLJFLKRZJSNFRGJHXPDHYJYBZGDLQCSEZGXLBLGYXTWMABCHECMWYJYZLLJJYHLG [DJLSLYGKDZPZXJYYZLWCXSZFGWYYDLYHCLJSCMBJHBLYZLYCBLYDPDQYSXQZBYTDKYXJY [CNRJMPDJGKLCLJBCTBJDDBBLBLCZQRPPXJCJLZCSHLTOLJNMDDDLNGKAQHQHJGYKHEZNMSHRP [QQJCHGMFPRXHJGDYCHGHLYRZQLCYQJNZSQTKQJYMSZSWLCFQQQXYFGGYPTQWLMCRNFKKFSYYLQBMQAMMMYXCTPSHCPTXXZZSMPHPSHMCLMLDQFYQXSZYYDYJZZHQPDSZGLSTJBCKBXYQZJSGPSXQZQZRQTBDKYXZKHHGFLBCSMDLDGDZDBLZYYCXNNCSYBZBFGLZZXSWMSCCMQNJQSBDQSJTXXMBLTXZCLZSHZCXRQJGJYLXZFJPHYMZQQYDFQJJLZZNZJCDGZYGCTXMZYSCTLKPHTXHTLBJXJLXSCDQXCBBTJFQZFSLTJBTKQBXXJJLJCHCZDBZJDCZJDCPRNPQCJPFCZLCLZXZDMXMPHJSGZGSZZQLYLWTJPFSYASMCJBTZKYCWMYTCSJJLJCQLWZMALBXYFBPNLSFHTGJWEJJXXGLLJSTGSHJQLZFKCGNNNSZFDEQFHBSAQTGYLBXMMYGSZLDYDQMJJRGBJTKGDHGKBLQKBDMBYLXWCXYTTYBKMRTJZXQJBHLMHMJJZMQASLDCYXYQDLQCAFYWYXQHZ " // Get it! ls_ReturnStr = "" For i = 1 To Len (as_inputstring) // sequentially processing each character as_InputString ls_ch = Mid (as_inputstring, i, 1) If Asc (ls_ch) < 128 Then // non-kanji ls_ReturnStr = ls_ReturnStr + ls_ch // unchanged Else // Chinese characters ls_ch = Mid (as_inputstring, i, 2) // out this characters li_SectorCode = Asc (Left (ls_ch, 1)) - 160 // area code li_PositionCode = Asc (Right (ls_ch, 1)) - 160 // bit code li_SecPosCode = li_SectorCode * 100 + li_PositionCode // area code If li_SecPosCode > 1600 And li_SecPosCode < 5590 Then // first character For J = 23 To 1 Step -1 // find initials If li_SecPosCode > = li_SecPosValue [J] Then ls_ReturnStr = ls_ReturnStr + lc_FirstLetter [J] Exit End If Next Else // first character li_offset = (li_SectorCode - 56) * 94 + li_PositionCode - 1 // calculate the offset If li_offset > = 0 And li_offset <= 3007 Then // two zones characters ls_ReturnStr = ls_ReturnStr + Mid (ls_SecondSecTable, li_offset, 1) // remove this word initials End If End If i = i + 1 // point to the next one kanji End If Next // processed // Return result Return Lower (ls_ReturnStr) // return as_InputString consonant strings End Function |
Tips 123: How to use WINSOCK control in the POWERBUILDER
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | //==================================================================== // How to use WINSOCK control in the POWERBUILDER //==================================================================== /* With resource sharing And real-time Communication needs, many computer applications have already bypassing individual combat mode, Into joint action. network In the computer world, increasingly play a pivotal role. In WINDOWS applications, Most commonly used For real-time Communication Microsoft WINSOCK Control Or provided By the company. much Of the information detailing the WINSOCK In VB To use, even WINDOWS Hlp file itself Is also written For VB. the author because Of the need Of practical Application, figure out the Application WINSOCK Control In the PB Of methods. good things did Not dare To enjoy alone, come To share With you. following a simple program To illustrate the use Of the PB WINSOCK Control Of: First, add WINSOCK Control In the window: In the Application To Open a new window, click On the controls In the window Painter - > OLE menu Item Insert Object pop-up window, click Insert control labels, selected From the list box, double-click the Microsoft Winsock control, the winsock icon attached to the window. The control name In the program as winsock_a (Party) And winsock_b (B). Second, the setting information input And output text box: Add a button cb_1 In the window, two-line text box sle_1, sle_2, respectively, the input string to send And accept each other For sending String Third, Set the communication protocol:WINSOCK control allows the user to UDP And TCP Choose one of two protocols For communication. */ //1.UDP protocol settings: UDP protocol is a connectionless protocol, before the communication, the need to bind remotehost And remoteport //Property, if necessary two-way communication, but also Set localport property. //Party A (the machine address is: 134.1.1.1) Open event window add the following statement: //winsock_a.object.protocol = 1 // winsock communication protocol is set to UDP protocol winsock_a.Object.remotehost = "134.1.1.2" // Each other's ip address winsock_a.Object.remoteport = 6000 // The other side of winsock communication port number winsock_a.Object.localport = 6001 // This machine winsock communication port number winsock_a.Object.bind // Binding protocol //Open event of the window to add the following statement: In the B (134.1.1.2 address of the machine): winsock_b.Object.protocol = 1 // winsock communication protocol is set to UDP protocol winsock_b.Object.remotehost = "134.1.1.1" // Each other's ip address winsock_b.Object.remoteport = 6001 // The other side of winsock communication port number winsock_b.Object.localport = 6000 // This machine winsock communication port number winsock_b.Object.bin // Binding protocol //2.TCP Protocol Settings: TCP protocol communications need to be connected before. //Party A (as a server-side) Open event window add the following statement: winsock_a.Object.protocol = 0 // winsock communication protocol to TCP protocol winsock_a.Object.localport = 6001 // This machine winsock communication port number winsock_a.Listen () // Start listening // add the following statement Connectionrequest Party winsock_a Control's event: // The other side of the connection request received If winsock_a.Object.State <> 0 Then winsock_a.Close () End If winsock_a.accept (requestID) // Establish a direct connection // requestID event is Connectionrequest own parameters //In B (as a client) Open event window add the following statement: winsock_b.Object.protocol = 0 // winsock communication protocol to TCP protocol winsock_b.Object.remotehost = "134.1.1.2" // Each other's ip address winsock_b.Object.remoteport = 6000 // The other side of winsock communication port number winsock_b.Connect () // connection request //3 Either protocol uses, should add the following statement In the Close event of the window: If winsock_a.Object.State <> 0 Then winsock_a.Close () End If //Otherwise, problems may occur when Using unusual second time //Third, start communication //Add the following sentence at the button cb_1 (caption attribute is Set to 'send')'s click event: winsock_a.Object.Send (sle_1.Text) //Add the following statement dataarrival winsock_a control's event: //Other data received after // String datastr1 winsock_a.Object.GetData (def datastr1) sle_2.Text = datastr1 // the data string is displayed in a text box //The above Procedure is actually reflects the underlying chat works, minor modifications can be made to expand a nice chat software |
Good Luck!