VC에서 BDS로 넘어오면서 처음에 힘들었던 기능이 TRACE 기능의 부재이다..
실행시키면서 그냥.. TRACE만 보면 되기에...

볼랜드에서도 이와 비슷한 기능을 구현할수가 있다...(물론 함수가 있으니까.. 조금 가공하면 된다..)

BDS에서 TRACE 기능을 하는 함수가 바로 OutputDebugString이다..

이 함수는 인자로 char형을 받으므로.. 프로그램에서 받는 부분을 sprintf(stdio.h 참조)나 wsprintf(vcl에 포함)를 이용해서 형변환을 시켜주면 된다...

간단히 예를 보자..

int MenuValPost,  MenuVal;

char buf[1000];
wsprintf (buf, "MenuValPost - %d, MenuVal  - %d", MenuValPost,  MenuVal);
printf("%d", MenuValPost);


이것을 좀더 응용해 보면..

AnsiString TTT;

TTT.sprintf("MenuValPost - %d, MenuVal  - %d", MenuValPost,  MenuVal);
OutputDebugString(TTT.c_str());


이것의 출력은 Debug의 Event Log 창에 나타난다..


MFC의 습관이 무섭다면...
가장 상위에 define 하는것도 하나의 방법일듯...

#define TRACE OutputDebugString

이렇게 하면.. VC에서 쓰는것이랑 비슷하게 쓸수 있을듯..


자세한 함수 설명은 아래쪽에..

OutputDebugString

The OutputDebugString function sends a string to the debugger for display.

void OutputDebugString(   LPCTSTR lpOutputString ); 

Parameters

lpOutputString
[in] Pointer to the null-terminated string to be displayed.

Return Values

This function does not return a value.

Remarks

If the application has no debugger, the system debugger displays the string. If the application has no debugger and the system debugger is not active, OutputDebugString does nothing.

Windows Me/98/95:  OutputDebugStringW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows Me/98/95 Systems.

Requirements

Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.
Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server.
Unicode: Implemented as Unicode and ANSI versions. Note that Unicode support on Windows Me/98/95 requires Microsoft Layer for Unicode.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.

See Also

Basic Debugging Overview, Debugging Functions

+ Recent posts