|
Its best to throw by value and catch by const-reference:
throw Exception( "Error Message." );
[...].catch (const Exception& e)
{cout << e.what();
}
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Does anyone knows how to set power button action in Window2000 & WinXP? I found the API WriteGlobalPwrPolicy() to do that. But, it can't work properly. After I involved this API the return value is nonzero. This is means this API is success. Even so, the system's global power button action doesn't have been change. The following code is my testing code, please help me to check it if it has any wrong. Or, you can tell me any tip to do it.
Testing code:
GLOBAL_POWER_POLICY gpp;<br />
ReadGlobalPwrPolicy(&gpp);
gpp.user.PowerButtonAc.Action = (POWER_ACTION)2;
<br />
if(WriteGlobalPwrPolicy(&gpp) == 0)<br />
TRACE(_T("Failed!\n"));<br />
else<br />
TRACE(_T("Successful!\n"));<br />
ReadGlobalPwrPolicy(&gpp);<br />
TRACE(_T("PowerButtonAc.Action:%d\n"), gpp.user.PowerButtonAc.Action);
Relation resource:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/power/base/power_management_functions.asp
Thanks for your help!
Best regards,
Ryan
|
|
|
|
|
I'm afraid I think you've drifted into custom control territory. You'll need to implement this one yourself.
You'll need to be familiar with the Windows drawing model and how to manipulate text and images within that model.
|
|
|
|
|
G'day folks,
I'm attempting to write out a CSV file (don't ask) in a format that can be read by Excel (also don't ask) across Locales. Now, this is fine, I can format the numeric values correctly and then separate them using the locale's list separator. However, it seems that Excel only ever uses the System Locale list separator. That is, if some user overrides their separator (again, don't ask) to ',', Excel doesn't use that, but the original default setting for the locale (in the Italian locale, ';').
Is this behaviour expected? Sensible? A pain in the #$%?
Thanks.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Are you sure that Excel is supposed to use the locale's list separator? Maybe what Excel is dealing with is not considered a list. Anyway, once you have the data in Excel, you can use the Text to Columns menu option to fix the problem.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
someone can show me how to read and write record table (SQL DataBase) with VC++??
--code is better
thanks
Nho'c Ti`
|
|
|
|
|
To Write:::
db.OpenEx("DSN=YOUR DSN;Uid=YOUR USER ID FOR SQL;Pwd=YOUR PASSWORD FOR SQL",CDatabase::noOdbcDialog)
CString query="INSERT INTO Userinfo(Userid,Passw,Name,Address1,Address2,City,Country,Zip,Phone,Email,Pincode,Dateofentry) VALUES ('" + uid + "','" + pwd + "','" + uname + "','" + add1 + "','" + add2 + "','" + ucity + "','" + scountry + "','" + uzip + "','" + uphone + "','" + uemail + "','" + test + "',GetDate())";
db.ExecuteSQL (query);
To Read::
CRecordset rs( &db );
CString check;
check.Format ("SELECT Userid FROM Userinfo WHERE Pincode='" + test +"'");
rs. Open ( CRecordset::dynaset, check, CRecordset::none ) ;
rs.GetFieldValue("your field",CString variable to store);
after this you can convert it to integer or anythine..thats all..hope it helps..
cheers
Himanshu
|
|
|
|
|
hello,
I'm fresh to VC,
I need an example for loading picture to PictureBox(control).
e.g., if I enter the file path, like c:\abc.bmp, then the picture will be loaded into picture(control).
I don't know which is good, using Hbitmap or Cbitmap.
Could anyone give me some example code?
Thanks.
|
|
|
|
|
both of them does the same thing. Its just like if u set the bitmap through resource to any particular bitmap it is static type...There are other times when u need to change the bitmaps from time to time or depending on some conditions...then using HBitmap..and CBitmap are mre or less same..u can use any of them depending on the dialogs u r using..in most of the dialogs u will have to use CBitmap..as HBitmaps are global..and used for globally setting the Bitmaps to maybe other applications...not urs of course..Its just an idea..i am not sure though..Hope it helps
Himanshu
|
|
|
|
|
I'm trying to get a CString representation of _variant_t type VT_CY and VT_DECIMAL. Does anyone know of any classes/code out there that accomplishes this?
RS
|
|
|
|
|
Have you tried using VariantChangeType to convert to a BSTR ?
I'll admit it's not very controllable!
VT_CY doesn't look too bad: "A currency number is stored as 64-bit (8-byte), two's complement integer, scaled by 10,000 to give a fixed-point number with 15 digits to the left of the decimal point and 4 digits to the right." You can therefore work it out as follows:
__int64 unitPart = vt.cyVal / 10000;
UINT fracPart = vt.cyVal % 10000;
CString strValue;
strValue.Format( _T( "%I64d.%u" ), unitPart, fracPart ); Unfortunately, I can't find any documentation for VT_DECIMAL that indicates which bits do what. The document I referenced above ('VARIANT and VARIANTARG' in the Automation section of the Platform SDK) says only "Decimal variables are stored as 96-bit (12-byte) unsigned integers scaled by a variable power of 10. VT_DECIMAL uses the entire 16 bytes of the Variant."
|
|
|
|
|
No I didn't try VariantChangeType - didn't come across it. I was using itoa, ltoa, ultoa and _gcvt (float,double). I will test it out though.
You say that it's not controllable. What problems have you encountered?
Thanks for the currency snippet above. If I run into any anomolies with VariantChangeType I'll revert back to itoa, ltoa... and you currency code.
|
|
|
|
|
When I say 'not controllable', I mean that there's no way to specify how many digits you're going to get (for example, after a decimal point).
|
|
|
|
|
I saw that with my first try. The amount 78.90 became 78.9 - not that nice for display purposes.
|
|
|
|
|
I sent this to myself by accident.
----------------
It seems that I can use
_variant_t vt;
COleCurrency oleCur(vt);
CString strCur = oleCur.Format();
This will work for a date string as well
COleDateTime oleDT(vt);
CString strDT = oleDT.Format();
I have some testing to do.
I also found the DECIMAL conversion in Carlos Antollini's CADORecordset
double val = vtFld.decVal.Lo32;
val *= (vtFld.decVal.sign == 128)? -1 : 1;
val /= pow(10, vtFld.decVal.scale);
str = DblToStr(val); // also define in his class
Thanks,
RS
|
|
|
|
|
It seems that I can use
_variant_t vt;
COleCurrency oleCur(vt);
CString strCur = oleCur.Format();
This will work for a date string as well
COleDateTime oleDT(vt);
CString strDT = oleDT.Format();
I have some testing to do.
I also found the DECIMAL conversion in Carlos Antollini's CADORecordset
double val = vtFld.decVal.Lo32;
val *= (vtFld.decVal.sign == 128)? -1 : 1;
val /= pow(10, vtFld.decVal.scale);
str = DblToStr(val); // also define in his class
Thanks,
RS
|
|
|
|
|
Hi I want to change the name of my dll everytime I build it but dont want to manually edit my workspace each time. I can write a script to automatically edit the dsp file before building the dll, but does not seem to be a good solution. Does any one know of a VC++ option to do this or may be suggest a better solution.
Thanks for your ideas.
|
|
|
|
|
There are two ways (that I know of) of using a VBScript macro to do this:
a) Use the script to directly access the workspace Developer Studio objects and make the necessary changes. or
b) Use the script to modify the workspace file as a text file. This is the method that I normally use because it is then easy to apply search and replace operation to change project names, output names etc in text format. You can then get the macro to load up the workspace/project as usual. As an example, try this:
<br />
ExecuteCommand "SaveCloseAllThings"<br />
Documents.Open "myworkspace.dsw", "Text"<br />
ActiveDocument.Selection.StartOfDocument<br />
blnFound = ActiveDocument.Selection.FindText("ProjectName")<br />
If blnFound = false Then<br />
ActiveDocument.ReplaceText "ProjectName", "NewProjectName"<br />
End If<br />
ActiveDocument.Save<br />
Documents.Open "myworkspace.dsw", "Auto"<br />
whichs opens myworkspace.dsw, finds all instances of "ProjectName" and replaces them with "NewProjectName", saves the changes, and then loads up the file as a normal workspace. The initial "SaveCloseAllThings" has only been included to make sure that all active windows are closed.
|
|
|
|
|
I'm a Maths student. Now I'm having a project that I need to call Maple inside my project and do some calculation. Anyone has experiences on this please help me.
|
|
|
|
|
You could be more specific about your problems. You can use maple routines and data structures in your C/C++ application by using the OpenMaple API and it's easy to find example program listings from the net. Did this help?
- Jussi
|
|
|
|
|
Firstly, Thanks.
I can explain it clearer like this:
+ In my project, I let the user type some text in LaTeX format and I want to let to user do some calculation. For this, I need to call Maple. I don't know how can I do this !!!
Would you please give me some more details???
|
|
|
|
|
I am trying to build a dialog to allow the user to select directory
path as in Visual basic.
|
|
|
|
|
SHBrowseForFolder()
I'm not sure if I get your point.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
I know that I have asked this, but I need to understand what is going on.
If you create a CRichEditCtrl on the screen (canned width/height), then make the default font 12 point Times New Roman. Enter in a string of characters until it wants to wrap (stop just prior to the wrapping). Now, get the text along with the font information and calculate the width of the string. What I'm finding is that the same string that is to be drawn to the screen is wider than the control! How could that be?
Any help would be appericated.
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
I guess that I have you guys stumpped!
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|