祝愿大家身体健康!

 站点注册  找回密码
 站点注册

QQ登录

只需一步,快速开始

查看: 22301|回复: 5

PB技巧

[复制链接]

PB技巧

[复制链接]
ehxz

主题

0

回帖

57万

积分

管理员

积分
570784
贡献
在线时间
小时
2005-7-20 17:02:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?站点注册

×

主  题:
推荐!PB技巧!取得系统用户名的方法!
作  者: joss (季节...草堂夏意浓)
信 誉 值: 158
所属论坛: PowerBuilder Pb脚本语言
问题点数: 0
回复次数: 49
发表时间: 2003-05-24 19:13:41Z
平时写程序时会用到系统用户名,现将实现方法贴出,大家分享!
1、申明API函数
FUNCTION ulong WNetGetUser(ref string lpName,ref string lpUserName,ref ulong lpnLength) LIBRARY "mpr.dll" ALIAS FOR "WNetGetUserA" 

2、PB脚本语言
 string ls_name, ls_username
 ulong ll_len
 ll_len = 256
 ls_username = space(ll_len)
 setnull(ls_name)
 WNetGetUser(ls_Name,ls_UserName,ll_Len) 
 messagebox("系统登录用户名",ls_username)

以上脚本在WIN2000下测试通过

joss
回复人: flyerlxg(飞鸟) ( ) 信誉:101 2003-05-24 19:44:26Z 得分:0
认真听课,仔细做题
Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 22:07:46Z 得分:0
通过调用APi函数WNetGetUserName,你可以获取大数网络客户端的网络用户标识,该函数适用于Netware, Windows for Workgroups, Windows NT, Windows 95与LanManager. 对于32 位应用程序,需要使用另一个API函数:GetUserNameA(). 
16-bit程序
//外部函数说明:
function int WNetGetUser( ref string userid, ref uint len ) library "user.exe"

PowerScript脚本
string login_name
uint   lui_len
int    li_rc
string ls_temp

lui_len = 255
ls_temp = space( 255 )
li_rc = WNetGetUser( ls_temp, lui_len )
login_name = Trim( ls_temp )

32-bit程序
//外部函数说明
Function boolean GetUserNameA( ref string userID, ref ulong len ) library "ADVAPI32.DLL"

Powerscript脚本
string  login_name
string  ls_temp 
ulong   lul_value
boolean lb_rc

lul_value = 255
ls_temp = Space( 255 )
lb_rc = GetUserNameA( ls_temp, lul_value )
login_name = Trim( ls_temp )

Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 22:08:05Z 得分:0
下面的例子给出了通过调用Novell API来获取用户名的方法: 
1.说明下面的外部函数:

function ulong NWInitialize() library "NWInfo"
function ulong NWGetInfo( Long Drv, Long info, ref string buffer ) Library "NWInfo"
2.然后定义一个函数并加入下面的程序

// i_sys=1 - novell
string login_name
string ls_temp
integer drv,info
long l_ret

login_name = "user_name_error"

if i_sys = 1 then   // novell login name.
	l_ret = NWInitialize()    // init the dll, check for client 32 ...
	if l_ret  = 0  then
		drv = 7 // network drive g:
		info = 35 // typeless user name 
		ls_temp = Space( 129 )
		//  get the login name for specific drive
		l_ret = NWGetInfo( drv, info, ls_temp )
		if l_ret = 0 then
			login_name = Trim( ls_temp )
		end if
	end if			
end if

return login_name

Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 22:12:15Z 得分:0
利用Api函数ShellAboutA可以显示一个与Windows操作系统风格一致的About对话框    
关键字     显示一个与Windows操作系统风格一致的About对话框:
首先声明如下外部函数: 
function int ShellAboutA(ulong al_hWnd, string as_szApp, string as_szOtherStuff,  ulong hIcon) library "shell32.dll" 

ShellAboutA(handle(parent),"关于学籍管理系统","欢迎使用学籍管理系统",0)  


在应用程序中启动控制面板 

在应用程序中启动控制面板,只需用ShellExecute函数打开对应的CPL文件即可,例如要在应用程序中修改Windows密码,只需打开Password.cpl文件,启动ODBC管理器只要打开ODBCCP32.CPL。

函数声明:
Function Long ShellExecute(Long hwindow, String lpOperation, String lpFile, String lpParameters, String lpDirectory, Long nShowCmd) Library 'shell32.dll' Alias for ShellExecuteA 
Function Long GetDesktopWindow() Library 'user32.dll' 

脚本如下:
String ls_cpl_name 
String ls_null 

SetNull(ls_null) 
ls_cpl_name = "Password.cpl" 

ShellExecute(GetDesktopWindow(), ls_null, 'rundll32.exe', "shell32.dll,Control_RunDLL " + ls_cpl_name + ",", ls_null, 0) 

 将指定的窗口带至窗口列表顶部 
在应用程序中有时我们需要用Bringwindowtotop将指定的窗口带至窗口列表顶部。倘若它部分或全部隐藏于其他窗口下面,则将隐藏的部分完全显示出来。但是在某些情况下这个函数并不能达到我们想要的效果,倘若某窗口并非前台应用程序的一部分,那么一旦随同该窗口调用本函数,仍会将窗口带至它自己那个应用程序的窗口列表顶部。但是,不会同时使那个应用成为前台应用程序。这意味着在调用了本函数后,窗口仍会保持隐藏状态。那么如何使应用成为前台应用呢?我们可以使用SetForegroundWindow函数。

例如:
FUNCTION long FindWindowA( ulong Winhandle, string wintitle ) Library "user32" 
FUNCTION ulong SetForegroundWindow(ulong hwnd) LIBRARY "user32.dll" 

long ll_winhandle 


ll_winhandle=FindWindowA( 0, "test" ) 
if ll_winhandle >0 then 
SetForegroundWindow(ll_winhandle) 
end if 
 
获得Windows系统目录 
在应用程序中有时需要用到Windows系统目录,用GetWindowsDirectory函数即可实现。


首先声明如下外部函数:
Function uint GetWindowsDirectoryA( & 
ref string dirtext, uint textlen) & 
library "KERNEL32.DLL"

 Script如下:
String ls_WinPath 
ls_WinPath = Space( 128 ) 
GetWindowsDirectoryA( ls_WinPath, 128 ) 
 

用ExitWindowEx关闭系统 
为方便用户,有时需要在应用程序中增加退出并关闭计算机的功能,其实只要几行代码即可实现。首先声明API函数:

Function long ExitWindowsEx (long uFlags , long dwReserved ) Library "user32" 
然后在程序中调用:

ExitWindowEx( 1, 0 )

