|
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
|
|
|
|
|
Vu Ngoc Quyen wrote: I embed excel to my program...
How did you do this?
Vu Ngoc Quyen wrote: How can I open excel file?
Using what method?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Vu Ngoc Quyen wrote:
Hi expert
I embed excel to my program and now I can't not open file excel.
Which Interface are you using?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hello all's
i am new in VC++ and feel some problem in my program
i am trying to making a login program but in some line
i think i am wrong .The code of that line are below
can any one help me and also tell me where i am wrong
int i, j, k;
MYSQL * myDB ;
MYSQL_RES * res,*res1;
MYSQL_ROW row,row1;
CString sStr, sPwd;
SetDlgItemText(IDC_STATIC, "Logging in. Please wait...");
if ( (myDB = mysql_init((MYSQL*) 0)) &&
mysql_real_connect( myDB, "localhost", " ", NULL, NULL, MYSQL_PORT, NULL, CLIENT_MULTI_STATEMENTS ) )
{
if ( mysql_select_db( myDB, "login") < 0 )
{
SetDlgItemText(IDC_STATIC, "Can't select the database !\nTry later.") ;
goto exit_here;
}
}
else
{
SetDlgItemText(IDC_STATIC, "Can't connect to the mysql server !\nPlease try later.") ;
goto exit_here;
}
sStr.Empty();
GetDlgItemText(IDC_USER, sStr);
sStr = "CALL sp_auth_user(\'" + sStr + "\', \'";
GetDlgItemText(IDC_PASS, sPwd);
sStr = sStr + sPwd + "\');";
if (!mysql_query( myDB, sStr) )
{
res = mysql_store_result( myDB ) ;
i = (int) mysql_num_rows( res );
if (i != 1)
{
SetDlgItemText(IDC_STATIC, "Incorrect User Name / Password. Please try again.");
mysql_free_result( res ) ;
goto exit_here;
}
SetDlgItemText(IDC_STATIC, "Login Successful.");
if ( (row = mysql_fetch_row( res )) )
{
sStr.Empty();
j = mysql_num_fields( res ) ;
//for ( k = 0 ; k < j ; k++ )
// sStr += (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k]) ;
sStr = "Welcome - ";
sStr += (((row[2]==NULL)||(!strlen(row[2])))?"NULL":row[2]) ; // Name
sStr += " (";
sStr += (((row[1]==NULL)||(!strlen(row[1])))?"NULL":row[1]) ; // Group
sStr += ")";
SetDlgItemText(IDC_STATIC, sStr);
}
mysql_free_result( res ) ;
}
else
SetDlgItemText(IDC_STATIC, "Could not execute query on server.") ;
Please mailing me
|
|
|
|
|
But what is your problem.
Is the application crashing at some point. or are you not able to verify the user login and password.....
From a look at your code what I feel is there is something wrong in the conditions . given here with the goto exit_here statements ie if the we are not connected to the database you are checking the password.
if ( mysql_select_db( myDB, "login") < 0 )
{
SetDlgItemText(IDC_STATIC, "Can't select the database !\nTry later.") ;
goto exit_here;
}
}
else
{
SetDlgItemText(IDC_STATIC, "Can't connect to the mysql server !\nPlease try later.") ;
goto exit_here;
}
in ti
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 5:29 Friday 9th June, 2006
|
|
|
|
|
My problem is that application is looked after creating database connection
and it not check the below if condition:
if (!mysql_query( myDB, sStr) )
{
res = mysql_store_result( myDB ) ;
i = (int) mysql_num_rows( res );
if (i != 1)
{
SetDlgItemText(IDC_STATIC, "Incorrect User Name / Password. Please try again.");
mysql_free_result( res ) ;
goto exit_here;
}
SetDlgItemText(IDC_STATIC, "Login Successful.");
application are blocked before
plz tell me that the line of code
sStr.Empty();
GetDlgItemText(IDC_USER, sStr);
sStr = "CALL sp_auth_user(\'" + sStr + "\', \'";
GetDlgItemText(IDC_PASS, sPwd);
sStr = sStr + sPwd + "\');";
is correct or not.
Thanking you
Please mailing me
|
|
|
|
|
Hi there.
I have an application that uses CRecordset to query the contents of a large MSSQL database table. The main task of this application is to loop through the CRecordset using CRecordset::MoveNext() and print each record to a file on disk.
Unfortunately, calling MoveNext() with DoFieldExchange causes the SQL database to be queried singly for each and every row - causing performance issues on the SQL Server (there are many thousand records).
To improve the performace, I'm looking at using DoBulkFieldExchange so that more than one record at a time are queried. However, I'm having trouble finding info for this approach on the web.
Q: Is this a wise approach to take (the lack of web resources is making me nervous!)?
If so, any ideas of where I could find good code samples?
If not, what other approaches could be taken?
Any halp would be much appreciated!
Len
|
|
|
|
|