My simple API
来源:互联网 发布:宏毅网络 编辑:程序博客网 时间:2024/05/10 12:38
#include <windows.h>
/***********************************************************************/
LRESULT CALLBACK WinProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch( uMsg )
{
case WM_KEYDOWN://击键消息
switch( wParam )
{
case VK_ESCAPE:
PostMessage(hwnd, WM_CLOSE, 0, 0);//给窗口发送WM_CLOSE消息
break;
}
return 0; //处理完一个消息后返回0
case WM_CLOSE: //准备退出
DestroyWindow( hwnd ); //释放窗口
return 0;
case WM_RBUTTONDOWN:
MessageBox(hwnd,"鼠标右键按下了!","Mouse",MB_OK);
return 0;
case WM_DESTROY: //如果窗口被人释放…
PostQuitMessage( 0 ); //给窗口发送WM_QUIT消息
return 0;
}
//调用缺省消息处理过程
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
/***********************************************************************/
HWND InitWindow(HINSTANCE hinst, int nCmdShow)
{
HWND hwnd; // the window handle we obtain will be put here
WNDCLASSEX wc;
// set up and register window class
memset(&wc, 0, sizeof(wc));
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WinProc; // change this to NULL and crash!
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinst;
wc.hIcon = NULL;
wc.hIconSm = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = CreateSolidBrush(RGB(100,0,0)); //CreateSolidBrush (RGB(100, 0, 0));
wc.lpszMenuName = NULL;
wc.lpszClassName = "MyCoolWindow";
RegisterClassEx(&wc);
// create a window that's 200 pixels wide, 100 tall
hwnd = CreateWindowEx(0, "MyCoolWindow", "My First Window",
WS_OVERLAPPEDWINDOW, 50, 50, 200, 100, NULL, NULL, hinst, NULL);
if (!hwnd) {
::MessageBox(NULL, "CreateWindow failed!", "Ch1p1_HackedWindowProc", MB_ICONSTOP);
exit(-1);
}
ShowWindow(hwnd, nCmdShow);
return(hwnd);
}
/***********************************************************************/
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hwnd = InitWindow(hInstance, nCmdShow);
MSG msg;
//进入消息循环:
for(;;)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if ( msg.message==WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
- My simple API
- My simple functions
- My simple english resume
- my simple vim configure
- my simple shell bashrc configure
- Simple API for XML
- Simple Consumer Scala API
- OpenGL API simple summary
- simple-mock-api
- API mixerGetNumDevs My masterd1
- SAX:Simple API for XML
- SAX---SIMPLE API FOR XM
- Simple API for Z-Stack
- Simple Code Overwriting API Hook
- SAX--Simple API for XML
- SAX: Simple API for XML
- kafka 0.8 simple api使用
- My Google Maps API key
- 蝶恋花词牌
- 添加“显示桌面”到快速启动栏
- 宋词概述
- 一点体会
- 非一般的 “hello,world.”
- My simple API
- 文件重复
- 关于SQL Server2005支不支持一条insert语句插入多条记录的问题
- 最近的事
- 分页加载数据效果的新颖改进
- 11
- flyinghearts《编程之美》读书笔记连载(4)
- 创新工厂面试经历
- 第一次开通