参数型及说明: 
uFlags Long,指定下述一个或多个标志(用OR运算符合并到一起) 
EWX_FORCE 强迫中止没有响应的进程 
EWX_LOGOFF 中止进程,然后注销 
EWX_SHUTDOWN 关掉系统电源(如果可能的话,ATX电源就可以) 
EWX_REBOOT 重新引导系统 
EWX_SHUTDOWN 关闭系统 

dwReserved Long,保留,设为零
 


 

Top
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 2003-05-24 23:25:32Z 得分:0
多谢老刀兄的捧场,大家共同学习提高!
自已再来添把火!
用API函数实现显示隐藏任务栏!
首先声明如下外部函数: 
Function long FindWindowExA ( long hWnd, long hWndChild, ref string pszClassName, ref string lpszWindow) library 'user32'
Function long ShowWindow  (long hWnd, long nCmdShow ) library 'user32' 
在Script中加入如下内容:
Constant Long SW_HIDE = 0
Constant Long SW_NORMAL = 1
Constant Long SW_SHOWMINIMIZED = 2 
Constant Long SW_SHOWMAXIMIZED = 3 
Constant Long SW_SHOWNOACTIVATE = 4
Constant Long SW_SHOW = 5 
Constant Long SW_MINIMIZE = 6 
Constant Long SW_SHOWMINNOACTIVE = 7
Constant Long SW_SHOWNA = 8 
Constant Long SW_RESTORE = 9
Constant Long SW_SHOWDEFAULT = 10
String ls_ShellTaskBarWnd = "Shell_TrayWnd" 
String ls_isnull 
Long ll_HTaskBar, ll_HDeskTop 
ll_HTaskBar = FindWindowExA( 0, 0, ls_ShellTaskBarWnd, ls_Null )
ShowWindow( ll_HTaskBar, SW_HIDE ) 
MessageBox( "你好", "看不到任务栏了吧!呵,确定就恢复了!" ) 
ll_HTaskBar = FindWindowExA( 0, 0, ls_ShellTaskBarWnd, ls_Null ) 
ShowWindow( ll_HTaskBar, SW_SHOW )

其中脚本可以另外写,做到开关任务栏效果!!爽吧!
我的实例一直在做着!!


Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 23:27:50Z 得分:0
用WinHelpA函数显示Pop-Up帮助 

First, go to the Window painter and select Declare, Global External Functions from the menu. Paste this declaration: 
FUNCTION integer WinHelpA(long hWnd, string lpHelpFile, integer wCommand, integer dwData) LIBRARY "User32.dll" 
This tells PowerBuilder how to call a function that resides in a DLL. 

Next, you create a help file with indexed topics using a tool like Doc-to-help or RoboHelp. Here's the code you would put in some event that corresponds to the user hitting F1, or whatever: 
WinHelpA(handle(parent), "application.hlp", 8, 1) 

This example comes from a control on a window. The first parameter gets a handle to the window, which is the control's parent. "application.hlp" is your help file. The number "8" tells the function to display the yellow context-sensitive help. The last parameter, a "1" in this example, means topic number 1
 

在PB中调用外部程序并判断其运行结束 
在PB中经常要调用外部程序并等待此程序运行结束后显示相关信息。如我们要备份Adaptive Server Anywhere 6.0数据库,在备份结束后显示"备份完成!"的提示信息,如果在调用备份程序dbbackup后马上用messagebox显示提示信息,那么程序运行时则会出现这种情况: dbbackup备份程序还在运行,"备份完成!"的提示就已经显示了,显然不符合我们的设想。对于这种情况,我们可以借助API函数FindWindowA()、IsWindow()和PB本身函数yield()来解决。

声明API函数:
Function long FindWindowA (String lpClassName , String lpWindowName ) Library "user32.dll" 
Function boolean IsWindow (Long hwnd ) Library "user32.dll"

调用:
ulong ll_handle
int li_loop

SetPointer(HourGlass!) //设置鼠标指针
//运行备份数据库程序dbbackup,并使其最小化
run("dbbackup -c ~"uid=dba;pwd=sql; dbf=D:\Sybase\Adaptive Server Anywhere 6.0\asademo.db~" d:\backup", Minimized!)

ll_handle = 0
//循环至dbbackup窗口打开
Do While ll_handle = 0
    ll_handle = FindWindowA("tty","dbbackup")
    yield() //
loop    
//等待dbbackup窗口关闭
Do While isWindow(ll_handle)
    Yield()
Loop
//应用执行完成
MessageBox("提示信息", "备份完成!")
 

关键:WindowsAPI函数:sndPlaySoundA和waveOutGetNumDevs   新建标准(Standard)用户自定义对象(user object)uo_command,在“Select Standard Visual Type”框中选择“commandbutton”。 在用户对象中, 1)定义Local External Functions,主要用到了两个API函数:sndPlaySoundA和waveOutGetNumDevs。 Function boolean sndPlaySoundA (string SoundName, ulong Flags) Library "WINMM.DLL" Function ulong waveOutGetNumDevs () Library "WINMM.DLL" 2)定义实例变量(Instance Variables): string is_soundfile = 'default.wav',其中,“default.wav”为按扭默认发出的声音。 3)定义用户事件:ue_setsoundfile(无须填事件ID),主要用于设置您需要播放的文件名,例如 : is_soundfile = 'xxx.wav' ,按扭就播放文件名为 xxx.wav的声音文件。在用户在窗口中加入该控件(用户对象)时使用,以修改按扭的播放声音。 定义完以上几项后,在按扭的Clicked事件中写入: //修改播放声音文件 This.TriggerEvent("ue_setsoundfile") //开始播放Wav ulong lul_numdevs lul_numdevs = WaveOutGetNumDevs() If lul_numdevs > 0 Then sndPlaySoundA(is_soundfile, 1) End If 到此便大功告成。你只需在窗口中加入该对象,在ue_setsoundfile事件中写入is_soundfile = 'xxx.wav',会发声的按扭便OK了。
Top
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 2003-05-24 23:28:28Z 得分:0
上面定义写错了 string ls_isnull 应写成string ls_null!

//--------------------------------------------------
数据类型转换表  
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 

Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 23:28:53Z 得分:0
制作会出声的按扭 

