数据库已创建好,根据卡号获取姓名,再根据姓名查找显示图片。。。
void CbitMapDlg::OnLoadBitMap()
{
// TODO: 在此添加控件通知处理程序代码
CppSQLite3DB db;
db.open(L"meninfo.db");
CppSQLite3Query query = db.execQuery(L"select * from meninfo where cardNO = 123;");
LPCTSTR name = query.getStringField(L"name");
//CBitmap bitmap;
TCHAR path[256] = {0};
swprintf((wchar_t*)path, L"FlashDisk\picSrc\%s.bmp",name);
//bitmap.LoadBitmap(IDB_BITMAP);
HBITMAP hbitmap = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
path,//文件全路径
IMAGE_BITMAP,
0,
0,
0x00002000|0x00000010);
CDC dcCompatible;
CDC *pDC=GetDlgItem(IDC_PICTURE)->GetDC();
dcCompatible.CreateCompatibleDC(pDC);
dcCompatible.SelectObject(hbitmap);
CRect rect;
GetDlgItem(IDC_PICTURE)->GetClientRect(&rect);
BITMAP bmpInfo;
CBitmap cbitmap;
cbitmap.Attach(hbitmap);//由HBITMAP 得到关联的CBitmap
cbitmap.GetBitmap(&bmpInfo); // 由CBitmap 得到关联的BITMAP
pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight,SRCCOPY);
}