Link to home
Start Free TrialLog in
Avatar of jzzhang
jzzhangFlag for Canada

asked on

How to redirect "printf( )" to a window in Visual C++?

Dear experts:

I am now doing a course project using Visual C++. I am trying to transplant an existing UNIX Ansi C program to
Windows 95 platform. In this C program, there are many "printf()" functions to print out some information to the screen. I would like to convert these outputs to a window ( a ScrollView ) rather than DOS mode screen. May you tell me a proper way of doing that using Visual C++? Thanks.

-jzzhang
ASKER CERTIFIED SOLUTION
Avatar of alexo
alexo
Flag of Antarctica image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jzzhang

ASKER

Alexo:

Thank you for your answer. It works fine using your method. However, the output in a CEdit control is reverse. That is the last line of string always displays at the top. The first line of string goes to the bottom. Can you provide me a solution to display all these lines of strings in the right order? Thanks.

Jzzhang
Avatar of jzzhang

ASKER

Alexo:

Can you tell me what means to set the selection (EM_SETSEL) to [0x7FFF-0x7FFF]? What is the meaning of this number?

Jzzhang
The number is what will make the CEdit box act normal.
It will select the area *after* your last line so replacing the selection will add the line.
Use: SetSel(0x7FFF, 0x7FFF)

Avatar of jzzhang

ASKER

Alexo:

Your method is great! I would like to give you 200 points. But how?

Thanx.  I appreciate it!
You can post a dummy 200-point question titled "for alexo only".  Just let me know in what area.