关键:WindowsAPI函数:sndPlaySoundA和waveOutGetNumDevs   新建标准(Standard)用户自定义对象(user object)uo_command,在“Select Standard Visual Type”框中选择“commandbutton”。 在用户对象中, 1)定义Local External Functions,主要用到了两个API函数:sndPlaySoundA和waveOutGetNumDevs。 Function boolean sndPlaySoundA (string SoundName, ulong Flags) Library "WINMM.DLL" Function ulong waveOutGetNumDevs () Library "WINMM.DLL" 2)定义实例变量(Instance Variables): string is_soundfile = 'default.wav',其中,“default.wav”为按扭默认发出的声音。 3)定义用户事件:ue_setsoundfile(无须填事件ID),主要用于设置您需要播放的文件名,例如 : is_soundfile = 'xxx.wav' ,按扭就播放文件名为 xxx.wav的声音文件。在用户在窗口中加入该控件(用户对象)时使用,以修改按扭的播放声音。 定义完以上几项后,在按扭的Clicked事件中写入: //修改播放声音文件 This.TriggerEvent("ue_setsoundfile") //开始播放Wav ulong lul_numdevs lul_numdevs = WaveOutGetNumDevs() If lul_numdevs > 0 Then sndPlaySoundA(is_soundfile, 1) End If 到此便大功告成。你只需在窗口中加入该对象,在ue_setsoundfile事件中写入is_soundfile = 'xxx.wav',会发声的按扭便OK了。
Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 23:30:06Z 得分:0
Windows帮助诀窍 
PowerBuilder提供的ShowHelp函数允许在程序在存取Help文件中的基本元素。在windows 3.1系统下,它的使用是很顺利的,但是当Windows 9X与NT 4出现之后,该函数并没有作出相应的改变,其使用会出现一些问题。engine in Windows 95 and Windows NT 4. 

有两个特殊的细节是很有用的,第一个是存取Help对话框中新的内容表,按照如下的方法使用ShowHelp函数,可使PowerBuilder程序打开Help文件的索引标签。

ShowHelp( 'pbbdrtray.hlp', KeyWord!, '' )
但是如果能存取第一个tab标检,程序会显得更专业。

第二是,可能使帮助引挚弹出一个弹出式窗口来显示帮助文件的内容,就像你在OS的标准对话框中点出?图标一样,这是帮助引挚的标准功能。

执行这一功能的API函数是WinHelp,因此要PB执行这个功能需要使用API函数调用: 

function long WinHelpA(ulong hwind, string lpszHelp, uint uCommand, ulong dwData) library "user32" 

注意:在调用该函数是需要在名称后加A,以表示我们传递函数的是ASCII字符类型的参数而不是Unicode类型的字符串。

然后我们为函数说明参数,具体的参数内容及意义可以参见该函数的C语言.H文件。ts as such:

Protected:
integer HELP_CONTEXT = 1
integer HELP_CONTENTS = 3
integer HELP_CONTEXTPOPUP = 8
integer HELP_FINDER = 11
这样我们就可以调用这个API函数来完成我们想要执行的功能。 

The first function will open the 3 tab dialog with the first tab showing.

WinHelp( 0, , HELP_FINDER, 0 )
This next function will display a help popup for a given help topic.

WinHelp( 0, , HELP_CONTEXTPOPUP,  )
These functions and a few others for accessing the WinHelp engine are built into a small object and available for download from the Software Page.
 

Top
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 2003-05-24 23:30:34Z 得分:0
PB环境中使用API函数让程序中切换中英文输入法  
函数声明: function boolean ImmSimulateHotKey (ULong hWnd, ULong dwHotKeyID) library "IMM32.dll" 
function ulong GetKeyboardLayout(ulong dwLayout) LIBRARY "user32.dll" 
function boolean ImmIsIME(uLong hklKeyboardLayout) library "IMM32.DLL" 
脚本如下: 
constant int IME_THotKey_IME_NonIME_Toggle=112 
ulong hklCurrent ulong hnd 
//切换到英文输入法 
hklCurrent=GetKeyboardLayout(0) 
if ImmIsIME(hklCurrent) then 
hnd=Handle(parent) 
ImmSimulateHotKey(hnd,IME_THotKey_IME_NonIME_Toggle) 
end if 
//切换到中文输入法 
hklCurrent=GetKeyboardLayout(0) 
if not ImmIsIME(hklCurrent) then 
hnd=Handle(parent) 
ImmSimulateHotKey(hnd,IME_THotKey_IME_NonIME_Toggle) 
end if 

Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 23:32:06Z 得分:0
Win32 API函数与PB编程 



            1. 如何使PB窗口总在最上层 

            通过SetWindowPos函数吧窗口的显示层次修改为HWND_TOPMOST,就可以使指定窗 

            口永远不会被其他窗口覆盖,该函数声明为: 

            Function Long SetWindowPos(Long hwnd, Long ord, Long x, Long y, Long 

            dx, Long dy, Long uflag) Library “user32.dll” 

            参数1为要顶层显示的窗口句柄,参数2指定显示的层次,参数7为附加选项,其余 


            参数指定窗口位置和大小,均可忽略。在窗口的Open或Activate事件中加入如下 

            函数调用: 

            SetWindowPos(Handle(This),-1,0,0,0,0,3) 

            参数2取-1表示在最顶层显示窗口,取1表示在最底层显示;最后一个参数若取1, 

            表示窗口大小保持不变,取2表示保持位置不变,因此,取3(=1+2)表示大小和 

            位置均保持不变,取0表示将窗口的大小和位置改变为指定值。 



            2. 在PB中如何获得光盘盘符 

            通过GetDriveType函数可以获取驱动器(如:软驱、硬盘、光驱、网络映射驱动 

            器等)的信息,该函数声明为: 

            Function Unit GetDriveTypeA(String drive) Library “kernel32.dll” 

            参数为一个盘符(如“C:”),返回值:1表示未知,2表示软驱,3表示本地硬盘 

            ,4表示网络驱动器,5表示光驱。因此如下代码可以获得光盘的盘符: 

            For I=Asc(‘D’) to Asc(‘Z’) 

            //列举所有可能的CDROM的驱动器 

            If GetDriveTypeA(Char(i)+”:”) = 5 Then 

            //若找到CDROM 

            Messagebox(“CDROM”,Char(i)+”:”) 

            //显示光盘盘符 

            Exit //退出循环 

            End if 

            Next 



            3. 在PB中如何获取目录信息 

            (1) 获取当前目录。通过GetCurrentDirectory函数可以获取当前目录,该函数 

            声明为: 

            Function Ulong GetCurrentDirectory(Ulong buflen,ref String dir) 

            Library “kernel32.dll” 

            参数2为接受当前目录的字符缓冲区,前面必须加ref表示地址引用;参数1用来指 

            定字符缓冲区的长度。调用过程为: 

            String curdir 

            Curdir=Space(256) 

            //为字符缓冲区开辟内存空间 

            GetCurrentDirectory(256,curdir) 

            MessageBox(“当前路径”,curdir) 

            (2) 获取Windows及系统目录。要用到GetWindowsDirectory和GetSystemDirec 

            tory两个函数,须作如下声明: 

            Function Uint GetWindowsDirectoryA(ref String dir,Uint buflen) 

            Library kernel32.dll” 

            Function Uint GetSystemDirectoryA(ref String dir,Uint buflen) 

            Library "kernel32.dll” 



            4. 在PB中如何注销当前用户、关闭计算机、重启计算机 

            通过ExitWindowsEx函数可实现这三个功能,首先作如下声明: 

            Function Long ExitWindowsEx(Long uflag, Long nouse) Library "user32.dll” 

            参数2保留不用,可取0;参数1取0可以注销当前用户,取1可以关闭计算机,取2 

            可以重启计算机,其值再加4表示强制结束“未响应”的进程。 



            5. 控制由Run运行的程序(简称Run程序) 

            在PB程序设计中,可以用Run()来运行一些程序。但Run程序无法与PB主程序协调 

            工作,若用户多次调用,就会启动Run程序的多个实例,主程序退出时,Run程序 

            依然运行。可以用如下函数使它们协调工作: 

            Function Ulong FindWindowA(Ulong classname, String windowname) 

            Library "user32.dll” 

            Function Long SetParent(Long childwin, Long parentwin) Library "user32.dll” 

            (1) 使Run程序只运行一个实例 

            handle = FindWindowsA(nul,wtitle) 

            //查找Run程序是否已经运行,wtitle为Run程序的窗口标题 

            If handle > 0 Then Return 

            //若已经在运行就返回 

            Run(“c:\luhan.chm”) 

            //否则运行Run程序 

            (2) PB主程序退出时,Run程序也关闭 

            Handle = FindWindowA(nul,wtitle) 

            SetParent(handle,Handle(w_main)) 

            //使Run程序窗口成为PB主程序的子窗口 



            6. 映射网络驱动器 

            若要在程序中把远程主机的资源映射到本地驱动器,可以用如下函数: 

            Function Long WNetAddConnectionA(String path, String pwd, String drv)  

            Library “mpr.dll” 

            如下代码可以把远程主机Alexander上的共享文件夹My Documents映射到本地的J 

            盘: 

            WnetAddConnectionA(“\\ Alexander\ My Documents”,””,”J:”) //参数2 

            为访问口令 

            它的作用相当于在DOS提示符下执行:Net Use J: \\ Alexander\ My Documents 



            7. 显示或隐藏Windows的任务栏 

            要显示或隐藏任务栏,首先要得到它的窗口句柄。任务栏是一个特殊的窗口,它 

            的窗口类为:Shell_TrayWnd,没有标题,故只能用FindWindowEx函数来取得它的 

            句柄: 

            Function Long FindWindowEx(Long ph, Long ch, ref String cn, ref 

            String wn) Library “user32.dll” 

            Function Long ShowWindow(Long hWnd, Long nCmdShow) Library “user32.dll” 

            用ShowWindow来显示或隐藏窗口,其第二个参数为0表示隐藏,为5表示显示: 

            handle = FindWindowEx(0,0,” Shell_TrayWnd”,wn) //wn为空串 

            ShowWindow(handle,0) //隐藏任务栏 



            8. 如何将长文件名转换为短文件名 

            通过GetShortPathName函数可以把上文件名转换为8.3格式,其声明为: 

            Function Long GetShortPathNameA(String lf, ref String sf, Long 

            buflen) 

             Library “kernel32.dll” 

            参数1为长文件名,参数2为保存短文件名的缓冲区,参数3为缓冲区长度。例如: 



            GetShortPathNameA(“C:\My Document\Powerbuilder编程实践.Doc”,sf,256) 

            \ 

            //sf = Spcace(256) 



            9. 如何在PB中实现延时 

            延时函数很有用,PB虽然没有提供,但可以通过Wind32的Sleep函数来扩展: 

            Function Long Sleep(Long ms) Library “kernel32.dll” 

            调用:Sleep(1000) //延时1秒 



            10. 如何在PB中播放音乐 

            PB没有提供任何多媒体函数,要播放音乐只能通过Win32 API的PlaySound来实现 

            : 

            Function Long PlaySound(String Filename, Int Mod, Int Flags) Library 

            “ winmm.dll” 

            参数1为wav文件名,参数2必须取0,参数3取1表示后台播放,取8表示循环播放, 

            因此取9(=1+8)表示在后台循环播放。 

 

