BITMAPINFOHEADER 的有关问题
BITMAPINFOHEADER 的问题
单文档MFC页面上放置picture控件,动态加入图片,自动适应图片控件大小,初始化函数如下
------解决方案--------------------
m_bmp.GetObject( sizeof(ds), &ds );
int cx= "bminfo".biWidth;
int cy= "bminfo".biHeight;
改为:
m_bmp.GetObject( sizeof(ds), &ds );
int cx= ds.biWidth;
int cy= ds.biHeight;
怎么会用"bminfo"呢???
------解决方案--------------------
你这代码是抄来的吧??
怎么会出现双引号呢?
去掉双引号就可以了
单文档MFC页面上放置picture控件,动态加入图片,自动适应图片控件大小,初始化函数如下
BOOL pic::OnInitDialog(),运行时,提示错误
{
CDialog::OnInitDialog();
if( m_bmp.m_hObject != NULL )
m_bmp.DeleteObject();
HBITMAP hbmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),"c://12.bmp", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE);
if( hbmp == NULL )
return FALSE;
m_bmp.Attach( hbmp );
DIBSECTION ds;
BITMAPINFOHEADER &bminfo = ds.dsBmih;
m_bmp.GetObject( sizeof(ds), &ds );
int cx= "bminfo".biWidth;
int cy= "bminfo".biHeight;
CRect rect;
GetDlgItem(IDC_PICTURE)->GetWindowRect(&rect);
ScreenToClient(&rect);
GetDlgItem(IDC_PICTURE)->MoveWindow(rect.left,rect.top,cx,cy,true);
return TRUE; // return TRUE unless you set the focus to a control
}
error C2228: left of '.biWidth' must have class/struct/union type什么问题啊,怎样解决啊??
error C2228: left of '.biHeight' must have class/struct/union type
------解决方案--------------------
m_bmp.GetObject( sizeof(ds), &ds );
int cx= "bminfo".biWidth;
int cy= "bminfo".biHeight;
改为:
m_bmp.GetObject( sizeof(ds), &ds );
int cx= ds.biWidth;
int cy= ds.biHeight;
怎么会用"bminfo"呢???
------解决方案--------------------
你这代码是抄来的吧??
怎么会出现双引号呢?
去掉双引号就可以了