|
Do you have one handle bitmap (of course is valid)?
whitesky
|
|
|
|
|
Sorry, What do you mean?
-- modified at 6:56 Friday 9th June, 2006
|
|
|
|
|
maybe your handle isnt valid or its null
whitesky
|
|
|
|
|
I think not because in my Application the values iHeight and iWidth of the bitmap are right. that means for me, that the handle "desc.bmp.hbitmap = (HBITMAP)bmp.GetSafeHandle();" is valid.
|
|
|
|
|
yes you have one handle hbitmap (desc.bmp.hbitmap ) but in OnBnClickedButton1
i think(not sure)you dont have one valid handle pPicture->get_Handle((OLE_HANDLE FAR *) &hBmp);
what size(parametes) from hBmp GetObject(hBmp,sizeof(bm),&bm);
whitesky
|
|
|
|
|
pPicture->get_Handle((OLE_HANDLE FAR *) &hBmp);<br />
<br />
<br />
if (hBmp) <br />
{ <br />
MesssageBox("it exists");<br />
}
After "if" it comes the MesssageBox .
But if i do the follow:
if(GetObject(hBmp,sizeof(BMP), &BMP)==0) MessageBox("0 bytes");
it comes the MessageBox also.
Is the hBMP valid or not?
-- modified at 9:00 Friday 9th June, 2006
|
|
|
|
|
And why work the follow code:
pPicture->get_Width(&lWidth);<br />
pPicture->get_Height(&lHeight);
Width and Height are correct . the same size of the original bitmap.
But
pPicture->get_Width(&lWidth);<br />
pPicture->get_Height(&lHeight);
is not valid.
I not understand
|
|
|
|
|
Dear masanne,
its not way but usually i test hbitmap with this
if you run this code in getImage for bmp then you get one file in drive c
<br />
CImage m_Image;<br />
m_Image.Attach(hBmp);<br />
m_Image.Save("c:\\test.bmp");<br />
m_Image.Detach();<br />
but if you run this code in OnBnClickedButton1
/*pPicture->get_Handle((OLE_HANDLE FAR *) &hBmp);*/for hBmp you get one error
can you test this code and answer to me,please? of course include atlImage.h
whitesky
|
|
|
|
|
If include this code in GetImage()-Methode , it happens nothing
(no File under the path " C:\work\test\test.bmp".
HBITMAP hBmp = (HBITMAP)bmp.GetSafeHandle();<br />
CImage m_Image;<br />
m_Image.Attach(hBmp);<br />
m_Image.Save("C:\work\test\test.bmp");<br />
m_Image.Detach();
And if i include the follow code in the Application under OnBnClickedButton1
pPicture->get_Handle((OLE_HANDLE FAR *) &hBmp);<br />
<br />
<br />
CImage m_Image;<br />
m_Image.Attach(hBmp);<br />
m_Image.Save("C:\work\test\test.bmp");<br />
m_Image.Detach();
it happens nothing
(no File under the path " C:\work\test\test.bmp") and it comes to a error.
|
|
|
|
|
yes you get one error nBytes==Sizeof....
and if you use GetObject you cant get width and height and i think my guess is true (i hope)you dont have one handle bitmap.See here
<br />
CBitmap bmp ;<br />
PICTDESC desc;<br />
<br />
long lWidth, lHeight;<br />
int iWidth, iHeight;<br />
<br />
HBITMAP hbit=(HBITMAP)LoadImage(AfxGetApp()->m_hInstance,"c:\\0.bmp",IMAGE_BITMAP, 0,0,LR_LOADFROMFILE);<br />
bmp.Attach(hbit);<br />
<br />
desc.cbSizeofstruct = sizeof(PICTDESC) ;<br />
desc.picType = PICTYPE_BITMAP;<br />
desc.bmp.hbitmap = (HBITMAP)bmp.GetSafeHandle();<br />
IPicture *pd;<br />
<br />
::OleCreatePictureIndirect(&desc, IID_IPicture, FALSE,(LPVOID*)&pd);<br />
<br />
pd->get_Width(&lWidth);<br />
pd->get_Height(&lHeight);<br />
<br />
iWidth = (lWidth * GetDeviceCaps(GetDC()->m_hDC, LOGPIXELSX)) / 2540;<br />
iHeight = (lHeight * GetDeviceCaps(GetDC()->m_hDC, LOGPIXELSY)) / 2540;<br />
CRect Rect(0,0,iWidth,iHeight);<br />
<br />
pd->Render(GetDC()->m_hDC,0,0, <br />
Rect.right - Rect.left,<br />
Rect.bottom - Rect.top,<br />
0,lHeight,<br />
lWidth,-lHeight,<br />
&Rect);<br /> maybe it is some helpful to you
whitesky
|
|
|
|
|
Thats it! Thank u very much!
<br />
VARIANT_BOOL CGetImageCtrl::getImage(VARIANT* image)<br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState());<br />
<br />
<br />
VARIANT p1;<br />
PICTDESC desc;<br />
HRESULT hres;<br />
<br />
bmp.LoadBitmap(IDB_BITMAP1);
VariantInit(&p1);<br />
<br />
desc.cbSizeofstruct = sizeof(PICTDESC) ;<br />
desc.picType = PICTYPE_BITMAP;<br />
desc.bmp.hbitmap = (HBITMAP)bmp.GetSafeHandle();<br />
<br />
IPicture *pd;<br />
<br />
hres = ::OleCreatePictureIndirect(&desc, IID_IPicture, FALSE,(LPVOID*)&pd);<br />
<br />
<br />
<br />
if(SUCCEEDED(hres))<br />
{<br />
p1.vt = VT_UNKNOWN;<br />
p1.punkVal = pd;<br />
<br />
*image = p1;<br />
}<br />
<br />
return VARIANT_TRUE;<br />
}
/////////////////////////////////////////////////////////////////////////7
<br />
void CGetImageTestDlg::OnBnClickedButton1()<br />
{<br />
<br />
<br />
VARIANT image;<br />
IUnknown* pUnk;<br />
IPicture *pPicture= 0;<br />
long lWidth, lHeight;<br />
int iWidth, iHeight;<br />
<br />
<br />
<br />
VariantInit(&image);<br />
m_myGetImage.getImage(&image);<br />
<br />
pUnk = image.punkVal;<br />
HRESULT hr = pUnk->QueryInterface(&pPicture);<br />
<br />
if(SUCCEEDED(hr))<br />
{ <br />
pPicture->get_Width(&lWidth);<br />
pPicture->get_Height(&lHeight);<br />
<br />
iWidth = (lWidth * GetDeviceCaps(GetDC()->m_hDC, LOGPIXELSX)) / 2540;<br />
iHeight = (lHeight * GetDeviceCaps(GetDC()->m_hDC, LOGPIXELSY)) / 2540;<br />
<br />
CRect Rect(0,0,iWidth,iHeight);<br />
<br />
pPicture->Render(GetDC()->m_hDC,0,0,Rect.right - Rect.left,Rect.bottom - Rect.top,0,lHeight,lWidth,-lHeight,&Rect);<br />
<br />
}<br />
else MessageBox("The Displaying of the Image is not possible!");<br />
<br />
}<br />
|
|
|
|
|
How can i make the combo box to drop down automatically?
|
|
|
|
|
m_combobox.SendMessage(CB_SHOWDROPDOWN ,(WPARAM)true,0);
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Just follow the method below u will get ur rsult.
Right click on the combo box;
Select ‘Properties’ from the list displayed. This will open the ‘Properties’ window;
Click on ‘Event’ tab and place your cursor next to the ‘On Got Focus’ event;
Then, click on the ‘…’ button;
Select ‘Code Builder’ from the code builder window and click on OK.
The following Subprocedure will be created:
Private Sub Combo2_GotFocus()
End Sub
You can also call the function on Event of Mouse Move.
OK
|
|
|
|
|
alternatively you can also use
m_combobox.ShowDropDown();
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
_AnShUmAn_ wrote: alternatively you can also use
m_combobox.ShowDropDown();
if (!pmyComboBox->GetDroppedState())
pmyComboBox->ShowDropDown(TRUE);
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Use the CBS_SIMPLE style.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
How to find the reading order of the language of the current locale or the input language. Are there any APIs available?
Thanks.
Adios,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Use GetProcessDefaultLayout() .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks DavidCrow.
Adios,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Is it possible to handle active x control events using COleControl class.
if so how?
|
|
|
|
|
Hi expert
I embed excel to my program and now I can't not open file excel.
How can I open excel file?
Thanks
Ngoc Quyen
|
|
|
|
|
CSpreadsheet class will retrive columns wise data.so download. its as simple as opening a normal file
|
|
|
|
|
From where can i get the CSpreadSheet class.
|
|
|
|
|
download from codeproject website
|
|
|
|