如何動態建立控制項

2021-04-20 11:36:29 字數 393 閱讀 6152

分配乙個控制項物件的例項並呼叫其create成員函式。開發者最容易忽略兩件

事:忘記指定ws_visble標籤和在棧中分配控制項物件。下例動態地建立乙個下壓按

鈕控制項:

//in class declaration (.h file ).

private :

cbutton* m _pbutton ;

//in class implementation (.cpp file ) .

m_pbutton =new cbutton ;

assert_valid   (m_pbutton);

m_pbutton —>create (_t ("button title ") , ws_child |ws_visible |bs_pushbutton.

VB動態建立控制項

dim withevents mybtn as commandbutton set mybtn controls.add vb.commandbutton button1 with mybtn caption 我可以響應事件!width 1800 left 100 top 700 visible t...

c 動態建立控制項

htmltable tablerow tablecell 動態建立form 直接從標準控制項中繼承過來 動態建立table htmltable ht1 new htmltable 動態建立tablerow,tablecell tablerow tr new tablerow tablecell tc...

PB動態建立控制項

第一種,直接建立 其實就是根據系統的類名建立 commandbutton lbtn new lbtn new create commandbutton lbtn new.width 300 lbtn new.height 100 lbtn new.visible true lbtn new.text...