Example #1
0
//添加Button控件到CoolBarList, 
// pszString必须是动态的(非Static)
// nWidth 为0 -- 自动长度
Int32 CtrlAddItemToCoolBarList_Button(TWindow*pWin,  TBarListItem* pListItem, Coord nX, Coord nY, Coord nWidth, Int32 nHeight, TUChar* pszString)
{
	TRectangle obBtnRec(0,0,0,0);
	Int32 nButtonId = pListItem->AddCtrl(CTL_CLASS_BUTTON, 20, 5);
	TButton* pButton = static_cast<TButton*>(pWin->GetControlPtr(nButtonId));

	obBtnRec.SetRect(nX, nY, nWidth, nHeight);
	pButton->SetBounds(&obBtnRec);
	pButton->SetEnabled(TRUE);
	pButton->SetCaption(pszString,FALSE);
	return nButtonId;
}
Example #2
0
Int32 CtrlAddItemToPanel_Button(TWindow*pWin,  TPanel* pPanel, Coord nX, Coord nY, Coord nWidth, Int32 nHeight, TUChar* pszString)
{
	TRectangle obBtnRec(0,0,0,0);
	TButton* pButton = new TButton();
	Int32 nButtonId = -1;
	if(pButton->Create(pPanel))
	{
		 nButtonId = pButton->GetId();

		obBtnRec.SetRect(nX, nY, nWidth, nHeight);
		pButton->SetBounds(&obBtnRec);
		pButton->SetEnabled(TRUE);
		pButton->SetCaption(pszString,FALSE);
	}
	return nButtonId;
}