windows编程之文本输出(字体渐变)
来源:互联网 发布:yum缓存目录 编辑:程序博客网 时间:2024/06/07 15:30
代码如下:
#include<windows.h>#include<math.h>#include<stdio.h>const double PI = 3.1415926;LRESULT CALLBACK WndProc( HWND hwnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message parameter LPARAM lParam // second message parameter);int WINAPI WinMain( HINSTANCE hInstance, // handle to current instance HINSTANCE hPrevInstance, // handle to previous instance LPSTR lpCmdLine, // command line int nCmdShow // show state){WNDCLASS wndclass;wndclass.cbClsExtra = 0;wndclass.cbWndExtra = 0;wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);wndclass.hInstance = hInstance;wndclass.lpfnWndProc = WndProc;wndclass.lpszClassName = "我的窗口";wndclass.lpszMenuName = NULL;wndclass.style = CS_HREDRAW | CS_VREDRAW;RegisterClass(&wndclass); //注册窗口类HWND hwnd;hwnd = CreateWindow("我的窗口", "窗口", WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, NULL, NULL, hInstance, NULL);ShowWindow(hwnd, SW_SHOWNORMAL);UpdateWindow(hwnd);MSG Msg;while(GetMessage(&Msg, NULL, 0, 0)){TranslateMessage(&Msg); DispatchMessage(&Msg); }return 0;}LRESULT CALLBACK WndProc( HWND hwnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message parameter LPARAM lParam // second message parameter){HDC hdc;PAINTSTRUCT ps;HFONT hfont;TEXTMETRIC tm;SIZE size;char str[] = "文字渐变练习";int i, nchlen;switch(uMsg){case WM_PAINT:hdc = BeginPaint(hwnd, &ps);hfont = CreateFont(20, 0, 0, 0, FW_HEAVY, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "粗体字");SelectObject(hdc, hfont);GetTextMetrics(hdc, &tm);GetTextExtentPoint32(hdc, str, strlen(str), &size);SetTextColor(hdc, RGB(0, 0, 0));GetTextMetrics(hdc, &tm);TextOut(hdc, 200, 200, str, strlen(str));MoveToEx(hdc, 200, 200, NULL);SetTextColor(hdc, RGB(0, 255, 0));SetBkColor(hdc, RGB(255, 0, 0));nchlen = size.cx / strlen(str);for(i=0; i<strlen(str); i=i+2){TextOut(hdc, 200 + nchlen * i, 200, &str[i], 2);Sleep(800);}EndPaint(hwnd, &ps);DeleteObject(hfont);break;case WM_CLOSE:DestroyWindow(hwnd);break;case WM_DESTROY:PostQuitMessage(0);break;default:return DefWindowProc(hwnd, uMsg, wParam, lParam);}return 0;}
- windows编程之文本输出(字体渐变)
- API之文本和字体函数 (windows 编程)
- windows api之文本和字体函数
- 《Windows程序设计》读书笔记之输出文本
- 【Windows编程】系列第三篇:文本字符输出
- UGUI研究院之Text文本渐变(十一)
- UGUI研究院之Text文本渐变(十一)
- Windows程序设计-文本输出(二)
- Windows程序设计--文本输出
- Windows程序设计-文本输出
- Windows程序设计-文本输出
- Windows文本字体函数 - EnumFonts
- Windows文本字体函数 - GetCharABCWidths
- Windows文本字体函数 - GetTextAlign
- Windows文本字体函数 - SetTextAlign
- Windows文本字体函数 - SetTextColor
- Windows文本字体函数 - TextOut
- windows程序设计:文本和字体
- JAVA视频笔记(day7)
- Spring MVC和Struts2的比较
- linux下C/C++ IDE比较 Code::Blocks还是不错的
- html标签一
- 非常实用的VC中线程使用说明
- windows编程之文本输出(字体渐变)
- 全排列的递归算法(以此加深对递归的理解)
- sem
- 栈,堆,代码区,全局(静态)区 ,常量区
- Java NIO原理和使用
- eclipse没有提示
- Some others
- 安装JVET
- Java IO Stream 总结