Win32基础编程 窗口创建和消息循环(三)

本文介绍了Windows编程中的回调和钩子机制,重点讲解了窗口创建和消息循环的基础知识。回调函数在特定事件时被调用,而钩子允许程序在特定事件发生时优先获取消息。在Win32中,窗口类通过WNDCLASSEX结构体的lpfnWndProc指定消息处理函数,消息由消息名称和两个参数组成,用于通知操作系统发生的事件。
摘要由CSDN通过智能技术生成

窗口创建和消息循环

    先来说一下Windows两个经典的机制:回调、钩子。

    回调是指程序员自己定义函数,在特定的事件或条件发生时由另外的一方调用的,用于对该事件或条件进行响应。

    钩子:当每次发生您感兴趣的事件时,WINDOWS钩子优先获得消息。许多木马程序就是由钩子实现的。

    消息定义:在Windows中发生的一切都可以用消息来表示,消息用于告诉操作系统发生了什么,所有的Windows应用程序都是消息驱动的。一个消息是由消息的名称(UINT)和两个参数(WPARAM, LPARAM)组成。消息的参数中包含有重要的信息。例如对鼠标消息而言,LPARAM中一般包含鼠标的位置信息,而WPARAM参数中包含了发生该消息时,SHIFT、CTRL等键的状态信息,对于不同的消息类型来说,两个参数也都相应地具有明确意义。

    在Win32中,注册窗口类时,WNDCLASSEX结构体的lpfnWndProc成员指向一个回调函数,进行Windows消息的处理。Win32中消息定义和指定回调函数的原型࿱

Forger 推荐的学习windows 编程的所有书籍都在这儿: windows 编程 windows MFC入门到精通 windows 高级编程 windows 网络编程 Programming Windows Programming Windows with MFC Programming Applications for Windows Network Programming for Microsoft Windows Programming Windows by Charles Petzold. The book to get on Win32 API. If you want to write programs using just the API (which is what this tutorial covers), you need this book. 如果你想只用windows API编程,这本书是入门经典,你需要这本书。 Programming Windows with MFC by Jeff Prosise. If you want to venture into MFC (AFTER becoming fully accustomed to using the Win32 API), this is the book for you. If you don't like MFC but intend on getting a job doing windows developement, get this anyway, it's better to know than not. 如果你想用MFC这本书是你想要的 Programming Applications for Windows by Jeffrey Richter. Not for newbies, if you want to be up on managing processes and threads, dlls, windows memory management, exception handling, and hooking into the system, then this is the book for you. 如果你想了解操作系统内幕,这本书是经典,书中包含了进程,线程,动态库,windows内存管理,异常处理。。。 Visual C++ Windows Shell Programming by Dino Esposito. For anyone interested in the visual and user-friendly aspects of windows, this book covers writing extentions to the windows shell, working efficiently with files and drag and drop, customizing the taskbar and windows explorer, and numerous other tricks. Well worthwhile for anyone writing GUI apps in windows. Network Programming for Microsoft Windows Up to date information on network programming, including NetBIOS, mailslots and pipes, and of course the ever important windows sockets, complete with winsock2 and raw sockets. Also contains specific information on the various windows platforms including 2000 and CE.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值