|
Is there an easy way to write TRACES to a log? If not should I just use CFile or something similar?
Thanks in advance for your advice
Rob
|
|
|
|
|
Either create your own logging class (something derived from CFile), or re-define TRACE to add the text to a text file
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
One thing to make sure you do if you log to a file - make sure you CLOSE the file after each TRACE (or whatever) statement. That way if you crash, you don't lose the whole file.
Even a broken clock is right twice a day.
|
|
|
|
|
Not really, all you really need is the equivalent of a "flush" to ensure each message gets written. Continously opening, seeking to the end, and closing for each write operation sounds to me like a serious performance killer.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Thanks to everyone.. I went ahead and created a function with in my thread instead of doing a TRACE I run my function OnLog(strMessage) then in that function I do my logging.. everything is working great.. I found the problem after 5 mins of logging..
I'm sure its a huge performance hit but it was needed to debug, I'll disable the code once the problem is resolved.....
Thanks again..
Rob
|
|
|
|
|
Glad to have helped. A logging mechanism is essential for debugging applications such as yours.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
hi,
i want to know how costly is it to create fonts,pens etc and u know, selecting and destroying every time, say in ondraw.
My problem is this(with font only)
I have to adjust the font size for the names of somethings which will be displayed in resiable boxes.the names should be appropriately sized according the box size.
any help
Raja Huus
|
|
|
|
|
hi,
i want to know how exactly are the ui stuff like tabs(especiallY) or comboboxes etc are drawn by windows.is the code accessible.I want this because i want to draw these on my own especially tabs to get the flattish look like the output window in the IDE.
(i suppose one should know how to draw if these are owner drawn. right?)
Krujic
|
|
|
|
|
Malcom Krujic wrote:
is the code accessible
You can step right into most of the MFC-code (but not in anything of WIN32 or (most?, all?) of the common controls).
You will find the MFC source files below your MSVC++ installation directory in MFC/SRC and MFC/include.
I hope this helps a little.
--
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
Talking about MFC...
Controls ( Tabs, Buttons, ... ) are usually derived from CWnd, and handle message via the message routing.
WM_PAINT is one of those message, the message is send to each CWnd, and if the CWnd handles it ( added an ON_WM_PAINT to the MessageMap section of the class, and OnPaint member function ) it will be drawn there.
Some UI objects like buttons, menu, listbox, offer a style OWNERDRAW, that can be set in the resource editor, or at creation time, when this flag is set, the DrawItem member function is called; in which you can also draw.
The CTabCtrl offer the OWNERDRAW style, search here, at codeproject, maybe there's already something like that, and there's a HOWTO on MSDN with DrawItem and CTabCtrl that can help.
Max.
|
|
|
|
|
what about the tab buttons
|
|
|
|
|
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.)
|
|
|
|
|