Click here to Skip to main content
15,918,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Horrid Memory Management Issue Pin
Dangleberry11-Sep-03 0:14
sussDangleberry11-Sep-03 0:14 
GeneralRe: Horrid Memory Management Issue Pin
antlers11-Sep-03 9:39
antlers11-Sep-03 9:39 
GeneralRe: Horrid Memory Management Issue Pin
Dangleberry11-Sep-03 23:15
sussDangleberry11-Sep-03 23:15 
GeneralProblem handling pictures Pin
abhi197110-Sep-03 22:19
abhi197110-Sep-03 22:19 
GeneralRe: Problem handling pictures Pin
Dangleberry10-Sep-03 22:37
sussDangleberry10-Sep-03 22:37 
GeneralRe: Problem handling pictures Pin
abhi197110-Sep-03 22:51
abhi197110-Sep-03 22:51 
GeneralRe: Problem handling pictures Pin
Dangleberry10-Sep-03 22:58
sussDangleberry10-Sep-03 22:58 
GeneralRe: Problem handling pictures Pin
abhi197110-Sep-03 23:02
abhi197110-Sep-03 23:02 
I'm posting it, sorry it must have been a very very clumsy one Dead | X| -

CString filename;
char szFilters[]="Picture Files(*.bmp)|(*.gif)|All Files(*.*)|*.*||";
CFileDialog dlg(TRUE,"bmp","*.bmp",OFN_FILEMUSTEXIST|
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
szFilters,this);
if(dlg.DoModal()==IDOK)
{
filename=dlg.GetPathName();
}
else return;
OnNewFileLoaded();
bBitmap.Detach();
/*m_Bit.SetBitmap(LoadImage(filename.GetBuffer(20)));*/
bBitmap.Attach((HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE));
// m_Bit.SetBitmap((HBITMAP)bBitmap);
// m_TextDisplay.SetWindowText("Please Click on the Origin of the graph's axes"
// "and Press the DONE button");
CDC* pDC = GetDC();
CBrush brush(pDC->GetPixel(1,1)),*oldbrush;
oldbrush = pDC->SelectObject(&brush);
pDC->FloodFill(7,7,pDC->GetPixel(1,1));
pDC->SelectObject(oldbrush);
BITMAP BM;
if(bBitmap.GetObjectType()==0) {
AfxMessageBox("Invalid File Format.\nLoads only Bitmaps.");
return;
}
bBitmap.GetObject(sizeof(BM),&BM);
CRect rectClient;
GetClientRect(&rectClient);
if(rectClient.Height()<bm.bmheight||rectclient.width()<bm.bmwidth)
{
="" cmainframe*="" pmain="(CMainFrame*)" getparentframe();
="" pmain-="">ActivateFrame(SW_SHOWMAXIMIZED);
AfxGetApp()->m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
}
if(WIDTH>BM.bmWidth&&HEIGHT>BM.bmHeight){
destWidth = BM.bmWidth;
destHeight = BM.bmHeight;
}
else if(WIDTH>BM.bmWidth&&HEIGHT<bm.bmheight){
destwidth="(int)(destHeight*((double)BM.bmWidth/(double)BM.bmHeight));
" }
="" else="" if(width<bm.bmwidth&&height="">BM.bmHeight){
destHeight = (int)(destWidth*((double)BM.bmHeight/(double)BM.bmWidth));
}
else
{
if(BM.bmWidth>BM.bmHeight){
destWidth = WIDTH;
destHeight = int((double(BM.bmHeight)/double(BM.bmWidth))*double(destWidth));
}
else{
destHeight = HEIGHT;
destWidth = int((double(BM.bmWidth)/double(BM.bmHeight))*double(destHeight));
}


}
CPoint ratio;
ratio.x= destWidth;
ratio.y= destHeight;
ratioHeight = (double)BM.bmHeight/(double)ratio.y;
ratioWidth = (double)BM.bmWidth/(double)ratio.x;
CMainFrame* pMain= (CMainFrame*) GetParentFrame();
CToolBarCtrl* pCtrl = (CToolBarCtrl*)pMain->GetToolBar();
if(pCtrl->IsButtonChecked(ID_TOOLZOOM)){
OnToolzoom();
}
if(m_ShowZOOM.IsWindowVisible()) m_ShowZOOM.ShowWindow(FALSE);
RedrawWindow(NULL,NULL);
if(!rectBitmap.IsRectEmpty())this->ValidateRect(&rectBitmap);
if(HBITMAP(bBitmap)!=NULL){
BITMAP BM;
CDC MemDC;
MemDC.CreateCompatibleDC(NULL);
MemDC.SelectObject(bBitmap);
if(bBitmap.GetObjectType()==0){
AfxMessageBox("Invalid File Format.\nLoads only Bitmaps.");
return;
}
bBitmap.GetObject(sizeof(BM),&BM);
GetDC()->StretchBlt(7,7,destWidth,destHeight,&MemDC,0,0,BM.bmWidth,BM.bmHeight,SRCCOPY);

rectBitmap.top = 7;rectBitmap.left = 7;rectBitmap.bottom = destHeight+7;
rectBitmap.right = destWidth+7;
GetDC()->DPtoLP(&rectBitmap);
GeneralRe: Problem handling pictures Pin
Dangleberry10-Sep-03 23:41
sussDangleberry10-Sep-03 23:41 
GeneralRe: Problem handling pictures Pin
Jagadeesh VN11-Sep-03 4:51
Jagadeesh VN11-Sep-03 4:51 
GeneralRe: Problem handling pictures Pin
abhi197111-Sep-03 22:36
abhi197111-Sep-03 22:36 
GeneralSocket programming in Visual C++ 6 Pin
fahimtufaillara10-Sep-03 21:55
fahimtufaillara10-Sep-03 21:55 
GeneralRe: Socket programming in Visual C++ 6 Pin
R. Thomas10-Sep-03 22:11
R. Thomas10-Sep-03 22:11 
GeneralRe: Socket programming in Visual C++ 6 Pin
Jagadeesh VN11-Sep-03 4:58
Jagadeesh VN11-Sep-03 4:58 
GeneralMenu on Dialog not working Pin
Ph@ntom10-Sep-03 21:36
Ph@ntom10-Sep-03 21:36 
GeneralRe: Menu on Dialog not working Pin
Jagadeesh VN11-Sep-03 5:03
Jagadeesh VN11-Sep-03 5:03 
Generalcompiler errors - I am confused Pin
Slaru10-Sep-03 17:25
Slaru10-Sep-03 17:25 
GeneralRe: compiler errors - I am confused Pin
Joe Woodbury10-Sep-03 18:23
professionalJoe Woodbury10-Sep-03 18:23 
GeneralRe: compiler errors - I am confused Pin
Cedric Moonen10-Sep-03 20:15
Cedric Moonen10-Sep-03 20:15 
GeneralRe: compiler errors - I am confused Pin
PengFeidu10-Sep-03 20:12
PengFeidu10-Sep-03 20:12 
GeneralRe: compiler errors - I am confused Pin
Ph@ntom10-Sep-03 21:54
Ph@ntom10-Sep-03 21:54 
GeneralRe: compiler errors - I am confused Pin
Slaru11-Sep-03 2:22
Slaru11-Sep-03 2:22 
GeneralRe: compiler errors - I am confused Pin
David Crow11-Sep-03 3:11
David Crow11-Sep-03 3:11 
GeneralRe: compiler errors - I am confused Pin
Arthur Westerman12-Sep-03 2:14
Arthur Westerman12-Sep-03 2:14 
GeneralDisplaying Doubles Pin
fynox10-Sep-03 16:55
fynox10-Sep-03 16:55 

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.