Top
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 2003-05-24 23:33:16Z 得分:0
在PB中如何实现音乐的播放! 
方法一

1、声明外部函数
FUNCTION boolean sndPlaySoundA (string SoundName, uint Flags) LIBRARY "WINMM.DLL"
Function Uint LoadLibraryA(String As_Library) Library "kernel32.dll"
Subroutine FreeLibrary (Uint Hinstance) Library "kernel32.dll"
2、程序如下:
Uint Lu_instance
Lu_instance = LoadLibraryA("winmm.dll")
if Lu_instance = 0 then
    SndPlaySoundA("c:\windows\media\chimes.wav",1)
    FreeLibrary(Lu_instance)
end if
3、存在问题:
如何播放格式的音乐?

方法二:

1、声明外部函数
Function Uint ShellExecuteA (Uint hwndId,ref string op,ref string file,ref string parms,ref string dir,Uint show) library "shell32.dll"
Function Uint LoadLibraryA (String As_Library) Library "kernel32.dll"
Subroutine FreeLibrary (Uint Hinstance) Library "kernel32.dll"
2、程序如下:
String Ls_path,ls_file,ls_parms,ls_dir,ls_command
Uint lu_return,lu_instance
SetNull(ls_parms)
//check to see if the dll is available.Return number < 32 if not Lu_Instance = LoadLibraryA("shell32.dll")
if Lu_Instance <> 0 then
    MessageBox("操作提示","SHELL32.DLL动态库不存在!")
else
    //Shell32.dll is here.Get a filename from the user
    GetFileOpenName("打开文件",ls_path,ls_file,"*","All Files (*.*),*.*")
    if ls_path <> "" then
        SetPointer(HourGlass!)
        //Examine the checkbox for open or print configuration
        if cbx_print.checked then
            ls_command = "print"
        else
            ls_command = "open"
        end if
        //call the function.pass the parent as the ower.run normal.
        Lu_return = ShellExecuteA(Handle(parent),ls_command,ls_path,ls_parms,ls_path,1)
        //check for errors from function
        if lu_return < 32 then
            MessageBox("操作提示","程序执行非法操作! ~r~n" + ls_path)
        end if
    end if
    //free the resources from the dll since it was loaded with the loadlibrary call
    FreeLibrary(lu_instance)
end if
注:本方法可运行任何文件,当然可以播放音乐文件 和动画文件。在sndPlaySoundA() 的函数定义中,把 string SoundName 定义成 ref string SoundName,再试试,反正这个函数的原型就是有 ref 的。

Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 23:35:25Z 得分:0
16位DLL调用约定 
经常有人问我,如何写可由PowerBuilder调用的DLL函数的C语言代码,下面是一个没有具体算法的例子: 
//-------------------
// LibMain
//-------------------
int __export CALLBACK LibMain(HANDLE hModule, 
   WORD wDataSeg, WORD cbHeapSize,
   LPSTR lpszCmdLine)
{
     
    return 1;
}
     
