求助,用vc++6.0显示一条曲线的程序
要求是这样的:首先画一个坐标轴,然后在这个坐标轴上画一条线(直线也行,曲线也行,这个随便)。
希望会的留下QQ,我加你,今晚要搞定,很急的,做好了再加100分。
其他:#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
WNDCLASS wc = {0};
wc.lpszClassName = TEXT( "Simple" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc ;
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClass(&wc);
CreateWindow( wc.lpszClassName, TEXT("Simple"),
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 640, 480, NULL, NULL, hInstance, NULL);
while( GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
HPEN holdPen;
HPEN hPen;
POINT points[10] = {0};
POINT o = {0};
POINT ax = {0};
RECT rect;
int w = 100, h = 100;
int i;
DWORD color;
HFONT hFont, holdFont;
static TCHAR *tx[10] = {TEXT("0"), TEXT("1"), TEXT("2"), TEXT("3"), TEXT("4"), TEXT("5"), TEXT("6"), TEXT("7"), TEXT("8"), TEXT("9")};
switch(msg)
{
case WM_SIZE:
GetClientRect(hwnd, &rect);
InvalidateRect(hwnd, &rect, TRUE);
break;
case WM_PAINT:
if(GetClientRect(hwnd, &rect)){
w = rect.right - rect.left + 1;
h = rect.bottom - rect.top + 1;
o.x = rect.left + w/11;
o.y = rect.bottom - 1 - h/11;
ax.x = rect.left + w*10/11;
ax.y = o.y;
for(i = 0; i < 10; i++){
points[i].x = rect.left + (rect.right - rect.left + 1)*(i+1)/11;
points[i].y = o.y - (double)i*i/((10-1)*(10-1))*(o.y -h/11);
}
}
hdc = BeginPaint(hwnd, &ps);
MoveToEx(hdc, o.x, o.y, NULL);
LineTo(hdc, ax.x, ax.y);
color = GetSysColor(COLOR_BTNFACE);
SetBkColor(hdc, color);
for(i = 0; i < 10; i ++) TextOut(hdc, points[i].x, ax.y + 10, tx[i], lstrlen(tx[i]));
hPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
holdPen = SelectObject(hdc, hPen);
MoveToEx(hdc, points[0].x, points[0].y, NULL);
for(i = 0; i < 10; i ++){
LineTo(hdc, points[i].x, points[i].y);
}
SelectObject(hdc, holdPen);
DeleteObject(hPen);
EndPaint(hwnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
} 生产 89308375 g.DrawLine (&pen4, m_nX+34, m_nY+m_nHeight/4, m_nX+75, m_nY+m_nHeight/4);// long white line ``` 用GDI或者MFC的CDC
上一个:vc send 的问题
下一个:我也想用VC2010 调用matlab画图 请问你是怎么解决的