返回列表 发帖

[求助]用C语言编写屏幕保护程序

求原理。分析。源码。
谢谢~!
:12:  :12:

[求助]用C语言编写屏幕保护程序

用C编写可能麻烦点。
在鼠标移动事情中退出,并要响应单击退出,这是最基本的。
用Net开发平台或者Delphi,或者VB,开发起来比C++容易的多。

TOP

[求助]用C语言编写屏幕保护程序

这是表弟的期末作业。。
偶的想法是用函数不断生成曲线,就像贝赛尔曲线一样的。。

TOP

[求助]用C语言编写屏幕保护程序

[这个贴子最后由默数悲伤在 2006/12/25 09:10am 第 1 次编辑] GDI+中有一套绘制函数,很是方便。 GDI+使用起来也很方便。。。
#include #include using namespace Gdiplus; #pragma comment(lib, "Gdiplus.lib") LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); VOID AddExample(HDC hdc); INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow) { HWND hWnd; MSG msg; WNDCLASS wndClass; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; // Initialize GDI+. GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); 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 = TEXT("GDIPlus Test"); RegisterClass(&wndClass); hWnd = CreateWindow( TEXT("GDIPlus Test"), // window class name TEXT("GDIPlus Test"), // window caption WS_OVERLAPPEDWINDOW, // window style CW_USEDEFAULT, // initial x position CW_USEDEFAULT, // initial y position CW_USEDEFAULT, // initial x size CW_USEDEFAULT, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL); // creation parameters ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } GdiplusShutdown(gdiplusToken); return msg.wParam; } // WinMain LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; switch(message) { case WM_PAINT: hdc = BeginPaint(hWnd, &ps); AddExample(hdc); EndPaint(hWnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } } // WndProc VOID AddExample(HDC hdc) { Graphics graphics(hdc); Pen pen(Color(255, 0, 0, 255)); PenGreenPen(Color(255, 123, 255, 0), 10); GreenPen.SetAlignment(PenAlignmentInset); // 直线 graphics.DrawLine(&GreenPen, 50, 80, 50, 300); graphics.DrawLine(&pen, 50, 80, 50, 300); // 文字 SolidBrush brush(Color(255, 0, 0, 255)); FontFamily fontFamily(L"Times New Roman"); Font font(&fontFamily, 24, FontStyleRegular, UnitPixel); PointF pointF(10.0f, 20.0f); graphics.DrawString(L"Hello World!", -1, &font, pointF, &brush); // 矩形 pen.SetWidth(5); graphics.DrawRectangle(&pen, 20, 20, 300, 200); graphics.DrawRectangle(&GreenPen, 20, 20, 300, 200); // 带标志的直线 pen.SetEndCap(LineCapArrowAnchor); pen.SetStartCap(LineCapRoundAnchor); graphics.DrawLine(&pen, 100, 100, 300, 100); // Joining lines GraphicsPath path; Pen penJoin(Color(255, 0, 0, 255), 8); path.StartFigure(); path.AddLine(Point(50, 200), Point(100, 200)); path.AddLine(Point(100, 200), Point(100, 250)); penJoin.SetLineJoin(LineJoinMiter); // LineJoin: Bevel, Round, MiterClipped graphics.DrawPath(&penJoin, &path); // 虚线 pen.SetDashStyle(DashStyleDash); // DashStyle: Solid, Dot, DashDot, DashDotDot, Custom pen.SetWidth(1); graphics.DrawRectangle(&pen, 300, 200, 400, 500); REAL dashValues[4] = {5, 2, 15, 4}; pen.SetDashPattern(dashValues, 4); pen.SetWidth(5); graphics.DrawLine(&pen, Point(250, 60), Point(300, 220)); //线条填充 Image image(L"Logo1.gif"); TextureBrush tBrush(&image); Pen texturedPen(&tBrush, 30); graphics.DrawImage(&image, 310, 300, image.GetWidth(), image.GetHeight()); graphics.DrawEllipse(&texturedPen, 210, 20, 200, 100); ////////////////////////////////////////////////////////////////////////// // GraphicsPath.AddArc(); path.CloseFigure(); path.StartFigure(); path.AddArc(100, 200, 100, 100, 0.0, 360.0); path.AddArc(200, 300, 100, 100, 0.0, 360.0); path.CloseFigure(); graphics.DrawPath(&pen, &path); // GraphicsPath.AddBezier(); pen.SetDashStyle(DashStyleSolid); pen.SetStartCap(LineCapNoAnchor); pen.SetEndCap(LineCapNoAnchor); pen.SetWidth(1); path.AddBezier(Point(300,30), Point(400, 80), Point(420, 300), Point(460,460)); path.CloseFigure(); graphics.DrawPath(&pen, &path); // GraphicsPath.AddBeziers() Point pts[] = {Point(50,50), Point(60,20), Point(70,100), Point(80,50), Point(120,40), Point(150,80), Point(170,30)}; path.AddBeziers(pts, 7); path.CloseFigure(); graphics.DrawPath(&pen, &path); PointF ptsf[] = {PointF(150.0f,50.0f), PointF(160.0f,20.0f), PointF(170.0f,100.0f), PointF(180.0f,50.0f), PointF(220.0f,40.0f), PointF(250.0f,80.0f), PointF(270.0f,30.0f)}; path.AddBeziers(ptsf, 7); path.CloseFigure(); graphics.DrawPath(&pen, &path); // GraphicsPath.AddClosedCurve(); PointF ptscf[] = {PointF(450.0f,150.0f), PointF(460.0f,120.0f), PointF(470.0f,100.0f), PointF(480.0f,150.0f)}; path.AddClosedCurve(ptscf, 4, 1.4f); path.CloseFigure(); graphics.DrawPath(&pen, &path); // GraphicsPath.AddCurve(); PointF ptc[] = {PointF(450.0f, 50.0f), PointF(470.0f, 80.0f), PointF(400.0f, 100.0f), PointF(430.0f, 40.0f), PointF(450.0f, 90.0f), PointF(480.0f, 30.0f), PointF(410.0f, 120.0f), PointF(440.0f, 80.0f)}; path.AddCurve( ptc, 8, // There are eight points in the array. 2, // Start at the point with index 2. 4, // Four segments. End at the point with index 6. 1.0f); path.CloseFigure(); graphics.DrawPath(&pen, &path); //GraphicsPath.AddPie(); path.AddPie(300.0f, 300.0f, 400.0f, 400.0f, 0.0f, 270.0f); path.CloseFigure(); graphics.DrawPath(&pen, &path); }
至于屏幕保护程序,只是对于任何键盘和鼠标消息都退出的程序而已...

TOP

[求助]用C语言编写屏幕保护程序

我觉得屏保可以编写一个图片播放器,读取指定目录中的图片即可。应该简单许多。
我以前在此坛发过此类贴子。

TOP

[求助]用C语言编写屏幕保护程序

谢谢小默~!先看看。

TOP

返回列表 回复 发帖