|
Is there any standardized format for time span values? There are a number of standards for time and date values, ISO 8601 to name one, but I haven't found any standard for time span values. Do you know of such a standard?
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Hello everyone....Hope everyone is ready for the holidays and had a great Thanksgiving. I working on a new program to balance a check book.....There is just acouple of things I am stumped on. I need to put a bool varible in but I just don't know where to put it by the way I have ti set up. It's supposed to charge the person a 5.00 fee if the account balance falls below 500.00 at anytime during the month....and only charged once. And my other problem is how am I supposed to keep track of all of my charges for the month and I have to but the final amount of charges on my final screen...... Forexample of output screens....
Deposit Trans.
Deposit Amount: 100.00
current Balance: 600.00
deposit charge: .10 (for every depost made)
total charges : .45 (just the added sum of all charges so far that month....just not taken from balance until end of the month)
Check Trans.
Check amount: 600.00
Current Balance: 425.00
check charge: .15 ( for every deposit)
One Time Below 500.00 Charge: 5.00
total charges: 5.60
Any help would be appreciated... Here is my program...hopefully it isn't too hard to read
#include <iomanip>
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
void PrintInstructions (float&, string&);
void GetSingleTransInfo(char&, float&);
void ProcessDeposit (float, float, float&);
void ProcessCheck (float, float, float&);
void PrintFinalTotals ();
void PrintBlankLines (int);
const float CHECK_CHARGE = .15f;
const float DEPOSIT_CHARGE = .10f;
const float ONE_TIME_CHARGE = 5.00f;
int main ()
{
string month;
float balance;
float transAmount;
char transCode;
bool below500;
float currentBalance;
PrintInstructions (balance, month);
GetSingleTransInfo (transCode, transAmount);
if (transCode == 'C')
{ ProcessCheck(transAmount, balance, currentBalance);
}
else if (transCode == 'D')
ProcessDeposit(transAmount, balance, currentBalance);
else
cout <<" This is the end of the month\n";
return 0;
}
//************************************************************************************************************
void PrintInstructions(/*out*/ float& beginBalance, /*out*/ string& month)
// Purpose: Prints general instructions about how to use the program and will ask the user to enter the
// month and the beginning balance for the month.
// Pre:
// Post: None
{
cout <<"\n \"Balancing Your Checkbook\"\n";
PrintBlankLines (3);
cout << "This is a program to help you balance your checkbook for the month. The\n";
cout << "program will ask you to input the month name and the beginning balance\n";
cout << "for the month. The program will then ask you to input a transaction code.\n";
cout << "The transaction codes are as follows:\n\n";
cout << " C or c - for a check\n";
cout << " D or d - for a depsoit\n";
cout << " E or e - for the end of the month\n\n";
cout << "For each transaction code (except for E/e) the user needs to input the\n";
cout << "transaction amount. For each transaction any charges towards the account\n";
cout << "will be listed but will not be applied to your balance until the end of\n";
cout << " the month.\n\n";
cout << "The following charges will be accumulated and applied to your balance\n";
cout << " at the end of the month:\n\n";
cout << " * 10 cents for each deposit and 15 cents for each check processed.\n";
cout << " * A one time charge of 5.00 if the account balance falls below \n";
cout << " 500.00 at anytime during the month.\n";
cout << " * A service charge of 10.00 for each check that either puts the\n";
cout << " balance below zero or keeps the balance below zero.\n";
PrintBlankLines (3);
cout << "Please enter the month to be balanced: ";
cin >> month;
cout << endl;
cout << "Please enter the beginning balance for the month: ";
cin >> beginBalance;
PrintBlankLines (3);
system ("pause");
system ("cls");
}
//***************************************************************************************************************
void GetSingleTransInfo (/*out*/ char& code, /*out*/ float& amount)
// Purpose: This function should get the transaction code and the amount of the transaction
// from the user (if the transaction code is not an E or E).
// Pre: None
// Post: Code has a value of C, D, or E.
{
PrintBlankLines (4);
cout << " Select form the following transactions:\n\n";
cout << " C / c - for a check\n";
cout << " D / d - for a deposit\n";
cout << " E / e - for end of the month\n\n";
PrintBlankLines (3);
cout << "Enter you transaction choice: ";
cin >> code;
code = toupper (code);
cout << endl;
while (code != 'C' && code != 'D' && code != 'E')
{
cout << "\nError.....you must select a code from above\n\n";
cout << "Please enter a new transaction code: ";
cin >> code;
cout << endl;
code = toupper (code);
}
if (code == 'C' )
{
cout << "Please enter transaction amount: ";
cin >> amount;
cout << endl;
}
if (code == 'D')
{
cout << "Please enter transaction amount: ";
cin >> amount;
cout << endl;
}
system ("pause");
system ("cls");
}
//***************************************************************************************************************
void ProcessCheck(/*in*/ float amount, /*in*/ float balance,
/*out*/ float& currBalance)
// Purpose: Deduct amount of check from balance....apply charges if balance falls below zero by
// cause of check. Apply charge if balance falls below $500.00.
// Pre:
// Post:
{
currBalance = balance - amount;
cout << " Check Transaction\n\n\n";
cout << fixed << setprecision (2) << endl;
cout << "Check Amount: " << amount << endl;
cout << "Current Balance: " << currBalance << endl;
cout << "Check Charge: " << CHECK_CHARGE << endl;
system ("pause");
system ("cls");
}
//***************************************************************************************************************
void ProcessDeposit (/*in*/ float amount, /*in*/ float balance,
/*out*/ float& currBalance)
{
currBalance = balance + amount;
cout << " Deposit Transaction\n\n\n";
cout << fixed << setprecision (2) << endl;
cout << "Deposit Amount: " << amount << endl;
cout << "Current Balance: " << currBalance << endl;
cout << "Deposit Charge: " << DEPOSIT_CHARGE << endl;
}
Thanks for you time once again!!
Autumn
"Hitting her head against a brick wall"
|
|
|
|
|
does anyone know how to add a new zone to a Windows 2000 DNS server with c/c++?
i've tried the dnsapi.lib from Microsoft's latest SDK, it seems only handling with resource records, but i'm still not sure about how to connect to the DNS server and create zone files or modify zone files. anyone has some idea about it? thanks a lot!
programming+soccer = my current life
|
|
|
|
|
Hi,
My column in the Listcontrol don't fit on the screen, how can i make the last column visible for the user?
I know the method EnsureVisible(..) but this works only for the row's.
Thanks
|
|
|
|
|
You will probably have to make use of the base class CWnd scroll functions to get the scroll range and set the scrollposition
int min;
int max;
m_Ctrl.GetScrollRange(SB_HORZ, &min, &max);
m_Ctrl.SetScrollPosition(SB_HORZ, max);
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
I am quite a bit further along than I was last night, but I still have a problem:
IVariantDictionary* pVD;
cxt.Session()->get_Contents(&pVD);
if (pVD)
{
int nCount = 0;
pVD->get_Count(&nCount);
for (int i = 0; i < nCount; ++i)
{
_variant_t vItem;
_variant_t vIndex(i);
_variant_t vKey;
pVD->get_Key(vIndex, &vKey);
pVD->get_Item(vKey, &vItem);
cxt.Response()->Write(vKey);
cxt.Response()->Write(_variant_t(" = "));
cxt.Response()->Write(vItem);
cxt.Response()->Write(_variant_t("<br/>"));
}
}
All of this works, except that get_Key and get_Item both require the name of the key. Why would I want to ask for the key if I know it ? There is a get__NewEnum method, but I can't figure out how to use it. I just want to iterate through the entire collection, it surely can't be as hard as MSDN makes it look ?
Help me Obi Wan Kenobi, you're my only hope....
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
_NewEnum is the actual method call translated from VB code (or other automation languages) anytime it's getting items of a collection.
Usually both the Item property and _NewEnum take a variant as input param and accept both VT_I4 indexes and VT_BSTR names. As a consequence, unless the implementation does not follow the standards, you should be easily able to enumerate the collection without bothering the keys.
|
|
|
|
|
That's what I expected, but I've been passing in an index and getting nothing back. You're saying in essence that the code I've tried should work ? That I should be able to pass in an index and get back the value ? I wonder if I need to change the VT of the number I am passing in to VT_I4 ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
have you tried VariantDictionnary[i] using VB code ?
If this works, then yes, switch your _variant_t type to VI_I4.
|
|
|
|
|
from "ATL Internals"
Chris Sells does this, on his definition:
<br />
IPrimeNumbers : IDispatch<br />
{<br />
[propget]<br />
HRESULT Count([out,retval] long *pCount);<br />
[propget,id(DISPID_VALUE)]<br />
HRESULT Item([in] long n, [out,retval] long* pVal);<br />
[propget, id(DISPID_NEWENUM)]<br />
HRESULT _NewEnum([out,retval] IUnknown** ppunkEnum);<br />
}<br />
interface IMyEnum : IUnknown<br />
{<br />
[local]<br />
[helpstring("method Next")] HRESULT Next([in] ULONG celt, [out] long* rgelt, [out] ULONG* pceltFetched);<br />
<br />
[call_as(Next)]<br />
[helpstring("method RemoteNext")] HRESULT RemoteNext([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] long* rgelt,[out] ULONG* pceltFetched);<br />
<br />
[helpstring("method Reset")] HRESULT Reset();<br />
[helpstring("method Clone")] HRESULT Clone([out] IMyEnum **ppenum);<br />
[helpstring("method Skip")] HRESULT Skip([in] ULONG celt);<br />
};<br />
that worked for me when i needed to do a for each in vb.
you also need to add this at the end of the idl file, just change IMyEnum with your enum interface:
<br />
cpp_quote("#ifdef __midl_proxy")<br />
cpp_quote("static HRESULT STDMETHODCALLTYPE")<br />
cpp_quote("IMyEnum_Next_Proxy(IMyEnum* This, ULONG celt, long* rgelt, ULONG* pceltFetched)")<br />
cpp_quote("{")<br />
cpp_quote(" ULONG cFetched;")<br />
cpp_quote(" if( !pceltFetched && celt != 1 ) return E_INVALIDARG;")<br />
cpp_quote(" return IMyEnum_RemoteNext_Proxy(This, celt, rgelt, pceltFetched ? pceltFetched : &cFetched);")<br />
cpp_quote("}")<br />
cpp_quote("")<br />
cpp_quote("static HRESULT STDMETHODCALLTYPE")<br />
cpp_quote("IMyEnum_Next_Stub(IEnumPrimes* This, ULONG celt, long* rgelt, ULONG* pceltFetched)")<br />
cpp_quote("{")<br />
cpp_quote(" HRESULT hr = This->lpVtbl->Next(This, celt, rgelt, pceltFetched);")<br />
cpp_quote(" if( hr == S_OK && celt == 1 ) *pceltFetched = 1;")<br />
cpp_quote(" return hr;")<br />
cpp_quote("}")<br />
cpp_quote("#endif // __midl_proxy")<br />
hope this can help you.
also this page may help you:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcconImplementingSTLBasedCollection.asp[^]
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
[^]
|
|
|
|
|
|
How can i determine that someone is scrolling in my listbox?
|
|
|
|
|
I'm not sure that this works on a listbox, but in the listctrl it does...
1. Create your own ListBox.
1.1. Create a new class using the wizard and select CListBox as base class
2. Handle the message ON_WM_VSCROLL (up/down scrolling)
2.1. In your newly created class you should right click it's name in the ClassView tab and add the mesage handlers (Vertical and horizontal scrolling)
3. Notify parent...
3.1. Use SendMessage/Postmessage (the nicest methods) or get access to your parent window and call a method/function in order to notify it...
I've used this in order to prevent the user to scroll while edition in the listctrl was active and it worked...
Hope this helps...
|
|
|
|
|
I don't know the answer, but I'm still curious: why does your app need to know this?
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
I am using the following to get a handle for the font that I need to write with.
HFONT hNewFont = ::CreateFont(iHeight, 0, 0, 0, (IsBold? FW_BOLD: FW_NORMAL),
IsItalic, IsUnderline, IsStrikeOut, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, FontName);
My problem is that I have to delete the handle after using it to free the memory, but when I use DeleteObject(hNewFont) the font is not drawn correctly. How can I remove the font handle from the memory that will not affect my drawing.
Daed
|
|
|
|
|
You probably still use the font (draw text with it) after you deleted the HFONT handle.
Maybe you selected it?
The solution is to DeleteObject the HFONT handle only after you unselected it in any window using it, e.g when the window is destroyed.
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|
|
I assume the font is being draw correctly if you don't delete it? If so, it sounds like you are calling DeleteObject before you have finished drawing the text. This usually happens becasue you have done something like PostMessage to draw the text then immediately afterwards called DeleteObject. I tend to do this, in "pseudo" code, when changing fonts
hFont = CreateFont
hFoldOld = SelectObject(hFont
drawtext
SelectObject(hFoldOld
DeleteObject(hFont
|
|
|
|
|
I pass the hNewFont as a parameter in a function SetMyFont, this function sets a member variable called m_hFont to hNewFont as follows:
void CMyClass::SetMyFont(HFONT hNewFont)
{
m_hFont = hNewFont;
}
then later I use the member variable m_hFont to draw the text. My exact code is:
HFONT hNewFont = ::CreateFont(iHeight, 0, 0, 0, (IsBold? FW_BOLD: FW_NORMAL),
IsItalic, IsUnderline, IsStrikeOut, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, FontName);
if (hNewFont)
{
SetMyFont(hNewFont);
}
I thought that there is no harm in deleting the handle here because I will use the copy of it, and I delete the m_hFont in the destructor.
Can you help me in this?
Daed
|
|
|
|
|
This statement m_hFont = hNewFont does not "make a copy" of the font, all you have done is assigned the variable m_hFont to hNewFont. m_hFont is a HANDLE it just points to some memory location, i.e. the same memory location as hNewFont. So basically don't delete hNewFont.
I suggest in the construtor
m_hFont = NULL;
then
if(m_hFont)
DeleteObject(hFont)
m_hFont = NULL;
hNewFont = ::CreateFont
if (hNewFont)
{
SetMyFont(hNewFont);
}
|
|
|
|
|
Sorry must learn to type
if(m_hFont)
DeleteObject(m_hFont)
|
|
|
|
|
I tried it, but i will still have one font handle in the memory!
|
|
|
|
|
If is difficult to answer your question, without seeing the code. I assume you are failing to delete a font you have created? You could have called CreateFont twice, thereby overwritting the previous font value?
Assuming, again, it is all in one class.
Constructor
m_hFont = NULL
CreatingFont
if(m_hFont)
DeleteObject(m_hFont)
m_hFont = NULL;
m_hFont = CreateFont(
Destructor
if(m_hFont)
DeleteObject(m_hFont)
This way you are only using m_hFont, so it is easier to check what you are doing. Also check the error returns from the functions.
|
|
|
|
|
Can anybody suggest a good profiling tool that will monitor the execution of a program and breakdown the amount of time spent calling the various Win32 API functions. In particular I need to know how long a program is spending reading, writing and flushing files.
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
Personally I prefer Quantify[^] from Rational. But you can do it also with the VC profiler.
TrueTime from Numega works too, but I dont like its interface. Too clumsy. Quantify is intuitive and really easy to use. Also gives better results.
I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge
|
|
|
|
|
Hi,
I am doing a very basic thing of sending data to a server and getting the reply back.
For which first I have to send in a Login request and get authenticated, once authenticated, I have to send the actual data.
The problem I am facing is when I send the data, it embeds some funny characters before the actual text, which is causing the problem.
Upon further investigation, it was found that if I send the data without the login, it gets to the server correctly.
Is there some kind of REFRESH!!! for the second time when the data is sent so that it has correct values?
[CODE]
=========================================
for login authentication:
e = sendto(sd,"<req><loginid>8888\n",89,0,(struct sockaddr *)&saServer,sizeof(saServer));
For sending Data:
e = sendto(sd,"<req><loginid>8888<reqtype>08<broadcast><messagetype>M<no>5359846<message>Test+Value\n");
==========================================
[CODE]
The second sendto, does not send the data correctly.
Is there some refresh after we do the first sendto?
Kindly Help!!!
Best Regards,
John
|
|
|
|
|