Home     contact  
 
 
 
 
 
 

 

 

 

 

 
 

Powerbuilder tips
 

// 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> 45000'
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 ()


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


// 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)


// 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 = ''") about;


// 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 ()


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


// 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;


// 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.


// 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!


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


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


// 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 ()


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


// Tip: Select to delete records
if dw_2.GetSelectedRow (0) = 0 then
MessageBox ("message", "Please select the record to be deleted!")
return
end if


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


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


// 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.


// By conditions on color-coded data in a row
case (cj when is> = 90 then rgb (255,0,0) when is <60 then rgb (0,255,0) else rgb (0,0,255)))


// PB simultaneously connect to multiple databases, such as connecting SQLServer2000 and Oracle8
string ls_startupfile
ls_startupfile = 'hisini.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 hisini.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'


//PB6.5 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' ''"


// 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 ()


// Data window, press the enter key to achieve tab function (in Enter event data window)
send (handle (this), 256,9, long (0,0))
return 1


// 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)

// 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 ()





// 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;


// 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;


// 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 ()


// 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 ()


// 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)


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


// 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 ()


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


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


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


// Exit button Generic Script
close (parent) or closeWithReturn (parent, returnvalue)


// 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 ()


// 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 !!!


//PB6.5 Run-time dynamic link library (Runtime Library)
PBVM60.DLL (PowerBuilder virtual machine) (required)
PBDWE60.DLL (DataWindow engine) (optional)
PBRTC60.DLL (Rich Text Control) (Optional)
PBTRA60.DLL (DLL used for tracing db calls) (optional)
Straight connector (Native Driver) or ODBC database interface connections required (ODBC Driver)
PBSYC60.DLL (connecting Sybase straight connector)
PBO7360.DLL (connection Oracle7.3 straight connector)
Client-side (such as Sybase's Open Client, Oracle's SQL Net) database connection required
These are Sybase's proposal.
My experience is that the compiled program must have pbdwe60.dll and pbvm60.dll job.
Also, if you need to use the ODBC database links pbodb60.dll, if you are using a dedicated interface, you need the corresponding DLL database
As Oracle7.3 with PBO7360.DLL, Sybase with PBSYC60.DLL


exe file execution //pb6.5 upgrade to problems that may occur after 6.5.1
Re-copy \ Sybase \ pbvm60.dll Shared under (3.24M) instead of when not upgraded pbvm60.dll (3.25M) on ok!


// Several common colors
Red: rgb (255,0,0) or change the eye-catching effect
Blue: rgb (0,0,255) attention to the role
Dark green: rgb (0,128,0) prompt action


// SQL AnyWhere installation methods:
When you install PB65 custom installation components ODBC Databases Drives in the Sybase SQL anywhere 5.5.04, this is just
PB components installed ODBC driver is not installed SQL ANYWHERE, if you need to use SQL Anywhere administration tools, you
Have the following operations: Genuine PB6.5 in the sixth disc, there is a directory name is SQLANY5504, there is SQL ANYWHERE
Installation disk, and run SETUP can. If it is pirated, it had to rely on your own to go up. In the installation directory there is a SETUP.BMP,
There SQL words ANHWERE above.


// Speaking to a lot of books FILE menu midpoint CREATE DATABASE, how to make this option out
In pb sixth CD (or use the D version of the second disc \ 6 \ sqlany5504), enter sqlany5504 directory, install sql anywhere 5.5,
The default installation path is: C: After the \ Program Files \ Sybase \ SQL Anywhere 5.0 \ win32, installation, modification
autoexec.bat, add a line for sqlanywhere file into the system search path:
path% PATH%; C: \ Progra ~ 1 \ Sybase \ SQLAny ~ 1.0 \ win32
After this reboot, you can see the File menu of the Create Database more this one.
Special Note: In the ... \ This directory under win32 there is a very important document, dbtl50t.dll, you can do an experiment, enter
PB DataBase drawing board (no exit), then switch to the File Manager will dbtl50t.dll files to rename, and then switch back to the PB,
Point File menu, you will find this a Create Database has disappeared. The dbtl50t.dll renamed back, back again PB Click here
File menu, everything has returned to normal. But no Create DataBase This one is not very important, you can also use
Sybase Central to manage the database, it is a comprehensive database management tool Sql anywhere, you can build storage procedures, triggers.
(In the "Start" -> "Programs" -> "Sybase" -> "Sql anywhere 5.0" below, in the hard disk to perform the file name is scview.exe).


// Not install Oracle client Oracle 8 ways to connect
Please following files are copied to the directory where the file operation
One, ODBC dynamic libraries:
ctl3d32.dll msvcrt40.dll odbc16gt.dll odbc32.dll odbc32gt.dll odbccp32.dll odbccr32.dll odbcint.dll
Second, the establishment EXTRA subdirectories, copy files to the subdirectory MSVCRT.DLL
EXTRA \ MSVCRT.DLL
Three, ORACLE dynamic libraries and configuration files
Tnsnames.ora CORE35O.DLL NASNSNT.DLL NAUNTSNT.DLL NCRNT.DLL Nlnt.dll NLSRTL32.DLL Nnfdnt.dll
NNFNNT.DLL NSNT.DLL NTNT.DLL NTTNT.DLL CIW32.DLL Ora73.dll OTRACE73.DLL Sqlnet.ora
Sqltnsnt.dll CORE35.DLL
Four, PB dynamic library
pbvm70.dll pbdwe70.dll Pbo7370.dll PBO8470.DLL pbodb70.dll libjcc.dll


