Click here to Skip to main content
15,890,512 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How many of you use _tcsinc ? Pin
Chintoo72325-Mar-05 1:20
Chintoo72325-Mar-05 1:20 
GeneralRe: How many of you use _tcsinc ? Pin
Blake Miller25-Mar-05 6:56
Blake Miller25-Mar-05 6:56 
AnswerRe: How many of you use _tcsinc ? Pin
David Crow25-Mar-05 3:35
David Crow25-Mar-05 3:35 
GeneralRe: How many of you use _tcsinc ? Pin
Chintoo72325-Mar-05 5:07
Chintoo72325-Mar-05 5:07 
AnswerRe: How many of you use _tcsinc ? Pin
Blake Miller25-Mar-05 6:47
Blake Miller25-Mar-05 6:47 
AnswerRe: How many of you use _tcsinc ? Pin
Michael Dunn25-Mar-05 6:49
sitebuilderMichael Dunn25-Mar-05 6:49 
AnswerRe: How many of you use _tcsinc ? Pin
cmk25-Mar-05 9:26
cmk25-Mar-05 9:26 
QuestionHow messages be dispatched? Pin
kokehqyu24-Mar-05 20:38
kokehqyu24-Mar-05 20:38 
class CEncoderView is a MDI's view class. class CBMWin which derived from class CWnd is the subwindow of class CEncoderView.
I want to save the view as a DIB, so that I firstly DoModal a dialog for getting the DIB file's path. then I send a message MY_SAVEWHOLE which is handled in DefWindowProc to save the view as a DIB file.But I find the dialog is also appeared in the DIB file.
In order to clear the dialog, I invalidate the whole desktop befor saving the view shown as step 1 in the source code below. At this time, there are only the subwindow frames be showed in the DIB. they client rect is empty,because they did't redraw themselves.
In step 2 shown in the source code below, I get messages from the message queue. I want to save the view after all of its subwindows have send a message MY_REDRAW to it. But I find that the function GetMessage can't retrieve message MY_REDRAW at label A in the source code below. Meanwhile, I can retrieve the message MY_REDRAW in the function DefWindowProc at label B which shown in the source code below.
How the message be dispatch in the window?Mad | :mad:

#define MY_SAVEWHOLE WM_APP + 2 //save a view window as a file
#define MY_REDRAW WM_APP + 3 //have redrawed a subwindow
void CEncoderView::OnExportimage()
{
CExportImageDlg exportidlg( this );
int nRet = -1;
nRet = exportidlg.DoModal();
if (( nRet == -1 ) || ( nRet == IDABORT ))
{
AfxMessageBox( "Dialog box could not be created!");
return;
}
if ( nRet != IDOK )
{
return;
}

//added in step 1
//redraw all windows
::InvalidateRect( NULL, NULL, FALSE );
//end of added in step 1

//added in step 2
//the number of subwindows whose type isCBMWin
int iRedrawedSubWin = 0;
MSG msg;
int bRet;
//if all of the subwindows had redrawed themselves
//then save the view as a DIB
while(( iRedrawedSubWin < iSubWinNum ) &&
((bRet = ::GetMessage( &msg, NULL, 0, 0 )) != 0))
{
//can't retrieve message MY_REDRAW at this point
if ( msg.message == MY_REDRAW )
{
//never execute,can't retrieved message MY_REDRAW
label A: iRedrawedSubWin++;
}
if (bRet == -1)
{
break;// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
//end of added in step 2
::SendMessage( m_hWnd, MY_SAVEWHOLE, ( WPARAM )( &exportidlg.m_CSFileRoute ), NULL );
}
LRESULT CEncoderView::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
CBMWin* pChildWnd = NULL;
int iRetValue;
PBITMAPINFO pBitmapInfo = NULL;
switch( message )
{
case MY_SAVEWHOLE:
iRetValue = Win2DIB( this, &pBitmapInfo);
if ( iRetValue != ERR_OK )
{
return 0;
}
SaveDIBFile( pBitmapInfo, ( CString* )wParam );
free( pBitmapInfo );
return 0;
case MY_REDRAW:
//when subwindow redraw,this message can be retrieved
label B: iRetValue = 0; //no mean.
}
return CView::DefWindowProc(message, wParam, lParam);
}
void CBMWin::OnPaint()
{
CPaintDC dc(this); // device context for painting
RECT rect;
GetClientRect( &rect );
//draw a DIB on the client rect
StretchDIBits( dc,
0, 0, rect.right, rect.bottom,
0, 0, ...);
//tell the prarent window CEncoderView it has redrawed itself
::SendMessage( GetParent()->m_hWnd, MY_REDRAW, NULL, NULL );
}

andy
QuestionCustom ActiveX control? Pin
foxyspy24-Mar-05 20:24
foxyspy24-Mar-05 20:24 
GeneralCapturing KeyUp and Setting Value ... Pin
Mitch F.24-Mar-05 20:19
Mitch F.24-Mar-05 20:19 
GeneralRe: Capturing KeyUp and Setting Value ... Pin
Anthony_Yio25-Mar-05 18:58
Anthony_Yio25-Mar-05 18:58 
GeneralDetermining if a character can be rendered in a certain font Pin
Taka Muraoka24-Mar-05 20:18
Taka Muraoka24-Mar-05 20:18 
GeneralPlease help me! Pin
dSolariuM24-Mar-05 20:13
dSolariuM24-Mar-05 20:13 
GeneralRe: Please help me! Pin
toxcct24-Mar-05 21:22
toxcct24-Mar-05 21:22 
GeneralRe: Please help me! Pin
wise_8224-Mar-05 23:23
wise_8224-Mar-05 23:23 
GeneralRe: Please help me! Pin
Chintoo72325-Mar-05 1:17
Chintoo72325-Mar-05 1:17 
GeneralRe: Please help me! Pin
toxcct25-Mar-05 1:30
toxcct25-Mar-05 1:30 
GeneralRe: Please help me! Pin
Chintoo72325-Mar-05 2:13
Chintoo72325-Mar-05 2:13 
GeneralRe: Please help me! Pin
toxcct25-Mar-05 2:19
toxcct25-Mar-05 2:19 
GeneralRe: Please help me! Pin
Chintoo72325-Mar-05 2:31
Chintoo72325-Mar-05 2:31 
Generalhardware enumeration Pin
brilliant10124-Mar-05 19:54
brilliant10124-Mar-05 19:54 
GeneralRe: hardware enumeration Pin
brilliant10124-Mar-05 20:00
brilliant10124-Mar-05 20:00 
GeneralRe: hardware enumeration Pin
toxcct24-Mar-05 22:07
toxcct24-Mar-05 22:07 
GeneralRe: hardware enumeration Pin
David Crow25-Mar-05 2:53
David Crow25-Mar-05 2:53 
Generalhigh performance graphic libaray! Pin
simonchen.net24-Mar-05 18:12
simonchen.net24-Mar-05 18:12 

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.