//-------------------
// WEP
//-------------------
int __export CALLBACK _WEP (int bSystemExit)
{
     
    return 1;
}
     
void __export FAR PASCAL Encrypt ( LPSTR Password ) 
{
}
     
void __export FAR PASCAL Decrypt ( LPSTR Password ) 
{
}
 


传递一个结构给DLL函数 
传递一个结构或字符串指针给一个DLL函数很容易使人感到困惑,把它定义成一个引用参数(ref),但是:

1)如何传递在另一个结构中的指针呢?

还有...

2) 如何将一个在SDK中预先定义的long参数传递给字符串或结构指针呢?

还好... 记得“老”C语言的strcpy吗?! 它可以将一个指针返回到一个字符串之中,不过它已经改名为lstrcpy,并且在kernel32.dll动态链接库之中了。 

函数指针
建立一个用户对象并说明以下的局部外部函数

function long lstrcpy(ref string lpString1,ref string lpString2) library "kernel32.dll" 

说明以下用户对象函数

 long of_StringPointer(ref string ps_string)
 {
 string foo

 foo = ps_string

 return lstrcpy(foo, ps_string)
 }

结构指针
建立一个用户对象并说明以下的局部外部函数

function long lstrcpy( & ref MyOversizedStructure lpMyOversizedStructure,& ref string lpString2) library "kernel32.dll" 

说明以下用户对象函数


long of_MyStructurePointer( & ref MyOversizedStructure ps_structure) 

{ string foo

foo = "" 

return lstrcpy(ps_structure, foo) 

} 

你也许会说"return lstrcpy(ps_structure, ps_string)"将覆盖了ps_sturcture结构的第一个字节。嗯...我们将结构定义为MyOversizedStructure,将它在第一个有用的字段前面定义一个额外的字节,就像下面一样:

typedef MyOversizedStructure 
{ long il_i_will_be_overwitten
[datatype] [yours structure 1st field]
[datatype] [yours structure 2nd field]
[datatype] [yours structure 3rd field]
...
} 

现在,函数如下... 

 long of_MyStructurePointer( &
     ref MyOversizedStructure ps_structure)
 {
 string foo

 foo = ""

 return lstrcpy(ps_structure, foo) + 4
 }

'+4'将跳过il_i_will_be_overwitten中多余的字段

Remember that the address is only good as far as you do not assign values to fields within the structure i.e 

 pointer_before = of_MyStructurePointer(my_structure)
 my_structure.my_field = some_value
 pointer_after = of_MyStructurePointer(my_structure)

'pointer_before' might be different from 'pointer_after'
 

没有拖放入口 
我已经为PB编写的一些新的部件,这些部件具有标准的PowerBuilder部件的拖放特性。我想让这些新的部件具有标准的PB控件的拖放特性:当拖动它时,根据是否允许拖入而显示不同的图标(光标),但我不知道如何完成这种工作,SetPointer函数是不能完成的。因此我只好查找API参考手册,并找到如下的解决办法:

1.在窗口中说明以下API函数调用: 

function long LoadCursorA( long al_happ, long al_hind ) library 'user32'
function long SetCursor( long al_hcur ) library 'user32'
function boolean DestroyCursor( long al_hcur ) library 'user32'
2.定义一个长整型的实例变量il_Image,然后中OPEN事件中加入以下代码

//32648 is the constant for the no entry cursor
Long IDC_NO = 32648 
il_Image = LoadCursorA( 0, IDC_NO )
3.在自定义的对象中的dragwithin事件中增加以下代码:当一个对象不允许拖动到该对象时,将显示没有入口的光标

IF source = dw_top THEN	
	// if the user drags from the tree, display the system
	// no entry symbol.
	SetCursor( il_Image )
END IF
4.最后一步是清除分配给光标的空间

DestroyCursor( il_Image )
 


在PB中实现热键功能的方法  (张 涛)
 
     
在程序中添加一些热键可以让用户更加快速实现某些功能,对于一些熟练的操作人员,他们更容易接受快捷键。例如大家熟悉的金山词霸,一般情况下她处在系统光标区,用户可以通过Ctrl+Alt+F1组合键来切换是否屏幕取词。那么如何让我们的程序也能实现这个功能呢?下面作者就介绍实现方法:
    1、首先我们必须声明Windows API的外部函数:
          function long SendMessageA(long lhWnd,uint uiMsg,long lwMsg,long lwParam) library 'user32.dll'
    2、接下来,我们必须给一些需要用到的定量赋上初始值。
    Public:
        Constant Long WM_SETHOTKEY = 50 //设置热键消息值
        Constant Long HK_MYHOTKEY = 1648 //热键参数值
        Constant Long SC_HOTKEY = 61776 //PB中的热键消息
    其中,HK_MYHOTKEY不是固定的,它根据用户的需要而定。它的具体值通过如下方法确定的:高8位字节 + 低8位字节组成16为字节,然后将她换算到十进制即得到所需的HK_MYHOTKEY值。高8位字节值为一些辅助键(Control、Alt、Shift等),低8位字节为你想使用的键的ASCII码。例如:A=65..Z=90,Shift=1,Control=2,Alt=4,Extended=8,F1=112..F12=123等,如果我们要使用Ctrl+Alt+A作为热键,则A=65,转换成十六进制为41,Ctrl+Alt=2+4=6,转换成十六进制仍然是6,两则组合即为641,再重新转换回十进制得到1601;同样,如果我们用Ctrl+Alt+F1作为热键,F1=112,可以得到HK_MYHOTKEY值应为1648。
    3、接下来,我们必须利用下面代码告诉窗口我们的热键:
//在窗口的Open事件中
long ll_RC

ll_RC = SendMessageA(Handle(this), WM_SETHOTKEY, HK_MYHOTKEY, 0)
if ll_RC <> 1 then
messagebox("错误","错误信息")
end if
    4、最后,编写当用户按下热键时的处理程序:
//在窗口的Other事件中
IF wparam = SC_HOTKEY THEN
    This.Show()
//在这里编写处理程序
END IF

 
 

Top
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 2003-05-24 23:37:26Z 得分:0
屏蔽窗口的ALT+F4键  
方法一:
1.在窗口的systemkey事件中增加以下代码:
IF KeyDown(KeyF4!) THEN 
  Message.Processed = TRUE 
END IF 
2.在窗口的closequery事件中增加如下代码:
Long ll_ret 
IF KeyDown(keyF4!) THEN 
   ll_ret = 1 
END IF 
return ll_ret 
方法二:
建一实例变量,在你的关闭程序上赋一个True然后在closequery中判断该值, 如为False则Return1
//-------------------------- 
在PB的数据窗口中,如何捕捉dropdowndw列的上下键事件 
 
