WM_NULL message
来源:互联网 发布:iphone usb共享网络 编辑:程序博客网 时间:2024/06/02 00:31
WM_NULL message
Performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore.
A window receives this message through its WindowProc function.
#define WM_NULL 0x0000
Parameters
- wParam
This parameter is not used.
- lParam
This parameter is not used.
Return value
Type: LRESULT
An application returns zero if it processes this message.
Remarks
For example, if an application has installed a WH_GETMESSAGE hook and wants to prevent a message from being processed, the GetMsgProc callback function can change the message number to WM_NULL so the recipient will ignore it.
As another example, an application can check if a window is responding to messages by sending the WM_NULL message with the SendMessageTimeoutfunction.
Requirements
Minimum supported client
Minimum supported server
Header
- Winuser.h (include Windows.h)
See also
- Windows Overview
Posts tagged WM_NULL
How to find whether a GUI application is freezed or is not responding?
35 YEARS AGOby Jijo Raj in Uncategorized, Windows APIsIt’s common that windows citizens usually hang after long run. Sometimes your application was meant to run for long period but stop responding after days or months. So how to automatically restart it if it gets hang? One method is to schedule a polling application which checks the application periodically. But how to determine whether an application is hung?
You can send WM_NULL message to the application window by using the api – SendMessageTimeout(). The WM_NULL does nothing. It can be used for poll the window. If an appliaction window is hung, it may not be able to process the WM_NULL message. If we use SendMessage(), since its a blocking call out caller thread too will be blocked.So we should use SendMessageTimeout() in which we can specify a timeout. In SendMessageTimeout() we can specify a flag – SMTO_ABORTIFHUNG which returns immedietly if the targeted application is hung. So SendMessageTimeout() is perfect for our purpouse. See the sample code snippet below.
DWORD Result = 0;LRESULT Return = 0;// Handle of application window.// Get it by using FindWindowEx function.// Here for compilation, i get the handle of my dialog.HWND hWnd = GetSafeHwnd(); // Send the NULL message to the window.// SMTO_ABORTIFHUNG is specified to return immediately,// if the process is hung.Return = ::SendMessageTimeout( hWnd, // Window Handle WM_NULL, // Message 0, // WParam 0, // LParam SMTO_ABORTIFHUNG, // Flags 500, // Timeout &Result ); // Result// Check whether the WM_NULL message is processed.if( !Return ){ // Since the WM_NULL message is not processed, // the targeted window is hung. Forget about it!}
Customize it according to your wish.
Just like null checking the pointer, you can check, whether a window is perfect by sending WM_NULL message.
Targeted Audience – Intermediate.
- WM_NULL message
- message
- message
- message
- Message
- Message
- Message
- Message
- Message
- Message
- Message
- Message
- message
- message
- message
- Runtime--Message、Message Forwarding
- message info
- Message Board
- JAVA run方法中得到线程名称
- js弹出对话框
- linq to xml基础
- js 获取服务器控件的值
- Error configuring application listener of class org.springframework.web.context.Context
- WM_NULL message
- jsp下载文件
- 【Linux基础】shell控制结构
- Windows XP硬盘安装Ubuntu 12.04双系统图文详解
- mysql 无法进行远程访问的问题
- 众核指令数据加载
- 学科起源(漫画版)
- Surface和SurfaceView以及SurfaceHolder的认识及使用
- C语言宏定义##连接符和#符的使用