Printf() debugging in a console window from within an ActiveX control
来源:互联网 发布:sql 删除数据库语句 编辑:程序博客网 时间:2024/05/22 14:21
使用Printf()在控制台窗口中调试activex控件
文章来自:
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 inclusion 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.
在开发浏览器使用的activex控件的过程中,我需要监测许多数据。使用标准断点会变得很笨重,而且事情会变得更糟糕,控件在远程的机器上会表现异常。
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 could see so I decided to try a quick test.
我所需要的是很容易监测数据,我决定看下是否有可能从控件中创建一个控制台窗口。我在网上并没有找到答案,决定自己试验一下。
As it turns out, it was quite simple to do. To do printf()
debugging from within a control, all you need to do is modify your OnCreate()
method as follows:
结果证明,它是很容易实现的。为了可以在控件中使用printf(),你所需要的就是按照如下修改oncreate():
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 should now be able to use printf()
from anywhere in your code.
你应该包括<stdio.h>并且可以在任何地方使用printf()函数。
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.
应该有其他方法跟踪输出,但是这个可以确保不需要其他工具就能使用。
Note: although I haven't done it, it should also be possible to remap stdin
and take input from the console window should you need to implement a simple debug console.
注释:虽然我没有试验,它应该可以重映射stdin并且可以从控制台窗口获取输入信息。
Just another one for the toolkit... use it as you will.
- Printf() debugging in a console window from within an ActiveX control
- How To Retrieve the URL of a Web Page from an ActiveX Control
- Hosting an ActiveX Control in WPF
- "An extender can't be in a different UpdatePanel than the control it extends." error really needs debugging information ,错误
- How to start a second thread in an MFC-based ActiveX control to fire events in Visual C++
- Creating an ActiveX Control in Visual Studio 2005
- Capturing an Image from a window
- How To: Assign a Macro to an ActiveX Control
- Reloading an ActiveX control error
- FreeRTOS: Change the priority of a task from within an ISR?
- How to get an X11 Window from a Process ID?
- #147 – Use SetCurrentValue When You Want to Set A Dependency Property Value from Within a Control
- How to cover an IE windowed control (Select Box, ActiveX Object, etc.) with a DHTML layer.
- Calling JavaScript in a WebBrowser control from C#
- Run a program from within a program
- wince6.0 printf VS console window
- Dialog frame as an ActiveX control(收藏)
- Dialog frame as an ActiveX control.
- Mysql并发控制
- 人人网移动开发架构及相关服务器架构
- cookie 和session 的区别详解
- Nginx 支持pathinfo模式
- 基于云技术的商务智能
- Printf() debugging in a console window from within an ActiveX control
- Fedora&Ubuntu编译vim7.3
- HDU 1251 统计难题 -- 字典树
- 华为2013校园招聘上机笔试题
- How to Build libiconv with Microsoft Visual Studio
- python定时邮件发送
- ERP三不要
- 啦啦啦啦
- yii的一点一滴