DDDW 事件概述 
⒈所有对DDDW的操作都通过触发pbm_command事件完成 
① 在PB的用户事件中,大多数事件对应的Windows 事件都有两个参数:lparam 和 wparam,而在PB5.0中,pbm_command没有参数,但可以通过message对象的两个属性取得Windows事件对应的Event ID,这两个属性就是: LongParm 和 WordParm。 LongParm 包含DDDW的Handle,用intLow()可取得其Handle WordParm 包含对DDDW的操作,用intHigh()可取得其Event ID
② 在PB6.0(^)中,pbm_command带3个参数,其中hwndchild(long)与notificationcode(unsignedinteger)即DDDW的Handle和Event ID。 
⒉DDDW 的Event ID 列表: 
Event Event ID
------------------------------- 
Clicked 1281 
RowFocusChanged 2048 
RightMouseButtonDown 2314 
Left Button Up 2313 
Retreive End 769 
MouseMove 2311 ... 至于问题中的上下滚动,倘为键盘,将导致行焦点改变(此外,还导致一个ID = 2049的事件): 
RowFocusChanged 2048 倘为鼠标点击滚动条上下按钮: 
PageUp/PageDown 2339 
 

Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 23:37:27Z 得分:0
在最近访问的文件中增加文件 
Windows有一个很酪的特色,它可以显示很多在资源管理器或其他应用程序中打开的文件。但不幸的是你需要在应用程序中由程序自己将文件加入到最近访问文件列表之中。你可以通过调用API函数在你编写的程序中将文件加入到最近访问文件列表之中。 
1.定义一个局部的外部函数:

Subroutine SHAddToRecentDocs( uint dwFlags, ref string dwData ) &
   Library 'shell32.dll'
2.然后在程序中加入以下代码:

Long ll_SHARD_PATH = 2
String ls_File
    
// Replace the next line with your own file
ls_File = 'c:\ken.txt'
SHAddtoRecentDocs( ll_SHARD_PATH, ls_file )
每当执行上面这段程序时,文件将会加入到最近访问文件列表之中,如果给SHAddtoRecentDocs传递一个Null参数,将清空最近访问文件列表
 


Long类型中的两个短整型数  
有时调用windows的外部函数时需要使用Long,我们知道Long类型的数据在内存中占4个字节,而在程序中有时需要分别其中的两个字节,这时你可以使用IntLow()与IngHigh()两个函数,例如:

Long ll_2Ints Integer li_one, li_two someexternalfunction( ll_2Ints ) li_one = IntHigh( ll_2Ints ) li_two = IntLow( ll_2Ints )
 

在PowerBuilder中调用ChooseColor函数 
 

首先创建一个Custom user object并定义如下Structure(OS_ChooseColor): 

long lstructsize 
ulong hwndowner 
ulong hinstance 
long rgbresult 
blob lpcustcolors 
long flags 
long lcustdata 
long lpfnhook 
long lptemplatename 

定义实例变量: 
Private: 

os_ChooseColor istr_ChooseColor 
long il_CustomInitColors[16] 
blob{64} ibl_CustomColors 

定义外部函数:: 

function boolean ChooseColorA( REF os_ChooseColor lpcc ) library "comdlg32.dll" 

在 constructor 事件中写入如下代码:: 


// initialize choosecolor information 
// convert the default custom color array to a blob variable blobedit(ibl_customcolors,1,il_custominitcolors) 

// let the structure element point to the blob array 
istr_choosecolor.lpcustcolors = ibl_customcolors 

// set the size 
istr_choosecolor.lStructSize = 36 

// no owner 
SetNull(istr_choosecolor.hwndOwner) 

// set flag 
istr_choosecolor.flags = 1 

创建对象函数:boolean of_choosecolor(ref long al_rgbresult) ,代码如下: 

boolean lb_ok 
istr_ChooseColor.rgbresult = al_rgbresult 
lb_ok = ChooseColorA ( istr_choosecolor ) 
al_rgbresult = istr_ChooseColor.rgbresult 
return lb_ok 
 


Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 23:41:24Z 得分:0
WIN2000 WIN98 WINNT下的
PB环境中使用API函数让程序中切换中英文输入法  

定义实例变量
long layout_handle,lay_old
说明函数
Function unsignedlong ActivateKeyboardLayout(unsignedlong HKL, string flags) library "user32.dll" 
FUNCTION ulong GetKeyboardLayoutName(ref string pwszKLID) LIBRARY "user32.dll" ALIAS FOR "GetKeyboardLayoutNameA"
在数据窗口中的itmefocuschanged中写:
long ll_lay
ll_lay=GetKeyboardLayout(layout_handle)
if ll_lay<>134481924 then
	lay_old=ll_lay
end if

if  dwo.name="name"  or dwo.name="mo_name" or dwo.name="sex"  then 
	//输入法设为中文
	//"name" , "mo_name" ,"sex"为字段名,根据自己的修改
	if lay_old<>0 and lay_old<>134481924 then
		ActivateKeyboardLayout(lay_old,"KLF_SETFORPROCESS")
	else
		ActivateKeyboardLayout(layout_handle,"KLF_SETFORPROCESS")
	end if

else //输入法设为英文
	ActivateKeyboardLayout(134481924,"KLF_SETFORPROCESS")
end if
在注册表里
HKEY_CURRENT_USER\Keyboard Layout\Preload
有输入法的值
智能ABC   FFFFFFFFE0040804	-536606716
微软拼音  FFFFFFFFE00E0804	-535951356
王码五笔  FFFFFFFFE0100804	-535951356
英文	  			 134481924

