标题:[求助]高手帮我看看这个程序
只看楼主
clark086
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-12-16
 问题点数:0 回复次数:0 
[求助]高手帮我看看这个程序

高手帮我看看这个程序,并给我注释一下大概的意思,因为我看不懂,还有就是这个程序具体是用来干什么的,还有就是这个是C++的程序还是C的程序? 谢谢

#include <windows.h>
#include <stdio.h>

HINSTANCE hInst;
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

MSG msg;

MyRegisterClass(hInstance);

if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return (int) msg.wParam;
}


ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "DDD";
wcex.hIconSm = NULL;

return RegisterClassEx(&wcex);
}



BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;

hInst = hInstance; // Store instance handle in our global variable

hWnd = CreateWindow("DDD", "DD", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

if (!hWnd)
{
return FALSE;
}

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

return TRUE;
}



LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
static char ch;
static int bKeyDown;
switch (message)
{
case WM_KEYDOWN:
ch = wParam;
bKeyDown=1;
::InvalidateRect(hWnd,NULL,TRUE);
break;
case WM_KEYUP:
ch = wParam;
bKeyDown=2;
::InvalidateRect(hWnd,NULL,TRUE);
break;

case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
{
char str[256];
if (bKeyDown!=0)
{
sprintf(str,"%c---%s",ch,bKeyDown==1 ? "down":"up");
::TextOut(hdc,0,0,str,strlen(str));
bKeyDown=0;
}
}
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

[此贴子已经被作者于2005-12-16 21:50:43编辑过]

搜索更多相关主题的帖子: include 干什么 
2005-12-16 21:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-38510-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.068164 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved