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, |