Click here to Skip to main content
16,012,166 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to find which Window have some DC ? Pin
Vitali Halershtein1-Sep-03 2:12
Vitali Halershtein1-Sep-03 2:12 
Generalclient server program Pin
vision20041-Sep-03 0:42
vision20041-Sep-03 0:42 
GeneralRe: client server program Pin
valikac1-Sep-03 5:52
valikac1-Sep-03 5:52 
GeneralDrawing on Dialog using DC Pin
YaronNir1-Sep-03 0:04
YaronNir1-Sep-03 0:04 
GeneralRe: Drawing on Dialog using DC Pin
Vitali Halershtein1-Sep-03 0:19
Vitali Halershtein1-Sep-03 0:19 
GeneralRe: Drawing on Dialog using DC Pin
YaronNir1-Sep-03 1:00
YaronNir1-Sep-03 1:00 
GeneralRe: Drawing on Dialog using DC Pin
Vitali Halershtein1-Sep-03 2:23
Vitali Halershtein1-Sep-03 2:23 
GeneralRe: Drawing on Dialog using DC Pin
csc1-Sep-03 2:10
csc1-Sep-03 2:10 
I'm doing that too, but it works. Even if the dialog needs a refresh / redraw.

Just to show an example, which should not look very strange from your point of view :

1) Define the handlers for InitDialog and OnPaint and add a CBitmap object in the dialogs header :

class CMyDialog : public CDialog
{
:
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
:
CBitmap m_bmMyBitmap;
:
};


2) make sure that the OnPaint:handler are in the CPP-File :
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
//{{AFX_MSG_MAP(CMyDialog)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()


3) Init the Bitmap object in the OnInitDialog function
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_bmMyBitmap.LoadBitmap( IDB_MY_BITMAP );
}

4) Fill the OnPaint-Handler :
void CDialogDruckauswahl::OnPaint()
{
CPaintDC dc(this); // device context for painting

// fill dialog background with some color.....
CRect crRect;
GetClientRect( &crRect );
COLORREF crColor = RGB( 255,255,255 );
CBrush* pFillBrush = new CBrush( crColor );
CBrush* pOldBrush = dc.SelectObject( pFillBrush );
CPen* pNewPen = new CPen( PS_SOLID, 1, crColor );
CPen* pOldPen = dc.SelectObject( pNewPen );
dc.Rectangle( crRect );
dc.SelectObject( pOldPen );
delete pNewPen;
pNewPen = NULL;
dc.SelectObject( pOldBrush );
delete pFillBrush;
pFillBrush = NULL;

// in welchen Bereich ?
DrawBitmap( &dc, crRect, &m_bmMyBitmap );
}

5) at least : define the bitmap drawing function :
void CMyDialog::DrawBitmap( CDC* pDC, CRect crRect, CBitmap* pBM )
{
// create a memory dc to prepare drawing via bitblt ...
CDC* pmemDCBitBlt = new CDC();
pmemDCBitBlt->CreateCompatibleDC( pDC );
CBitmap* pOldBM = pmemDCBitBlt->SelectObject( pBM );

// blit the bitmap into our view using the bitblt-xor-mode
pDC->BitBlt(crRect.TopLeft().x, crRect.TopLeft().y, crRect.Width(), crRect.Height(), pmemDCBitBlt, 0, 0, SRCCOPY );

// free the memory dc and the bitmap ....
pmemDCBitBlt->SelectObject( pOldBM );
delete pmemDCBitBlt;
pmemDCBitBlt = NULL;
}
GeneralRe: Drawing on Dialog using DC Pin
YaronNir1-Sep-03 2:12
YaronNir1-Sep-03 2:12 
GeneralString Parsing Pin
KKR31-Aug-03 23:50
KKR31-Aug-03 23:50 
GeneralRe: String Parsing Pin
Vitali Halershtein1-Sep-03 0:08
Vitali Halershtein1-Sep-03 0:08 
GeneralRe: String Parsing Pin
KKR1-Sep-03 0:20
KKR1-Sep-03 0:20 
GeneralRe: String Parsing Pin
Vitali Halershtein1-Sep-03 0:31
Vitali Halershtein1-Sep-03 0:31 
GeneralRe: String Parsing Pin
KKR1-Sep-03 0:56
KKR1-Sep-03 0:56 
GeneralDetermine whether keyboard connected with computer Pin
El'Cachubrey31-Aug-03 23:05
El'Cachubrey31-Aug-03 23:05 
GeneralLengthy operation without blocking the UI Pin
Jeremy Pullicino31-Aug-03 22:21
Jeremy Pullicino31-Aug-03 22:21 
GeneralRe: Lengthy operation without blocking the UI Pin
RChin31-Aug-03 22:57
RChin31-Aug-03 22:57 
GeneralRe: Lengthy operation without blocking the UI Pin
Frank Downunder1-Sep-03 2:17
Frank Downunder1-Sep-03 2:17 
GeneralFraction number input and output Pin
Jahangir Jamshed31-Aug-03 21:52
sussJahangir Jamshed31-Aug-03 21:52 
GeneralRe: Fraction number input and output Pin
KaЯl1-Sep-03 5:23
KaЯl1-Sep-03 5:23 
GeneralRe: Fraction number input and output Pin
LittleYellowBird1-Sep-03 5:36
LittleYellowBird1-Sep-03 5:36 
QuestionHow to position the controls in a view? Pin
ben231-Aug-03 21:04
ben231-Aug-03 21:04 
AnswerRe: How to position the controls in a view? Pin
CodeBrain31-Aug-03 21:19
CodeBrain31-Aug-03 21:19 
GeneralRe: How to position the controls in a view? Pin
ben231-Aug-03 21:54
ben231-Aug-03 21:54 
AnswerRe: How to position the controls in a view? Pin
Vitali Halershtein1-Sep-03 0:45
Vitali Halershtein1-Sep-03 0:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.