// Basic window (pb) with adaptive screen resolution)
Make an adaptive screen resolution window as the base class of all forms in an application. In this way, the entire program can be well adapted.
The screen resolution changes. The implementation principle is very simple, that is, when the window is opened, the size of the widget in the window is RESIZE,
Location. Refer to the following source code for easy understanding.
1. Create a window.
Write a function f_resize () for the window. Most of the work is here.
No input parameter
Returns an integer:
Environment env
Integer ii_ScreenWidth, ii_ScreenHeight
Double WRadio, HRadio, Radio
Integer ii_WinBolderWidth, ii_WinBolderHeight
Getenvironment (env)
Ii_WinBolderWidth = this. width-this. WorkSpaceWidth () // obtain the Border width of the form.
Ii_WinBolderHeight = this. height-this. WorkSpaceHeight ()
Ii_ScreenWidth = env. screenwidth
Ii_ScreenHeight = env. screenheight
// Compute the radio that need be resize
WRadio = ii_ScreenWidth/800 // The standard screen resolution is 800*600
HRadio = ii_ScreenHeight/600 // calculate the number of changes to the screen's resolution relative to 800*600
Radio = Min (WRadio, HRadio)
If Radio = 1.0 then // if the screen is default 800*600
Return 0
End if
This. hide ()
This. width = (this. width-ii_WinBolderWidth) * Radio + ii_WinBolderWidth
This. height = (this. height-ii_WinBolderHeight) * Radio + ii_WinBolderHeight
Integer I
Dragobject temp // used to retrieve various controls
For I = 1 to upperbound (this. control)
Temp = this. control [I] // adjust the size and position
Temp. width = temp. width * Radio
Temp. x = temp. x * Radio
Temp. y = temp. y * Radio
Temp. Height = temp. Height * Radio
Choose case typeof (temp)
Case tab!
Tab mtab
Mtab = temp
Mtab. textsize = mtab. textsize * Radio // set the font
Case commandbutton!
Commandbutton cb
Cb = temp
Cb. textsize = cb. textsize * Radio
Case singlelineedit!
Singlelineedit
Lupus = temp
Lupus. textsize = lupus. textsize * Radio
Case editmask!
Editmask em
Em = temp
Em. textsize = em. textsize * Radio
Case statictext!
Statictext st
St = temp
St. textsize = st. textsize * Radio
Case datawindow! // Datawindows get zoomed
Datawindow dw
Dw = temp
Dw. Object. DataWindow. zoom = string (int (Radio * 100) // note the differences between DATAWINDOW and other controls.
Case picturebutton!
Picturebutton pb
Pb = temp
Pb. textsize = pb. textsize * Radio
Case checkbox!
Checkbox cbx
Cbx = temp
Cbx. textsize = cbx. textsize * Radio
Case dropdownlistbox!
Dropdownlistbox ddlb
Ddlb = temp
Ddlb. textsize = ddlb. textsize * Radio
Case groupbox!
Groupbox gb
Gb = temp
Gb. textsize = gb. textsize * Radio
Case listbox!
Listbox lb
Lb = temp
Lb. textsize = lb. textsize * Radio
Case multilineedit!
Multilineedit mle
Mle = temp
Mle. textsize = mle. textsize * Radio
Case radiobutton!
Radiobutton rb
RB = temp
RB. textsize = RB. textsize * radio
End choose
Next
This. Show ()
Return 0
After writing the function, you can call the function in the open event of the form.
// Some PB printing problems
// How to use printed paper with holes in petabytes
Operating System: Win98
Programming tool: pb70
Problem: When printing data windows in Pb, it is often necessary to use a printed paper with holes. My approach is to select the print attribute in the data window.
"Default (0)", and then in the printer properties, set the custom paper (3800x2800), this can be printed. In use, if
Narrow Rows and wide rows of Custom paper need to be selected among multiple users, which is really troublesome. Can I use a command to set custom settings?
Paper, and no need to set printer properties, I now only have this problem in one project, other has been completed, very urgent to use, here I
Thank you very much ,! Please help me !!! Please enlighten me?
Level: Intermediate
Answer:
S_w_y comments:
This attribute is available in the Data Object window: dw_control.object.data?#print.paper.size can be achieved by setting this attribute
Customize the size of the printed paper.
Zwd comments:
I have a very stupid way to find out if it is feasible. Add multiple drivers for a printer in the printer list, and set various custom sheets respectively.
You only need to select the printer when printing.
Peng dingyou's opinion:
View the print attributes related to Datawindow: dw_1.object.data1_print.property
For example: dw_1.object.data?#print.copies = 10 print 10 copies
Dw_1.object.data1_1_print.orientation = 1 Horizontal Printing
Dw_1.object.data1_1_print.range = '1, 3-'print pages 1, 3, 4, 5, 6, 7, 8, 10
Dw_1.object.data1_print.paper.size = x (0-33 indicates the paper size respectively)
Dw_1.object.data‑embedded print.preview = true print preview
Dw_1.object.data?#print.zoom = 80% zoom out preview print
Dw_1.object.data1_1_print.scale = 2 Change the actual printing Ratio
Dw_1.object.data?#print.margin.top = 50 change the printing distance to the top.
.............
// How to control the printing of a specified page or page by PB
Operating System: Windows 98 oem
Programming tool: PowerBuilder 6.0
Q: Can I control the printing of a specified page or a certain page range like WORD printing in PB development applications (due to printer problems )?
When a page is broken, you need to do so ). Such a dialog box appears in PFC, but you do not know how to use it. And I developed it before.
In the PB program, some form names are the same as those in the PFC database (many problems are involved if you want to change it), and how to reference functions in the PFC database.
I am very grateful.
Answer: dw_1.object.data1_print.page.range = '1'
// Use the PRINTTEXT function to print the printed characters. How can I set the width of the printed characters?
Operating System: windows, nt
Programming tool: powerbuilder
Q: How do I set the width of the printed characters when printing using the PRINTTEXT FUNCTION OF PB?
Level: Intermediate
A: Set it with PrintDefineFont.
// Petabytes are printed on some existing forms with format and text
Programming tool: powerbuilder
Operating System: Windows 98
When I first came into contact with PB, I wanted to use it to compile a form print program for my friends. That is, I printed the corresponding printed format and text on some forms.
Data. I don't know how to implement it with PB? Thank you.
A: You can use two data windows, one for data input, and the other for data input.
Print data. In the second data window, place the control positions in the data window according to the printed form positions, print the sample
Reset. Try multiple times. After entering the data in the first data window, copy the data to the second data window, and then use
The print () function prints the second data window.
Comments of sulo_xxr:
Use printtext (), printsetspacing (), and print. We recommend that you first find out their usage.
Easy to implement.
// How to print the barcode
Operating System: win98
Programming tools: PB6.5
Q: Ask the Instructor How to print the barcode in PB and how to drive the barcode printer. Please!
Answer:
If Office2000 is installed, go to its Program FilesMicrosoft OfficeOfficeMsbcode9.ocx and Msbcode9.hlp
Bar code control.
Li Hai Note: if the control cannot be found in the directory, it indicates that the control is not selected during installation. You can run the installer again and
Under 2000, find the Barcode Control item. After installation, Microsoft Barcode Control 9.0 is displayed in software such as Visual Basic.
Office97 does not have this control, but Office XP includes this control, which is still Msbcode9.ocx.
In PB7, Insert-> Control-> OLE...
In the Insert Object dialog box, select Insert Control and click Register New to specify the. officeMsbcode9.ocx path.
(Or run: regsvr32 c: office2kofficeMsbcode9. ocx)
Code:
Long Job
Job = PrintOpen ()
Ole_1.border = false
Ole_1.Print (Job)
PrintClose (Job)
Ole_1.border = true
Good results!
Although msbcode9.ocx does not have the print method, the OLE container in PB has the print method (unexpected ).
The above articles are from the Internet and copyright belongs to the original author.
// Petabytes call external programs and determine their completion methods
Key: API functions find0000wa and iswindow
In Pb, you often need to run some external programs or commands, and wait until the execution is complete before running the remaining code. We can
There are two methods:
First, define global external functions:
Function long shellexecutea (long hwnd, string lpoperation, string lpfile, string lpparameters, string lpdirectory, long nshowcmd) Library "shell32.dll"
Function long findwindowa (string lpclassname, string lpwindowname) Library "user32.dll"
Function Boolean iswindow (long hwnd) Library "user32.dll"
The first method is to use the run () function to create a button in the window. The clicked event contains the following script:
Ulong ll_handle
Int li_loop
Setpointer (hourglass !)
// Minimal execution of XXX. bat
Run ("XXX. Bat", minimized !)
// Open the loop to the window, and set the number of li_loop cycles based on the time required for opening the program execution, which can be reserved for a longer period.
For li_loop = 1 to 10000
Ll_handle = find0000wa ("tty", "xxx ")
Yield () // For details about the Function function, see "use of Yield () function in PB" in "Pb technique".
If ll_handle <> 0 then
Exit
End if
Next
// Keep repeating until the window closes Do While isWindow (ll_handle)
Yield ()
Loop
// Application execution completed
Messagebox ('OK', 'execution completed! ')
The disadvantage of this method is that the external application window cannot be hidden and can only be minimized.
The second method is to use API functions to hide the application window. However, when calling the bat batch processing command, you must first create a PIF file to close the window after the execution is completed. Otherwise, the window will not be closed. You can create a button in the window. The clicked event contains the following Script:
Uint lu_return
Ulong ll_handle
Int li_loop
String ls_Path
SetPointer (HourGlass !)
Lu_return = ShellExecutea (handle (parent), "open", "xxx. pif", "", ls_path, 0)
// Change the last parameter to 4 to display the execution status.
If lu_return> 32 then
For li_loop = 1 to 10000
Ll_handle = find0000wa ("tty", "XXX ")
Yield ()
If ll_handle <> 0 then
Exit
End if
Next
// Keep repeating until the window is closed
Do While iswindow (lu_handle)
Yield ()
Loop
// Application execution completed
MessageBox ("OK", "execution completed! ")
Else
// Error
MessageBox ("error", "failed to call external application. Please check the application path! ")
End if
// Obtain the IP address of the computer in Pb
Declare Win32 API functions:
Function int wsastartup (uint uiversionrequested, ref s_wsadata lpwsadata) Library "wsock32.dll"
Function int wsacleanup () Library "wsock32.dll"
Function int wsagetlasterror () Library "wsock32.dll"
Function int gethostname (ref string name, int namelen) Library "wsock32.dll"
Function string GetHost (string lpszhost, ref blob lpszaddress) library "pbws32.dll"
Usage:
S_wsadata l_WSAData
String ls_HostName = space (128)
String ls_IpAddress
Int li_version = 257
Blob {4} lb_hostaddress
IF wsastartup (li_version, l_WSAData) = 0 THEN
IF gethostname (ls_HostName, len (ls_HostName) <0 THEN
Messagebox ("GetHostName", WSAGetLastError ())
ELSE
GetHost (ls_HostName, lb_HostAddress)
Ls_IpAddress = string (asc (string (blobmid (lb_HostAddress, 1, 1), "000") + "."
Ls_IpAddress + = string (asc (string (blobmid (lb_HostAddress, 2, 1), "000") + "."
Ls_IpAddress + = string (asc (string (blobmid (lb_HostAddress, 3, 1), "000") + "."
Ls_IpAddress + = string (asc (string (blobmid (lb_HostAddress, 4, 1), "000 ")
END IF
WSACleanup ()
ELSE
Messagebox ("GetHostName", WSAGetLastError ())
END IF
Sle_1.text = ls_hostname
Sle_2.text = ls_ipaddress
// PB error. number list, to be supplemented
String ls_msg
Choose case error. number
Case 1 // by zero
Ls_msg = "0 division error"
Case 2 // 2 Null object reference
Ls_msg = "Null Object Reference"
Case 3 // 3 Array boundary exceeded
Ls_msg = "array out-of-bounds"
Case 4 // 4 Enumerated value is out of range for function
Ls_msg = "the enumerated value exceeds the function range"
Case 5 // 5 Negative value encountered in function
Ls_msg = "negative number in the function"
Case 6 // 6 Invalid DataWindow row/column specified
Ls_msg = "the column or row in the data window is invalid"
Case 7 // 7 Unresolvable external when linking reference
Ls_msg = "external objects cannot be resolved during link calls"
Case 8 // 8 Reference of array with null subscript
Ls_msg = "using NULL subscript to reference an array"
Case 9 // 9 DLL function not found in current application
Ls_msg = "the function of the dynamic link library is not found in the current application"
Case 10 // 10 Unsupported argument type in DLL function
Ls_msg = "parameter types not supported by the dynamic link library function"
Case 11 // 11 Object file is out of date and must be converted to current version
Ls_msg = "the object file is outdated and must use the current version"
Case 12 // 12 DataWindow column type does not match GetItem type
Ls_msg = "the Data Type of the columns in the data window does not match that of the GetItem function"
Case 13 // 13 Unresolved property reference
Ls_msg = "Property Reference is not resolved"
Case 14 // 14 Error opening dll library for external Function
Ls_msg = "An error occurred while opening the dynamic link library for external function calls"
Case 15 // 15 Error calling external function name
Ls_msg = "An error occurred when calling an external function"
Case 16 // 16 maximum string size exceeded
Ls_msg = "the string length exceeds the maximum limit"
Case 17 // 17 datawindow referenced in datawindow object does not exist
Ls_msg = "The data window object referenced by the data window does not exist"
Case 18 // 18 function doesn' t return value
Ls_msg = "the function has no return value (should have but not )"
Case 19 // 19 cannot convert name in any variable to name
Ls_msg = "variables of any type cannot be converted to another type"
Case 20 // 20 DATABASE Command has not been successfully prepared
Ls_msg = "the database command is not prepared successfully"
Case 21 // 21 Bad runtime function reference
Ls_msg = "referenced wrong runtime function"
Case 22 // 22 Unknown object type
Ls_msg = "unknown object type"
Case 23 // 23 Cannot assign object of type name to variable of type name
Ls_msg = "objects cannot be assigned to variables. values cannot be assigned to two types"
Case 24 // 24 Function call doesn' t match its definition
Ls_msg = "the function call format is inconsistent with its definition"
Case 25 // 25 Double or Real expression has overflowed
Ls_msg = "double-precision or real-expression overflow"
Case 26 // 26 Field name assignment not supported
Ls_msg = "this field assignment is not supported"
Case 27 // 27 Cannot take a negative to a noninteger power
Ls_msg = "a negative number cannot be calculated to the power of a non-integer"
Case 28 // 28 VBX Error: name
Ls_msg = "VBX error"
Case 29 // 29 Nonarray expected in ANY variable
Ls_msg = "ANY type variables expect non-array types"
Case 30 // 30 External object does not support data type name
Ls_msg = "external objects do not support this variable type"
Case 31 // 31 External object data type name not supported
Ls_msg = "the Data Type of the external object is not supported"
Case 32 // 32 Name not found calling external object function name
Ls_msg = "the function name is not found when calling the external object function"
Case 33 // 33 Invalid parameter type calling external object function name
Ls_msg = "an incorrect parameter type is used when an external object function is called"
Case 34 // 34 Incorrect number of parameters calling external object function name
Ls_msg = "the number of parameters used to call external object functions is incorrect"
Case 35 // 35 Error calling external object function name
Ls_msg = "function error of calling external object"
Case 36 // 36 Name not found accessing external object property name
Ls_msg = "the attribute name is not found when accessing external object attributes"
Case 37 // 37 Type mismatch accessing external object property name
Ls_msg = "an unmatched type is used to access external object attributes"
Case 38 // 38 Incorrect number of subscripts accessing external object property name
Ls_msg = "an incorrect subscript is used to access external object attributes"
Case 39 // 39 Error accessing external object property name
Ls_msg = "attribute Error accessing external object"
Case 40 // 40 Mismatched ANY data types in expression
Ls_msg = "The ANY data type in the expression does not match"
Case 41 // 41 Illegal ANY data type in expression
Ls_msg = "the expression uses an invalid ANY data type"
Case 42 // 42 Specified argument type differs from required argument type at runtime in DLL function name
Ls_msg = "the specified parameter type is inconsistent with the parameter type required by the function in the dynamic link library"
Case 43 // 43 Parent object doesn' t exist
Ls_msg = "parent object does not exist"
Case 44 // 44 Function has conflicting argument or return type in ancestor
Ls_msg = "the function conflicts with the parameters or return values of the ancestor"
Case 45 // 45 Internal table overflow; maximum number of objects exceeded
Ls_msg = "internal table overflow; the maximum number of objects has exceeded"
Case 46 // 46 Null object reference cannot be assigned or passed to a variable of this type
Ls_msg = "null object reference cannot be assigned a value or passed to a variable of this type"
Case 47 // 47 Array expected in ANY variable
Ls_msg = "ANY type expect array"
Case 48 // 48 Size mismatch in array to object conversion
Ls_msg = "the group size does not match when converting an array to an object"
Case 49 // 49 Type mismatch in array to object conversion
Ls_msg = "converting an array to an object does not match"
Case 50 // 50 Distributed Service Error
Ls_msg = "distributed service error"
Case 51 // 51 Bad argument list for function/event
Ls_msg = "parameter list error of function/event"
Case 52 // 52 Distributed Communications Error
Ls_msg = "distributed communication error"
Case 53 // 53 Requested server not active
Ls_msg = "the requested server is not activated"
Case 54 // 54 Server not accepting requests
Ls_msg = "the server does not accept requests"
Case 55 // 55 Request terminated abnormally
Ls_msg = "unexpected request interruption"
Case 56 // 56 Response to request incomplete
Ls_msg = "incomplete response request"
Case 57 // 57 Not connected
Ls_msg = "no connection"
Case 58 // 58 Object instance does not exist
Ls_msg = "the object instance does not exist"
Case 59 // 59 Invalid column range
Ls_msg = "invalid column range"
Case 60 // 60 Invalid row range
Ls_msg = "invalid row range"
Case 61 // 61 Invalid conversion of number dimen1_array to object
Ls_msg = "converting multi-dimensional arrays to an object is invalid"
Case 62 // 62 Server busy
Ls_msg = "server busy"
Case 63 // 63 Function/event with no return value used in expression
Ls_msg = "no return value for function/event in expression"
Case 64 // 64 Object array expected in left side of assignment
Ls_msg = "Expect object array on the left of the value assignment statement"
Case 65 // 65 Dynamic function not found. Possible causes include: pass by value/reference mismatch
Ls_msg = "the dynamic function is not found, probably because the value transfer/reference transfer does not match"
Case 66 // 66 Invalid subscript for array index operation
Ls_msg = "The Group Index uses an invalid subscript"
Case 67 // 67 NULL object reference cannot be assigned or passed to an autoinstantiate
Ls_msg = "null object references cannot be assigned values or passed to an automatically instantiated object"
Case 68 // 68 NULL object reference cannot be passed to external DLL function name
Ls_msg = "null object reference cannot be passed to the external dynamic link library function"
Case 69 // 69 Function name cannot be called from a secured runtime session
Ls_msg = "This function cannot be called in security mode"
Case 70 // 70 External DLL function name cannot be called from a secured runtime session
Ls_msg = "external dynamic link library functions cannot be called in security mode"
Case 71 // 71 General protection fault occurred
Ls_msg = "A general protection error occurs"
Case 72 // 72 name failed with an operating system error code of number
Ls_msg = "an operating system error occurred in the field"
Case 73 // 73 Reference parameters cannot be passed to an asynchronous shared/remote object method
Ls_msg = "reference parameters cannot be passed to an asynchronous shared/remote object method"
Case 74 // 74 Reference parameters cannot be passed to a shared object method
Ls_msg = "the referenced parameter cannot be passed to a shared object method"
Case 75 // 75 The server has forced the client to disconnect
Ls_msg = "the server has forced the client to disconnect"
Case 76 // 76 Passing NULL as a parameter to external function name
Ls_msg = "passing a null value parameter to an external function"
Case 77 // 77 Object passed to shared/remote object method is not a nonvisual user object
Ls_msg = "the method for passing an object to a shared/remote object is not an invisible user object"
Case 78 // 78 Listen can only be done in Enterprise version of PowerBuilder
Ls_msg = "Listeners can only be used in PowerBuilder of Enterprise Edition"
Case 79 // 79 The argument to name must be an array
Ls_msg = "the parameter must be an array"
Case 80 // 80 The server has timed out the client connection
Ls_msg = "the time when the client tries to connect has exceeded the time limit set by the server"
Case 81 // 81 Function argument file creator must be a four character string
Ls_msg = "the creator of the function parameter file must be a four-character string"
Case 82 // 82 Function argument file type must be a four character string
Ls_msg = "the function parameter file type must be a four-character string"
Case 83 // 83 attempt to invoke a function or event that is not accessible
Ls_msg = "trying to call an unaccessable function or event"
Case 84 // 84 wrong number of arguments passed to function/event call
Ls_msg = "the number of parameters passed in the function/event is incorrect"
Case 85 // 85 error in reference argument passed in function/event call
Ls_msg = "the referenced parameter passed in the function/event is incorrect"
Case 86 // 86 Ambiguous Function/event reference
Ls_msg = "referencing ambiguous functions/events"
Case 87 // 87 the connection to the server has been lost
Ls_msg = "connection to the server has been lost"
Case 88 // 88 cannot ask for classdefinition information on open painter: Name
Ls_msg = "class definition information cannot be queried in the opened paint brush"
Case 85 // 89 5.0 style proxy objects are not supported. Copy the new style proxy that was generated at migration time
Ls_msg = "the type proxy object in 5.0 is not supported, and the new type proxy generated during copy migration"
Case 90 // 90 Cannot assign array of type name to variable of type array of name
Ls_msg = "arrays of the two data types cannot be assigned values"
Case 91 // 91 Cannot convert any in Any variable to string. Possible cause uninitialized value.
Ls_msg = "You cannot convert any type variable into variable"
Case else
Ls_msg = 'unknown error. Please record the error number and contact the postmaster'
End choose