|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-24 23:52:00Z |
得分:0 |
|
|
|
Step 6: Scripting the Function Call.
Now that you have the function declaration you need to pass it the proper arguments. Taking the function " GetFileVersionInfoA" listed in Step 4 the following script would be needed:
First you'll need to declare the datatypes. Keep in mind the variable names do not have to match the function declaration listed in step 4.
boolean lb_rtn // Return code
string ls_filename // 1st argument - filename
ulong lu_hand // 2nd argument - f_handle
ulong lu_len // 3rd argument - f_length
lpdata lpdata2 // Last argument - assigning an instance of a structure.
Next is the hardest part and that is assigning values to the arguments. This part may require use of the MSDN, API Bible or whatever reference is available that covers the function you are calling. In this particular case the information is contained within the MSDN.
The first argument " ls_filename ", should be set to the path and filename of the target file.
ls_filename = "c:\windows\calc.exe" // The calculator would be a good file to test against.
The second argument "lu_hand" according to the MSDN is ignored. This is probably reserved for a future version of Windows to use. To be safe the argument should be set to null.
setnull(lu_hand)
The third argument "lu_len" contains the size of the buffer that the information will be returned into. It is critical that the buffer size not be too small or the information may overflow into another part of memory causing a GPF or Dr. Watson error. In this particular case since the structure contains 13 elements that are all ulong, the number 256 should be sufficient to contain the information.
lu_len = 256
The last argument "lpdata2" is an instance of the structure "lpdata" and it will be populated by the function call.
The final script will appear as follows:
boolean lb_rtn
string ls_filename
ulong lu_hand, lu_len
lpdata lpdata2
ls_filename = "c:\windows\calc.exe" // The calculator would be a good file to test against.
setnull(lu_hand)
lu_len = 256
lb_rtn = GetFileVersionInfoA(ls_filename, lu_hand, lu_len, lpdata2)
// Viewing the output -------------------------------------------------------------
sle_1.text = string(lpdata2.dwSignature)
sle_2.text = string(lpdata2.dwStrucVersion)
sle_3.text = string(lpdata2.dwFileVersionMS)
sle_4.text = string(lpdata2.dwFileVersionLS)
sle_5.text = string(lpdata2.dwProductVersionMS)
sle_6.text = string(lpdata2.dwProductVersionLS)
sle_7.text = string(lpdata2.dwFileFlagsMask)
sle_8.text = string(lpdata2.dwFileFlags)
sle_9.text = string(lpdata2.dwFileOS)
sle_10.text = string(lpdata2.dwFileType)
sle_11.text = string(lpdata2.dwFileSubtype)
sle_12.text = string(lpdata2.dwFileDateMS)
sle_13.text = string(lpdata2.dwFileDateLS)
Messagebox("Return Code", string(lb_rtn))
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-24 23:52:36Z |
得分:0 |
|
|
|
// -----------------------------------------------------------------------------------------
Gotcha's to look out for:
1. Make sure the DLL you are referencing is the right bit level. This can sometimes be done by looking at the DLL's properties but most likely you'll need a third party product to determine this. Remember, a 16 bit application cannot make a 32 bit API call and visaversa.
2. Some functions are cap sensitive. "Findwindowa" might fail whereas "FindWindowA" works.
3. All handles in PowerBuilder 16 bit are UINT and 32 bit are ULONG. Using the datatypes INT or LONG may work but if the handle points to an area in high memory the latter two datatypes may not be able to support such a large number.
4. Make sure you have the correct function name. Under 32 bit many of the functions had an "A" (Whcih stands for Ascii) appended to the function name to make it unique from it's 16 bit counterpart. This allows developers to place both 16 bit and 32 bit function calls in the same application and then making the correct function call based on what bit platform the program is being run from. The real reason why Microsoft named the functions this way was to differentiate between (A)-Ascii and (W)-Unicode format. The MSDN does not always list the proper names for the functions. For example: GetFileVersionInfo is listed as a 32 bit function but it is in fact GetFileVersionInfoA.
5. Global versus Local External Function declaration. If the function is declared globally it can be called from anywhere in your application. If you declare the function as a Local External Function it can only be called from that window where it's declared. Local Function use less resources then globals but the difference is very minimal.
Error Messages and what they mean:
1. Error: Error opening DLL library <filename> for external function at line <line_number> in the <event name> event of object <object_name> of <window_name>.
Possible causes:
> DLL is 16 bit and thus incompatible.
> DLL is not in a searchable directory.
> DLL connects to another DLL that cannot be found.
> DLL has the same name as another already loaded into memory.
> DLL is corrupted or in an incompatible format.
2. Error: Error calling external function <function_name> at line <line_number> in the <event name> event of object <object_name> of <window_name>.
This is probably the result of an incorrectly spelt function name. Be sure to verify that the function name matches what is in the DLL exactly, including the case of the letters.
3. Error: Specified argument type differs from required argument type at runtime in DLL function <function_name>. (Invalid stack pointer on return from function call) at line <line_number> in <event_name> event of object <object_name> of <window_name>.
This error usually indicates the datatypes do not match what the DLL function is expecting.
4. PB050: Caused an Invalid Page Fault in module PBSHR050.DLL @ 0137:1111163e
This error can occur either immediately upon calling the function or when the application closes. The module and memory address may vary but the reason for this is usually the same. If PB is receiving a string and memory isn't allocated in advance using the SPACE( ) that string will overflow into another memory area. To allocate 12 characters to the string "ls_filename" the following code would be used.
ls_filename = space(13) // You may want to give it an extra space just to be safe.
5. Receiving garbage from the DLL. i.e. Last name populated as: "*#^&Ryan"
This problem is most likely the result of the byte alignment being set incorrectly. PowerBuilder expects the byte alignment to be set to one and if you are using MSVC++ compiler the default setting is four. To set the byte alignment to one you would need to do the following prior to compiling to a dll.
- Select the desired target
- Right mouse click and select Settings
- Select the C/C++ tabpage
- Select Code Generation from the Category dropdown list
- Select desired byte alignment from the Struct Member Alignment dropdown list.
The DOS switch to set the byte alignment to one is: /zp1
A handy trick to find functions quickly:
1. On Win95,Win98 or NT 4.0 click on the START button and select "Find", then "Files or Folders".
2. In the SLE entitled "Named" enter "c:\*.dll". If this is a Windows DLL that you'll be calling enter "c:\windows\*.dll".
3. Click on the "Advanced" tab and in the "Containing Text" SLE enter the exact function name you are looking for. For example: FindWindowA
4. There will usually be a lot of DLL's that contain the function you are looking for but try to use the main Windows DLL's whenever possible since they are already loaded into memory.
Related Faxlines:
47626 - External Functions Calls to the DLLs created using Visual C++
44596 - 16 Bit - Windows API Calls for PowerBuilder 4.0, 5.0 & 6.0
44545 - 32 Bit - Windows API Calls for PowerBuilder 5.0
44648 - Prototyping API Calls for PowerBuilder 4.0, 5.0 and 6.0
44588 - Dynamically Closing a Non-PowerBuilder Application
47703 - GPF's and The PowerBuilder Memory Defragger
47704 - Windows 3.10 and 3.11 Functions - Krnl386.exe, User.exe, Gdi.exe
47707 - 16 Bit - Win95 and NT Functions - Krnl386.exe, User.exe, Gdi.exe
47705 - 32 Bit - Win95 and NT Functions - Kernel32.dll, User32.dll, Gdi32.dll
44474 - External Function Calls
44538 - Passing a 32-bit PowerBuilder structure to a 32-bit C DLL Created in Power++
|
Top |
|
|
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 |
2003-05-24 23:54:16Z |
得分:0 |
|
|
|
问题:用GROUP DATAWINDOW时,分页打印各个GROUP,我想给每行纪录前加一个行号(1,2,3 ,...),而且每个GROUP重新开始.请我要怎样做?多谢!
回答:
直接用DATAWINDOW的功能较难实现,加一段代码吧。
在做DATAWINDOW时每行前面加一个TEXT对象,程序中根据分组条件循环所有记录,从1开始给TEXT对象赋值,发现变了组就重新从1开始。代码应该很简单写。
//-------------------------
PowerBuilder Windows 98
某表中含text字段,生成数据窗口后,为了完整显示其内容,对该字段设置滚动属性,但
打印时只能打印显示部分,请问如何打印全部text字段内容。多谢!
回答:
《PB ONLINE BOOK》中有详细的资料。
主要内容为:
1、为该字段取消“Auto Horz Scroll”,选中“Autosize Height”。
2、设置该Band“Autosize Height”属性。
我试过打印完全可以。
Specifying variable-height detail bands in a DataWindow object
Sometimes DataWindow objects contain columns whose data is of variable length. For example, a Memo column in a table might be a character column that can take up to several thousand characters. You don't want to reserve space for that much information for the column in the detail band, since it would make the detail band's height very large, meaning the users could see few rows at a time.
Instead, you want the detail band to resize based on the data in the Memo column. If the Memo column has only one line of text, you want the detail band to be one line. If the Memo column has 20 lines of text, you want the detail band to be 20 lines high.
To provide a detail band that resizes as needed, you specify that the variable-length columns and the band have Autosize Height.
To create a resizable detail band in a DataWindow object:
1Select Properties from the popup menu of a column that should resize based on the amount of data.
2Select the Autosize Height checkbox on the Position property page and click Apply.
3Clear the Auto Horz Scroll checkbox on the Edit property page and click OK.PowerBuilder will wrap text during preview instead of displaying text on one scrollable line.
4Repeat steps 1 to 3 for any other columns that should resize.
5Select Properties from the detail band's popup menu.
6Select the Autosize Height checkbox and click OK.During preview, the detail band will resize based on the contents of the columns you defined as having Autosize Height.
|
Top |
|
|
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 |
2003-05-24 23:54:58Z |
得分:0 |
|
|
|
我在TreeView的constructor事件中声明并使用dataStore的实例,通过该实例检索data window object得到数据后使用TreeView的InsertItem()可在控件加入根一级的数据显示项,在加入下一级数据项时,我使用了TreeView的Itempoplate事件,声明另一个datastore检索另一个数据窗口对象,得到数据并加入下一级item,在脚本中我使用了for next 循环以得到同一级的多个数据项.现在需要在这一级下面再加入子项,该怎样做?如果在for next 循环中嵌套一个for next循环,回出现很奇怪的现象,请参考PB5 的online books的Application technique中的chapter 12 using Lists in a window 关于treeview的部分.多谢指点!
A1:完全可用多重循环来实现。插入可用函数insertitemlast()来完成,注意其语法为:
treeviewname.InsertItemLast(handleparent, item )
其中handleparent为要插入Item其父项的句柄(第插入一项都返回一个句柄,long型),item为treeviewitem。
for example:
for i = 1 to row1 step 1
name = dept_datastore.getitemstring(i,"dept_name")
code = dept_datastore.getitemnumber(i,"dept_code")
xt_tvitem.label = name
xt_tvitem.data = dept_datastore.getitemnumber(i,"dept_code")
xt_tvitem.pictureindex = 2
xt_tvitem.selectedpictureindex = 2
ll_newitem = tv_1.insertitemlast(ll_rootitem,xt_tvitem)//返回一个句柄ll_newitem ,作其子项父句柄。ll_rootitem为根句柄
for j = 1 to row2 step 1
xt_tvitem.label = emp_datastore.getitemstring(j,"name")
xt_tvitem.data = emp_datastore.getitemnumber(j,"em_code")
xt_tvitem.pictureindex = 3
xt_tvitem.selectedpictureindex = 3
tv_1.insertitemlast(ll_newitem,xt_tvitem)//用到父句柄
next
next
|
Top |
|
|
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 |
2003-05-24 23:57:16Z |
得分:0 |
|
|
|
我用的是ORACLE数据库,PB中想动态修改DW的select语句的条件部分:string newwhere newwhere = 'where (~~"table1~~".~~"field1~~" = ' + ' ~'Y~')'是正确的.如果想把常量'Y'改为一个变量该怎么办?请各位大虾指教。
A1:可以这样写:
string ls_Y
ls_Y = 'Y'
newwhere = "where (~~table1~~.~~field1~~ = '" + ls_Y + "')"
A2:pb倒是没有提供标准的modify接口,可能要用死办法直接修改syntax的table区,具体格式可以看 SRD
//-------------------------------------
是关于修改显示器分辩率的ChangeDisplaySetting, 请指教:)
A1:The first function returns the color of a specific pixel(像素;显示器的最小分辨单元). The SetPixel function changes the targeted pixel to the color sent. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION ulong GetPixel(ulong hwnd, long xpos, long ypos) LIBRARY "Gdi32.dll"
FUNCTION ulong SetPixel(ulong hwnd, long xpos, long ypos, ulong pcol) LIBRARY "Gdi32.dll"
Script:
long lx, ly
ulong rtn
ulong l_handle, l_device
lx = 100
ly = 100
l_handle = handle(w_main)
l_device = GetDC(l_handle)
rtn = GetPixel(l_device, 100, 100)
MessageBox("Position " + string(lx) + "," + string(ly),"Color = " + string(rtn))
SetPixel(l_device, lx, ly, 0) // This call will set the pixel at lx, ly to black.
//-----------------------------------
我本人最近遇到了这么一个问题!pb6.0在win95中文环境下一切正常,但是移植到win98时汉字出现的却全都是乱码,请问如何解决这个问题?谢谢!!!
A1:请您使用黑体或楷体,否则在无盘工作站和WIN98中都会出现字体显示不出来的情况.
//-----------------------------
我如何能动态地在一个grid风格的datawindow中加一个标题行,该datawindow也是动态创建的。多谢!
A1:用grid风格的datawindow想加标题行比较麻烦,因为grid风格中的标题band中也会显示网格线,而且要将text控件的band属性设为Foreground.你可以用Create语句创建一个text控件,然后指定它的位置和band属性.create的语法如下:
dw_1.Modify('create text(band=foreground alignment="2" name=datetext text="text" border="0" color="0" x="0" y="0" height="69" width="650" font.face="Arial" font.height="-9" font.weight="400" font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="16777215" )')
其中text的属性大部分为必需的,如果不完整的话,该text可能不能显示.据我所知,用grid风格的datawindow时要想加上标题,而且要显示得比较好看,只能用text控件将显示出的多余的网格线给盖住,这样做语法上比较麻烦,因为你要得到这个datawindow中最后一个列的y值和width,以控制text的width,特别是你这个datawindow和text是动态创建的.当然这些都是可以实现的,多多钻研吧!
//---------------------------------
因为要用连续纸打印发票和报表,在PWIN95中打印机设置处,用自定义纸张设好特定大小发票,用于打印发票。但是当打印完一张发票以后,打印机自动切纸以后,再打第二张发票时,继续重新打在第一张发票的位置上,不知如何是好?是否要在PB中用调用外部函数设置自定义纸张大小,才起作用?
A1: I had a solution, like follows,
void WINAPI PrintSet(LPCTSTR PrinterName, DWORD PaperSize, DWORD Height, DWORD Width, LPDWORD ret_code, LPTSTR errortext)
{
DEVMODE* lv_devmode;
DEVMODE* lv_devmode_2;
PRINTER_INFO_2* lv_printer_info;
LPTSTR lv_str, pDeviceName;
HANDLE phPrinter;
DWORD pcbNeeded, lv_dword;
lv_printer_info = malloc( 500 );
if (!OpenPrinter(PrinterName, &phPrinter, NULL))
{
free(lv_printer_info);
*ret_code = GetLastError();
lv_str = "打开打印机失败 !";
strcpy(errortext, lv_str);
return;
}
if (!GetPrinter(phPrinter, 2, lv_printer_info, 500, &pcbNeeded ))
{
free(lv_printer_info);
*ret_code = GetLastError();
ClosePrinter(phPrinter);
lv_str = "无法得到打印机参数 !";
strcpy(errortext, lv_str);
return;
}
lv_devmode = lv_printer_info->pDevMode;
pDeviceName = lv_devmode->dmDeviceName;
lv_dword = DocumentProperties(0, phPrinter, pDeviceName, lv_devmode, 0, DM_OUT_BUFFER);
if (lv_dword<0)
{
free(lv_printer_info);
*ret_code = GetLastError();
ClosePrinter(phPrinter);
lv_str = "无法取得打印机参数 !";
strcpy(errortext, lv_str);
return;
}
// 修改DEVMODE结构, 设置纸张大小及其高度和宽度
lv_devmode->dmFields = lv_devmode->dmFields|DM_ORIENTATION|DM_PAPERLENGTH|DM_PAPERWIDTH|DM_PAPERSIZE;
lv_devmode->dmOrientation = DMORIENT_PORTRAIT ;
lv_devmode->dmPaperSize = PaperSize ;
lv_devmode->dmPaperLength = Height;
lv_devmode->dmPaperWidth = Width;
// 通过调用DOCUMENTPROPERTIES函数传会修改的DEVMODE结构,
// 在调用时指定DM_IN_BUFFER|DM_OUT_BUFFER
lv_devmode_2 = malloc(500);
lv_dword = DocumentProperties(0, phPrinter, pDeviceName, lv_devmode_2, lv_devmode, DM_IN_BUFFER|DM_OUT_BUFFER);
if (lv_dword<0)
{
free(lv_devmode_2);
free(lv_printer_info);
*ret_code = GetLastError();
ClosePrinter(phPrinter);
lv_str = "无法设置打印机参数 !";
strcpy(errortext, lv_str);
return;
}
if (!SetPrinter(phPrinter, 2, lv_printer_info, NULL))
{
free(lv_printer_info);
*ret_code = GetLastError();
ClosePrinter(phPrinter);
lv_str = "无法设置打印机参数 !";
strcpy(errortext, lv_str);
return;
}
free(lv_devmode_2);
free(lv_printer_info);
ClosePrinter(phPrinter);
lv_str = "设置打印机参数成功 !";
strcpy(errortext, lv_str);
*ret_code = 1;
return ;
}
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-24 23:58:33Z |
得分:0 |
|
|
|
PB中可使用的Windows API调用简介
Lists the PowerBuilder syntax for calling Windows API functions. Also included is the PowerBuilder script needed to make the function calls
32 Bit - Windows API Calls for PowerBuilder
The following information lists the PowerBuilder syntax for calling Windows API functions. Also included is the PowerBuilder script needed to make the function call. If you would like an example of these API calls the sample pbl is located on the Powersoft FTP server. The file can be downloaded from:
These API calls are only a subset of all the API calls available. For a more complete listing of API calls you can consult the windows SDK helpfile which is named either win32.hlp or win32sdk.hlp(depending on what compiler the SDK has been installed from). Technote #44648 can assist you with the function declaration of the API call from powerscript.
The following API calls are referenced in this document:
Arc GetCurrentDirectoryA Mouse_Event
Beep GetCurrentThread MoveToEx
BringWindowToTop GetCursor MoveWindow
Chord GetCursorPos Pie
CloseHandle GetDC Polygon
CloseWindow GetKeyboardState PostMessageA
CopyFileA GetKeyState Rectangle
CreateDirectoryA GetModuleHandleA ReleaseCapture
DeleteFileA GetParent SetCapture
DeleteMenu GetPixel SetComputerNameA
DestroyWindow GetSystemTime SetCurrentDirectoryA
DllRegisterServer GetSystemMenu SetCursorPos
Ellipse GetSystemMetrics SetFocus
ExitWindowsEx GetThreadPriority SetKeyboardState
FatalExit GetUserNameA SetPixel
FindWindowA GetWindowsDirectory Sleep
FreeLibrary GlobalMemoryStatus SndPlaySoundA
GetBkColor LineTo SwapMouseButton
GetCapture LoadLibraryA WaveOutGetNumDevs
GetComputerNameA mciSendStringA WinExec
GetClassNameA MessageBoxA ...
ADDITIONS: GetVolumnInformationA ...
Arc( )
This function draws an arc based on the coordinates the function receives. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean Arc(ulong hwnd, long r1, long r2, long r3, long r4, long a1, long a2, long a3, long a4) LIBRARY "Gdi32.dll"
Function ulong GetDC(ulong hwnd) library "user32.dll"
Script:
Boolean rtn
ulong l_handle, l_device
long lv[8]
l_handle = handle(w_main) // 'w_main' is the name of the sample window.
l_device = GetDC(l_handle)
lv[ ] = {10,40,300,220,0,0,180,0}
rtn = Arc(l_device, lv[1], lv[2], lv[3], lv[4], lv[5], lv[6], lv[7], lv[8])
Beep( )
The Beep function causes the system to make an internal beep sound. This is identical to the PowerBuilder function Beep( ).
Global External Function:
FUNCTION boolean Beep(long freq,long dur) LIBRARY "Kernel32.dll"
Script:
Boolean rtn
Long ll_freq, ll_dur
ll_freq = 500
ll_dur = 20
rtn = Beep(ll_freq, ll_dur)
BringWindowToTop( )
The BringWindowToTop function sends a message to the target window telling it to come to the foreground. The PowerBuilder equivalent is limited to PowerBuilder Windows only, the script is as follows: <window > .bringtotop = true
Global External Function:
FUNCTION boolean BringWindowToTop(ulong w_handle) LIBRARY "User32.dll"
Script:
Boolean rtn
ulong l_handle
l_handle = handle(w_win2)
rtn = BringWindowToTop(l_handle)
Chord( )
A Chord is a region bounded by the intersection of an ellipse and a line segment. This function draws a chord based on the coordinates the function receives. There are no PowerBuilder equivalents.
Global External Function:
FUNCTION boolean Chord(ulong hwnd,long x1,long y1,long x2,long y2,long r1, long r2, long r3, long r4) LIBRARY "Gdi32.dll"
Script:
boolean rtn
ulong l_handle, l_device
long lv[8]
l_handle = handle(w_main)
l_device = GetDC(l_handle)
// This can be done in one line: i.e. l_device = GetDC(handle(w_main))
lv[ ] = {5,5,200,200,0,0,200,300}
rtn = Chord(l_device, lv[1], lv[2], lv[3], lv[4], lv[5], lv[6], lv[7], lv[8])
CloseHandle( )
The CloseHandle function releases an open object handle. The closest PowerBuilder equivalent is the function Destroy, but it is only used with PowerBuilder created objects.
Global External Function:
FUNCTION boolean CloseHandle(ulong w_handle) LIBRARY "Kernel32.dll"
FUNCTION ulong FindWindowA(ulong classname,string windowname) LIBRARY "User32.dll"
Script:
boolean rtn
ulong l_handle
string ls_wname
ls_wname = "<Window Title>"
l_handle = FindWindowA(0, ls_wname) // Usually you would already have the handle.
rtn = CloseHandle(l_handle)
CloseWindow( )
This function does not close a window as one might think. CloseWindow minimizes the window that is targeted. The closest PowerBuilder equivalent is the WindowState command, but this is limited to PB windows only. The syntax in PowerBuilder is as follows: <window>.WindowState = Minimized!
Global External Function:
FUNCTION boolean CloseWindow(ulong w_handle) LIBRARY "User32.dll"
FUNCTION ulong FindWindowA(ulong classname,string windowname) LIBRARY "User32.dll"
Script:
boolean rtn
ulong l_handle
string ls_wname
ls_wname = "<Window Title>"
l_handle = FindWindowA(0, ls_wname) // Be sure to use the exact title of the window you are targeting.
rtn = CloseWindow(l_handle)
CopyFileA( )
This function copies a file by taking the source and destination names as a string by reference. If the flag is set to true the file will not overwrite an existing file, if set to false it will overwrite an existing file. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean CopyFileA(ref string cfrom, ref string cto, boolean flag) LIBRARY "Kernel32.dll"
Script:
string l_from, l_to
boolean l_flag, rtn
l_flag = false
l_from = "c:\program files\sybase\readme.txt"
l_to = "c:\new_readme.txt"
rtn = CopyFileA(l_from, l_to, l_flag)
MessageBox("CopyFile", string(rtn))
CreateDirectoryA( )
This function create a new directory folder under the current directory.The second argument is exclusively used by NT and can be ignored under Win95. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean CreateDirectoryA(ref string pathname, int sa) LIBRARY "Kernel32.dll"
Script:
boolean rtn
string l_dir
l_dir = "API Demo"
rtn = CreateDirectoryA(l_dir, 0)
If rtn then
MessageBox("New Directory Created", "API Demo directory is located under current directory.")
else
MessageBox("CreateDirectory", "Failed")
end if
|
Top |
|
|
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 |
2003-05-24 23:59:24Z |
得分:0 |
|
|
|
如何动态创建控件 ,虽然能够用CREATE来创建构件, 但无法在窗口中显示。
A1:原因是你创建控件的语法不完整,一些必须的属性没有说明,如X,Y,band.你可以先将控件的语法先输出到文本里,再替换为你的控件的属性.以下为一个text控件的最基本的语法.
create text(band=detail alignment="0" text="aaaa:" x="691" y="52" height="77" width="426" name=aaaa font.face="Arial" font.height="-12" font.family="2" font.charset="0" background.mode="1" )
A2: 我又看了看帮助,找到了答案:现在公布:
window.openUserObject ()
Description
Opens a user object of a known data type.
Controls
Window objects
Syntax
windowname.OpenUserObject ( userobjectvar {, x, y } )
Argument Description
windowname The name of the window in which you want to open the user object
userobjectvar The name of the user object you want to display. You can specify a user object defined in the User Object painter (which is a user object data type) or a variable of the desired user object data type. Open places a reference to the opened user object in userobjectvar
x
(optional) The x coordinate in PowerBuilder units of the user object within the window's frame. The default is 0
y
(optional) The y coordinate in PowerBuilder units of the user object within the window's frame. The default is 0
Return value
Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is NULL, OpenUserObject returns NULL.
Usage
Use Syntax 1 when you know what user object you want to open. Use Syntax 2 when the application will determine what type of user object to open when the script runs.
You must open a user object before you can access the properties of the user object. If you access the user object's properties before you open it, an execution error will occur.
A user object that is part of a window's definition (that is, it was added to the window in the Window painter) does not have to opened in a script. PowerBuilder opens it when it opens the window.
OpenUserObject will add the newly opened user object to the window's Control array, which is a property that lists the window's controls.
When you open a user object during execution, the window does not destroy the user object automatically when you close the window. You need to call CloseUserObject to destroy the user object, usually when the window closes. If you don't destroy the user object, it holds on to its allocated memory, resulting in a memory leak.
PowerBuilder displays the user object when it next updates the display or at the end of the script, whichever comes first. For example, if you open several user objects in a script, they will all display at once when the script is complete, unless some other statements cause a change it the screen's appearance (for example, the MessageBox function displays a message or the script changes a visual property of a control).
Calling OpenUserObject twice If you call Syntax 1 twice to open the same user object, PowerBuilder activates the user object twice; it does not open two instances of the user object.
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-25 00:00:06Z |
得分:0 |
|
|
|
DeleteFileA( )
This function receives a string by reference containing a fully path qualified filename and deletes that file. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean DeleteFileA(ref string filename) LIBRARY "Kernel32.dll"
Script:
string l_file
boolean rtn
l_file = string("c:\test.txt")
rtn = DeleteFileA(l_file)
MessageBox("DeleteFile", string(rtn))
DeleteMenu( )
The DeleteMenu function deletes an item from the specified menu. If the menu item opens a menu or submenu, this function destroys the handle to the menu or submenu and frees the memory used by the menu or submenu.
Global External Function:
FUNCTION boolean DeleteMenu(ulong mhand, uint upos, uint flag) LIBRARY "user32.dll"
FUNCTION boolean GetSystemMenu(ulong mhandle, boolean flag) LIBRARY "user32.dll"
Script:
ulong m_handle
boolean rtn
m_handle = handle(w_main)
rtn = GetSystemMenu(handle(w_main), false) // Need to get the handle of the system menu first.
rtn = DeleteMenu(m_handle, 1, 0) // The second argument, the '1', refers to the position in the menu.
Messagebox("Return Code", string(m_handle))
Messagebox("Return Code", string(rtn))
DestroyWindow( )
This function sends a destroy message to the targeted window. The closest PowerBuilder equivalent is Close(<window>), but this is limited to PB windows only.
Global External Function:
FUNCTION boolean DestroyWindow(ulong w_handle) LIBRARY "USER32.DLL"
Script:
boolean rtn
ulong l_handle
open(w_win2) // Open a test window
l_handle = handle(w_win2)
rtn = DestroyWindow(l_handle)
DllRegisterServer( )
This function triggers an OCX to self-register. This function when called from the constructor event of an application allows a PB application to dynamically register an OCX on the machine it is run on. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION long DllRegisterServer() LIBRARY "c:\windows\ocxname.ocx"
Script:
Long ll_rtn
ll_rtn = DllRegisterServer()
//Note: A return code of zero most likely means the OCX is already registered.
Ellipse( )
An Ellipse function draws a circular object based on the coordinates the function receives. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean Ellipse(ulong hwnd,long x1,long y1,long x2,long y2) LIBRARY "Gdi32.dll"
Function ulong GetDC(ulong hwnd) library "user32.dll"
Script:
Boolean rtn
ulong l_handle, l_device
long lv[4]
l_handle = handle(w_main)
l_device = GetDC(l_handle)
lv[ ] = {5,5,300,300}
rtn = Ellipse(l_device, lv[1], lv[2], lv[3], lv[4])
ExitWindowsEx( )
This function sends a call to the Windows OS telling it to shut down. This function is especially good for increasing the security of your application. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean ExitWindowsEx(uint dwReserved, uint uReserved) LIBRARY "User32.dll"
Script:
boolean rtn
rtn = ExitWindowsEx(0,0) // Zero's tell it to shut down immediately.
FatalExit( )
This function abruptly stops an application from running. As a result, nothing gets closed properly and objects are left hanging in memory. This function will produce a GPF the moment it is called and you will need to reboot. FatalExit is meant to be used for debugging purposes and is not recommended otherwise. There is no PowerBuilder equivalent.
Global External Function:
SUBROUTINE FatalExit(int exitcode) LIBRARY "Kernel32.dll"
Script:
int rtn
rtn = MessageBox("This API call is suppose to produce a GPF!","Are You Sure?", Exclamation!, YesNo!,2)
If rtn = 1 Then
MessageBox("Final Notice!","You will have to reboot after this API call!")
FatalExit(1)
End If
FindWindowA( )
This function gets the handle any window that is called by name. A common pitfall is to make a call with the window's save name rather than the name that appears in the title bar, i.e. "Microsoft Word - api32.doc" . The PowerBuilder equivalent is the function Handle( ), but it is limited to PB windows only.
Global External Function:
FUNCTION ulong FindWindowA(ulong classname,string windowname) LIBRARY "User32.dll"
Script:
ulong l_handle
string ls_wname
ls_wname = "<Window Title>" // i.e. "File Manager" or "Numbers.txt - NotePad"
l_handle = FindWindowA(0, ls_wname)
FreeLibrary( )
This function releases a dll from active memory. This function works in conjunction with LoadLibraryA( ) function. There is no PowerBuilder equivalent. Warning: Unloading a dll that is being used will cause a GPF.
Global External Function:
SUBROUTINE FreeLibrary(ulong libhandle) LIBRARY "Kernel32.dll"
FUNCTION ulong LoadLibraryA(string modname) LIBRARY "Kernel32.dll"
Script:
ulong modhandle // This would usually be an instance variable
modhandle = LoadLibraryA("<32 bit dll filename>") // This would usually be done in another event.
FreeLibrary(modhandle)
GetBkColor( )
This function returns the background color reference number of the window targeted. The PowerBuilder equivalent is as follows:
ulong l_color
l_color = w_main.BackColor
Global External Function:
FUNCTION ulong GetBkColor (ulong hwnd) LIBRARY "Gdi32.dll"
Function ulong GetDC(ulong hwnd) library "user32.dll"
Script:
ulong l_handle, l_device, l_color
l_handle = handle(w_main)
l_device = GetDC(l_handle)
l_color = GetBkColor(l_device)
GetCapture( )
This function returns the handle of the window that has captured the mouse. Keep in mind that the window receives mouse input regardless of where the cursor is positioned. This function, however, doesn't appear to do anything at all. (Maybe you'll have more luck with it.) There is no PowerBuilder equivalent.
Global External Function:
FUNCTION ulong GetCapture( ) LIBRARY "User32.dll"
Script:
ulong l_handle
l_handle = GetCapture( )
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-25 00:01:43Z |
得分:0 |
|
|
|
GetComputerNameA( )
This function returns the computer's name into a string by reference. Be sure to allocate enough space for the string or you'll get a GPF when you exit PowerBuilder. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean GetComputerNameA(ref string cname,ref long nbuf) LIBRARY "Kernel32.dll"
Script:
string ls_compname
long ll_buf
ll_buf = 25
ls_compname = space(ll_buf)
GetComputerNameA(ls_compname, ll_buf)
MessageBox("Computer name is:", ls_compname)
GetClassNameA( )
This function returns the class name of any object or window whose handle it receives. Be sure to allocate enough space for the string or you'll get a GPF when you exit PowerBuilder. There is no PowerBuilder equivalent to this function.
Global External Function:
Function long GetClassNameA(ulong hwnd, ref string cname, int buf) Library "User32.dll"
Script:
string l_class
long rtn
ulong l_handle
l_handle = handle(w_main)
l_class = space(50)
rtn = GetClassNameA(l_handle,l_class,50)
Messagebox("Classname", l_class)
GetCurrentDirectoryA( )
This function returns the current working directory into a string by reference. Be sure to allocate enough space for the string or you'll get a GPF when you exit PowerBuilder. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION ulong GetCurrentDirectoryA(ulong BufferLen, ref string currentdir) LIBRARY "Kernel32.dll"
Script:
string ls_curdir
ulong l_buf
l_buf = 100
ls_curdir = space(l_buf)
GetCurrentDirectoryA(l_buf, ls_curdir)
MessageBox("Current Directory:", ls_curdir)
GetCurrentThread( )
This function returns the current thread's handle. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION ulong GetCurrentThread() LIBRARY "Kernel32.dll"
Script:
ulong rtn
rtn = GetCurrentThread()
MessageBox("Current Thread Handle", string(rtn))
GetCursor( )
This function returns a handle of the cursor. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION ulong GetCursor( ) LIBRARY "User32.dll"
Script:
ulong l_cursor
l_cursor = GetCursor( )
GetCursorPos( ) & SetCursorPos( )
This function returns the x and y position of the cursor into a structure. SetCursorPos moves the cursor to the coordinates it receives. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean GetCursorPos(ref mousepos mousepos2) LIBRARY "User32.dll"
FUNCTION boolean SetCursorPos(int cx, int cy) LIBRARY "User32.dll"
Structure: (Mousepos)
long xpos, long ypos
Script:
mousepos mouseloc
GetCursorPos(mouseloc)
Messagebox("Cursor Position", "X = " + string(mouseloc.xpos) + " Y = " + string(mouseloc.ypos))
SetCursorPos(300,350)
Messagebox("Cursor Position", "X = " + string(mouseloc.xpos) + " Y = " + string(mouseloc.ypos))
GetDC( )
This function returns the device context of the targeted window's handle that it receives. The device context is required if you wish to perform any graphical function calls. There is no PowerBuilder equivalent.
Global External Function:
Function ulong GetDC(ulong hwnd) library "user32.dll"
Script:
ulong l_handle, l_device
l_handle = handle(w_main)
l_device = GetDC(l_handle)
MessageBox("Handle", string(l_device))
GetKeyboardState( ) & SetKeyboardState( )
The first function returns the present state of every key on the keyboard into an array of 256 integers based on the characters ASCII representation. The second function sets the keyboard to the state given in the array. A zero value represents that the key is not pressed. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean GetKeyboardState(ref integer kbarray[256]) LIBRARY "USER32.DLL"
FUNCTION boolean SetKeyboardState(ref integer kbarray[256]) LIBRARY "USER32.DLL"
Function ulong GetDC(ulong hwnd) library "user32.dll"
Script:
//GetKeyboardState( )
boolean rtn
integer ipkey[256]
rtn = GetKeyboardState(ipkey)
//SetKeyboardState( )
rtn = SetKeyboardState(ipkey)
if rtn = false then
Messagebox("Failed","Something went wrong when loading into array")
else
Messagebox("Successful","Keyboard state is loaded back into buffer")
end if
GetKeyState( )
This function returns the present state of a specific key on the keyboard based on that key's ASCII representation. A zero value represents that the key is not pressed. There is no PowerBuilder equivalent.
Global External Function:
Function int GetKeyState(integer VirtualKeycode) Library "User32.dll"
Script:
int rtn
rtn = GetKeyState(65) // 65 = A
if rtn = 0 then
MessageBox("Key State","Letter 'A' not pressed!")
else
MessageBox("Key State","Letter 'A' is pressed!")
end if
GetModuleHandleA( )
This function returns the handle of a module or dll that is in active memory. The function FreeLibrary works directly with this function in releasing the dll from memory based on the handle that this function returns. There is no PowerBuilder equivalent.
Global External Function:
Function long GetModuleHandleA(string modname) Library "Kernel32.dll"
Script:
ulong rtn
rtn = GetModuleHandleA("User32.dll")
MessageBox("Return Code", string(rtn))
|
Top |
|
|
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 |
2003-05-25 00:03:02Z |
得分:0 |
|
|
|
PB可以调用ORACLE中的存储过程或存储函数。但我试过多次,PB无法调用定义在PACKAGE中的函数 或过程,此时这些函数或过程在PB中根本看不到。不知是PB的问题还是我用的不对。
A1:首先在PACKAGE声明方法(Function,受JAVA的“METHOD”的影响不习惯叫“函数”, HEHE..)这个声明把该方法声明成公共 (Public)方法。然后在PACKAGE BODY中定义该方法。(如果仅在PACKAGE BODY中定义该方法,则被认为是私有(Private)方法,将不能被包外的应用访问,OOP的典型应用)例如:定义包,并声明一个 procedure pro_1:
Package p_zhhz is procedure pro_1(v1 in number);
end p_zhhz;
定义包体,在包体中定义这个 procedure pro_1:
Package BODY p_zhhz is procedure pro_1(v1 in number) is begin
delete from a_zhhz_test where zhhz_number = v1;
end pro_1;
end p_zhhz;
在PB中调用:
int li_v1
//声明procedure,并且置初值
li_v1=5
DECLARE sel_zp_zhhz_1998_9_2 procedure for p_zhhz.pro_1(:li_v1) ;
EXECUTE sel_zp_zhhz_1998_9_2;
CLOSE sel_zp_zhhz_1998_9_2;
A2: 感谢你的帮助.由于我的存储过程是个函数,所以没采用EXECUTE;在TRANSACTION对象中声明时采用"RFCFUNC"定义为一个函数,加上包名.问题已得到解决.
//-----------
sybase之数据库除过磁带机备份,还有何方便的方式?用镜像如何恢复?其它方式?
2.假设本地亦有数据库(sybase或sql anywhere),通过拨号定期用数据管道更新sybase服务器,且需更新的表较多,如何制定更新策略,如 何在速度及可操作性两方面取得很好的折中,用统一的方式进行?
A1: 1, 备份方法最简单的是畚份为文件。
ex: isql下用 dump database pub2 to pub2980911 镜像设备如果是文件设备,把文件cp一下就可以(我没用过)。CD-RW是一个不错的备份方法。
2,用bcp要比pipeline快很多。
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-25 00:03:35Z |
得分:0 |
|
|
|
GetParent( )
This function receives the handle of a child and returns the handle of its parent. The PowerBuilder function 'GetParent' is identical. The PB syntax is as follows: objectname.GetParent( )
Global External Function:
FUNCTION ulong GetParent(ulong hwnd) LIBRARY "User32.dll"
Script:
ulong l_handle, rtn
l_handle = handle(cb_getparent) // Command Button name
rtn = GetParent(l_handle)
Messagebox("GetParent", "Parent handle = " + string(rtn) + " / Child handle = " + string(l_handle))
GetPixel( ) & SetPixel( )
The first function returns the color of a specific pixel. The SetPixel function changes the targeted pixel to the color sent. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION ulong GetPixel(ulong hwnd, long xpos, long ypos) LIBRARY "Gdi32.dll"
FUNCTION ulong SetPixel(ulong hwnd, long xpos, long ypos, ulong pcol) LIBRARY "Gdi32.dll"
Script:
long lx, ly
ulong rtn
ulong l_handle, l_device
lx = 100
ly = 100
l_handle = handle(w_main)
l_device = GetDC(l_handle)
rtn = GetPixel(l_device, 100, 100)
MessageBox("Position " + string(lx) + "," + string(ly),"Color = " + string(rtn))
SetPixel(l_device, lx, ly, 0) // This call will set the pixel at lx, ly to black.
GetSystemMenu( )
This function allows the application to access the system or window menu for copying and modifying. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean GetSystemMenu(ulong mhandle, boolean flag) LIBRARY "user32.dll"
Script:
boolean flag, rtn
ulong l_handle
l_handle = handle(w_main)
flag = false
rtn = GetSystemMenu(l_handle, flag)
Messagebox("Return Code", rtn)
GetSystemTime( )
This function returns the system time into a structure by reference. There is no PowerBuilder equivalent.
Global External Function:
SUBROUTINE GetSystemTime(ref systemtime systimeptr) Library "Kernel32.dll"
Structure: (SystemTime)
uint year, uint month, uint dayofweek, uint day, uint hour, uint minute, uint second, uint millisecond
Script:
systemtime s_systime
string l_day, l_date, l_time
GetSystemTime(s_systime)
l_date = string(s_systime.month) +"/"+ string(s_systime.day) &
+"/"+ string(s_systime.year)
l_time = string(s_systime.hour) +":"+ string(s_systime.minute) &
+":"+ string(s_systime.second) +":"+ string(s_systime.millisecond)
CHOOSE CASE s_systime.dayofweek
CASE 1
l_day = "Sunday"
CASE 2
l_day = "Monday"
CASE 3
l_day = "Tuesday"
CASE 4
l_day = "Wednesday"
CASE 5
l_day = "Thursday"
CASE 6
l_day = "Friday"
CASE 7
l_day = "Saturday"
END CHOOSE
Messagebox("System Time:",l_date + " " + l_day + " " + l_time)
GetThreadPriority( )
This function returns the priority level of a given thread. The default value is zero and anything higher would hold a higher priority thus receiving more CPU time. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION int GetThreadPriority(ulong hthread) LIBRARY "Kernel32.dll"
Script:
ulong l_handle
integer rtn
l_handle = GetCurrentThread()
rtn = GetThreadPriority(l_handle)
MessageBox("Current Thread Priority", string(rtn))
GetSystemMetrics( )
This function will provide the current resolution in pixels of the screen. It has been observed that this particular function is cap sensitive. Be sure to exactly declare the function as "GetSystemMetrics" and not "getsystemmetrics". There is no PowerBuilder equivalent.
Global External Function:
FUNCTION int GetSystemMetrics(int indexnum) LIBRARY "user32.dll"
Script:
int l_xx, l_yy
l_xx = GetSystemMetrics(0)
l_yy = GetSystemMetrics(1)
Messagebox("Screen Resolution", string(l_xx) + " , " + string(l_yy))
GetUserNameA( )
This function returns the current users logon name. Be sure to allocate enough space for the string or you'll get a GPF when you exit PowerBuilder. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean GetUserNameA(ref string uname, ref ulong slength) LIBRARY "ADVAPI32.DLL"
Script:
string ls_username
string ls_var
ulong lu_val
boolean rtn
lu_val = 255
ls_username = Space( 255 )
rtn = GetUserNameA(ls_username, lu_val)
Messagebox("GetUserNameA", "Username = " + string(ls_username))
GetVolumnInformationA( )
This function returns information about the harddrive.
Global External Function:
FUNCTION boolean GetVolumeInformationA(ref string lpRootPathName,ref string lpVolumeNameBuffer,ulong nVolumeNameSize,ref ulong lpVolumeSerialNumber,ref ulong lpMaximumComponentLength,ref ulong lpFileSystemFlags,ref string lpFileSystemNameBuffer,ulong nFileSystemNameSize) Library "kernel32.dll"
Script:
boolean rtn
string lprootpathname = "c:"
string lpVolumeNameBuffer = space(256)
ulong nVolumeNameSize = 256
ulong lpVolumeSerialNumber
ulong lpMaximumComponentLength
setnull(lpVolumeSerialNumber)
lpMaximumComponentLength = 256
ulong lpFileSystemFlags
setnull(lpFileSystemFlags)
string lpFileSystemNameBuffer = space(256)
ulong nFileSystemNameSize = 256
rtn = GetVolumeInformationA(lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize,&
lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags,&
lpFileSystemNameBuffer, nFileSystemNameSize)
sle_1.text = lprootpathname
sle_2.text = lpVolumeNameBuffer
sle_3.text = string(nVolumeNameSize)
sle_4.text = string(lpVolumeSerialNumber)
sle_5.text = string(lpMaximumComponentLength)
sle_6.text = string(lpFileSystemFlags)
sle_7.text = string(lpFileSystemNameBuffer)
sle_8.text = string(nFileSystemNameSize)
GetWindowsDirectoryA( )
This function returns the default windows directory into a string by reference. Be sure to allocate enough space for the string or you'll get a GPF when you exit PowerBuilder. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION ulong GetWindowsDirectoryA(ref string wdir, ulong buf) LIBRARY "kernel32.dll"
Script:
ulong l_buf
string windir
l_buf = 144
windir = space(144)
GetWindowsDirectoryA(windir, l_buf)
MessageBox("Current Directory", windir)
GlobalMemoryStatus( )
This function returns all the information related to the computers present memory into a structure by reference. There is no PowerBuilder equivalent.
Global External Function:
SUBROUTINE GlobalMemoryStatus(ref memory mem2) LIBRARY "Kernel32.dll"
Structure: (Memory)
ulong m_length, ulong m_loaded, ulong m_totalphys, ulong m_availphys, ulong m_totalpagefile, ulong m_availpagefile, ulong m_totalvirtual, ulong m_availvirtual
Script:
memory sysmem
GlobalMemoryStatus(sysmem)
Messagebox("Memory Length", string(sysmem.m_length))
Messagebox("Memory Loaded", string(sysmem.m_loaded))
Messagebox("Total Physical Memory", string(sysmem.m_totalphys))
Messagebox("Total Available Memory", string(sysmem.m_availphys))
Messagebox("Total Page Size", string(sysmem.m_totalpagefile))
Messagebox("Available Page Size", string(sysmem.m_availpagefile))
Messagebox("Total Virtual Memory", string(sysmem.m_totalvirtual))
Messagebox("Available Virtual Memory", string(sysmem.m_availvirtual))
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-25 00:04:33Z |
得分:0 |
|
|
|
LoadLibraryA( )
This function loads a dll into active memory. The function is limited to 32 bit dll's and there is no PowerBuilder equivalent.
Global External Function:
FUNCTION ulong LoadLibraryA(string modname) LIBRARY "Kernel32.dll"
Script:
ulong modhandle
modhandle = LoadLibraryA("c:\windows\mydll.dll") // Pathing isn't necessary if dll is in dos search path.
If modhandle > 0 Then
MessageBox("Return Code", "Load Successful -> handle = " + string(modhandle))
else
MessageBox("Result","Unable to load module")
end if
mciSendStringA( )
This function runs an AVI type file by making calls to the library, "winmm.dll". This API call is very complex and there is no PowerBuilder equivalent.
Global External Function:
FUNCTION long mciSendStringA(string cmd, REF string rtn, long size, long wnd) LIBRARY "winmm.dll"
Script:
string s_errortext
string filename
filename = "c:\winnt\clock.avi"
mciSendStringA ("open "+Filename+" type AVIVideo alias test wait",s_errortext, 0,0)
mciSendStringA ("Window test handle " + string(handle(w_main)) + " wait",s_errortext, 0, 0)
mciSendStringA ("Put test destination wait",s_errortext, 0, 0)
mciSendStringA ("Play test wait", s_errortext, 0, 0)
mciSendStringA ("Close test", s_errortext, 0, 0)
MessageBoxA( )
This function produces a messagebox. This is identical to the PowerBuilder "messagebox" command.
Global External Function:
FUNCTION long MessageBoxA(ulong hwnd, ref string text, ref string title, ulong style) LIBRARY "User32.dll"
Script:
long rtn
ulong handle1, style1
string text1
string title1
handle1 = handle(parent)
text1 = "This is an API Messagebox"
title1 = "API MessageBox"
style1 = 0
rtn = MessageBoxA(handle1,text1,title1,style1)
Mouse_Event( )
This function has the ability of moving the mouse pointer, activating the mouse buttons, and doing anything that the user can do with the mouse. The sample script will move the mouse 80 pixels left and 50 pixels up. The structure is populated by the mouses previous position. There is no PowerBuilder equivalent.
Global External Function:
SUBROUTINE Mouse_Event(ulong dwflag,ulong dx,ulong dy,ulong cbutton,ulong dwextra) LIBRARY "User32.dll"
Structure: (Mousepos)
long xpos, long ypos
Script:
int l_loop, lx, ly, lflag
mousepos mouseloc
lx = mouseloc.xpos
ly = mouseloc.ypos
lflag = 1 //1 = do nothing, 7 = L-button clicked, 25 = R-button clicked
mouse_event(lflag,-80,-50,0,0)
MoveToEx( ) & LineTo( )
The MoveToEx function moves the cursor to the coordinates it receives and the previous position is sent to a structure by reference. The LineTo function draws a line from the present location of the cursor to the coordinates it receives. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean MoveToEx(ulong hwnd,long wx, long wy,ref prepos prepos2) LIBRARY "Gdi32.dll"
FUNCTION boolean LineTo(ulong hwnd,long wx, long wy) LIBRARY "Gdi32.dll"
Function ulong GetDC(ulong hwnd) library "user32.dll"
Structure: (Prepos)
long xpos, long ypos
Script:
ulong l_handle, l_device
prepos previouspos
l_handle = handle(w_main)
l_device = GetDC(l_handle)
MoveToEx(l_device,100,100,previouspos)
LineTo(l_device,200,200)
MoveWindow( )
This function moves and resizes the window based on the coordinates it receives. This function has the same effect as changing a windows X, Y, Height and Width properties from within PowerBuilder.
Global External Function:
FUNCTION boolean MoveWindow(ulong whand,int wx,int wy,int ww,int wh,boolean wflag) LIBRARY "user32.dll"
Script:
boolean rtn
ulong l_handle, l_device
l_handle = handle(w_main)
rtn = MoveWindow(l_handle,10,10,100,100,true)
MessageBox("Return Code",string(rtn))
Pie( )
This function draws a pie chart based on the coordinates the function receives. There are no PowerBuilder equivalents.
Global External Function:
FUNCTION boolean Pie(ulong hwnd,long x1,long y1,long x2,long y2,long x3,long y3,long x4,long y4) LIBRARY "Gdi32.dll"
Function ulong GetDC(ulong hwnd) library "user32.dll"
Script:
Boolean rtn
ulong l_handle,l_device
long lv[8]
lv[ ] = {10,50,290,220,0,0,80,0}
l_handle = handle(w_main)
l_device = GetDC(l_handle)
rtn = Pie(l_device,lv[1],lv[2],lv[3],lv[4],lv[5],lv[6],lv[7],lv[8])
Polygon( )
This function draws a polygon shape based on the coordinates the function receives. There are no PowerBuilder equivalents.
Global External Function:
FUNCTION boolean Polygon(ulong hdc, ref struct poly poly2, int cnt) LIBRARY "Gdi32.dll"
Function ulong GetDC(ulong hwnd) library "user32.dll"
Structure: (Poly)
long xpos[5], long ypos[5] //The size of the array is proportional to the number of sides in the Polygon.
Script:
ulong l_handle, l_device
int pcnt
l_handle = handle(w_main)
l_device = GetDC(l_handle)
pcnt = 5
poly poly3
poly3.xpos[ ] = {50,100,150,200,250}
poly3.ypos[ ] = {50,100,150,200,250}
Polygon(l_device,poly3,pcnt)
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-25 00:05:10Z |
得分:0 |
|
|
|
PostMessageA( )
This function posts a message (such as minimize or close) in the message queue associated with the thread that created the specified window and then returns without waiting for that thread to process the message. There is no PowerBuilder equivalent. For more information on the codes associated with this function see the MSDN.
Global External Function:
FUNCTION boolean PostMessageA(ulong hwndle,UINT wmsg,ulong wParam,ulong lParam) Library "User32.dll"
Script:
ulong l_handle
boolean rtn
l_handle = handle(w_main)
rtn = PostMessageA(l_handle,274,61472,0) // 61472 = minimize, 61488 = maximize, 61728 = normal state
Rectangle( )
This function draws a rectangle based on the coordinates the function receives. There are no PowerBuilder equivalents.
Global External Function:
FUNCTION boolean Rectangle(ulong hwnd,long x1,long y1,long x2,long y2) LIBRARY "Gdi32.dll"
Function ulong GetDC(ulong hwnd) library "user32.dll"
Script:
Boolean rtn
ulong l_handle,l_device
long lv[4]
lv[ ] = { 10,10,275,215}
l_handle = handle(w_main)
l_device = GetDC(l_handle)
rtn = Rectangle(l_device,lv[1],lv[2],lv[3],lv[4])
SendMessageA( )
This function sends a message to the message queue associated with the thread that created the specified window and doesn't return until that message is processed. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION long SendMessageA(ulong hwndle,UINT wmsg,ulong wParam,ulong lParam) Library "User32.dll"
Script:
ulong l_handle
long rtn
l_handle = handle(w_main)
rtn = SendMessageA(l_handle,274,61728,0)
SetCapture( ) & ReleaseCapture( )
These functions works directly with each other. The SetCapture function locks control of the mouse until ReleaseCapture( ) is called. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION ulong SetCapture(ulong a) LIBRARY "User32.dll"
FUNCTION boolean ReleaseCapture( ) LIBRARY "User32.dll"
Script:
boolean rtn
ulong l_loop, u_test, u_long
u_test = handle(parent)
u_long = SetCapture(u_test)
SetPointer(SizeNWSE!)
for l_loop = 1 to 150000
next
rtn = ReleaseCapture( )
SetComputerNameA( )
This function changes the computer's name to the string it receives by reference. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean SetComputerNameA(ref string cname) LIBRARY "kernel32.dll"
Script:
boolean rtn
string l_name
l_name = "PowerBuilder"
rtn = SetComputerNameA(l_name)
if rtn then
MessageBox("Computer name changed to 'PowerBuilder'", "You'll need to reboot for it to take effect")
else
MessageBox("SetComputerName", "Failed")
end if
SetCurrentDirectoryA( )
This function changes the current directory that the OS is pointing to. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean SetCurrentDirectoryA(ref string cdir) LIBRARY "kernel32.dll"
Script:
boolean rtn
string l_dir
l_dir = "c:\My Documents"
rtn = SetCurrentDirectoryA(l_dir)
MessageBox("SetCurrentDirectory", string(rtn))
SetFocus( )
This function changes the focus to the object or window whose handle is given. The only PowerBuilder equivalent is limited to PowerBuilder objects and the syntax is as follows: <Object>.SetFocus( )
Global External Function:
SUBROUTINE SetFocus(long objhandle) LIBRARY "User32.dll"
Script:
SetFocus(handle(sle_1)) // This function gets the handle from PB.
SetThreadPriority( )
This function sets the priority level of a given thread. The default value is zero and anything higher would hold a higher priority thus receiving more CPU time. Don't set the priority level too high or the mouse won't work. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean SetThreadPriority(ulong hthread, int npriority) LIBRARY "Kernel32.dll"
FUNCTION ulong GetCurrentThread() LIBRARY "Kernel32.dll"
Script:
ulong l_handle
boolean rtn
l_handle = GetCurrentThread()
rtn = SetThreadPriority(l_handle, 2) // Set the priority of thread higher.
MessageBox("Current Thread Priority Changed", string(rtn))
Sleep( )
This function tells the OS to ignore the current thread for X number of milliseconds. The screen will not be redrawn while this API call is active. This is the same as running a for-next loop from within PowerBuilder.
Global External Function:
SUBROUTINE Sleep(ulong milli) LIBRARY "Kernel32.dll"
Script:
ulong l_delay
l_delay = 2000
Sleep(l_delay)
SndPlaySoundA( ) & WaveOutGetNumDevs()
These functions run a WAV file from within PowerBuilder. There is no PB equivalent.
Global External Function:
FUNCTION boolean SndPlaySoundA(string wavfile, uint flag) LIBRARY "WINMM.DLL"
FUNCTION uint WaveOutGetNumDevs() LIBRARY "WINMM.DLL"
Script:
uint lui_NumDevs, l_mode
string ls_file
l_mode = 0
ls_file = string("c:\windows\media\chimes.wav")
lui_NumDevs = WaveOutGetNumDevs()
IF lui_NumDevs > 0 THEN
SndPlaySoundA(ls_file, l_mode)
END IF
SwapMouseButton( )
This function reverses the mouse buttons making the right button the left and visaversa. The function needs to be called again to return the mouse to a normal state. This is a great API to use on a collegues computer. There is no PowerBuilder equivalent.
Global External Function:
FUNCTION boolean SwapMouseButton(boolean var) LIBRARY "User32.dll"
Script:
boolean rtn, l_mouse
rtn = SwapMouseButton(l_mouse)
If l_mouse = true Then
MessageBox("Change Made","Right button on Left Side")
Else
MessageBox("Change Made","Right button on Right Side")
End If
WinExec( )
This function sends a filename and path to the OS triggering it to be run. The PB equivalent is the function RUN. (i.e. Run("c:\windows\calc.exe")
Global External Function:
FUNCTION uint WinExec(ref string filename, uint wstyle) LIBRARY "kernel32.dll"
Script:
string ls_filename
uint rtn, wstyle
ls_filename = "c:\windows\calc.exe"
wstyle = 1
rtn = WinExec(ls_filename, wstyle)
Messagebox("Return Code", string(rtn))
|
Top |
|
|
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 |
2003-05-25 00:08:07Z |
得分:0 |
|
|
|
获得应用运行的模式
运行如下脚本:
Handle(GetApplication()),如果返回0,则应用运行在开发模式,否则运行的是编译后的EXE文件
/----------------------
移动窗口中的控件
在mousedown事件中写入如下脚本即可在窗口中任意移动此控件:
Send(handle(this), 274, 61458, 0)
如果控件没有mousedown事件,定义事件如下:
ue_mousedown pbm_lbuttondown
将以上代码写在窗口的mousedown事件中,在窗口客户区任意地方按下鼠标左键即可拖动窗口
//------------------------
捕获控制菜单中的Close事件
用户按控制菜单中的Close按钮(窗口右上角)关闭窗口时会触发pbm_syscommand事件,定义事件如下:
ue_close pbm_syscommand
在事件中加入如下代码:
IF Message.WordParm = 61536
THEN MessageBox("","窗口将关闭")
END IF
//------------------
用DWSyntax获得颜色值
有时我们需要在脚本中直接使用颜色值,如何获得呢?打开DWSyntax,单击'RGB'按钮,选中需要的颜色后按“确定”,然后在Script窗口中“粘贴”,OK!
//------------------
在PowerBuilder中动态调用函数
目前流行的大部分应用程序中都提供了Undo功能,在PowerBuilder中也可以利用Undo()函数实现该功能。Undo()函数可用于DataWindow, EditMask, MultiLineEdit, RichTextEdit和SingleLineEdit 对象,如果只对某一个对象进行Undo操作,只需在Undo菜单项的单击事件中键入如下脚本:
Objectname.undo(),
但是当窗口中有多个对象,我们在编写脚本时并不知道要对哪个对象执行undo()操作,如何解决这一问题呢?
在PowerBuilder中,undo()等函数只能用于可视对象,而所有可视对象均继承自系统对象类GraphicObject。因此我们可以定义一个GraphicObject对象的实例变量go_object,等到运行时再用getfocus()函数确定具体操作对象。然后用Typeof()函数确定当前对象的类型,再用Choose case语句根据不同的类型引用不同的实例变量,代码如下:
graphicobject go_object
DataWindow dw_object
EditMask em_object
MultiLineEdit mle_object
RichTextEdit rte_object
SingleLineEdit sle_object
go_object=getfocus()
choose case TypeOf(go_object)
case DataWindow!
dw_object=go_object dw_object.undo()
case EditMask!
em_object=go_object em_object.undo()
case MultiLineEdit!
mle_object=go_object
mle_object.undo()
case RichTextEdit!
rte_object=go_object
rte_object.undo()
case SingleLineEdit!
sle_object=go_object
sle_object.undo()
case else
messagebox("Error","Can not undo")
end choose
其实我们可以用动态调用函数的方法简单地解决这一问题(只需三行代码),即对GraphicObject对象调用undo()函数,然后在函数名前加上关键字Dynamic。因为对象类GraphicObject并没有undo()这个对象函数,如果不加关键字Dynamic,编译时就会出现错误。使用了Dynamic关键字,PowerBuilder在编译时不检查该函数和所用参数的有效性,而到脚本运行时才去检查该函数。代码如下:
GraphicObject go_object
go_object=getfocus()
go_object.dynamic undo()
允许动态调用函数是的PowerBuilder的特性之一。在程序设计中灵活运用动态函数调用的方法有助于提高所设计程序的可维护性、可重用性。
//-----------------
如何在SCRIPT中调用数据管道
首先打开Pipe画板,定义源数据库、源表、目标数据库、目标表,然后取名存盘,在本例中Pipe名为Pipe_sample。
打开User Object画板,定义一个用户对象,该对象继承自系统对象Pipeline,并在该对象中定义如下实例变量:
STATICTEXT READ
STATICTEXT WRITTEN
STATICTEXT ERROR
这三个变量用来记录数据管道执行时读入的行数,写入的行数,发生错误的行数。
在该用户对象的Pipemeter事件中写入如下语句:
READ.TEXT=STRING(ROWSREAD)
WRITTEN.TEXT=STRING(ROWSWRITTEN)
ERROR.TEXT=STRING(ROWSINERROR) 然后取名存盘,在本例中取名为U_Pipe_Sample。
打开窗口画板,创建一个窗口,在该窗口中放置一个数据窗口对象和三个静态文本对象,分别名为DW_1,ST_READ,ST_WRITTEN,ST_ERROR,这个数据窗口用来记录管道执行过程中发生的错误信息,不要为该数据窗口对象指定数据窗口。
在该窗口中定义如下实例变量:
Transaction I_SRC,I_DST
U_Pipe_Sample I_PIPE
在窗口的Open事件中写入如下语句:
i_src=create transaction
i_src.dbms='odbc'
i_src.dbparm="Connectstring='DSN=数据库名';uid=用户名;pwd=口令"
connect using i_src;
If i_src.sqlcode <> 0 then
Messagebox("源数据库连接错误",i_src.sqlerrtext)
Return
End If
i_dst=create transaction
i_dst.dbms='odbc'
i_dst.dbparm="Connectstring='DSN=数据库名';uid=用户名;pwd=口令"
connect using i_dst;
If i_dst.sqlcode <> 0 then
Messagebox("目标数据库连接错误",i_dst.sqlerrtext)
Return
End If
在窗口中放置一个按钮用来运行数据管道,在此按钮的Clicked事件中写入如下语句:
i_pipe=create u_pipe_sample
i_pipe.read=st_read
i_pipe.written=st_written
i_pipe.error=st_error
i_pipe.dataobject="Pipe_Sample"
//execute pipe
i_pipe.start(i_src,i_dst,dw_1)
//----------------------
如何在DataWindow中实现列的自动折行
我们在PowerBuilder应用程序的开发过程中, 使用DataWindow时, 经常会遇 到某列的数据太长, 不能同时全部显示的情况. 若采用自动水平滚动, 操作起 来又不够简便.
下面介绍一种方法, 实现列数据多行显示, 即实现列数据的自 动折行.具体步骤如下:
1) 在DataWindow Painter中打开此DataWindow.
2) 在需设定自动折行的列上双击鼠标, 弹开此列的属性窗口.
3) 选择Position标签, 选中Autosize Height 多选框.
4) 选择Edit标签, 不选中Auto Horz Scroll多选框.
5) 单击OK按钮, 保存所做的修改.
6) 点中Detail Band (即写有Detail的灰色长带), 单击鼠标右键, 选择 Properties... 菜单项.
7) 选中Autosize Height多选框.
8) 单击OK按钮, 保存所做的修改.
9) 保存此DataWindow.
注意: 连在一起的汉字(中间没有标点或空格分隔), 系统将认为是一个单词, 不 会自动进行折行.
//-------------------------------------------
复制和粘贴Text对象以节约时间
在Datawindow中往会有许多Text对象用于显示一些报表的其他信息,为了节约时间,当有一个text已设置好字体,颜色,你只用简单的用Mouse右键选择此Text,然后从弹出菜单中选择“复制”和“粘贴”即可生成一个同样风格和外观的Text对象,如果需要的话,简单的设置此文本的名称即可。
//---------------------------
方便编程,去掉Column名称讨厌的table前缀字符串
在DataWindow数据源中如果有多于一张表,在生成的Column名称会以tablename_field1形式出现,这样在使用Setitem, GetItemxxxxx等函数时免不了要多键入一些字符,如果你在选择数据源时先选择一张主表(通常是需要update的表,使用Setitem,GetItemxxxx函数机会最多的),然后选择需要的列生成Datawindow以后,再改动data source,加入新的表,这样只有新加入表的Column名称才会以tablename_field1形式出现。
//--------------------------------
用记事本查看Datawindow数据
dw_1.SaveAs("c:\sample.txt", Text!, TRUE) Run ("Notepad.exe c:\sample.txt", Maximized!)
可以将这段代码放在DoubleClicked(鼠标双击)事件中,实现快速数据转换
//------------------------------------
利用Query对象快速建立二个具有相同数据源不同表现风格的DataWindow
打开已有的datawindow,然后在Data Source菜单中选择File->Save Query将数据源保存为query对象,这样生成新datawindow时,在出现Select Table 对话框时单击cancel按钮,然后选择菜单File->Open Query调出相应对象,这样就快速生成了Datawindow,这种方法在Data Source由多张表组成的时候很方便。
//-------------------------------------
关于Datawindow每页打印固定行的问题:
第一步:增加一个计算列,此计算列必须放在Detail段,Expression中输入:
ceiling(getrow()/20) <--这里20还可以用全局函数取代,这样可以允许用户任意设置每页打印多少行。
第二步:定义分组,选择菜单Rows->Create Group...
按计算列字段分组,并一定将check box-->New Page On Group Break选中。
第三步:将此计算列设为不可视。
另外,如果需要最后一页不足补空行。也很简单,如下:
long ll_pagerow = 6 //每页打印行数
long ll_count, ll_row
ll_count = dw_report.retrieve(...) //取得现有报表的总行数
ll_count = ll_pagerow - mod(ll_count, ll_pagerow)
If ll_count < ll_pagerow Then
for ll_row = 1 to ll_count
dw_print.insertrow(0) //补足空行
next
end If
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-25 00:15:05Z |
得分:0 |
|
|
|
不陪你玩了,两个神经病,大半夜在这贴贴子
|
Top |
|
|
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 |
2003-05-25 00:18:33Z |
得分:0 |
|
|
|
操作系统: windows9X
编程工具: PB6.5
问题: PB中如何在大型BLOB变量中快速查找4位BLOB变量!
在下列程序中,由于在BLOB数据类型中没有提供类似字符串查找的pos(str1,str2)函数,因此查找速度极慢,请教各位高手有办法加快查找速度吗?
[注:若使用mm=string(m),则mm为NULL,故无法使用pos(mm,'9988')查找]
blob {1000000000} m
blob {4} v
.. // m 已被赋值
v=blob('9988')
for i=1 to 1000000000 STEP 4
if BlobMid(m,i, 4) = v then
MessageBox("提示",'在M中查找到V的位置为:' + string(i*4) )
end if
next
水平: 中级
回答:
我想你可能需要用C++写一段程序(并不难!),自己来检索二进制数据了。PB未提供相应的函数(我只有PB 6.5)。另外:你的程序中
for i=1 to 1000000000 STEP 4
if BlobMid(m,i, 4) = v then
MessageBox("提示",'在M中查找到V的位置为:' + string(i*4) )
end if
next
好像有问题,例如:m=119988,v=9988时将找不到,只要把STEP 4去掉就行了。
//---------------------------
在PB应用程序中实现对系统注册登记表的访问
摘要:系统注册登记表是Windows 9x中所有配制信息的中央仓库。它除了保存操作系统自身的软件、硬件及环境信息外,另一个用途就是保存应用程序中用户定制的配制信息。把应用程序保存到系统注册登记表中的方法是使应用程序的适用性提高的最佳方法之一。在Power Builder应用程序中,通过使用PB内嵌的注册函数对系统注册登记表的访问,可以方便地设置和获取应用程序及用户设置的信息:如进入应用程序时,通过访问系统注册登记表来获取主窗口的原有大小及位置信息,而退出程序时可保存用户改变了的窗口大小及位置信息;可以将用户的设置保存到系统注册登记表中,在必要时从系统注册登记表中取出;亦可创建一个.REG文件(注册登记)来安装自己的应用程序,以及实现存取ODBC驱动信息等等。
//-------------------
陈伟:
操作系统:windows98,windowsNT
编程工具:PowerBuilder6.5 ,delphi5.0
问题:在PB中调用DELPHI编写的DLL时,字符串并不能通过参数的方式从DLL的函数里正确的传递给PB(参数用PCHAR或STRING类型都不行),如果用SHORTSTRING类型,则在PB中得到的字符串不正确(因为SHORTSTRING的第一个字节表示该SHORTSTRING的长度),困惑不已,请高手不吝赐教!!!
水平: 中级
回答:
在DELPHI的DLL里:
function dosomething(out s:shortstring) :dword ;stdcall;
var
len : integer;
begin
/*对S赋值*/
...
/*获取S的长度*/
len := length(s);
/*从第2个字节将S 前移一位*/
move(s[1],s[0],len);
/*将S 变成null-terminate的字符串*/
s[len] := #0;
result := 1;
end;
|
Top |
|
|
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 |
2003-05-25 01:11:19Z |
得分:0 |
|
|
|
老刀请听?
........鸣金收兵....哈!哈!
PB版多几个老刀兄这样的铁杆网友,一定更火的!
过1点还在网上答题!... ...
|
Top |
|
|
回复人: pbtech(再不堕落) ( ) 信誉:89 |
2003-05-25 08:07:20Z |
得分:0 |
|
|
|
强!!!!!!!!!!!
|
Top |
|
|
回复人: pbtech(再不堕落) ( ) 信誉:89 |
2003-05-25 08:07:46Z |
得分:0 |
|
|
|
老刀厉害
|
Top |
|
|
回复人: bastenlee(Lee) ( ) 信誉:98 |
2003-05-25 09:42:28Z |
得分:0 |
|
|
|
受益无穷~~~~
|
Top |
|
|
回复人: 946(情系会计) ( ) 信誉:105 |
2003-05-25 10:21:19Z |
得分:0 |
|
|
|
mark
|
Top |
|
|
回复人: dadapp() ( ) 信誉:100 |
2003-05-25 11:01:26Z |
得分:0 |
|
|
|
haode
|
Top |
|
|
回复人: devil_heart(心魔) ( ) 信誉:108 |
2003-05-25 11:34:14Z |
得分:0 |
|
|
|
好贴,加入精华啊!
|
Top |
|
|
回复人: macroyan(天涯) ( ) 信誉:100 |
2003-05-25 13:02:23Z |
得分:0 |
|
|
|
高手,学习!
|
Top |
|
|
回复人: dberror() ( ) 信誉:97 |
2003-05-25 15:44:45Z |
得分:0 |
|
|
|
理应感谢!
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-25 20:50:35Z |
得分:0 |
|
|
|
PB高级开发环境配置
Advanced Development Environment Configuration
Notice
This document provides extra information on the development environment for advanced users only. Use of this information presumes knowledge of the registry. This information is provided for those developers who wish to make use of it. However, Because this is not a part of the standard documentation, this information is likely to change between releases without backward compatibility and no guarantees are made by Sybase, Inc. that this technology will be supported in any way or in any future release of PowerBuilder. This is considered an advanced and unsupported feature. Use at your own risk.
Notation
This document uses the following notational conventions:
name -- italics are used for placeholders
| -- separates different choices
[ ] -- surrounds optional items
Base Registry Keys
PowerBuilder use the following registry keys:
HKEY_CURRENT_USER\Software\Sybase\PowerBuilder\7.0
HKEY_LOCAL_MACHINE\Software\Sybase\PowerBuilder\7.0
InfoMaker uses the following registry keys:
HKEY_CURRENT_USER\Software\Sybase\InfoMaker\7.0
HKEY_LOCAL_MACHINE\Software\Sybase\InfoMaker\7.0
DataWindow Builder uses the following keys:
HKEY_CURRENT_USER\Software\Sybase\DataWindowBuilder\7.0
HKEY_LOCAL_MACHINE \Software\Sybase\DataWindowBuilder\7.0
International versions will add a one letter suffix to the version (i.e. 7.0u)
u - Unicode
j - Japanese
Through the remainder of this document, the product's HKEY_CURRENT_USER key will be abbreviated to product-hkcu and the product's HKEY_LOCAL_MACHINE key will be abbreviated to product-hklm.
Painter Names
Both URLs and the command line make use of painter names.
The following painter names are valid for PowerBuilder, InfoMaker, and DataWindow Builder:
http
ftp
mailto
execute
wizard
Database
DBProfile
DataPipeline
FileEdit
Library
Query
Report
RunReport
The following additional painter names are valid for PowerBuilder:
Application
DataWindow
Debug
Function
Menu
Project
RunWindow
Structure
UserObject
Window
The following additional painter names are valid for InfoMaker:
Form
The following additional painter names are valid for DataWindow Builder:
DataWindow
PowerBuilder URLs
Internet URL format is identified by the leading slashes "//" and follows the pattern:
<service>://<user>:<password>@<host>:<port>/<url-path>
This format is usually extended to support parameters with the following format:
<service>://<user>:<password>@<host>:<port>/<path>
?<name>=<value>&<name>=<value>
The following parts may be excluded:
<user>:<password>@
:<password>
:<port>
/<path>?<name>=<value>&<name>=<value>
?<name>=<value>&<name>=<value>
&<name>=<value>
The following part may be repeated at the end of the pattern:
&<name>=<value>
The service may only consist of the characters:
a-z 0-9 . + -
In the path on Wintel, the following translations occur:
: |
\ /
In the name and value sections, the following translations occur:
space +
+ %2b
In the user, password, host, and port sections, the following translation occurs:
/ %2f
In all sections, the following characters are otherwise encoded as % with two hex characters:
0x00-0x1f space 0x7f-0xff
< > " # % { } | ^ ~ [ ] ` ; @ ? = & : \
Service identifies the component that will interpret the remainder of the URL. Path generally points to the content. Often, the extension in the path or the content is used by the service to identify another component that processes the content. The parameters can be used by the service or the component processing the content.
The following standard browser URL services are supported and they all invoke the default browser to process them.
http://user:password@host/path
ftp://user:password@host
mailtuser@host
For example:
http://www.sybase.com
ftp://www.sybase.com
mailtsupport@sybase.com
Programs can be executed with the following URL:
execute://path?args=arguments
For example:
execute://C|/Program Files/Microsoft Office/Office/winword.exe?args=c:\My+Documents\Sample.doc
Windows that are a part of the internal wizard application can be opened with:
wizard:?entry=windowname
wizard:?entry=windowname/option
where option may be
0 -- start wizard
1 -- object wizard
2 -- project wizard
For example:
wizard:?entry=w_sample
Painters that don't work on objects in a library or file, can be opened using:
painter://
Painters that operate on objects in a file, can be opened using:
painter://?action=new
painter://file?action=dosfile
Painters that operate on objects in a library, can be opened using:
painter://?action=new
painter://library?action=open&entry=objectName
painter://library?action=inherit&entry=objectName
painter://library?action=run&entry=objectName
painter://library?action=runonly&entry=objectName
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-25 20:51:35Z |
得分:0 |
|
|
|
PB高级开发环境配置
The painter userobject also supports the following additional arguments for new user objects (may be added to the end of the URL separated by &):
udotype=cv|ev|sv|cnv|snv
udoclass=class-name
The painters userobject, window, and application also support the following additional arguments for positioning to an individual script:
function=function-name
control=control-name
event=event-name
line=line-number
The painters userobject, window, application, and function also support the following additional arguments for positioning to a structure:
structure=structure-name
The painter project also requires the following additional argument for specifying the project type when action=new.
guid={genererator-guid}
The GUIDs for the projects are:
{bb0dd543-b36e-11d1-bb47-000086095dda} -- Application
{36A08730-A06D-11D0-AEDC-00A0D103F6BC} -- Proxy Library
{1B1DCEE1-E514-11D1-B30A-006008925BD4} -- Jaguar Proxy
{DF93F2A2-E504-11D1-B30A-006008925BD4} -- Jaguar Component
{3D326055-5AB3-11D1-9281-00A0247712F1} -- COM/MTS Component
{CA82AC28-36A9-11d2-B30B-006008925BD4} -- Automation Server
{DA7487C2-3843-11d2-B30F-00600825A521} -- Web.PB
{44E34E90-41B2-11D1-BD7B-080009AC019B} -- Java Proxy
New Dialog
The new dialog can be customized to include additional icons. In this way, icons can be added that would, for instance, open a new window that is inherited from a specific object. The icons can map to any of the URLs described in the previous section.
Each item that appears in the new dialog must be registered under a key with a unique CLSID. The CLSID should be generated with Microsoft's GUIDGEN or UUIDGEN.
product-hklm\CLSID\{clsid}
The values that are supported under that key:
(default)=label
DefaultIcon=path,index
URL=internal-url
Icons appear in the PowerBuilder new dialog by specifying one of the following values:
StartTool=
ObjectTool=
DataWindowTool=
DatabaseTool=
ProjectTool=
Tool=
Icons appear in the InfoMaker and DataWindow Builder new dialogs by specifying one of the following values:
IMLibraryTool=
IMObjectTool=
IMDatabaseTool=
IMTool=
Icons may be restricted to certain products by specifying one of:
OnlyInPB=
OnlyInIM= -- InfoMaker without form painter
OnlyInIX= -- InfoMaker with form painter
OnlyInDWB=
For example:
product-hklm\CLSID\{d49b4590-3880-11d2-bc50-000000000000}
(default)=Sybase Home Page
URL=http://www.sybase.com
DefaultIcon=C:\Program Files\PLUS!\Microsoft Internet\IEXPLORE.EXE,1
Tool=
To-Do List
All of the to-do list entries appear in the registry under the key:
product-hkcu\Application\$pbl-path(application-name)\ToDo
Where pbl-path is the path the application's library with slashes (\ or /) translated to $ and application-name is the name of the application.
Under that key the following values are used to save the number of items and the last selection:
Count=count
Selection=selection
Each of the to-do entries are stored under sequentially numbered values of the format:
n=y|n ~t text ~t URL
The y or n represents the checked state of the item. The checked state, text, and URL are separated by tab characters (~t). The URL may be any of the URLs described in the URL section above.
Note: When the to-do list is closed, it completely rewrites this key. Any changes made to this key while the to-do list is open will be lost.
To-Do List Wizards
With the following registry entries, additional entries may be added to a user's to-do list with a wizard is run.
product-hklm\CustomTo-Do\wizard-type\wizard-tab
where wizard-type may be one of:
template
jaguar proxy
jaguar component
com component
ole auto component
and wizard-tab may be one of:
start
object
project
Value names under this key can be any legal value name. All values will be used in alphabetical order.
The values must be a semicolon (;) delimited set of name=value pairs or an URL with a and text sub-value. For example:
Item1=service=window;path=c:\pbls\myapp.pbl;action=open;entry=w_main;text=Open w_main window
Item2=http://www.sybase.com;text=Go to Sybase web page
Wizard Application Lib List
The wizards in PowerBuilder were written using PowerBuilder itself. PowerBuilder simply starts up a run-time session with a separate application. Windows in this application are usually opened using an URL with a service of wizard. The library list to this application can be extended through the registry. A maximum of 30 libraries may be added.
The library values must be under the key:
product-hklm\WizardLibraries
The libraries must be in sequentially numbered values. For example:
1=c:\powerbuilderextension1.pbd
2=c:\powerbuilderextension2.pbd
Note: If Sybase needs to add additional wizards between releases, the installation of those wizards will overwrite one or more of these entries.
Duplicating Configurations
To duplicate the keyboard shortcuts, toolbar configuration, or view layouts between machines use the Export Registry File and Import Registry File menu items in regedit.exe to duplicate the following keys:
product-hkcu\Shortcuts
product-hkcu\Toolbar
product-hkcu\Layout
Command Line Arguments
/painter painterName or /p painterName
Identifies the target painter. See the section above.
/library objectLibName or /l objectLibName
Identifies the library for an open or inherit operation.
/file fileName or /f fileName
Identify the file. For the painter FileEdit opens the specified file in the editor. For the painter Report, opens the specified .psr in the editor.
/open objectName or /o objectName
Identifies the object that the painter should be opened to display. The object MUST be in the library specified in the /library option.
/inherit ancestorName or /i ancestorName
Create a new object that inherits from the passed object that must be in the library specified in the /library option.
/argument argument or /a argument
A painter dependent argument. Used by Sybase only.
/new or /n
Indicates that a new object should be created.
/run or /r
Runs the painter. Used with painter project to run a project. Used with painter runreport to preview a datawindow. Used with form to preview a form.
/runonly or /ro
Run the painter and then close immediately. This can be used with the painter project to run a project and exit.
/appname appObjName or /ap appObjName
Specify the application object name. The object must exist in the library specified by /applibrary.
/applibrary appLibraryName or /appl appLibraryName
Indicates the library that the application is in. If there is only a single library in the library list, then the /librarylist parameter does not have to be specified.
/searchlist libList or /s libList
/librarylist libList or /libraryl libList
/path libList or /pat libList
Specify the library list. This does not need to be specified if the /applibrary is the only library.
/sdi
Indicates that the painter should operate in SDI look mode. This is done by maximizing the sheet and removing MDI menu items and decorations. The behavior of the frame is modified as well. When no sheet is visible, then the frame is made invisible.
/url painterUrl or /u painterUrl
Open according to an URL. See the section on URLs.
Toolbar Customization
URLs may also be entered as the command line for custom toolbar items in the toolbar customization dialogs.
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-25 20:52:25Z |
得分:0 |
|
|
|
动态获得Sybase10/SQLServer中的存储过程列表
我们当中的大多数人很可能有这样的经验:当你建立一个基本存储过程的数据窗口或者是你在PB的数据库管理员(admin)画笔中存择了"Objects->rocedure Syntax”菜单时,需要花大量时间来从数据库中提取所有的存储过程列表。
Here is what one can do to speed up the response from server in this case. It also serves as a good example of how one can customize Sybase's interface to Sybase/SQL Server databases to advantage.
PowerBuilder uses a no. of stored procedures to communicate with the databases SQL Server and SYBASE System 10/11. In case of Sybase System 10/11 they reside in the Sybsystemprocs database. One can either change one or more of these stored procedures or override them by having a procedure with the same name in the user-database he/she generally works with. The changed version of the stored procedure has to go under his/her own login name or the dbo.
In particular, the Sybase-defined stored procedure 'sp_pbX0proc' brings the list of all stored procedures from the databases residing on the server (where X = 4, 5 depending on PowerBuilder's major version). It actually pulls the list of all stored procs from system databases Master and Sybsystemprocs along with the current user database; and this is what makes it take such a lot of time. Usually, when you are in development you are not much bothered about system stored procs from system databases Master and Sybsystemprocs. Hence you may want to modify the Sybase procedure sp_pb40proc to refer only to the currently connected database, for faster access. Following is the changed version of this procedure which will retrieve the list within no time on most of the installations:
create proc sp_pb40proc @procid int = NULL,
@procnumber smallint = NULL as
if @procid = null
select o.id, o.name, o.uid, user_name(o.uid), 1, '1'
from dbo.sysobjects o
where o.type = 'P'
else
select name, type, length, colid from dbo.syscolumns
where (id = @procid and number = @procnumber)
return;
Similarly, the procedure 'sp_pbX0table' retrieves the list of tables from a database in the database painter. Many times one doesn't want to see the development versions of actual tables created by various other developers in the development database. If this no. is very large instead of scanning the huge list every time for actual (dbo-owned) or your tables, you can customize this PB-procedure by adding following WHERE criteria in the SELECT statement:
where(user_name(o.uid) in ("dbo", "") )
It will then retrieve only your or dbo's tables in the database painter.
|
Top |
|
|
回复人: killerdanny(月影-月下轻舞剑 酒里怀过往) ( ) 信誉:92 |
2003-05-26 17:29:48Z |
得分:0 |
|
|
|
upup!不错不错!呵呵
TO:tchatcha(老刀)
兄弟和楼主配合的很默契呀!
当斑竹如何??
一起做脚本语言的斑竹?
估计很适合!
有意请用短消息告诉我哦!
|
Top |
|
|
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 |
2003-05-29 09:43:09Z |
得分:0 |
|
|
|
数据类型转换表
MICROSOFT PB(16Bit) PB(32Bit)
Bool Boolean Boolean
Byte,Char Char Char
Char* Ref string Ref String
Colorref Uint Ulong
Double Double Double
Dword Uint Ulong
Float N/A N/A
Handle Uint Ulong
Hdc Uint Ulong
Hfile Uint Ulong
Hinstance Uint Ulong
Hwnd Uint Ulong
Int Int Int
Long Long Long
Lparam Uint Ulong
Lpbyte Ref Int Ref Long
Lpcwstr Ref Blob Ref Blob (Unicode use ToUnicode())
Lpcvoid Ref String Ref String
Lpdword Ref Uint Ref Ulong
Lpfiletime Ref Time Ref Time
Lpint Ref Int Ref Long
Lpstr,Lpcstr Ref String Ref String
Lpvoid Ref Structstruct_inst Ref Struct struct_inst
Lpword Ref Int Ref Ulong
Mcierror Long Long
Pbyte Ref Int[#] Ref Long[#]
Short Int Int
Structure Ref Struct struct_inst Ref Struct Struct_inst
Uint Uint Uint
Void** SUBROUTINE SUBROUTINE
Word Int Long
Wparam Uint Ulong
| |