日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 嵌入式 > 嵌入式軟件
[導(dǎo)讀]這樣使添加處理消息函數(shù)變得簡單步驟1: 頭文件中添加相關(guān)項步驟2: cpp添加具體實現(xiàn)方法步驟3: 結(jié)構(gòu)體數(shù)組中添加相關(guān)項.h 文件:struct DecodeUint{UINT meesage;LONG (*

這樣使添加處理消息函數(shù)變得簡單

步驟1: 頭文件中添加相關(guān)項

步驟2: cpp添加具體實現(xiàn)方法

步驟3: 結(jié)構(gòu)體數(shù)組中添加相關(guān)項

.h 文件:

struct DecodeUint{

UINT meesage;

LONG (*fun)(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

};

#define dim(x) (sizeof(x)/sizeof(x[0]))

LONG OnDestory(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

LONG OnPaint(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

.c文件:

#include

#include "Border.h"

struct DecodeUint MainMessageProc[] = {

WM_DESTROY,OnDestory,

WM_PAINT,OnPaint,

};

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

int WinMain(HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPTSTR lpCmdLine,

int nCmdShow)

{

WNDCLASS wc;

wc.cbClsExtra = 0;

wc.cbWndExtra = 0;

wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);

wc.hCursor = NULL;

wc.hIcon = NULL;

wc.hInstance = hInstance;

wc.lpfnWndProc = WndProc;

wc.lpszClassName = TEXT("hello");

wc.lpszMenuName = NULL;

wc.style = CS_HREDRAW | CS_VREDRAW;

if (!RegisterClass(&wc)) return -1;

HWND hWnd = CreateWindow(TEXT("hello"),TEXT("helloworld"), WS_VISIBLE | WS_BORDER | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CAPTION,

10,10,320,240,NULL,NULL,hInstance,NULL);

UpdateWindow(hWnd);

ShowWindow(hWnd,nCmdShow);

MSG msg;

while (GetMessage(&msg, NULL, 0, 0))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

return 1;

}

LONG OnDestory(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

{

PostQuitMessage(1);

return TRUE;

}

LONG OnPaint(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

{

PAINTSTRUCT ps;

HDC hdc;

RECT rect;

GetClientRect(hWnd,&rect);

hdc = BeginPaint(hWnd,&ps);

DrawText(hdc,TEXT("hello world"),-1,&rect,DT_VCENTER | DT_CENTER);

EndPaint(hWnd,&ps);

return TRUE;

}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

{

for (int i = 0;i < dim(MainMessageProc); i++)

{

if (MainMessageProc[i].meesage == message)

{

(*MainMessageProc[i].fun)(hWnd,message,wParam,lParam);

}

}

return DefWindowProc(hWnd,message,wParam,lParam);

}

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