回复 20楼 smallmoon521
谢谢你的建议。

梅尚程荀
马谭杨奚
2012-02-14 13:11
程序代码:#include <windows.h>
#include <math.h>
#define NUM 100
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] =TEXT("拥抱世界");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW || CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
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 0;
}
hwnd = CreateWindow(szAppName, TEXT("风光无限好"), // CreateWindow下波浪线,是整个程序中唯一一处。
WS_OVERLAPPENDWINDOW, /*但是编译出现错误提示是 error C2065: “WS_OVERLAPPENDWINDOW”: 未声明的标识符*/
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
int i;
PAINTSTRUCT ps;
POINT apt[NUM];
RECT rect;
switch(message)
{
case WM_CREATE:
PlaySound(TEXT("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rect);
DrawText(hdc, TEXT("Hello, Windows program design!"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}我应该没写错别英文文字吧。

2012-02-14 15:18
2012-02-14 16:37
2012-02-14 16:38
2012-02-14 16:40
2012-02-14 16:46
2012-02-14 16:55

程序代码:LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int cxClient, cyClient ; // 是定义X Y坐标吗?
HDC hdc;
int i ;
PAINTSTRUCT ps ; // 这个结构体指针有什么用?
POINT apt [NUM] ; // 是放点的数组吧。
switch (message)
{
case WM_SIZE:
cxClient = LOWORD (lParam) ; // 这两句什么意思
cyClient = HIWORD (lParam) ;
return 0 ;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
MoveToEx (hdc, 0,cyClient / 2, NULL) ; // 移到下一个点?为什么要除2
LineTo (hdc, cxClient, cyClient / 2) ; // 为什么只有y除以2?
for (i = 0 ; i < NUM ; i++)
{
apt[i].x = i * cxClient / NUM ;
apt[i].y = (int) (cyClient / 2 * (1 - sin (TWOPI * i / NUM))) ; // 循环确定点的坐标放到数组中?
}
Polyline (hdc, apt, NUM) ; // 这个函数怎么实现的?
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}如果要画一个点,一条线段,一个矩形,一个圆该怎么改?
2012-02-14 16:55


2012-02-14 16:58

2012-02-14 17:07