當前位置:編程學習大全網 - 編程語言 - PowerBuilder編程實用技巧匯集

PowerBuilder編程實用技巧匯集

壹 用Enter鍵實現物件的焦點切換

在PowerBuilder中已定義許多事件所對應的MessageID 而在其所提供的元件 大部分有對應的keydown事件 其ID值不壹定相同 例如在datawindow->pbm_dwnkey singlelineedit->pbm_keydown 其他參考使用手冊 因此先對使用的元件新增key 的使用者事件 當user在元件上按任何按鍵時 將會觸發此keydown事件

妳將獲得所傳的參數key(按鍵代碼) keyflags(復合鍵代碼) 當所按的是Enter時 妳就把焦點切換到下壹元件或下壹欄位 選擇要處理的datawindowcontrol 然後選擇menu的declare的userevents 此時會顯示壹個使用者事件box 於eventname設定使用者事件名稱例如:ue_checkkey 然後在eventID填入pbm_dwnkey(或從Pasteevent選擇) 然後按OK 妳可在datawindowcontrols的script中selectevent裏發現多了壹個使用者事件 ue_checkkey 並且此事件會傳遞 個參數keycodekey unsignedlongkeyflags 在script中可以如下填寫 choose case key case KeyTab!//響應按Tab鍵 //writeyourcode case KeyEnter!//響應按Enter鍵 //writeyourcode case KeyEscape!//響應按Esc鍵 //writeyourcode end choose註意 ( )keycode是Enumeratedatatype 可在onlinehelp或browers中獲得其屬性 ( )妳可以設定returnvalue: 或 如果是在DataWindow上 可參考以下的方式 在DataWindow宣告壹userevent ?( )如ue_enter 將EventID參考至pbm_dwnprocessenter ( )在ue_enter加入以下的程式碼 send(handle(this) long( )) return 二 在MDI視窗內加入其他Controls 並使其在sheets視窗中正確顯示 把MDIWindow的ClientArea打開(Resize) ClientArea可視為壹種Control PB將它的名字內定為MDI_ //Example//m m r r areallinteger //movetheclientareatobeginat(m m ) mdi_ Move(WorkspaceX()+m WorkspaceY()+m ) //Resizetheclientareabasedonthevalue(r r )yougived mdi_ Resize(r r ) 需要註意的是ClientArea打開後 區域內的Control會被蓋掉 ? 三 PowerBuilder與CommPort的連接 .使用可以控制CommPort的OCX 例如MicrosoftCommunicationsControl或pdqComm .InitiatetheOCX //Script如下 ole_ 為OCXName ole_ object CommPort= ole_ object Settings= N ole_ object PortOpen=true ole_ object InputLen= GetData or PutData //GetData ole_ object input() //PutData ole_ object output= ATDT +char( )

四 在 grid中實現列標題覆蓋多列

lishixinzhi/Article/program/PB/201311/24571

  • 上一篇:糖葫蘆怎麽做視頻教程
  • 下一篇:個子高有1米85左右,近視學什麽技術好
  • copyright 2024編程學習大全網