




已阅读5页,还剩44页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
PB 中一些技巧 1 RGB 函数计算公式 颜色值 65536 Blue 256 Green Red 2 控件可拖动 send handle this 274 61458 0 3 如何用程序控制下拉子数据窗口的下拉和收起 用 modify 或者直接用 dw 1 object col1 dddw showlist true 4 检索参数有些不需要传入则传 5 如何屏蔽鼠标滚轮触发 在控件的 other 事件写 if message number 522 then return 1 6 得到数据窗口的语法 string ls dwsyntax ls dwsyntax dw 1 describe datawindow syntax 7 得到数据窗口中各列及标题 long ll count i string ls value ls colname ll colnum Long dw 1 object datawindow column count for i 1 to ll colnum 得到标题头的名字 ls colname dw 1 describe string i name t ls value dw 1 describe ls colname text next 8 在程序中动态设置初始值 ex dw contro object columnName initial xxxx 9 如何在 DataWindow 的 SQL 语法中不使用 SELECT DISTINCT 实现删除重复的行 起先对你要显示唯一值的列进行排序 city A 然后增加如下过滤字符 串 city city 1 or GetRow 1 10 如何改变列的字体颜色 提醒用户此列已做修改 在列的 Color 属性中 输入如下表达式 IF column name column name Original RGB 255 0 0 RGB 0 0 0 在这个条件中 如果此列已改变 则显示红色字体 否则显示黑色字体 这个表达式主要用 column name column name Original 比较当前列的值和原始列的值是否相 同来达到判断的目的 11 在数据窗口的 clicked 或 doubleclicked 事件中写上注释 可解决一些意外 的 bug 12 如何屏蔽上下鍵触发 新建一个事件 id 为 pbm dwnkey IF KeyDown KeyDownArrow OR KeyDown KeyUpArrow Then Return 1 End IF 13 你注意到没有 数据窗口画板里面 在写表达式的时候 试着用一些用户自 定义的全局变量和全局函数 你会发现在某些特殊的场合 这个小窍门还是很 有用的 14 有些程序员在窗口的右键 pop 菜单里面写了很多代码 在菜单里面有很多 w windowname controlname 等等引用 如果这个窗口被继承 很容易就会出毛 病 别忘了在菜单里面可以引用 parentwindow 哦 有了它我的 pop 菜单里面的 代码和具体窗口无关 随便继承 当然强烈建议最好还是把所有和窗口相关的 逻辑都转移到窗口的函数和事件中去 在 pop 菜单中触发调用 15 whichdw describe evaluate lookupdisplay colname string r ow 这个表达式可以得到指定列的显示值 这个知识点有滥竽充数之嫌 但是一 时间我真是想不起来太多的东西 16 在数据窗口画板里面我们如果想要比较当前行和上一行或者下一行的值 怎 么比较呢 哈哈 看这个就知道了 if yw bc circuit dlcode yw bc circuit dlcode 1 and yw bc circuit dlname yw bc circuit dlname 1 and yw bc circuit xtno yw bc circuit xtno 1 0 1 这个表达式就是比较当前行和上一行是否相同的 其他的依此类推就行了 17 两个结构相同的数据窗口之间快速复制数据 dw 1 object data dw 2 object data 18 根据条件改变记录颜色 if Mod getrow 2 0 rgb 0 255 255 rgb 255 255 255 奇偶行不同 色 if currentRow getrow rgb 0 255 255 rgb 255 255 255 当前行不 同色 19 使窗口总位于所有打开窗口的最上面 w main SetPosition Topmost 20 取数据窗口中列的总数 string ls count ls count dw 1 describe datawindow column count 21 取数据窗口中可列新的表名 string ls table ls table dw 1 describe datawindow updatetable table 22 取数据窗口对象中列的名称及类型 string ls cols ls types int li count i li count integer ls count for i 1 to li count ls cols i dw 1 describe string i name ls types i dw 1 describe string i coltype next 23 Case dealintype WHEN 0 THEN RGB 254 251 235 WHEN 2 THEN rgb 254 251 235 ELSE RGB 0 0 255 写道字段的 protect 中不仅仅是颜色改变的问题看看 24 dw Object col n 直接获得数据窗口的 col 列第 n 行的数据 25 在做数据窗口时 我们有时候希望能够多一些字段来作一些特殊的用处 但是在数据窗口中又不能乱加字段 因为已有的字段必须是数据库中有的或者 是他们的组合 呵呵 大家不妨看看这个 sql 用产生什么样的数据窗口 select colname1 colname2 1 from tablename 是不是多出了两个字段阿 一个是字符串字段 一个是数字字段 别忘了要 convert syntax 哦 26 清空数组 string a b a 1 1 a 1 2 a 1 3 a b 即可以清空 a 27 只允许修改第 n 行的 name 列 dw 1 modify name protect 1 t if getrow n 0 1 28 让 run 程序和主程序一起关闭 function ulong findwindowA user32 dll function long setparent user32 dll handle findwindowA nul win title setparent handle handle w main 29 取得某一天以前或以后 n 天的函数 RelativeDate date n 例 取得当天前 10 天的日期 RelativeDate Today 10 取得当天后 10 天的日期 RelativeDate Today 10 30 不想做排序窗口 调用 PB 自身的好了 string ls null SetNull ls null dw 1 SetSort ls null dw 1 Sort 31 调用 PB 自身的过滤窗口 dw 1 SetFilter ls null dw 1 Filter 32 增量输入定位代码或名称记录位置 定义一个窗口 放一个 SLE 1 在它的 MODIFY 程序中写 long ll find string value0 value0 sle 1 text if not isnull sle 1 text or sle 1 text then if left sle 1 text 1 0 or integer sle 1 text 0 then 输 入的为代码 ll find jwl dmxz dw 1 find dm like value0 1 jwl dmxz dw 1 rowcount jwl dmxz 为主窗口 dm 为查 询的字段名 这里是代码 else 输入的为名称 ll find jwl dmxz dw 1 find mc like value0 1 jwl dmxz dw 1 rowcount end if if ll find 0 then jwl dmxz dw 1 scrolltorow ll find 为了避免首次目标记录为第一条 无法选中 if ll find ll find0 then jwl dmxz dw 1 selectrow ll find true elseif ll findll find0 then jwl dmxz dw 1 selectrow ll find true jwl dmxz dw 1 selectrow ll find0 false ll find0 ll find end if end if end if 33 然后在查询窗口中的 TIMER 事件中写 timer 0 05 sle 1 triggerevent modified 34 判断计算器是否存在 string is fileExists boolean is Exists is fileExists c windows calc exe is Exists fileExists is fileExists if is Exists then run c windows calc exe else messagebox 提示信息 本机的 WINDOWS 没有计算器 stopsign end if 35 得到硬盘序例号 String ls Rootpath ls volumnename ls return softpath GetCurrentDirectoryA 256 softpath softpath left softpath 2 if softpath C then ls Rootpath D 指定要得到序列号的硬盘 一般情况都是 C 盘 除非你能保证用户存在其它逻辑盘或物理盘 else ls Rootpath C end if ls volumnename Space 256 分配足够的空间 下同 Ulong lul VolumeNameSize lul VolumeNameSize 256 Ulong lul VolumeSerialNumber lul MaximumComponentLength lul FileSystemFlags lul MaximumComponentLength 256 String ls FileSystemNameBuffer ls FileSystemNameBuffer space 256 Ulong lul FileSystemNameSize lul FileSystemNameSize 256 int i long ls num ls gnum ls dnum i GetVolumeInformation ls Rootpath ls volumnename lul VolumeNameSize lul VolumeSerialNumber lul MaximumComponentLength lul FileSystemFlags ls FileSystemNameBuffer lul FileSystemNameSize ls return string lul VolumeSerialNumber return ls return PB 问答 1 如何让存储文件目录的列 显示图片 答 选择对应的 column 的 display as picture 属性为 true 2 如何复制 grid 类型的所选择的行的数据到系统剪切板 答 string ls selected ls selected dw 1 Object DataWindow Selected Data clipboard ls selected 3 如何复制 graph 风格的 datawindow 中的图形到剪切板 答 dw 1 clipbord gr 1 4 如何设置的 DW 底色 在 DW 的 editsource 中改变 color 的值 5 如何将 Grid 风格改成自由格式 在 DW 的 editsource 中将 processing 1 的 1 改为 0 6 要新建一个表 A 但风格和现有表格 B 风格一样 怎么将 A 表快速设置成表 B 风格 复制 B 表 C 在 C 表的 DW 中的 editsource 中将表名和字段名改成 A 表的 即 可 7 如何实现 gird 风格的 datawindow 的多栏表头 答 添加 text 到 header 带区 并设置 band 属性为 foreground 保存 edit source 修改 text 的 x 和 width 属性表达式如下 x 100 t integer describe firstcol x width 100 tinteger describe lastcol x integer describe firstcol x integer describe lastcol width 8 如何过滤 dddw 编辑风格的显示值为指定值的记录 答 dw 1 setfilter lookupdisplay column name ls display value your dw 1 filter 9 如何设置 datawindow 的某一列为空 答 string ls temp setnull ls temp dw 1 O B J E C T columnname primary current ls temp 10 如何设置 datawindow 的单双行不同颜色间隔 答 在 detail 带区的 color 属性表达式中写上 if mod getrow 2 1 rgb 255 0 0 rgb 0 255 0 如果是当前行以第三种颜色表示 表达式如下 if getrow current rgb 255 0 0 if mod getrow 2 1 rgb 0 0 255 rgb 0 255 0 11 如何获取指定名称的 datawindow O B J E C T 答 DWObject ldwo use ldwo abc ldwo use dw 1 Object ldwo abc ldwo use get attribute t 1 FALSE t 1 为 datawindow 中 text 对象的名称 12 如何使用 datawindow 的查询模式 答 dw 1 Object DataWindow QueryMode yes 将 datawindow 改变为查询模式 后 接收用户的输入 再使用一下代码获取结果 dw 1 accepttext dw 1 retrieve 13 如何缩放 datawindow 的打印大小 答 dw 1 O B J E C T datawindow zoom 150 or dw 1 O B J E C T datawindow zoom 75 14 如何在已过滤后的数据基础上对 datawindow 进行过滤 答 dw 1 setfilter dw 1 describe datawindow table filter your join your new filter dw 1 filter 15 如何在 datawindow 中显示动态时间 答 建立一个计算域 表达式为 string datetime today now yyyy 年 mm 月 dd 日 hh 点 mm 分 ss 秒 同时设置 datawindow 的属性 dw 1 Object DataWindow Timer Interval 500 16 如何让带用 title bar 的 datawindow 控件的标题栏诚活动窗口的颜色 答 外部函数定义 funcation logn SetActiveWindow long hwnd Library user32 dll datawindow 控件的 clicked 事件代码 setactivewindow handle this 17 如何设置 datawindow 的当前行指示图标 答 在 datawindow 中建立一个计算列 expression 为 并将该计算列移动为 datawindow 的第一个列 在 datawindow 控件的 rowfocuschanged 事件中写入代码 SetRowFocusIndicator hand 或 setrowfucsindicator p 1 p 1 为窗口上的 picture 控件名 18 如何通过代码打开 dddw 答 定义外部函数引用声明 SUBROUTINE keybd event int bVk int bScan int dwFlags int dwExtraInfo LIBRARY user32 dll 代码如下 constant integer VK F4 115 dw 1 SetFocus dw 1 SetColumn dept head id 设置当前 dddw keybd event VK F4 0 0 0 按下 F4 键 keybd event VK F4 0 2 0 释放 F4 键 19 如何打印 datawindow 的内容到文件中 答 dw 1 O B J E C T datawindow print fileName c temp prn dw 1 print 20 如何设置 dddw 的初始值 答 dw 1 O B J E C T columnname Initial your initial value 21 如何只显示不同的数据 答 dw 1 filter isnull columnname 1 and columnname columnname 1 dw 1 filter 22 如何让带有 title bar 的 datawindow 不可以移动 答 在 datawindow 的自定义事件 ue nchittest pbm nchittest 中写入如下代 码 return 1 23 如何在 N UP 显示风格中建立基于第 N 栏中的列的计算列 答 如 column 有两列 number 和 price 并显示为两栏 则第一栏的 cost 计 算列的 expression 为 number price 第二栏的 cost 1 计算列的 expression 为 number 1 price 1 24 如何清空 ddlb 或 edit codetable 中项目 答 dw 1 Object columnname Values 25 如何实现指定的 column 的字体旋转 90 度 答 dw 1 O B J E C T columnname font Escapement 900 26 如何获取 datawindow 的 sql 代码 答 可以通过以下四种方法获取 sql 代码 string szselect szselect dw 1 describe datawindow table select szselect dw 1 describe datawindow table sqlselect szselect dw 1 describe datawindow table select attribute szselect dw 1 getsqlselect 27 如何获取 datawindow 对象占有的虚拟存储的容量 答 使用 datawindow storage 属性 举例 在 datawindow 控件的 retrieverow 事件中 写如如下代码 long lstorage lstorage long dw 1 O B J E C T datawindow storage if lstorage 50000 then dbcancel 28 如何控制打印横向 dw control O B J E C T datawindow print orientation 1 29 如何进行预览 dw control O B J E C T datawindow print preview yes 30 如何连续在同一张纸打印两个数据窗口 答 dw 1 O B J E C T datawindow print filename temp prn dw 2 O B J E C T datawindow print filename temp prn dw 1 print dw 2 print 31 如何将 pb9 0 的 datawindow 转化为 pb 8 0 版本的 datawindow 答 edit source 将 release 9 改为 release 8 并删除以下内容 print printername print canusedefaultprinter yes print cliptext no print overrideprintjob no hidegrayline no encodeselflinkargs 1 export xml headgroups 1 includewhitespace 0 metadatatype 0 savemetadata 0 import xml export pdf method 0 distill custompostscript 0 xslfop print 0 32 如何设置 datawindow 分组后每个分组中的记录号 答 建立一个计算列 expression 为 getrow first getrow for group 1 1 33 如何实现在 datawindow 中只有新增的行 才可以编辑 答 在所有的 column 的 protect 属性表达式中写入以下表达式 if isrownew 0 1 34 保存 datawindow 数据到 excel 中 Init docname GetFileOpenName or any other method if dw 1 SaveAs docname HTMLTable True 1 then MessageBox Warning Unable to export data Error writing to file Exclamation return end if Convert HTML file to Excel native format OLEObject excel excel CREATE OLEObject if excel ConnectToObject docname 0 then excel application DisplayAlerts FALSE excel application workbooks 1 Parent Windows excel application workb ooks 1 Name Visible True excel application workbooks 1 saveas docname 39 excel application workbooks 1 close end if DESTROY excel done 35 除了循环以外 有没有更好的方法统计数据窗口中处于选中状态的行数 一般习惯于使用循环来统计数据窗口中处于选中状态的行数 有没有更好的方 法 其实此问题在应用上用处不大 讨论一下 活跃一下思维还是有好处的 方法一 long ll Selected ll Selected long dw 1 describe evaluate sum if IsSelected 1 0 for all 1 方法二 long ll Selected ll Selected long dw 1 describe evaluate count IsSelected for all 1 方法三 upperbound dw 1 Object Data Selected 36 问 怎么让 PB 只打印当前记录 是用 Free 格式制作的数据窗口 答 DataStore ldt temp long ll Row ll Rows ll Rows dw XX Rowcount If ll Rows 0 Then GoTo the end If ll Rows 1 Then dw XX Print GoTo the end End if dw XX SetRedraw False ldt temp Create DataStore ldt temp DataObject dw XX DataObject ll Row dw XX GetRow dw XX RowsMove 1 ll Rows Primary ldt temp 1 Primary ldt temp RowsMove ll Row ll Row Primary dw XX 1 Primary dw XX Print dw XX RowsMove 1 1 Primary ldt temp ll Row Primary ldt temp RowsMove 1 ll Rows Primary dw XX 1 Primary Destroy ldt temp dw XX SetRedraw True the end 只用将上述脚本拷入到打印部分即可 dw XX 为被打印的 free 型数据窗口 该方法可保证 dw XX 中的数据在打印前后包括 sort 等属性均不发生任何改变 但效率较低 不宜用在数据量太大的数据窗口中 当然 考虑到打印本身速度 就比较慢 所以 3000 行数据是可以采用这种方法并让用户接受的 若在同一窗 口上存在与 dw XX 共享的 grid 数据窗口并且与 dw XX 同时显示 则需要与 dw one 一起 SetRedraw 37 怎样将数据窗口 free 格式 中的内容转成 word 文档 答 给你两个函数 1 辅助函数 PBExportHeader f cncharnum srf PBExportComments 得到字符串中汉字或者双字节的个数 global type f cncharnum from function O B J E C T end type forward prototypes global function integer f cncharnum string aString end prototypes global function integer f cncharnum string aString 函数名 f cncharnum 用途 返回一个字符串中汉字的个数 输入 aString string 给定的字符串 返回值 li num Integer 给定的字符串中汉字的个数 注意 1 此方法基于汉字的国标汉字库区位编码的有效性 不符合此编码 的系统此函数无效 2 若汉字串含有非汉字字符 如图形符号或 ASCII 码 则这些非汉字字符 将保持不变 例如 li ret f cncharnum 摆渡人 ferryman li ret 3 string ls ch 临时单元 string ls SecondSecTable 存放所有国标二级汉字读音 integer li num 0 返回值 integer i j For i 1 to Len aString ls ch Mid aString i 1 If Asc ls ch 128 then 是汉字 li num i i 1 End if Next Return li num end function 2 转到 WORD PBExportHeader f outputtoword new srf global type f outputtoword new from function O B J E C T end type forward prototypes global function integer f outputtoword new datawindow adw end prototypes global function integer f outputtoword new datawindow adw 函数名 f outputtoword new 输入 adw datawindow 指定的数据窗口 返回值 Integer constant integer ppLayoutBlank 12 OLEObject ole O B J E C T ole O B J E C T CREATE OLEObject integer li ret li ret ole O B J E C T ConnectToObject word application IF li ret 0 THEN 如果 Word 还没有打开 则新建 li ret ole O B J E C T ConnectToNewObject word application if li ret 0 then MessageBox OLE 错误 OLE 无法连接 错误号 string li ret return 0 end if ole O B J E C T Visible True END IF long ll colnum ll rownum constant long wdWord9TableBehavior 1 constant long wdAutoFitFixed 0 constant long wdCell 12 string ls value pointer oldpointer oldpointer SetPointer HourGlass string ls O B J E C Ts ls obj ls objs ls objtag long ll pos ll len ll num 0 ls O B J E C Ts trim adw Describe datawindow Objects do while pos ls O B J E C Ts t 0 ll pos pos ls O B J E C Ts t ll len ll pos 1 ls obj left ls O B J E C Ts ll len if adw Describe ls obj type column or ls ret ls syntax 截掉 ls syntax 中的数据部分 5 0 以 sparse names dept name 作 为参考位置 6 0 以 html 作为参考位置 long pos1 pos2 pos1 pos ls syntax sparse names 1 pos2 pos ls syntax pos1 16 ls syntax left ls syntax pos1 mid ls syntax pos1 1 pos2 pos1 1 dw New create ls syntax ls error if ls error then messagebox Create Error ls error else dw new settrans O B J E C T sqlca dw new retrieve end if pb6 pb7 的代码可以参照 pb5 自己写 只是文件头和数据窗结束标记不同而已 global type f createextenddw from function O B J E C T end type forward prototypes global function string f createextenddw ref datawindow dw string cols end prototypes global function string f createextenddw ref datawindow dw string cols string sql dw general sql dw columns type sql dw headers conf sql dw columns conf ls errors int i long ll colcount string ls colnametype string ls colname ls coltype long ll pos ll colcount upperbound cols generals sql dw general release 8 if sqlca sqlCode 1 then messageBox 错误 连接失败 end if messageBox 错误 连接失败 else commit using sqlca end if 确保数据保存的成功 if dw 1 update 1 then RollBack Using SQLCA MessageBox 警告 数据保存失败 else Commit Using SQLCA End if 4 读取网页内容 sle 1 text ole 1 object Document body outertext ole 1 object Document body scroll no mle 1 text ole 1 object document body outerhtml 5 tab 1 createondemand 在需要时创建 tab 1 createondemand 在需要时创建 提高在 open 事件时的效率 tab 1 的 某一 tabpage 里的内容在 open 时不创建 仅当选择该页时或 selecttab 才创建 不过 在未创建时 不能对其中的控件及属性引用 6 如何在程序中对 BLOB 数据库进行写入 和后台数据库有关 以 SQLANYWAY 为例 一般用 UPDATEBLOB 和 SELECTBLOB 两个 SQL 语句来实现 建一个表 TABLE1 一个字段是 ID 另一个是 BLOB SELECTBLOB BLOB FROM TABLE1 WHERE ID xx UPDATEBLOB SET BLOB BLB X FROM TABLE1 WHERE ID yy 删除时删除 ID 为 mm 的记录即可 新增是先插入一条 ID 为 mm 的记录 然后 用 UPDATEBLOB 将数据写入 表内 其他的数据库可参照手册进行 其命令与上述差别不大 7 API 系统消息及其它 dll 调用 1 控件可拖动 send handle this 274 61458 0 2 如何屏蔽鼠标滚轮触发 在控件的 other 事件写 if message number 522 then return 1 3 隐藏任务栏的方法 在 OnCreate 事件里利用 Window API 函数 SetWindowLong SetWindowLong Application Handle GWL EXSTYLE WS EX TOO LWINDOW PB 使用时首先声明函数 FUNCTION long SetWindowLong ulong hWnd integer nIndex ulong dwNewLong library user32 dll ALIAS FOR SetWindowLongA 然后调用 SetWindowLong Handle this 20 128 4 在 PB 中调用屏幕保护的方法 send handle This 274 61760 0 5 得到一个应用程序如 Outlook 的路径 RegistryGet HKEY LOCAL MACHINESOFTWAREMicrosoftWindowsCurrentVersion App PathsMSIMN EXE Handle 代表 DW 的句柄 256 代表 TAB 键 9 代表不加入 shift 键 7 代表加入 Long 0 0 代表预留空位 send handle this 256 9 long 0 0 return 1 This statement scrolls the window w emp up one page Send Handle w emp 277 2 0 Both of the following statements click the CommandButton cb OK Send Handle Parent 273 0 Handle cb OK cb OK TriggerEvent Clicked minimizes the DataWindow Send Handle dw 1 274 61472 0 maximizes the DataWindow Send Handle dw 1 274 61488 0 returns the DataWindow to its normal defined size Send Handle dw 1 274 61728 0 13 如何使 PB 窗口总在最上层 Always On Top 通过 SetWindowPos 函数把窗口的显示层次修改为 HWND TOPMOST 就可使指定 窗口永远不会被其它窗口覆 盖 该函数声明为 Function Long SetWindowPos Long hwnd Long ord Long x Long y Long dx Long dy Long uflag Library user32 参数 1 为要顶层显示的窗口句柄 参数 2 指定显示的层次 参数 7 为附加选项 其余参数指定窗口位置和 大小 均可忽略 在窗口的 Open 或 Activate 事件中加入如下函数调用 SetWindowPos Handle This 1 0 0 0 0 3 参数 2 取 1 表示在最顶层显示窗口 取 1 表示在最底层显示 最后一个参数若 取 1 表示窗口大小保持不 变 取 2 表示保持位置不变 因此 取 3 1 2 表示大小和位置均保持不变 取 0 表示将窗口的大小和 位置改变为指定值 14 在 PB 中如何获得光盘盘符 通过 GetDriveType 函数可以获取驱动器 如 软驱 硬盘 光驱 网络映射驱 动器等 的信息 该函数 声明为 Function Uint 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 15 在 PB 中如何获取目录信息 获取当前目录 通过 GetCurrentDirectory 函数可以获取当前目录 该函数 声明为 Function Ulong GetCurrentDirectoryA Ulong buflen ref String dir Library kernel32 dll 参数 2 为接收当前目录的字符缓冲区 前面必须加 ref 表示地址引用 参数 1 用来指定字符缓冲区的长度 调用过程为 String curdir curdir Space 256 为字符缓冲区开辟内存空间 GetCurrentDirectoryA 256 curdir MessageBox Current Directory curdir 获取 Windows 及系统目录 要用到 GetWindowsDirectory 和 GetSystemDirectory 两个函数 须作如下声明 Function Uint GetWindowsDirectoryA ref String dir Uint buflen Library kernel32 dll Function Uint GetSystemDirectoryA ref String dir Uint buflen Library kernel32 dll 16 在 PB 中如何注销当前用户 关闭计算机 重启计算机 通过 ExitWindow 函数可实现这三个功能 首先作如下声明 Function Long ExitWindow Long uflag Long nouse Library user32 dll 参数 2 保留不用 可取 0 参数 1 取 0 可以注销当前用户 取 1 可以关闭计算 机 取 2 可以重启计算机 其值 再加 4 表示强制结束 未响应 的进程 17 控制由 Run 运行的程序 简称 Run 程序 在 PB 程序设计中 可以用 Run 来运行一些程序 比如用户按了 F1 就运行一 个 chm 文件 但 Run 程序无法 与 PB 主程序协调工作 若用户按了多次 F1 就会启动 Run 程序的多个实例 主程序退出时 Run 程序依然 运行 可以用如下函数来使它们协调工作 Function Ulong FindWindowA Ulong classname String windowname Library user32 dll Function Long SetParent Long childwin Long parentwin Library user32 dll 使 Run 程序只运行一个实例 handle FindWindowA nul wtitle 查找 Run 程序是否已经运行 wtitle 为 Run 程序的标题 IF handle 0 Then Return 若已经在运行就返回 Run C Program FilesJointJoint chm 否则运行 Run 程序 PB 主程序退出时 Run 程序也关闭 handle FindWindowA nul wtitle SetParent handle Handle w main 使 Run 程序窗口成为 PB 主程序的子窗口 18 映射网络驱动器 若要在程序中把远程主机的资源映射到本地驱动器 可以用如下函数 Function long WNetAddConnectionA String path string pwd String drv Library mpr dll 19 在 PB 中如何打开一个文件 如 txt doc 就像在资源管理器中双击打开 文件一样 答 可以通过 API
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 社工中级考试题及答案
- 驾照考试题库及答案
- nacos面试题及答案
- 危重病人试题及答案
- 听力音符测试题及答案
- 乡村特岗考试试题及答案
- 2024年老年三区护理理论试题及答案
- (2025)工业机器人系统操作员技术及理论知识竞赛试题库(附含参考答案)
- 三级营销员模考试题含答案
- 免疫规划培训试题及答案2024
- 农业与食品行业营销方案
- CBL教学法应用介绍
- 提高肋骨骨折影像学诊断
- 东华临床科研数据管理系统解决方案白皮书
- 辽宁省丹东市《教师基本素养及教育教学综合能力知识》教师教育
- 2023年全国保密知识竞赛全套复习题库及答案(共460道题)
- (推荐下载)家族性结肠息肉病教学课件
- 水生产企业(自来水公司)安全生产责任制(含安全手册)
- 《材料成型装备及自动化》课程大纲
- 临时用电JSA分析表
- 如何提高护士对患者病情掌握的知晓率
评论
0/150
提交评论