|
One solution:
static void write(char* str,...)
{
#ifdef _DEBUG
write to log file here
#endif
} Now all of the calls to write() can remain untouched.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
The following was based on how it is done in MFC (Afx.h):
#ifndef __MYTRACE_H__
#define __MYTRACE_H__
void MyTrace(int nLevel, LPCTSTR pFmt, ...);
#ifdef _DEBUG
#define MYTRACE MyTrace
#else
#define MYTRACE 1 ? ((void)0) : MyTrace
#endif
#endif // __MYTRACE_H__
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Yes, that is another way.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
ok, I'll try that. In fact the idea is not to include the parameters in the define...
What I don't understand is what it will do in release mode : 0(myparameters). This should crash, shouldn't it ? Or maybe there's something I missed in #define principle
thanks
Ed
|
|
|
|
|
Ed01 wrote:
What I don't understand is what it will do in release mode : 0(myparameters). This should crash, shouldn't it ? Or maybe there's something I missed in #define principle
The function gets called the same in release mode as it is in debug mode. The only difference is that the body of the function is "missing" in debug mode.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello Friends,
What is memory leak ?
How does it affects the cpp programs and how can memory leaks can be avoided using the virutal destructors ?
Hoping for are reply.
Yours,
Phijo
|
|
|
|
|
In my knowledge you can only create memory leaks when you don't use delete for every new .
When you use new , your program reserves some memory to store the object you're creating.
You have to manually release that memory (using delete ) so it can be used again.
If you don't you reserve more and more unused memory exhausting the cpu's resources.
It's one of the things you really, really don't do. If I see a big memory leak my reaction would be: and ! Memory leaks aren't always that easy to avoid though.
try to google for more info.
good luck.
only 1 thing to remember : for every new (including the ones in loops!) do a delete !
(equal: malloc , alloc : or something (don't use them myself))
No hurries, no worries.
|
|
|
|
|
Can someone point me in the right direction? I need to connect to:
a) connect to an instance of SQL Server using VC++ ( .NET ver ) The instance may or may not be on my local box. I need to some some simple queries from system tables (like sysobjects). Does my project need to be of a certain type? ( ie, when I create the project in Studio )
b) some method of moving through the rowset it returns.
I know that it would be easier in ado.net, but I don't have that luxury.
Any help would be appreciated!
|
|
|
|
|
you can accomplish these things with 2 MFC clasees
CDatabase and CRecordset
CDatabase Allows connection with a DSN ( supports DSN less connection too..)
yes you can create DSN s for remote machines. and you can connect via DSN.
Create A CDatabase Object
make a connection string
connect to database
create CRecordset object
set m_pDatabase member to your connected Database
submit the query to Recordset
the returned resultset is in ur recordset object itself
you can Extract them by using the GetFieldValue() member function
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
Hi,
could you tell me does vc++ can send email, if yes, how??
Thanks!
|
|
|
|
|
|
I saw tom.schultz's question,MDI Document with data from UDP.
I have the same problem too,so I want to ask,maybe stupid.
Can I do this,Class CDocEX : public CDocument ,public CWnd
or Class CDocEX : public CCmdTarget , which is a mixture of CDocument and CWnd.
then I can use SetTimer() and place MSComm in Document.
Thanks for any help.
|
|
|
|
|
You do not have to have window to set up timer. Use timer procedure and specify NULL for window handle.
Send command message from timer procedure and handle it in a document.
JohnCz
|
|
|
|
|
Hi,
I'm experiencing some problems with reading data from sockets. I have a thread that constanly reads(polls) data from the sockets port. Except it randomly hangs on on the recv() function. Is there something I'm doing wrong. Here is code sample.
Thanks
DWORD ThreadProc(LPVOID lparam)
{
char szBuffer[256];
while(1)
{
if(recv(socket, szBuffer, 256, 0)!= SOCKET_ERROR)
ParseData(szBuffer);
}
return 0;
}
|
|
|
|
|
do you mean the thread gets blocked on the recv() function if no data ? if yes, that's the expected behaviour:
If no incoming data is available at the socket, the recv call blocks and waits for data to arrive according to the blocking rules defined for WSARecv with the MSG_PARTIAL flag not set unless the socket is nonblocking. In this case, a value of SOCKET_ERROR is returned with the error code set to WSAEWOULDBLOCK. The select, WSAAsyncSelect, or WSAEventSelect functions can be used to determine when more data arrives.
Serge
|
|
|
|
|
(Using VSC++ 6 - MFC)
I've looked through several articles (such as Printing with MFC Made Easy by Dan Pilat) and posts but, the information I'm looking for just isn't there. Plus, this is something that I want to do on my own, I just want to understand how it works; not have someone do it for me.
I'm trying to get data from a list control straight to the printer and have it formatted correctly. So far, everything I've tried hasn't worked. I've tried setting up tabs, but the printer prints them out as little squares. I've tried to manually set where each piece of information should print out at (x and y coordinates), but it's not working either, especially if the size of the string being printed changes (it throws everything else off).
Basically, here's what I want to set up and what I'm looking for some help with:
Column #1 Column#2 Column #3 (and so on)
Some data here Some more Right-aligned data
Because this is pretty much how it's coming out (or some variation thereof):
Column #1 Column#2 Column #3 (and so on)
Some datSome moreRight-aligned data
Any ideas on how I can get the information to format correctly? Any help is appreciated.
|
|
|
|
|
There are several articles here[^] that will likely provide useful information and perhaps even a canned class that you can use to achieve your goal.
Btw, I cheat by writing my app's[^] contents to a temporary HTML file and printing that. Works beautifully with any paper size and both landscape/portrait modes!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks for the links and tips.
I have read through some of those articles that seemed to be the best ones for what I'm looking for. However, I haven't been able to find any that actually show how the data is formatted for the printed report (unless I missed it somewhere - always possible). I guess I'll just keep combing through them until I come across what I'm looking for or I figure it out for myself.
Again, thank you.
|
|
|
|
|
I have code that was developed with Visual C++ 6.0.
I have a machine that has only Visual C++ .NET 2003 installed.
Some of the ActiveX controls that were available with 6.0 do not seem to be included with 2003. When I go to load a dialog which uses one or more of these controls, I get an error message that the control is not registered. For one of them (FlexGrid - flxgrd.ocx), I was able to download it from the internet and register it on the machine. However, now when I load the dialog, I get an error message that the control could not be instantiated because it requires a design-time license.
|
|
|
|
|
Hi,
any1 can refer me to a code please?
i know how to implement a popup menu with sub items for the shell context menu, but i don't know how to add a second submenu that is displayed dynamically
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
|
I will give you an example to clarify:
when you right click on a file and the context menu open , if you are using icq, there is a popup menu 'icq lite-send to user' this pop up menu is populated dynamically, i.e the users that are currently online are shown.
I need to do the exact same thing
can you help
thanks
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
This just started happening all of a sudden. I have even deleted the ncb file but thats not it.
I cant put a breakpoint anywhere in my code . its the debug version and there was no problem earlier.
What can I do to fix this?
Thanks,
sb
I tried rebooting too.
|
|
|
|
|
The .pdb file and your source code are probaly out of sinyc. Normaly a rebuild all will take care of that.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
We are wanting to use Visio Viewer 2003 within our application. Based on what I am reading, Visio Viewer is only available through IE. I would like to launch IE that with a file name of a Visio Viewer 2003 MIME type that would bring up that drawing automatically. I can already of course launch IE using ShellExecute but only get it to work with an URL.
thank you
|
|
|
|