花的编程代码C语言,C语言花朵代码的.doc

编程知识 行业动态 更新时间:2024-06-13 00:21:51

C语言花朵代码的

.

C语言——绘画花朵

代码部分

#include

#include

#define PI 3

LRESULT CALLBACK WindowProcedure ( HWND, UINT, WPARAM, LPARAM );

void OnPaint ( HDC );

void DrawLine ( HDC, int, int, int, int );

void DrawFlower ( HDC, int, int, COLORREF );

void DrawTie ( HDC, int, int, COLORREF );

int WINAPI WinMain ( HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil )

{

char szClassName[] = TEXT ( "DrawFlower" );

HWND hwnd;

MSG msg;

WNDCLASSEX wc = { 0 };

wc.hInstance = hThisInstance;

wc.lpszClassName = szClassName;

wc.lpfnWndProc = WindowProcedure;

wc.style = CS_DBLCLKS;

wc.cbSize = sizeof ( WNDCLASSEX );

wc.hIcon = LoadIcon ( NULL, IDI_APPLICATION );

wc.hIconSm = LoadIcon ( NULL, IDI_APPLICATION );

wc.hCursor = LoadCursor ( NULL, IDC_ARROW );

wc.hbrBackground = ( HBRUSH ) ( COLOR_WINDOW+1 );

if ( !RegisterClassEx ( &wc ) ) return 0;

hwnd = CreateWindowEx ( 0, szClassName, szClassName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_DESKTOP, NULL, hThisInstance, NULL );

ShowWindow ( hwnd, nFunsterStil );

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

{

TranslateMessage ( &msg );

DispatchMessage ( &msg );

}

return msg.wParam;

}

LRESULT CALLBACK WindowProcedure ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )

{

PAINTSTRUCT ps;

HDC hdc;

switch ( msg )

{

case WM_PAINT:

hdc = BeginPaint ( hwnd, &ps );

OnPaint ( hdc );

EndPaint ( hwnd, &ps );

break;

case WM_DESTROY:

PostQuitMessage ( 0 );

break;

default:

return DefWindowProc ( hwnd, msg, wParam, lParam );

}

return 0;

}

void OnPaint ( HDC hdc )

{

HPEN h;

// 画蝴蝶结

DrawTie ( hdc, 195, 354, RGB ( 255,0,255 ) );

// 画枝干

h = CreatePen ( PS_SOLID, 1, RGB ( 0,255,0 ) );

SelectObject ( hdc, h );

DrawLine ( hdc, 189, 372, 180, 400 )

更多推荐

花的编程代码C语言,C语言花朵代码的.doc

本文发布于:2023-04-01 06:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/8fa9b87433270cc19ba9b8af95550b94.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语言   代码   花朵   doc

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!