Click here to Skip to main content
16,003,902 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSTL and UNICODE Pin
Nick Blumhardt2-Jul-01 17:19
Nick Blumhardt2-Jul-01 17:19 
GeneralRe: STL and UNICODE Pin
Michael Dunn2-Jul-01 18:52
sitebuilderMichael Dunn2-Jul-01 18:52 
GeneralRe: STL and UNICODE Pin
Nick Blumhardt2-Jul-01 19:11
Nick Blumhardt2-Jul-01 19:11 
GeneralRe: STL and UNICODE Pin
2-Jul-01 21:30
suss2-Jul-01 21:30 
GeneralRe: STL and UNICODE Pin
3-Jul-01 5:02
suss3-Jul-01 5:02 
GeneralRe: STL and UNICODE Pin
3-Jul-01 12:30
suss3-Jul-01 12:30 
GeneralRe: STL and UNICODE Pin
[James Pullicino]3-Jul-01 5:18
[James Pullicino]3-Jul-01 5:18 
Generalload image Pin
Kathrin2-Jul-01 16:08
Kathrin2-Jul-01 16:08 
I try to create an image app based on Sam Teach Yourself Visual C++ in 21 Days chapter - 8 - Adding Flash--Incorporating Graphics, Drawing, and Bitmaps. The example shows that in order to load an image requires some kind of open file function, but I don’t want to use that function. I want to load my image that I’ve initialized. So I didn’t use some functions mentioned on the example, and it caused an error. The error is saying :
Debug Assertion failed. File afxwin1.inl. Line 418.
And the code is :

// ImageDlg.cpp : implementation file
void CImageDlg::OnBitmap()
{/*I did’t use this function to load the image
// Build a filter for use in the File Open dialog
static char BASED_CODE szFilter[] = "Bitmap Files (*.bmp)|*.bmp||";
// Create the File Open dialog
CFileDialog m_ldFile(TRUE, ".bmp", m_sBitmap,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);

// Show the File Open dialog and capture the result
if (m_ldFile.DoModal() == IDOK)
{
// Get the filename selected
m_sBitmap = m_ldFile.GetPathName();
// Load the selected bitmap file
HBITMAP hBitmap = (HBITMAP) :LoadImage(AfxGetInstanceHandle(),
m_sBitmap, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION);

// Do we have a valid handle for the loaded image?
if (hBitmap)
{
// Delete the current bitmap
if (m_bmpBitmap.DeleteObject())
// If there was a bitmap, detach it
m_bmpBitmap.Detach();
// Attach the currently loaded bitmap to the bitmap object
m_bmpBitmap.Attach(hBitmap);
}
*/the function to load the image end here

// But I used this function to load the image
m_bmpBitmap.LoadBitmap(IDB_BITMAP2);

// Invalidate the second dialog window
m_dlgImage.Invalidate();
}
}

// ImageDialog.cpp : implementation file
void CImageDialog::ShowBitmap(CPaintDC *pdc, CWnd *pWnd)
{
// Convert the pointer to a pointer to the main dialog class
CImageDlg *lpWnd = (CImageDlg *)pWnd;
BITMAP bm;
// Get the loaded bitmap
lpWnd->m_bmpBitmap.GetBitmap(&bm);
CDC dcMem;
// 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(lpWnd->m_bmpBitmap);
CRect lRect;
// Get the display area available
GetClientRect(lRect);
lRect.NormalizeRect();
// Copy and resize the bitmap to the dialog window
pdc->StretchBlt(10, 10, (lRect.Width() - 20),
(lRect.Height() - 20), &dcMem, 0, 0,
bm.bmWidth, bm.bmHeight, SRCCOPY);
}

void CImageDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting

// Get a pointer to the parent window
CImageDlg *pWnd = (CImageDlg *)GetParent();
// Do we have a valid pointer?
if (pWnd)
{
// Is there a bitmap selected and loaded? I didin’t use this function
//if (pWnd->m_sBitmap != "")
// I use this function to Display the image
ShowBitmap(&dc, pWnd);
}
}
what should I do if I don’t use the function (pWnd->m_sBitmap != "") .
Thanks a lot of for helping

Kathrin

Confused | :confused:
GeneralRe: load image Pin
Christian Graus2-Jul-01 17:38
protectorChristian Graus2-Jul-01 17:38 
GeneralRe: load image Pin
Kathrin3-Jul-01 21:10
Kathrin3-Jul-01 21:10 
GeneralRe: load image Pin
Erik Thompson3-Jul-01 7:28
sitebuilderErik Thompson3-Jul-01 7:28 
GeneralRe: load image Pin
Kathrin3-Jul-01 22:00
Kathrin3-Jul-01 22:00 
GeneralRe: load image Pin
Erik Thompson4-Jul-01 7:24
sitebuilderErik Thompson4-Jul-01 7:24 
GeneralRe: load image Pin
Kathrin4-Jul-01 19:08
Kathrin4-Jul-01 19:08 
GeneralRe: load image Pin
Christian Graus4-Jul-01 19:15
protectorChristian Graus4-Jul-01 19:15 
Generalchange filename Pin
2-Jul-01 14:07
suss2-Jul-01 14:07 
GeneralRe: change filename Pin
Carlos Antollini2-Jul-01 14:56
Carlos Antollini2-Jul-01 14:56 
GeneralRe: change filename Pin
2-Jul-01 15:21
suss2-Jul-01 15:21 
GeneralRe: change filename Pin
3-Jul-01 5:22
suss3-Jul-01 5:22 
GeneralCOM IDL Pin
William Bartholomew2-Jul-01 12:42
William Bartholomew2-Jul-01 12:42 
GeneralRe: COM IDL Pin
Richard Caetano2-Jul-01 13:43
Richard Caetano2-Jul-01 13:43 
GeneralRe: COM IDL Pin
Richard Caetano2-Jul-01 13:47
Richard Caetano2-Jul-01 13:47 
GeneralAudio looping using waveform functions. Pin
2-Jul-01 10:47
suss2-Jul-01 10:47 
GeneralCStatusBarCtrl::SetIcon Pin
Rickard Andersson202-Jul-01 9:42
Rickard Andersson202-Jul-01 9:42 
GeneralRe: CStatusBarCtrl::SetIcon Pin
Michael Martin2-Jul-01 13:50
professionalMichael Martin2-Jul-01 13:50 

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.