[问题]

Our project is running on Windows CE 6.0 and is written in C++ . We have some problems with the code , and we are unable to debug . We also found out that if in our application we create threads and try to printf from them , the output won't appear . The only output that will appear is the one from the main thread . I would like to do the following :

  • create a custom windows message
  • use as it's WPARAM the address of a char* I want to show on the screen
  • use as it's LPARAM the length of the char* I want to show on the screen
  • send the message
  • process it when it comes , so that it prints the char*

How could I create the custom windows message ? What are the types of WPARAM and LPARAM ? Is it possible to do what I just wrote ?

Thanks

【答案】

It's certainly possible to do what you describe. You don't need to actually do anything to create a custom message for communication within your application: just make sure that the code that sends the message and the code that receives the message agree on what the message number actually is, and use a message number that doesn't overlap with any of the numbers Windows uses. There is a RegisterWindowMessage() function, but that's only needed to get a message number that's unique across the entire operating system, so used for inter-process communication.

The simplest way to achieve this is to just have a header file somewhere containing your custom message numbers, starting with WM_USER and numbering upwards, like so:

#define WM_FIRST_CUSTOM_MSG (WM_USER+0)

#define WM_SECOND_CUSTOM_MSG (WM_USER+1)

The WPARAM and LPARAM types are defined when you include "windows.h", so can have different types on different systems. For 32-bit operating systems, they are both usually 32-bit integers. If you're just using the message for testing purposes, that's usually good enough, and you can stick whatever you want in there. For production code, though, you should be more careful: WPARAM is really for "integer-like" data, and LPARAM for "pointer-like" data. In Win64, for example, LPARAM is long enough to hold a 64-bit pointer, but WPARAM only holds a 32-bit integer. For passing more data than just an integer and a pointer, I'd use lParam to pass a pointer to some sort of structure containing all my arguments.

Having said all that, it sounds like a complicated way of getting debugging output. Have you tried using the OutputDebugString() API call? Or debugging the thread's printf() call?

 

From: https://stackoverflow.com/questions/293723/how-could-i-create-a-custom-windows-message

 

How could I create a custom windows message?的更多相关文章

  1. [转]How do you create a custom AuthorizeAttribute in ASP.NET Core?

    问: I'm trying to make a custom authorization attribute in ASP.NET Core. In previous versions it was ...

  2. hdu 1509 Windows Message Queue

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1509 Windows Message Queue Description Message queue ...

  3. Part 13 Create a custom filter in AngularJS

    Custom filter in AngularJS 1. Is a function that returns a function 2. Use the filter function to cr ...

  4. hdoj 1509 Windows Message Queue【优先队列】

    Windows Message Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  5. Windows Message Queue(优先队列)

    欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Windows Message Queue Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  6. Windows Message Queue--hdu1509

    Windows Message Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  7. Windows Message Queue

    Windows Message Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...

  8. zoj 2724 Windows Message Queue

    Windows Message Queue Time Limit: 2 Seconds      Memory Limit: 65536 KB Message queue is the basic f ...

  9. [Angular] Create a custom validator for reactive forms in Angular

    Also check: directive for form validation User input validation is a core part of creating proper HT ...

随机推荐

  1. 20款最好的免费 Bootstrap 后台管理和前端模板

    Admin Bootstrap Templates Free Download 1. SB Admin 2 Preview | Details & Download 2. Admin Lite ...

  2. [Go] 判断 文件/文件夹 是否存在?

    Golang 判断文件是否存在有点怪异,是根据在操作文件时返回的错误信息来判断的,而不能直接根据路径判断 版本1: func IsExists(path string) (bool, error) { ...

  3. AngularJS报错:[$injector:unpr] Unknown provider: $templateRequestProvider

    在页面中由上到下引用了: angular.js angular-route.js 创建model的时候也写明了依赖: var someApp = angular.module('someApp',[' ...

  4. OLE文件拖放

    使用IDropTarget接口同时支持文本和文件拖放 关于Windows的外壳扩展编程,拖放是比较简单的一种,在网上可以找到不少介绍这个技巧的文章.大部分是介绍使用MFC的COleDropTarget ...

  5. How To Create A Local Repository For SUSE Linux

    原文地址:http://candon123.blog.51cto.com/704299/1009294/ As you know,you can use the yum command to inst ...

  6. 转:iOS 越狱的原理是什么

         本文的主角是一个苦逼的程序员,最近打算开始研究越狱破解,因为打算做类似一类越狱插件的东西给自己使用.所以就了解了一下越狱破解的一个原理过程. 每个手机都会有手机系统,苹果也不例外.每个手机系 ...

  7. SharePoint Set-SPUser 命令拒绝访问

    · 前言 最近碰到一个问题,由于User Profile Service服务有问题,用户信息无法更新.所以,想到Set-SPUser命令可以更新,于是乎找到这个命令,但是更新的时候发现拒绝访问的错误. ...

  8. Loader的初步学习笔记

    Loader是一个异步加载数据的类,它和AsyncTask有类似也有不同,今天我们就先来学习下它.由于是对比学习,所以我们先来复习下AsyncTask的使用和特点. 一.AsyncTask 参考自:h ...

  9. <A>标签锚标记

    链接到本页面 – 锚记标签用于使用户“跳”到文档的某个部分 – HTML 的NAME 属性用于创建锚标记 <A NAME = “marker”>主题名称</A> – 为达到这种 ...

  10. 关于bootstrap Modal弹窗 滚动条的问题

    如果自己通过代码关闭Modal窗体,需要在代码里增加一句代码 $('body').removeClass('modal-open'); 把这个CSS样式移除了