WM_CLOSE、WM_DESTROY、WM_QUIT学习总结(点击关闭按钮会触发WM_CLOSE消息,DestroyWindow API会触发WM_DESTROY和WM_NCDESTROY消息,MSDN上写的很清楚)
WM_CLOSE:关闭应用程序窗口
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg); //将消息进行处理一下
DispatchMessage(&msg); //再将消息变量msg传给windows,让windows来调用消息处理函数
}
procedure TCustomForm.WMClose(var Message: TWMClose);
begin
Close;
end; procedure TCustomForm.Close;
var
CloseAction: TCloseAction;
begin
if fsModal in FFormState then
ModalResult := mrCancel
else
if CloseQuery then
begin
if FormStyle = fsMDIChild then
if biMinimize in BorderIcons then
CloseAction := caMinimize else
CloseAction := caNone
else
CloseAction := caHide;
DoClose(CloseAction);
if CloseAction <> caNone then
if Application.MainForm = Self then Application.Terminate
else if CloseAction = caHide then Hide
else if CloseAction = caMinimize then WindowState := wsMinimized
else Release;
end;
end; procedure TCustomForm.WMDestroy(var Message: TWMDestroy);
begin
if NewStyleControls then SendMessage(Handle, WM_SETICON, , );
if (FMenu <> nil) and (FormStyle <> fsMDIChild) then
begin
Windows.SetMenu(Handle, );
FMenu.WindowHandle := ;
end;
inherited;
end;
还有:
function TApplication.ProcessMessage(var Msg: TMsg): Boolean;
var
Handled: Boolean;
begin
Result := False;
if PeekMessage(Msg, , , , PM_REMOVE) then
begin
Result := True;
if Msg.Message <> WM_QUIT then
begin
Handled := False;
if Assigned(FOnMessage) then FOnMessage(Msg, Handled);
if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end
else
FTerminate := True;
end;
end;
DestroyWindow函数来自这里(TApplication.Destroy里也调用了这个函数):
procedure TWinControl.DestroyWindowHandle;
begin
Include(FControlState, csDestroyingHandle);
try
if not Windows.DestroyWindow(FHandle) then
RaiseLastOSError;
finally
Exclude(FControlState, csDestroyingHandle);
end;
FHandle := ;
end;
那难道每个TButton,每个TPanel,都会收到WM_DESTROY消息吗?
WM_CLOSE、WM_DESTROY、WM_QUIT学习总结(点击关闭按钮会触发WM_CLOSE消息,DestroyWindow API会触发WM_DESTROY和WM_NCDESTROY消息,MSDN上写的很清楚)的更多相关文章
- 2019-7-4-win10-uwp-处理用户点击关闭按钮
title author date CreateTime categories win10 uwp 处理用户点击关闭按钮 lindexi 2019-07-04 09:28:57 +0800 2019- ...
- Android学习笔记点击事件和触摸事件的区别
当我们点击手机屏幕的时候Android系统不仅会触发单击事件,还会触发触摸事件.在Android中它会先触发触摸事件,如果这个触摸事件没有被消费掉再去触发单击事件 代码示例: MainActivty. ...
- guava 学习笔记(二) 瓜娃(guava)的API快速熟悉使用
guava 学习笔记(二) 瓜娃(guava)的API快速熟悉使用 1,大纲 让我们来熟悉瓜娃,并体验下它的一些API,分成如下几个部分: Introduction Guava Collection ...
- abp学习(四)——根据入门教程(aspnetMVC Web API进一步学习)
Introduction With AspNet MVC Web API EntityFramework and AngularJS 地址:https://aspnetboilerplate.com/ ...
- 微服务架构学习与思考(10):微服务网关和开源 API 网关01-以 Nginx 为基础的 API 网关详细介绍
微服务架构学习与思考(10):微服务网关和开源 API 网关01-以 Nginx 为基础的 API 网关详细介绍 一.为什么会有 API Gateway 网关 随着微服务架构的流行,很多公司把原有的单 ...
- WM_CLOSE WM_DESTROY WM_QUIT的区别
WM_CLOSE:关闭应用程序窗口 WM_DESTROY:关闭应用程序 WM_QUIT:关闭消息循环
- winfrom 捕获是否点击关闭按钮关闭的窗体
const int WM_SYSCOMMAND = 0x0112; const int SC_CLOSE = 0xF060; protected override void WndProc(ref M ...
- vue 点击按钮弹窗,点击关闭按钮关闭弹窗。
<div @click="btnfc()">点击弹窗按钮</div> <div v-show="show"> <div ...
- OpenCV学习笔记——点击显示鼠标坐标
点击显示鼠标显示坐标,再次点击时上一次的坐标的会消失…… #include<highgui.h> #include<cv.h> void on_mouse(int event, ...
随机推荐
- js获取地址栏url以及获取url参数
js原生态写法 代码如下 复制代码 function getUrlParam(name) { var reg = new RegExp("(^|&)"+ name ...
- AdTime:多屏时代下传统媒体的鼓起
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzk1MTQzNQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...
- openssl生成pem,密钥证书的创建
使用OpenSSL生成证书 首先得安装OpenSSL软件包openssl,安装了这个软件包之后,我们可以做这些事情: o Creation of RSA, DH and DSA Key Paramet ...
- 基于visual Studio2013解决C语言竞赛题之1049抓牌排序
题目 解决代码及点评 /* 功能:插入排序.许多玩牌的人是以这样的方式来对他们手中的牌进行排序的: 设手中原有3张牌已排好序,抓1张新牌,若这张新牌的次序在原来的第2张牌之后,第 3 ...
- Codeforces Round #254 (Div. 2)D(预计)
D. DZY Loves FFT time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Javascript 正确用法 二
好的,废话不多说,接着上篇来. 变量(variables) 始终使用 var keyword来定义变量,假设不这样将会导致 变量全局化,造成污染. //bad superPower = new Sup ...
- ASP.NET - 出错页
配置Web.config,配置customError区域. <system.web> <customErrors mode ="RemoteOnly" defau ...
- 【linux】linux内核移植错误记录
欢迎转载,转载时请保留作者信息,谢谢. 邮箱:tangzhongp@163.com 博客园地址:http://www.cnblogs.com/embedded-tzp Csdn博客地址:http ...
- js模板引擎--artTemplate
js模板引擎--artTemplate 以前研究过一段时间的handlebars,但因为其渲染性能略逊于腾讯的artTemplate(在artTemplate的GitHub官网上有推荐的性能测试地址) ...
- 在Centos 5.4上安装Mysql5.5.10 (整理以前的工作文档)
1. 安装环境 1.1. 目的 安装Mysql5.5.10服务,提供公司XXXX测试环境.正式环境也采用该版本的mysql 1.2. 硬件环境 PC机:IntelE5300 内存4G 硬盘5 ...