// SQL7 client is not installed, the method SQL7 connection:
Just to SQL's DBNMPNTW.DLL, NTWDBLIB.DLL and PB of PBVM60.DLL, PBDWE60.DLL copied to the directory where the EXE file
You can!


// Set the default properties of an object
In the user interface design, each adding an object such as buttons, text boxes, etc., PowerBuilder will use the default font, size, color
And other attributes to define objects. If this is not the properties we need, then we need to modify the properties individually. You can by default
Property changes needed to simplify for this operation. Open the application brush, in the properties can be the default font, size, color and other attributes
Need to change the default properties.


// 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.

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


// System of five predefined global variables
sqlca, sqlda, sqlsa, error, message


// Relationship in PowerBuilder and RGB color values between the values as follows:
color = R * 256 * 256 + G * 256 + B


// 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 ()


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


// 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.


// 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.


// 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.


// How to generate a fixed-length front plus zero digits, for example: 12 generation "00012" 1234 generation "01234." The method is simple:
String (ll_number, "00000")


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


// 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)


// How to Grid-based datawindow into Tabular type
Export data window into .srd file, use Notepad to open the processing = 1 into processing = 0


Role // 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.


//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.
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


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


// In PB how to open a file (such as .txt, .doc), just like in Explorer, double-click to open the file the same
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)


// Insert a row after a default value to the default value but do not modify, CloseQuery event does not excite method
long 1_Row
1_Row = dw_1, InsertRow (dw_1, GetRow ())
dw_1.SetItem (1_Row, "discount_pct", 0,10)
dw_1.SetItemStatus (1_Row, 0, Primary!, New!)


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





Rule checking data window //
When a user enters data in the edit control, the data will not be written immediately buffer the data window until the occurrence of any of the following,
PowerBuilder DataWindow only writes data from the edit control buffer.
1 user presses the Enter key
2 user presses the Tab key to jump to the next field
3 user presses the mouse button to jump to another field
4 Run AcceptText () function
After completely through the four steps of rule checking, will really put data into the data buffer from the edit control window. Error in any one step
. Would produce data window ItemError Event data rule checking step data window are as follows:
Whether 1 data change
2 Data Types meets
3 meets user-defined field rules
4 meets ItemChanged Event program


// Edit control function
AcceptText (): write data to the data in the edit control window buffer.
Do not write Acceptext () function in Itemchanged or ItemError event because Acceptext () function may drive
ItemChanged or ItemError event, which will cause an infinite loop occurs.
GetText (): read the text edit control.


// Function Function similar event and every event, there will be arguments argument and return value return value.
ItemChanged Event Returns:
0.5 accept data values (default)
1 reject the value of data
2-value data and refuse to change focus
ItemError Event Returns:
0.5 reject the value of the data, and displays a system error message (default)
Value of 1. Reject the data, but the system does not display an error message
Accept the value of the data
3-value data and refuse to change focus


// dw's update properties
Where conditional clause is generated by:
1. Key Columns: When comparing raw data buffer and the data generated by the current database where clause condition is not stringent enough, so in the same
A time when there are a lot of users may use the database with the changed circumstances would someone data coverage will occur in order to
Avoid this from happening, usually we will KeyColumns way relationship with a single user or a table, all the fields are
Primary Key of the situation.
2.Key and Updateable Columns: because the data in the buffer and compare the original data generated by the current database
where conditional clause is very rigorous, so in the same time, when a lot of users use the database together, does not happen to other people
Data covering the situation changed, so we can get the maximum consistency when data is saved.
3.Key and Modified Columns: because the data in the current database generated by comparing the data buffer where clause
Conditions more flexible (Modified to modify the current value of the field), so in the same time, when many users use the data together
Library, the situation will be changed by others data coverage may occur.
The main field (Key Column) changes the way:
1.Use Delete then Insert: This is the data window when you modify the main field (Key Column) is the default option, the choice this way
When you modify the data, the data will first be deleted and then re-increase a data, but in the use of special note is that if the relationship
Database, when designing deleted for Cascade Delete, modify data in time may result in additional data not want to delete are deleted.
In addition, the choice of the field must select all the fields, otherwise there is no way to increase a further weight data.
2.Use Update: This option will directly modify the value Key field, but not all of the relational database (DBMS) provides such
Function.

// Dynamic Data Window
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 ()


// 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.)
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;


// 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.


// Get the display value of the pull-down data window
ls_value = dw_1.Describe ("Evaluate ('LookupDisplay (column_name)'," + string (row_number) + ")")

// Previous column method of fixing the data window, 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


// 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 ()


