Printf () debugging in a console window from within an ActiveX Control

Source: Internet
Author: User

Use printf () to debug ActiveX controls in the console window

Article from:

Http://www.codeproject.com/Articles/11420/Printf-debugging-in-a-console-window-from-within-a

Introduction

OK, here's the deal... in the process of developing an ActiveX control for processing sion in a browser, I had developed a need to watch a large amount of data. it became very cumbersome to use the standard breakpoint debugging, and to make matters worse, the control
Was misbehaving on a remote machine.

When developing ActiveX controls used by browsers, I need to monitor a lot of data. Using standard breakpoints can be cumbersome and worse, and controls can run abnormally on remote machines.

Needing to be able to see the data easily, I decided to see if it was possible to create a console window from within the control. A Web search didn't turn up anything as far as I cocould see so I decided to try a quick test.

All I need is easy to monitor data. I decided to see if it is possible to create a console window from the control. I did not find the answer on the Internet. I decided to test it myself.

As it turns out, it was quite simple to do. To Doprintf()Debugging from within a control, all you need to do is modify
YourOnCreate()Method as follows:

The results show that it is easy to implement. To use printf () in the control, you need to modify oncreate () as follows ():

Collapse | copy
Code
 LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {  // TODO : Add Code for message handler.  // Call DefWindowProc if necessary.   /* create a seperate console window for     printf (print, println and debug) output */  AllocConsole();  freopen ("CONOUT$", "w", stdout );   return 0; }

You'll also need to include the appropriate Headers<Stdio. h>And you shoshould now be able to useprintf()From
Anywhere in your code.

You should include <stdio. h> and can use the printf () function anywhere.

There are certainly other methods of tracing output... but this is guaranteed to be available and viewable on machines that don't have any tools installed.

There should be other methods to trace the output, but this can be used without other tools.

Note: Although I haven't done it, It shoshould also be possible to remapstdinAnd take input from the console window
Shocould you need to implement a simple debug console.

Note: Although I have not tried it, it should be able to remap stdin and get input information from the console window.

Just another one for the Toolkit... use it as you will.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.