void CTWenUGCtrlEx::OnSetup(void) { CFont * pcFont = GetFont(m_nFontID_Content); CUGCell cell; GetGridDefault(&cell); cell.SetTextColor(RGB(0,0,0)); cell.SetFont(pcFont); cell.SetReadOnly(true); SetGridDefault(&cell); CString AppPath = CApplication::GetApplicationPath(); AppPath += _T('\\'); m_nIndexBMP_Delete = AddBitmap(AppPath + _T("_Action_Delete.bmp")); m_nIndexBMP_INF = AddBitmap(AppPath + _T("_Action_Info.bmp")); m_nIndexBMP_Add = AddBitmap(AppPath + _T("_Action_Add.bmp")); CString s; if(m_nIndexBMP_Delete<0) s += (_T("\r\n") + AppPath + _T("_Action_Delete.bmp")); if(m_nIndexBMP_INF<0) s += (_T("\r\n") + AppPath + _T("_Action_Info.bmp")); if(m_nIndexBMP_Add<0) s += (_T("\r\n") + AppPath + _T("_Action_Add.bmp")); if(!s.IsEmpty()) AfxMessageBox(_T("以下图片未能加载:") + s); }
void CanvasMessage::AddCursor(const ServerCursor& cursor) { //TODO:send as .cur data: Add(cursor.GetHotSpot()); AddBitmap(cursor); }
//--------------------------------------------------------------------------- TShip::TShip(TWinControl* AParent) : TGraphicObject(AParent) { AddBitmap("images/pingwin.bmp"); BitmapIndex = 0; Y = 0.1; X = (double)rand() / RAND_MAX; }
void COptionTreeItemImage::AddBitmap(CString strBitmap, COLORREF crMask, CString strText) { // Declare variables CBitmap bBitmap; // Load bitmap bBitmap.LoadBitmap(strBitmap); // Add bitmap AddBitmap(bBitmap, crMask, strText); }
void ClientView::CopyBitmap(const BBitmap *bmp, BRect frame, bool diff) { if(diff) AddBitmap(mBmp, frame, bmp); else CopyBitmap(mBmp, frame, bmp); BMessage msg(UPDATE); msg.AddRect("rect", frame); Window()->PostMessage(&msg, this); }
BOOL CPaletteBar::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID ) { BOOL bRet = CToolBarCtrl::Create(dwStyle, rect, pParentWnd, nID); m_nButtonCount = ID_ELLIPSE - ID_ERASE + 1; VERIFY(AddBitmap(m_nButtonCount,IDR_PALETTEBAR) != -1); m_pTBButtons = new TBBUTTON[m_nButtonCount]; int nIndex; for (nIndex = 0; nIndex < m_nButtonCount; nIndex++) { CString string; string.LoadString(nIndex + ID_ERASE); // Add second '\0' int nStringLength = string.GetLength() + 1; TCHAR* pString = string.GetBufferSetLength(nStringLength); pString[nStringLength] = 0; VERIFY((m_pTBButtons[nIndex].iString = AddStrings(pString)) != -1); string.ReleaseBuffer(); m_pTBButtons[nIndex].fsState = TBSTATE_ENABLED; m_pTBButtons[nIndex].fsStyle = TBSTYLE_CHECKGROUP; m_pTBButtons[nIndex].dwData = 0; m_pTBButtons[nIndex].iBitmap = nIndex; m_pTBButtons[nIndex].idCommand = nIndex + ID_ERASE; } for (nIndex = 0; nIndex < m_nButtonCount; nIndex++) { VERIFY(AddButtons(1,&m_pTBButtons[nIndex])); } return bRet; }
bool CTransparentBar::Create(CWnd* parent, UINT id) { int height= GetApp()->IsWhistlerLookAvailable() ? 25 : 23; if (!CToolBarCtrl::Create(WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | //TBSTYLE_TRANSPARENT | CCS_NOMOVEY | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER, CRect(0,0,80,height), parent, id)) { ASSERT(false); return false; } SendMessage(WM_SETFONT, WPARAM(::GetStockObject(DEFAULT_GUI_FONT))); // Add toolbar buttons // SetButtonStructSize(sizeof(TBBUTTON)); static const int anCommands[]= { ID_PHOTO_PREV, ID_PHOTO_NEXT, SC_CLOSE }; const int COUNT= array_count(anCommands); // no of buttons CSize btn_size; { CBitmap Bmp; Bmp.LoadBitmap(IDB_TRANSPARENT_BAR); BITMAP bmp; Bmp.GetBitmap(&bmp); btn_size = CSize(bmp.bmWidth / COUNT, bmp.bmHeight); // determine single button bitmap size } SetBitmapSize(btn_size); SetButtonSize(btn_size + CSize(8, 7)); AddBitmap(COUNT, IDB_TRANSPARENT_BAR); // RString tb(IDS_MAIN_TOOLBAR); // tb += "\n"; // tb.Replace('\n', '\0'); // int string= AddStrings(tb); CSize padding_size= GetApp()->IsWhistlerLookAvailable() ? CSize(5, 9) : CSize(3, 7); SendMessage(TB_SETPADDING, 0, MAKELONG(padding_size.cx, padding_size.cy)); for (int i= 0; i < COUNT; i++) { TBBUTTON btn; if (anCommands[i] == 0) { btn.iBitmap = 8; btn.idCommand = -1; btn.fsState = TBSTATE_ENABLED; btn.fsStyle = TBSTYLE_SEP; btn.data = 0; btn.iString = 0; AddButtons(1, &btn); } btn.iBitmap = i; btn.idCommand = anCommands[i]; btn.fsState = TBSTATE_ENABLED; btn.fsStyle = TBSTYLE_BUTTON; // | TBSTYLE_AUTOSIZE; // if (anCommands[i] == ID_RECURSIVE || anCommands[i] == ID_EXIF_ONLY) // btn.fsStyle |= TBSTYLE_CHECK; // else if (anCommands[i] == ID_VIEW_DETAILS || anCommands[i] == ID_VIEW_THUMBNAILS) // btn.fsStyle |= TBSTYLE_CHECKGROUP; // if (anCommands[i] == ID_FOLDER_LIST) // btn.fsStyle |= BTNS_WHOLEDROPDOWN; // if (anCommands[i] == ID_BROWSER || anCommands[i] == ID_COMPOSER || anCommands[i] == ID_READ_CAMERA) // btn.fsStyle |= BTNS_DROPDOWN; btn.data = 0; // if (anCommands[i] == ID_BROWSER || anCommands[i] == ID_COMPOSER || // anCommands[i] == ID_READ_CAMERA || anCommands[i] == ID_FOLDER_LIST) // btn.iString = string++; // else btn.iString = -1; AddButtons(1, &btn); } // SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS); return true; }
BOOL CRRECToolbar::Create( CWnd* parent, CRect& rc ) /* ============================================================ Function : CRRECToolbar::Create Description : Creates the toolbar control Access : Public Return : BOOL - "TRUE" if success Parameters : CWnd* parent - Parent editor CRect& rc - Rectangle to place toolbar in. Usage : Called from the parent editor ============================================================*/ { BOOL result = FALSE; HINSTANCE hInstance = AfxFindResourceHandle( MAKEINTRESOURCE( TOOLBAR_CONTROL ), RT_TOOLBAR ); if(!hInstance) return FALSE; HRSRC hRsrc = ::FindResource( hInstance, MAKEINTRESOURCE( TOOLBAR_CONTROL ), RT_TOOLBAR ); if( !hRsrc ) return FALSE; HGLOBAL hGlobal = LoadResource( hInstance, hRsrc ); if (hGlobal == NULL) return FALSE; CToolBarData* pData = ( CToolBarData* ) LockResource( hGlobal ); if (pData == NULL) return FALSE; ASSERT( pData->wVersion == 1 ); TBBUTTON tb, tbSep; memset ( &tb, 0, sizeof( tb ) ); memset ( &tbSep, 0, sizeof( tbSep ) ); result = CToolBarCtrl::Create(WS_VISIBLE|WS_CHILD, rc, parent, TOOLBAR_CONTROL); if( result ) { SetButtonStructSize( sizeof ( tb ) ); CSize sz ( pData->wWidth, pData->wHeight ); SetBitmapSize( sz ); sz.cx += 4; sz.cy += 4; SetButtonSize( sz ); // Loop through adding buttons. tb.fsState = TBSTATE_ENABLED; tb.fsStyle = TBSTYLE_BUTTON; tb.iString = -1; tb.iBitmap = 0; tbSep.iString = -1; tbSep.fsStyle = TBSTYLE_SEP; for( WORD w = 0; w < pData->wItemCount; w++ ) { if ( pData->items()[ w ] == 0 ) AddButtons( 1, &tbSep ); else { tb.idCommand = pData->items()[ w ]; AddButtons( 1, &tb ); tb.iBitmap++; } } HBITMAP hBitmap = (HBITMAP) ::LoadImage( hInstance, MAKEINTRESOURCE( TOOLBAR_CONTROL ), IMAGE_BITMAP, 0,0, LR_LOADMAP3DCOLORS ); if( !hBitmap ) return FALSE; BITMAP bm; memset( &bm, 0, sizeof ( bm ) ); ::GetObject( hBitmap, sizeof ( bm ), &bm ); AddBitmap( bm.bmWidth / pData->wWidth, CBitmap::FromHandle ( hBitmap ) ); UnlockResource( hGlobal ); FreeResource( hGlobal ); ///////////////////////////////////// // Map in combo boxes // CRect rect; TBBUTTONINFO tbi; tbi.cbSize = sizeof( TBBUTTONINFO ); tbi.cx = FONT_COMBO_WIDTH; tbi.dwMask = TBIF_SIZE | 0x80000000; // By index SetButtonInfo( FONT_NAME_POS, &tbi ); GetItemRect( FONT_NAME_POS, &rect ); rect.bottom += COMBO_HEIGHT; // The font name combo if( m_font.Create( WS_CHILD | WS_VSCROLL | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWN | CBS_SORT | CBS_HASSTRINGS, rect, this, DROPDOWN_FONT ) ) { m_font.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( ANSI_VAR_FONT ) ) ); m_font.FillCombo(); tbi.cx = COMBO_WIDTH; SetButtonInfo( FONT_SIZE_POS, &tbi ); GetItemRect( FONT_SIZE_POS, &rect ); rect.bottom += COMBO_HEIGHT; // The font size combo if( m_size.Create( WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS, rect, this, DROPDOWN_SIZE ) ) { m_size.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( ANSI_VAR_FONT ) ) ); m_size.FillCombo(); CString color; CString defaultText; CString customText; color.LoadString( STRING_COLOR ); defaultText.LoadString( STRING_DEFAULT ); customText.LoadString( STRING_CUSTOM ); tbi.cx = COLOR_WIDTH; SetButtonInfo( FONT_COLOR_POS, &tbi ); GetItemRect( FONT_COLOR_POS, &rect ); // The color picker if( m_color.Create( color, WS_VISIBLE| WS_CHILD, rect, this, BUTTON_COLOR ) ) { m_color.SetDefaultText( defaultText ); m_color.SetCustomText( customText ); m_color.SetSelectionMode( CP_MODE_TEXT ); m_color.SetBkColour( RGB( 255, 255, 255 ) ); m_color.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( ANSI_VAR_FONT ) ) ); result = TRUE; } } } } return result; }
void RemoteMessage::AddCursor(const ServerCursor& cursor) { Add(cursor.GetHotSpot()); AddBitmap(cursor); }