概述

链接1:http://www.cppblog.com/suiaiguo/archive/2009/07/18/90412.html

链接2:http://www.cnblogs.com/findumars/p/3948427.html


代码框架

#include <windows.h>

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = ;
wndclass.cbWndExtra = ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return ;
}
hwnd = CreateWindow (szAppName, // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, , ))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
} LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ; switch (message)
{
case WM_CREATE:
PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
return ; case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ; GetClientRect (hwnd, &rect) ; DrawText (hdc, TEXT ("Hello, Windows 98!"), -, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
EndPaint (hwnd, &ps) ;
return ; case WM_DESTROY:
PostQuitMessage () ;
return ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}

Windows 函数

HWND WINAPI CreateWindow(
_In_opt_ LPCTSTR   lpClassName,
_In_opt_ LPCTSTR   lpWindowName,
_In_     DWORD     dwStyle, // Window Style
_In_     int       x,
_In_     int       y,
_In_     int       nWidth,
_In_     int       nHeight,
_In_opt_ HWND      hWndParent,
_In_opt_ HMENU     hMenu,
_In_opt_ HINSTANCE hInstance,
_In_opt_ LPVOID    lpParam
);
 //使用CreateWindow之前要先依次 【定义】和 【注册】  【窗口类型】
// 【定义】 并初始化
WNDCLASS wndclass;
......
wndclass.lpszClassName = TEXT("WindowClassName");
...... // 【注册】
if (!RegisterClass (&wndclass))
{
MessageBox ( NULL, TEXT ("This program requires Windows NT!"), szAppName, MB_ICONERROR) ;
return ;
} //CreateWindow 与 窗口类型wndclass 的联系是通过 CreateWindow 第一个 参数建立起来的
// 如果要使用上面第3行定义的 wndclass 则使用时第一个参数如下: hwnd1 = CreateWindow( TEXT("WindowClassName"), // window class name
.
.
.
             NULL) ; // creation parameters //CreateWindow 后必须使用以下两函数才能 显示和刷新
ShowWindow (hwnd1, iCmdShow) ;     //设置特定的状态
UpdateWindow (hwnd1) ; // 向procedure 发送 MS_PAINT

Windows Notifications (Windows Procedure 所接收的“通知”)

KeyBord Input Notification

windows 消息机制的学习的更多相关文章

  1. <Win32_1>深入浅出windows消息机制[转自crocodile_]

    上学期学习了Java ,感觉Java写一个窗口真心简单,很易上手,也就难怪很多开发人员选择Java作为自己的开发编程语言.但是由于自身对windows的热爱,让我觉得c.c++语言才是我亲睐的编程语言 ...

  2. 转:Windows消息机制要点

    Windows消息机制要点 1. 窗口过程     每个窗口会有一个称为窗口过程的回调函数(WndProc),它带有四个参数,分别为:窗口句柄(Window Handle),消息ID(Message ...

  3. Windows消息机制

    Windows的消息系统是由3个部分组成的: · 消息队列.Windows能够为所有的应用程序维护一个消息队列.应用程序必须从消息队列中获取消息,然后分派给某个窗口.· 消息循环.通过这个循环机制应用 ...

  4. 我对windows消息机制的理解(参考深入浅出MFC,欢迎批评指正!!)

    以消息为基础,以事件驱动之 程序的进行依靠外部消息来驱动,即:程序不断等待任何可能的输入,然后做判断,然后再做适当的处理. 消息输入:操作系统捕获,以消息形式进入程序.(操作系统通过其USERS模块中 ...

  5. 深入Delphi -- Windows 消息机制

    http://www.txsz.net/xs/delphi/3/Windows%20%E6%B6%88%E6%81%AF%E6%9C%BA%E5%88%B6.htm Windows 消息机制 by m ...

  6. 收藏:Windows消息机制

    百度百科介绍的windows消息机制也不错:http://baike.baidu.com/view/672379.htm Windows的应用程序一般包含窗口(Window),它主要为用户提供一种可视 ...

  7. windows消息机制(转)

    1. 引言Windows 在操作系统平台占有绝对统治地位,基于Windows 的编程和开发越来越广泛.Dos 是过程驱动的,而Windows 是事件驱动的[6],这种差别的存在使得很多Dos 程序员不 ...

  8. 深入理解windows 消息机制

    深入理解Windows消息机制 今天我们来学一学Windows消息机制,我们知道在传统的C语音程序中,当我们需要打开一个文件时,我们可以调用fopen()函数,这个函数最后又会调用操作系统提供的函数以 ...

  9. windows消息机制框架原理【简单版本】

    windows消息机制框架原理 结合两张图理解 窗口和窗口类 Windows UI 应用程序 (e) 具有一个主线程 (g).一个或多个窗口 (a) 和一个或多个子线程 (k) [工作线程或 UI 线 ...

随机推荐

  1. gulp初涉

    1.什么是gulp? gulp是前端开发过程中一种基于流的代码构建工具,是自动化项目的构建利器:它不仅能对网站资源进行优化,而且在开发过程中很多重复的任务能够使用正确的工具自动完成:使用它,不仅可以很 ...

  2. VB 中ListView 某一列的颜色添加不上去的解决方法

    做过VB,对添加某一行中的某一列的背景颜色 ,和文字颜色,来表明某种意义的时候,会有添加不上去的情况 abc = Nothing abc = New ListViewItem.ListViewSubI ...

  3. C#中的线程二(BeginInvoke和Invoke)

    近日,被Control的Invoke和BeginInvoke搞的头大,就查了些相关的资料,整理如下.感谢这篇文章对我的理解Invoke和BeginInvoke的真正含义 . (一)Control的In ...

  4. 关于开发C#中的asp.net中gridview控件的使用

    原文网址:http://blog.sina.com.cn/s/blog_67f1b4b201017663.html 1.GridView无代码分页排序: 效果图: 1.AllowSorting设为Tr ...

  5. 学习日记_SSH框架web.xml配置文件篇

    1.参考一:http://www.blogjava.net/yxhxj2006/archive/2012/07/09/382632.html 2.参考二: <!-- web 容器启动spring ...

  6. Linux安装配置mongodb

    1. 下载MongoDB 2. 解压文件到某目录下,然后重命名: [root@localhost var]# tar -xzvf mongodb-linux-i686-2.0.1.tar [root@ ...

  7. iOS应用架构谈 开篇 (转)

    iOS应用架构谈 开篇  iOS应用架构谈 view层的组织和调用方案 iOS应用架构谈 网络层设计方案 iOS应用架构谈 动态部署方案 iOS应用架构谈 本地持久化方案 缘由 之前安居客iOS ap ...

  8. 关于idea激活

    1.在线激活 https://www.iteblog.com/idea/ 使用可访问:http://idea.iteblog.com/   或者  http://idea.lanyus.com/ ht ...

  9. pugixml使用教程

    pugixml介绍 pugixml是一个高性能.轻量级并且简单易用的xml解析库,支持UTF8 encoding.Little-endian UTF16.Big-endian UTF16.UTF16 ...

  10. 【USACO 3.2.3】纺车的轮子

    [描述] 一架纺车有五个纺轮,这五个不透明的轮子边缘上都有一些缺口.这些缺口必须被迅速而准确地排列好.每个轮子都有一个起始标记(在0度),这样所有的轮子都可以在统一的已知位置开始转动.轮子按照角度变大 ...