Top
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 2003-05-24 23:41:38Z 得分:0
SQL Anywhere 数据库的LOG文件丢失,无法连接数据库,该怎么办? 
用 ISQL 连接一次  
///------------------------------------
如何将主窗口永远在最上层? 如何使应用程序窗口位于其他窗口上 
Windows 3.1介绍一个最顶窗口的概念。最顶窗口即使不是活动的窗口也在其 他非最顶窗口之上。如果要创建一个最顶窗口,要指定WS_EX_TOPMOST扩展窗口风格, 运行时可以调用CWnd : : SetWindowPos增加和删除最顶风格,调用 CWnd : : GetExStyle 可以确定是否设置了最顶风格。下面的例子函数双向设置一个指定窗口的最顶风格。 
void ToggleTopMost (CWnd* pWnd ){ ASSERT _VALID (pWnd); pWnd->SetWindowPos (pWnd—> GetExStyle ( ) & WS_EX_TOPMOST) ?&wndNoTopMost : &wndTopMost , 0 , 0 , 0 , 0 , SSP_NOSIZE |WSP_NOMOVE) ;} //////////////////////////////////////////////////// 当然,可以调用API函数,有很多方法获得主窗口的句柄 可以直接传,也可以用findwindow() API  
//----------------------
怎样使动态建立的数据窗口可修改? 
dw_1.Object.DataWindow.Table.UpdateWhere = 0 
dw_1.object.dept_name.update = "yes" 
dw_1.Object.dept_id.key = "yes" 
dw_1.update()  
//----------------------
动态设置Win和NT的缺省打印机  
//STEP 1: Get the current default printer name. string ls_default RegistryGet("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device", ls_default) 
sle_def.text = ls_default 
//Step 2: Set a new default printer name.
int li_rtn li_rtn = RegistrySet("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", & "Device", sle_new.text) 
if li_rtn = 1 then 
Messagebox("Setting new printer name", "Successful") 
else
Messagebox("Setting new printer name", "Failed") 
end if 
//---------------------------
Powerbuilder 与UNIX版本的SYBASE相连接的问题客户机: 
PWIN98 SYBASE OPEN CLIENT , POWERBUILDER6.5服务器 SCO UNIX OPENSERVER 5.0.5 SYBASE SYSTEM 11.0.3两机使用D-LINK 220P网卡相 连,可互相PING通,客户机也可TELNET到服务器在客户机上用DSEDIT设置连接信息,选用NLWNSCK协议, SERVER名,IP地址及断口号均正确,可PING SERVER 不能成功,其他协议没有相应的DLL文件,在PB 中直 接用PROFILE文件连接提示错误如下:
CT_CONNECT() NETWORK PACKET LAYER: INTERNL NET LIBRARY ERROR: NET_LIB PROTOCOL DRIVER CALL TO CONNECT TWO ENDPOINTS FAILED。
请各位高手指教,如何用PB连通sybase 11 ,谢谢!
即然能ping通,那么说明网络是通的,ping server不通,证明sybase客户端未配置好,pb中当然不通。
sybase客户端软件的版本可能选择了16位,bin/winsql运行不了!建议重新安装syabse客户端,选择32位。 
只有bin/winsql能连接上数据库时,才证明能连上数据库。 
//-------------------------------------
如何编写“进度”指示条? 举个例子来说明: 
 1。创建一个应用程序(working_out)<br>
      2。创建一个窗口(w_01) <br>
      3. 在应用程序的open事件中最末尾open()函数改为open(w_o1) <br>
      4。编辑窗口。 <br>
      添加三个控件在窗口上,即两个rectangle:r_1,r_2和一个commandbutton :cb_1 <br>
      将r_1的fill color:设为 white, 将line color:设为black,将X设243 Y设为645,width为1541,height设为113。 
      按确定健即可。 <br>
      将r_2的fill color:设为blue,将line color:设为white,将X设261 Y设为661,width为5,height设为85。按确定健即可。<br>
      在cb_1的clicked事件中填写: <br>
      r_1.visible=true 


r_2.visible=true <br>
      int lock <br>
      lock=0<br>
      do while lock<100 <br>
      lock=lock_1<br>
      r_2.width=lock*15<br>
      loop 5.<br>
      按“run"健运行此程序,就看到一条从头走到 尾的向安装win98一样的指示灯出现在你的程序窗口上。
 

Top
回复人: joss(季节...草堂夏意浓) ( ) 信誉:158 2003-05-24 23:48:08Z 得分:0
缩小含较少数据的Sybase数据库的规模,如2G的数据库,其中含200M的数据,如何将其转换为500M左右的数据库。望饱学志士不吝赐教! 
高级方法:不用BCP,使用修改系统表SYSUSAGES的方法。详细方法在SYSBASE NEWSGROUP 有。你可以在www.sybase.com找到administrator 论坛。  
//------------------------------------------
请教两个sybase sql server 之间复制数据的方法 

 
SYBASE有一个东东叫Replication Server,专用来复制Sybase SQL Server,不过就是对维护人员要求高 
//-------------------------------------------
我们用VC编写一动态连接库,函数形式为 int ecrtx(string cmd,word i,string retval),在Delphi中正常调用,但在PB6中就是出错提示:
1.指定的参数类型和需要的参数类型不一致,
2.从函数调用中返回无效的堆栈指针。我们的调用方法是: 
    int j
    uint i(用int i也不同)
    string a,b
    j=ecrtx(a,i,b)
函数好象能够运行,就是出错。劳烦各位大虾出手相救

 
在VC中, int 是32位. 而在PowerBuilder 中int 是16位, long则是32位. 
//----------------------------------------------
我使用Infomaker 5.0.0.01 转换Foxpro25 DBF文件到MS SQL SERVER6.5时,发现转入不能成功。其中Foxpro的ODBC driver 为 Pb Intersolv 2.12.0000 32Bit DBASEFile 96.1.15, SQL Server ODBC Driver使用MS SQL Server 自带的。问题如下:1.转换两个字段都为char的一个表示,转入成功,用各种T-SQL工具发现转入是成功的
2.如果使用如下的表结构的DBF文件,发现失败。
slsj date 
slno char 6
spjg char 8
qymc char 70
fddbr char 20
hzrq date
sldh char 3
slname char 10
现象有:字段内容“审批通过”用Infomaker Query 工具发现变成“审批通?”,用SQL Server 自身带的SQL Query Tool发现“审批通过”变成“悽彛柱?”为什么是这样?快帮帮我。 

 
A1:不要使用PB的ODBC驱动,用MS的

A2:将SQL SERVER的CHAR类型改成VARCHAR类型
 
//---------------------------------
我所用的Sybase数据库的一张表已输入大量数据,现遇到一个字段的宽度不能够满足一个记录的宽度,请问如何处理 
 
A1:BCP is another way. 

A2:不能修改,可以另外建一个表,用PIPELINE将数据倒过去。
 
//-------------------------------
ORACLE数据库的Client/Server连接成功,且Delphi能够连接到ORACLE 7.3.4 For NT,但是,PB连接ORACLE时,出现如下错误:没连接接口驱动程序---功能未执行? 
 
A1:sqlca.servername = '@' + ORACLE数据库别名 
sqlca.dbms='o72'
sqlca.login = 'SYSTEM'
sqlca.loginpass = 'MANAGER'  
//---------------------------------
060由于服务器没正常关机,导致数据库脱机,用sp_helpdb命令得到“cinms"数据库被标记为"offline",请问如何去掉这个标记,使得数据库能工作? 
A1:不妨试试如下命令(在交互式环境下)
online database cinms
go


看看是否可以解决问题!!! 

A2:手工更改master库中的sysdatabases表,它有两个状态栏status,status2,可以去掉SUSPECT位,具体数值意义可以看SYBASE的参考资料. 
 //------------------------
怎样屏蔽PB,datawindow中操作错误时产生的英文信息
 
通过判断默认事务对象sqlca的属性sqlcode来决定.
if slqca.sqlcode=** then
    messagebox('','中文提示')
end if
当然要了解pb的错误级别.
 

