|
There was a recent change to C++ that says you can't write class_name::function_name to get a pointer to the function, you have to write &class_name::function_name
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
See
<br />
void MyThread( LPVOID pv );<br />
...<br />
...<br />
void CTest::RunThread()<br />
{<br />
_beginthread(MyThread,0,NULL);<br />
}<br />
<br />
<br />
void MyThread( LPVOID pv )<br />
{<br />
CTest* m_Answer = (CTest*) pv;<br />
<br />
m_Answer->Modify();<br />
<br />
}<br />
<br />
void CTest::Modify()<br />
{<br />
MessageBox("A");<br />
}
whitesky
|
|
|
|
|
WhiteSky wrote: _beginthread(MyThread,0,NULL);
You meant _beginthread(MyThread,0,this); no ?
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
yes
whitesky
|
|
|
|
|
hi,
i develop one application in VC++-MFC 6.0 ,
this application is responsible for inserting image into the database (oracle)-ODBC.
but when i try to insert a image file , it through a error like
"Data type conversion error."
////////////////////////////////////////////////////////////////////////
CDaoDatabse db;
CDaoRecordset recset(&db);
void CDBODBC::InsertintoDB();
{
CByteArray BlobFile;
BlobFile.RemoveAll(); // I clear the Array
CFile aFile("image.jpg",CFile::modeRead);
BlobFile.SetSize(aFile.GetLength());
aFile.Read(BlobFile.GetData(),aFile.GetLength());
aFile.Close();
COleVariant aVar(BlobFile);
CString Sql = "SELECT * FROM sample3";
db.Open("abc",FALSE,FALSE,"ODBC;UID=abc;PWD=abc;DSN=abc;");
recset.Open(AFX_DAO_USE_DEFAULT_TYPE,Sql,dbAppendOnly);
// bool b=recset.CanUpdate();
recset.AddNew();
recset.SetFieldValue("[num]","6"); //varchar field
recset.SetFieldValue("[photo]",aVar); //BLOB field -image field
recset.Update();
recset.Close();
db.Close();
}
/////////////////////////////////////
it works for Access database ..
but i got error in oracle...
"Data type conversion error."
Try again and again,
At last you will say
I don't know the meaning for impossible.,.
|
|
|
|
|
|
tnx,
but , it is MSACCESS database with the column datatype of "OLE Object"
so using COleVariant class,we convert the image as bytestream to COlevariant..
but i want to do the same thing for oracle ..with the column datatype "BLOB"
here also i create same COleVariant ,but it doesn't acceptable by database field "BLOB".....
"Data type Conversion error"
Try again and again,
At last you will say
I don't know the meaning for impossible.,.
|
|
|
|
|
Hi!
I have here a activeX- component "spectrometer.ocx" with the method "getImage(VARIANT *image)".
If a Application call this method, the activeX have to give back a bitmap (which was included in the ressourses). The bitmap have to convers in a VARIANT.
the Method:
<br />
BOOL CSpectrometerCtrl::getImage(VARIANT* image)<br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState());<br />
<br />
<br />
CBitmap bmp ;<br />
VARIANT p1;<br />
PICTDESC desc;<br />
HRESULT hres;<br />
<br />
bmp.LoadBitmap(IDB_BITMAP1);<br />
VariantInit(&p1);<br />
<br />
desc.cbSizeofstruct = sizeof(PICTDESC) ;<br />
desc.picType = PICTYPE_BITMAP;<br />
desc.bmp.hbitmap = (HBITMAP)bmp.GetSafeHandle();<br />
IPicture *pd;<br />
<br />
hres = ::OleCreatePictureIndirect(&desc, IID_IPicture, FALSE,(LPVOID*)&pd);<br />
<br />
<br />
if(SUCCEEDED(hres))<br />
{<br />
p1.vt = VT_UNKNOWN;<br />
p1.punkVal = pd;<br />
<br />
*image = p1;<br />
<br />
return TRUE;<br />
}<br />
else<br />
return FALSE;<br />
}
In my Application i call this method and i want that the bitmap is shown on a dialog.
void CSpectrometerTestDlg::OnBnClickedButton1()<br />
{<br />
<br />
VARIANT imageData;<br />
IUnknown* pUnk;<br />
IPicture *pPicture= 0;<br />
long lWidth, lHeight;<br />
int iWidth, iHeight;<br />
<br />
CClientDC pDC(this);<br />
<br />
CDC memdc;<br />
memdc.CreateCompatibleDC(&pDC);<br />
<br />
VariantInit(&imageData);<br />
m_mySpectrometer.getImage(&imageData);<br />
<br />
pUnk = imageData.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(pDC, LOGPIXELSX)) / 2540;<br />
iHeight = (lHeight * GetDeviceCaps(pDC, LOGPIXELSY)) / 2540;<br />
<br />
pPicture->Render(pDC, 0, 0, iWidth, iHeight, 0, lHeight, lWidth, -lHeight, 0);<br />
<br />
<br />
<br />
<br />
}<br />
<br />
}
The variables "iWidth, iHeight" have already the right values. It means that something comes on but the displaying doesn't work.
Is there someone with a Idea? What is wrong?
Thanks
-- modified at 6:50 Friday 9th June, 2006
|
|
|
|
|
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
|
|
|
|
|