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, ...
随机推荐
- CF 338E Optimize! (线段树)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 出题人题解没看懂...囧. 然后看了下touris ...
- dfs-hdu-4620-Fruit Ninja Extreme
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4620 题目大意: 切水果.给n刀,每刀的时间,每刀切的水果的种类.求能切的最多的刀数,使得每相邻的两 ...
- 11181 - Probability|Given
N friends go to the local super market together. The probability of their buying something from them ...
- jQuery.localStorage() - jQuery SDK API
jQuery.localStorage() - jQuery SDK API jQuery.localStorage() From jQuery SDK API Jump to: navigati ...
- 用lisp来让计算机学会写作
大部分的代码.思路参考了<Ansi Common Lisp>P138~P141. 问题:给一篇英文文本,如何让计算机依据此文本而生成随机但可读的文本.如: |Venture| The Na ...
- CodeForces 462B Appleman and Card Game(贪心)
题目链接:http://codeforces.com/problemset/problem/462/B Appleman has n cards. Each card has an uppercase ...
- JavaWeb图表插件的小研究
背景 近期的一个项目中,对数据的统计分析有非常大的要求,这就要求有一款非常强大的报表.图表插件.因此,组长给分了任务.让我们各自去研究不同的图表插件.用了一两天的时间,对java这块的图表插件做了一个 ...
- dephi中单击鼠标拖动窗口(使用WM_SYSCOMMAND)
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Int ...
- jquery 提交数据
目录 jquery ajax的应用 1 表单提交 2 ajax的提交(ajax post get) 普通的表单提交 <%@ page language="java" impo ...
- linux 控制台使用技巧
1. 键盘无响应 可能是按下ctrl+s, 此时按下scroll即可解锁 2. 想看上一屏的信息 shift+pageup 3. 打印的信息和错误信息区分 普通信息, 用printf, cout打印的 ...