Top
回复人: tchatcha(沧桑,孤独,浪漫,但执着!) ( ) 信誉:151 2003-05-24 23:50:39Z 得分:0
PB API调用原型   
   
  The tens of thousands of function calls in the Windows environment can be helpful to PowerBuilder users, but documenting them is nearly impossible. After hundreds of user inquiries, Powersoft Technical Support compiled these technical tips to enable PowerBuilder developers to translate standard Microsoft function calls into PowerBuilder syntax, and to empower developers to use any of the external API calls within their owerBuilder environments.. 

The following information will help you translate and Windows SDK call to a PowerBuilder API function call. It doesn't matter whether you're using PowerBuilder 4.0, 5.0, 6.0, 7.0 or 8.0 but there are important differences between the 16- and 32-bit versions, as we'll discuss below. 

Step 1: Converting an SDK Call to a PowerBuilder API Call. 

First you need to get the syntax that wil be converted. This can be obtained from either a Windows API Bible or the MSDN (Microsoft Developers Network). 

Step 2: Determining Whether it is a Function or a Subroutine. 

Function calls return a value; subroutines do not. 

Here is an example of a Microsoft function: 
BOOL GetFileVersionInfo( LPTSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData ); 

Here is an example of a Microsoft subroutine: 
VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer); 

Step 3: Converting the datatypes from Microsoft to PowerBuilder. MICROSOFT PB(16Bit) PB(32Bit) 
Bool Boolean Boolean 
Char* Ref string Ref String 
Colorref Uint Ulong 
Dword Uint Ulong 
Handle Uint Ulong 
Hdc Uint Ulong 
Hfile Uint Ulong 
Hinstance Uint Ulong 
Hwnd Uint Ulong 
Int Int Int 
Lparam Uint Ulong 
Lpbyte Ref Int Ref Long 
Lpdword Ref Uint Ref Ulong 
Lpfiletime Ref Time Ref Time 
Lpint Ref Int Ref Long 
Lpstr,Lpststr Ref String Ref String 
Lpvoid Ref Structstruct_inst Ref Struct struct_inst 
Mcierror Long Long 
Lpstr,Lpststr Ref String Ref String 
Lpvoid Ref Structstruct_inst Ref Struct struct_inst 
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 Ulong 
Wparam Uint Ulong 


Most of the datatypes are listed above, but some may be missing. When in doubt read the datatype description first. If still unsure, it is usually safe to assume a 16 bit datatype is a "uint" and a 32 bit datatype is a "ulong", since they are the most common. 

*If the word "Callback appears as a datatype, it cannot be performed by PowerBuilder. Callback routines are functions that are called from within functions. 

Step 4: Coding the Global/Local External Function: 

This is a Microsoft function: 
BOOL GetFileVersionInfo( LPTSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData ); 

The BOOL represents a boolean return code, which is translated to "Boolean" in PB for both 16 and 32 bit. A LPCTSTR means a pointer to a string (see step 3). In PowerBuilder, simply use the word "ref" before declaring the string in either 16- or 32-bit platofrms. DWORD is translated to "uint" for 16 bit and "ulong" for 32 bit. An LPVOID indicates that a structure is being used. In PowerBuilder, create a structure, assign it to an instance variable of that structure and pass it by reference. As a result, the following function declarations can be derived: 

PowerBuilder 16 bit: 
FUNCTION boolean GetFileVersionInfo(ref string filename, uint f_handle, uint f_length, ref lpdata lpdata2) LIBRARY "ver.dll" 

PowerBuilder 32 bit: 
FUNCTION boolean GetFileVersionInfoA(ref string filename, ulong f_handle, ulong f_length, ref lpdata lpdata2) LIBRARY "version.dll" 

Note: In the "gotchas" section listed below, you'll get a further explanation why an "A" is appended to the 32-bit function. You'll also find a handy technique to help you locate function calls within the DLLs. 

Step 5: Creating a Structure 

In this particular example a structure is needed so you'll need information on what elements are contained within this structure. The MSDN provides this information since the function being called is a Windows function. 

In the MSDN the structure appears like this: 
LPDATA = { DWORD dwSignature ; DWORD dwStrucVersion ; DWORD dwFileVersionMS ; DWORD dwFileVersionLS ; DWORD dwProductVersionMS ; DWORD dwProductVersionLS ; DWORD dwFileFlagsMask ; DWORD dwFileFlags ; DWORD dwFileOS ; DWORD dwFileType ; DWORD dwFileSubtype ; DWORD dwFileDateMS ; DWORD dwFileDateLS } 

In PB you would go into the structure painter and in this particular case all of these elements would be converted to ULONG. If one of the elements within the structure was a nested structure or callback routine you would not be able to use this function within PB. In that case the only option would be to create a C DLL that makes the function call and call it from PB. 

 

共享共进共赢Sharing And Win-win Results
SYBASEBBS - 免责申明1、欢迎访问“SYBASEBBS.COM”,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2、本文内容仅代表作者观点,不代表本站立场,作者自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3、本文内容,包括但不限于源码、文字、图片等,仅供参考。本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容。
4、如本帖侵犯到任何版权问题,请立即告知本站 ,本站将及时删除并致以最深的歉意!客服邮箱:admin@sybasebbs.com
ehxz 楼主

主题

0

回帖

57万

积分

管理员

积分
570784
贡献
在线时间
小时
2005-7-20 17:02:42 | 显示全部楼层
Top
回复人: 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 

共享共进共赢Sharing And Win-win Results
help

主题

0

回帖

1

积分

新手上路

积分
1
贡献
在线时间
小时
2005-8-9 19:34:27 | 显示全部楼层

http://www.tiantiansoft.com/Soft_Show.asp?SoftID=9

bitmap: 捕捉窗口或控件的图象,保存为bmp文件。(主要调用gdi32函数)

我用的pb8, 以上有pb9的源码,那位帮忙把脚本贴出来

共享共进共赢Sharing And Win-win Results
awang

主题

0

回帖

24

积分

版主

积分
24
贡献
在线时间
小时
2005-10-10 21:57:45 | 显示全部楼层
[em01]
共享共进共赢Sharing And Win-win Results
zcy007

主题

0

回帖

1

积分

新手上路

积分
1
贡献
在线时间
小时
2005-12-7 12:22:14 | 显示全部楼层

学习了!谢谢楼主

共享共进共赢Sharing And Win-win Results
winnie

主题

0

回帖

2

积分

新手上路

积分
2
贡献
在线时间
小时
2006-1-5 11:29:46 | 显示全部楼层
好好学习 [em09]
共享共进共赢Sharing And Win-win Results
您需要登录后才可以回帖 登录 | 站点注册

本版积分规则

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com

QQ|Archiver|PowerBuilder(PB)BBS社区 ( 鲁ICP备2021027222号-1 )

GMT+8, 2024-4-29 03:26 , Processed in 0.084447 second(s), 10 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表