sadmo54321
دوشنبه 05 تیر 1391, 17:16 عصر
سلام دوستان ويژوال ++C كار
من يه سوال برام پيش اومده، البته خودم روش خيلي فكر كردم و البته خيلي هم دنبال جواب بودم.
خوب حالا سوالم چيه؟
من ميخوام يه تصوير رو كه از طريق پنجره Open file مشخض كردم، رو نمايش بدم.
البته تونستم تصويرو روي كنترلي از نوع IDC_Static نشون بدم. اما هر كاري كردم نتونستم تصوير مورد نظرو،
روي پنجره اصلي برنامه نشون بدم. البته عكس هم ميزارم كه بهتر منظورم رو برسونم.
اينم قسمتي ار برنامه كه گفتم:
HBITMAP hBmp2 = (HBITMAP)LoadImage(0,m_sFilename,0,0,0,LR_LOADFROM FILE);
//HBITMAP hBmp1 = m_pic1.GetBitmap();
// namayeshe akse entekhab shode
m_pic1.SetBitmap(hBmp2);
//-----------------------------------------------------------------------------------
//bmp.LoadBitmapA(IDB_BITMAP1);
bmp.Attach(hBmp2);
// Get the size of the bitmap
bmp.GetBitmap(&bmpInfo);
// Create an in-memory DC compatible with the
// display DC we're using to paint
dcMemory.CreateCompatibleDC(pDC);
// Select the bitmap into the in-memory DC
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
// Find a centerpoint for the bitmap in the client area
GetClientRect(&rect);
int nX = rect.left + (rect.Width() - bmpInfo.bmWidth) / 2;
int nY = rect.top + (rect.Height() - bmpInfo.bmHeight) / 2;
//--- namayesh pahna va ertafa tasvir-----
m_Width.Format("%d",bmpInfo.bmWidth);
m_Da1.SetWindowTextA(m_Width);
m_Height.Format("%d",bmpInfo.bmHeight);
m_Da2.SetWindowTextA(m_Height);
//----------------------------------------
// Copy the bits from the in-memory DC into the on-
// screen DC to actually do the painting. Use the centerpoint
// we computed for the target offset.
m_bool = BitBlt(pDC->m_hDC,0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, dcMemory,0, 0, SRCCOPY);
http://sadmonew.persiangig.com/other/pic2hex_1.JPG
من يه سوال برام پيش اومده، البته خودم روش خيلي فكر كردم و البته خيلي هم دنبال جواب بودم.
خوب حالا سوالم چيه؟
من ميخوام يه تصوير رو كه از طريق پنجره Open file مشخض كردم، رو نمايش بدم.
البته تونستم تصويرو روي كنترلي از نوع IDC_Static نشون بدم. اما هر كاري كردم نتونستم تصوير مورد نظرو،
روي پنجره اصلي برنامه نشون بدم. البته عكس هم ميزارم كه بهتر منظورم رو برسونم.
اينم قسمتي ار برنامه كه گفتم:
HBITMAP hBmp2 = (HBITMAP)LoadImage(0,m_sFilename,0,0,0,LR_LOADFROM FILE);
//HBITMAP hBmp1 = m_pic1.GetBitmap();
// namayeshe akse entekhab shode
m_pic1.SetBitmap(hBmp2);
//-----------------------------------------------------------------------------------
//bmp.LoadBitmapA(IDB_BITMAP1);
bmp.Attach(hBmp2);
// Get the size of the bitmap
bmp.GetBitmap(&bmpInfo);
// Create an in-memory DC compatible with the
// display DC we're using to paint
dcMemory.CreateCompatibleDC(pDC);
// Select the bitmap into the in-memory DC
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
// Find a centerpoint for the bitmap in the client area
GetClientRect(&rect);
int nX = rect.left + (rect.Width() - bmpInfo.bmWidth) / 2;
int nY = rect.top + (rect.Height() - bmpInfo.bmHeight) / 2;
//--- namayesh pahna va ertafa tasvir-----
m_Width.Format("%d",bmpInfo.bmWidth);
m_Da1.SetWindowTextA(m_Width);
m_Height.Format("%d",bmpInfo.bmHeight);
m_Da2.SetWindowTextA(m_Height);
//----------------------------------------
// Copy the bits from the in-memory DC into the on-
// screen DC to actually do the painting. Use the centerpoint
// we computed for the target offset.
m_bool = BitBlt(pDC->m_hDC,0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, dcMemory,0, 0, SRCCOPY);
http://sadmonew.persiangig.com/other/pic2hex_1.JPG