Click here to Skip to main content
15,917,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: UINT == long ??? Pin
Hadi Rezaee17-Jul-01 17:56
Hadi Rezaee17-Jul-01 17:56 
GeneralOpening a new document by passing the file name in CView class. Pin
mr200316-Jul-01 2:54
mr200316-Jul-01 2:54 
GeneralRe: Opening a new document by passing the file name in CView class. Pin
Ben Burnett16-Jul-01 5:20
Ben Burnett16-Jul-01 5:20 
GeneralRe: Opening a new document by passing the file name in CView class. Pin
mr200316-Jul-01 6:33
mr200316-Jul-01 6:33 
GeneralRe: Opening a new document by passing the file name in CView class. Pin
Ben Burnett16-Jul-01 9:29
Ben Burnett16-Jul-01 9:29 
GeneralRe: Opening a new document by passing the file name in CView class. Pin
mr200317-Jul-01 2:32
mr200317-Jul-01 2:32 
GeneralRe: Opening a new document by passing the file name in CView class. Pin
Ben Burnett17-Jul-01 5:27
Ben Burnett17-Jul-01 5:27 
GeneralRe: Opening a new document by passing the file name in CView class. Pin
mr200317-Jul-01 7:47
mr200317-Jul-01 7:47 
Thanks for replying
this is the whole deal,,

void CTurboMechView::OnToolsNewDocuemnt()
{
// TODO: Add your command handler code here
CWinApp* pApp = AfxGetApp();
CTurboMechDoc *pFirstDoc= GetFirstDocument();

pApp->OpenDocumentFile(pFirstDoc->m_filePathArray.GetAt(0));

CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;

// Get the active MDI child window.
//CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();

CMDIChildWnd *pChild = pFrame->MDIGetActive();

// Get the active view attached to the active MDI child
// window.
CTurboMechView *pView = (CTurboMechView *) pChild->GetActiveView();
pView->LoadBitmap(pFirstDoc->m_filePathArray.GetAt(0));
pView->OnPaint();
// so up there, I loaded the bitmap in the new View, but it still doesn't show it... weird !!!

}

This my OnPaint()
void CTurboMechView::OnPaint()
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
CRect lrec;
CTurboMechDoc* pDoc=GetDocument();

if(pDoc->m_sBitmap !="" /*&& showstate==TRUE*/)
{
ShowBitmap(&dc,lrec);
}
OnDraw(&dc);
// Do not call CScrollView::OnPaint() for painting messages
}

void CTurboMechView::LoadBitmap(CString file)
{
CTurboMechDoc* pDoc = GetDocument();

if(file!="")
{
HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if (hBitmap)
{
// Delete the current bitmap
if (m_bmpBitmap.DeleteObject())
{
m_bmpBitmap.Detach();
}
// Attach the currently loaded bitmap to the bitmap object
m_bmpBitmap.Attach(hBitmap);
}
Invalidate(FALSE); // you may change this to False
//NOTE:IMPORTANT I moved this showstate inside the if
}
}

void CTurboMechView::ShowBitmap(CDC *pdc, CRect trect)
{
BITMAP bm;
CDC dcMem;
CRect lRect=trect;

// Get the loaded bitmap
m_bmpBitmap.GetBitmap(&bm);

// Create a device context to load the bitmap into
dcMem.CreateCompatibleDC(pdc);

// Select the bitmap into the compatible device context
CBitmap* pOldBitmap = (CBitmap*)dcMem.SelectObject(m_bmpBitmap);
lRect.NormalizeRect();
width=bm.bmWidth;
height=bm.bmHeight;

pdc->StretchBlt(0, 0, width*2.28, height*2.28, &dcMem, 0, 0, 255, 255, SRCCOPY);

}




Ehsan Behboudi
GeneralHelp About Scroll Message of ListView Pin
Leadream16-Jul-01 2:52
Leadream16-Jul-01 2:52 
GeneralHelp About Scroll Message of ListView Pin
Leadream16-Jul-01 2:52
Leadream16-Jul-01 2:52 
Generaldeleting cookies Pin
16-Jul-01 1:21
suss16-Jul-01 1:21 
GeneralBest way to learn MFC Pin
16-Jul-01 1:00
suss16-Jul-01 1:00 
GeneralRe: Best way to learn MFC Pin
Christian Graus16-Jul-01 1:07
protectorChristian Graus16-Jul-01 1:07 
GeneralRich Edit Control Pin
AJ12316-Jul-01 0:49
AJ12316-Jul-01 0:49 
GeneralHRESULT Pin
AJ12316-Jul-01 0:47
AJ12316-Jul-01 0:47 
GeneralRe: HRESULT Pin
Christian Graus16-Jul-01 0:58
protectorChristian Graus16-Jul-01 0:58 
GeneralRe: HRESULT Pin
16-Jul-01 7:12
suss16-Jul-01 7:12 
GeneralRe: HRESULT Pin
Christian Graus16-Jul-01 13:12
protectorChristian Graus16-Jul-01 13:12 
GeneralRe: HRESULT Pin
16-Jul-01 14:48
suss16-Jul-01 14:48 
GeneralRe: HRESULT Pin
16-Jul-01 7:10
suss16-Jul-01 7:10 
GeneralRe: HRESULT Pin
Ernest Laurentin16-Jul-01 8:00
Ernest Laurentin16-Jul-01 8:00 
GeneralRe: HRESULT Pin
AJ12316-Jul-01 9:29
AJ12316-Jul-01 9:29 
QuestionHow to add Hours to a DATE? Pin
16-Jul-01 0:11
suss16-Jul-01 0:11 
AnswerRe: How to add Hours to a DATE? Pin
Anders Molin16-Jul-01 0:32
professionalAnders Molin16-Jul-01 0:32 
GeneralRe: How to add Hours to a DATE? Pin
16-Jul-01 1:08
suss16-Jul-01 1:08 

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.