// When the edit box to get focus automatically selected content:
this.selecttext (1, len (sle_1.text))


// Determine whether there is a column in the data window
You can use Describe ("column_name.width") to determine whether the "!";


// Hide the taskbar method in use in the OnCreate event Window API function SetWindowLong: SetWindowLong (Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
PB using the first declare the function FUNCTION long SetWindowLong (ulong hWnd, integer nIndex, ulong dwNewLong) library "user32.dll" ALIAS FOR "SetWindowLongA",
Then call: SetWindowLong (Handle (this), - 20,128);


// 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)


PB // two useful internal functions
1.shRunDefltBrowser call the default browser, open the specified page
Version: PBVM60.dll, PBVM80.dll, PB7 I have not used, but I think there should be.
Function declaration: function long shRunDefltBrowser (string szUrl) library "pbvm60.dll"
Call the method: shRunDefltBrowser ("http://www.pdriver.com/")
2 shCenterWindow the window in the center of the screen
Version: PBVM60.dll, PBVM80.dll, PB7 I have not used, but I think there should be.
Function declaration: function long shCenterWindow (long hWnd) library "pbvm60.dll"
Call the method: shCenterWindow (handle (w_about))


// Allows the user to modify the newly added records, and the records retrieved are not allowed to modify.
Open the properties listed in the Expressions, input conditions in protect the discriminant:
if (isRowNew (), 0,1)


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


Use // progress bar
Although no such controls, but there is a PowerBuilder user object in the case brought in in PowerBuilder
uo_progress_bar able to complete the necessary requirements. The object is copied to the user's user database application resides, place it in the user interface
Local needs arise. Then when the task progress, with uf_set_position object () function indicates the current progress of the task.


// Call screen protection method in PB:
send (handle (This), 274,61760,0)


// Get an application such as Outlook's path
RegistryGet ("HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ App Paths \ MSIMN.EXE", &
"Path", ls_outlook_path)
Path // Outlook will be saved in the string variable ls_outlook_path.


// 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.


// 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.


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


// 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!


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


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


// When the program is used in a dynamic join objects, such as BMP resource files, data window object, PB compile time is less than the scan, the solution:
1. This object is written to the resource file:
The use Notepad to create a resource file dw_object.pbr writes: c: \ myprogram.pbl (dw_sj)
This file into the Resource File Name selected at compile time.
2. The application is compiled into PBD, DLL files.


// How to achieve in PB delay:
subroutine Sleep (long dwMilliseconds) library "kernel32.dll"
Delay of one second is called: Sleep (1000) // milliseconds.


// With the following expression can be obtained in a certain group recorded line number:
Getrow () - First (Getrow () for Group 1) +1


// 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.


// 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.


// 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))"


// Previous column method of fixing the data window, 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


// In the data window How to hide a computing unit
Set in its properties \ expression \ visible property "IF (1 = 2,1,0)" on it.


// Hyperlink
Inet linet_base
GetContextService ("Internet", linet_Base)
linet_Base.HyperlinkToURL ('http://www.neusoft.com')
Destroy (linet_base)


// ================================================ ===========================
// 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





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


// other events are what use
other event occurs when a Windows message and when the message is do not correspond to the control of a powerBuilder event trigger;
The numerical number message.number representative events, this number is provided by Windows


// PB of SHELL command
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.

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


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





// In the data window 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))


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


// 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 ()


// How can I control the security of a good program it
For example, I want to control the operating authority of a button in a window which
In datawindow, the operation of a field can be operated property, is to separate the coding of these it
Is there a better way
Windows were placed in authority among variables, and then cancel the permission of the window on it!


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


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


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


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





// 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.


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


// 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.


// 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)")


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


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


// 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!')


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


// 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.
// ================================================ ===========================
// Author: Raojia Hong Time: November 19, 2002
// ================================================ ===========================
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


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







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


// 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):
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.


// 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!


// Data window 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.


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


// 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) + "')"


// 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"


// 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.


// 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.


// 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.


// 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.


// Window Center:
function long shCenterWindow (long hwnd) library "Pbvm60.dll"


// Opens the specified Web page using IE:
function long shRunDefltBrower (string sellrl) library "Pbvm60.dll"


// 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 ()]


//PB6.5 In 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


// [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)))


// 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
// This program tested in pb6.5


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


Avoid head side table // Grid data window selection mode when there form lines.
Grid data window with a way to achieve a tabular report output, but if not controlled or treated at the head table side, it appears
Form Line Detail Band of each column of data, which we do not need. Reference method is to solve the problem:
①. Could head side table in the Header Band of adding a text box, so that the text box and can be wide enough to cover all of the data columns, while the
Vertical length adjustment Header Band in the head portion of the table flush.
②. Properties ... in the text box window, displays the contents of the text box to clear empty, background Font tab in the font in the
Colors (Background) with the same background color is set to the data window and Position tab will be its Layer (level) is amended as
Foreound, click the OK button, and immediately be able to see the effect.


// How to use WINSOCK control in the POWER BUILDER
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

 
 
       
Copyright (C) 2007-2010 pblSoft software, all rights reserved.