Jul 6, 2012

Powerbuilder - Extract Menu To Datawindow

1. Create Window, Datawindow and controls




2. Create A sample menu



3. Create window function

 public function boolean of_extract (menu am_menu, integer ai_from, integer ai_level, string as_parent);string     ls_text, ls_code  
 integer li_loop, li_count  
 Long ll_row  
 li_count = UpperBound(am_menu.Item[])  
 for li_loop = ai_from to li_count  
      ls_code = as_parent + string(li_loop,"00")  
      ls_text = am_menu.item[li_loop].Text  
      ll_row = dw_menu.InsertRow(0)  
      dw_menu.SetItem(ll_row,"menu_id", ls_code)  
      dw_menu.SetItem(ll_row,"label_menu", ls_text)  
      dw_menu.SetItem(ll_row,"level_id", ai_level)  
      dw_menu.SetItem(ll_row,"parent_id", as_parent)  
      of_extract(am_menu.Item[li_loop],1, ai_level + 1, ls_code)  
 next  
 return true  
 end function  


4. cb_extract Event Clicked()

 menu lm_main  
 if ddlb_1.text = 'm_main' then  
  lm_main = create m_main  
 else  
  lm_main = create m_sample  
 end if  
 dw_menu.reset()  
 of_extract(lm_main,1,0,'')   
 destroy lm_main  


5.See them in action



6. Cheers..



DOWNLOAD source code from 4Shared

Jul 4, 2012

Powerbuilder - Custom Messagebox

1. Create a Response window named w_msg with 1 static text and 3 command button.


2. w_msg event open

 string ls_data,ls_parse  
 integer li_loop,li_count  
 ls_data = message.stringparm  
 for li_loop = 1 to len(ls_data)  
      ls_parse += mid(ls_data,li_loop,1)  
      if right(ls_parse,1) = ',' then  
           ls_parse = left(ls_parse,len(ls_parse) - 1)  
           li_count++  
           choose case li_count  
                case 1  
                     st_msg.text = ls_parse  
                case 2  
                     cb_1.text = ls_parse  
                case 3  
                     cb_2.text = ls_parse  
                case 4  
                     cb_3.text = ls_parse  
           end choose  
           ls_parse = ''  
      end if  
 next  

3. cb_1 event clicked

 closewithreturn(parent,'1')  

4. cb_2 event clicked

 closewithreturn(parent,'2')  

5. cb_3 event clicked

 closewithreturn(parent,'3')  

6. Create Global Function named f_message

 global function integer f_message (string as_text, string as_option1, string as_option2, string as_option3);  
   
 string ls_return,ls_parm  
 ls_parm = as_text+','+as_option1+','+as_option2+','+as_option3+','  
 openwithparm(w_msg,ls_parm)  
 ls_return = message.stringparm  
 return integer(ls_return)  
   
 end function  
   

7. Call Your Custom Messagebox

   
 int li_option  
 li_option = f_message('Web Browser are you using','Chrome','Firefox','Internet Explorer')  
 choose case li_option  
      case 1  
           //Chrome  
      case 2  
           //Firefox  
      case 3  
           //Internet Explorer  
 end choose  


8. See Them in Action



9. Cheers.. :D

Are legacy 4GL applications keeping you from embracing modern technologies?

As the competitive advantages offered by cloud, mobile, and other new technologies become more apparent, the decision to migrate legacy 4GL ...