void CCqkjgDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon dc.DrawIcon(x, y, m_hIcon); } else {
char buf[512]; ::GetCurrentDirectory(512,buf); CString m_pic; m_pic="\\11.jpg"; strcat(buf,m_pic);
CFileStatus fstatus; CFile file; IStream *pStm; LONG cb; if(file.Open(buf,CFile::modeRead)&&file.GetStatus(buf,fstatus)&& ((cb = fstatus.m_size) != -1)) { HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb); LPVOID pvData = NULL; if (hGlobal != NULL) { if ((pvData = GlobalLock(hGlobal)) != NULL) { file.ReadHuge(pvData, cb); GlobalUnlock(hGlobal); CreateStreamOnHGlobal(hGlobal, TRUE, &pStm); } } } IPicture *pPic; //CComQIPtr<IPicture> pPic; if(SUCCEEDED(OleLoadPicture(pStm,fstatus.m_size,false,IID_IPicture,(LPVOID*)&pPic))) { long a,b; pPic->get_Width(&a); pPic->get_Height(&b); CSize sz(a,b); CDC *pdc=GetDC(); pdc->HIMETRICtoDP(&sz); CRect rect; this->GetClientRect(&rect); pPic->Render(*pdc,rect.left+160,rect.top+180,sz.cx,sz.cy,0,b,a,-b,&rect); }
CDialog::OnPaint(); } }
|