资源简介
使用updatelayeredwindow函数制作出漂亮的窗口,本窗口使用自绘加图片实现。(我要设置成不要积分下载的,或者最低积分)
代码片段和文件信息
#include
#include
//本代码用于建立特殊形状窗口
#pragma comment (lib “GdiPlus.lib“)
using namespace Gdiplus;
LRESULT CALLBACK WndProc(HWND hwnd UINT msg WPARAM wParam LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance HINSTANCE hPrevInstance LPSTR szCmdLine int
nCmdShow)
{
TCHAR szAppName[] = TEXT(“Windows程序设计“);
WNDCLASSEX wndClass;
MSG msg;
HWND hwnd;
ULONG_PTR token;
GdiplusStartupInput gin;
wndClass.cbSize = sizeof(WNDCLASSEX);
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.hIconSm = NULL;
wndClass.hInstance = hInstance;
wndClass.lpszClassName = TEXT(“AppTest“);
wndClass.lpszMenuName = NULL;
wndClass.lpfnWndProc = WndProc;
wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_IME | CS_DBLCLKS;
GdiplusStartup(&token &gin NULL);
RegisterClassEx(&wndClass);
hwnd = CreateWindowEx(WS_EX_layerED TEXT(“AppTest“) szAppName WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP/*无边框风格*/
0 0 100 100
NULL NULL hInstance NULL);
//设置本窗口为分层窗口支持透明
//分层窗口没有WM_PAINT消息
ShowWindow(hwnd SW_SHOW);
UpdateWindow(hwnd);
while (GetMessage(&msg NULL 0 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
GdiplusShutdown(token);
return 0;
}
void CreateRoundRectangle(Rect rc int Round GraphicsPath * gp)
{
gp->AddArc(0 0 Round Round 180 90);
gp->AddLine(Round 0 rc.Width - Round 0);
gp->AddArc(rc.Width - Round 0 Round Round 270 90);
gp->AddLine(rc.Width Round rc.Width rc.Height - Round);
gp->AddArc(rc.Width - Round rc.Height - Round Round Round 0 90);
gp->AddLine(rc.Width - Round rc.Height Round rc.Height);
gp->AddArc(0 rc.Height - Round Round Round 90 90);
}
LRESULT CALLBACK WndProc(HWND hwnd UINT msg WPARAM wParam LPARAM lParam)
{
static BOOL ldown;
static POINT TheFirstPoint;
static int cxClient cyClient;
switch (msg)
{
case WM_SIZE:
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
break;
case WM_LBUTTONDOWN:
ldown = TRUE;
SetCapture(hwnd);//这句代码可以进行容错处理谁知道那次window响应速度慢了你不信?‘-_-‘去掉这句代码试一试
TheFirstPoint.x = LOWORD(lParam);
TheFirstPoint.y = HIWORD(lParam);
break;
case WM_LBUTTONUP:
ldown = FALSE;
ReleaseCapture();
break;
case WM_MOUSEMOVE:
if (ldown)
{
POINT pt;
GetCursorPos(&pt);
pt.x -= TheFirstPoint.x;
pt.y -= TheFirstPoint.y;
SetWindowPos(hwnd NULL pt.x pt.y NULL NULL SWP_NOREDRAW |
SWP_NOSIZE | SWP_NOZORDER);
}
break;
case WM_LBUTTONDBLCLK:
DestroyWindow(hwnd);
case WM_CREATE:
{
Image image(TEXT(“bianping-christmas-2014-12.png“));
//加载窗口图形
int iWidth = image.GetWidth();
int iHeight = image.GetHeight();
HDC hdcScreen = GetDC(NULL);
HDC hdcMem = CreateCompatibleDC(hdcScreen);
HBITMAP hBitma
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-06-16 17:59 分层窗口\
目录 0 2015-06-15 16:43 分层窗口\Debug\
文件 5420 2014-12-08 14:34 分层窗口\Debug\bianping-christmas-2014-01.png
文件 44032 2015-06-15 16:45 分层窗口\Debug\窗口01.exe
文件 381388 2015-06-15 16:45 分层窗口\Debug\窗口01.ilk
文件 748544 2015-06-15 16:45 分层窗口\Debug\窗口01.pdb
目录 0 2015-06-15 16:47 分层窗口\Release\
文件 182272 2015-06-16 17:56 分层窗口\Release\窗口01.exe
文件 2796544 2015-06-16 17:56 分层窗口\Release\窗口01.pdb
目录 0 2015-06-16 17:59 分层窗口\窗口01\
文件 970 2015-06-15 07:32 分层窗口\窗口01.sln
文件 22528 2015-06-16 17:59 分层窗口\窗口01.v12.suo
文件 5420 2014-12-08 14:34 分层窗口\窗口01\a.png
文件 6632 2014-12-08 14:34 分层窗口\窗口01\bianping-christmas-2014-02.png
文件 5288 2014-12-08 14:34 分层窗口\窗口01\bianping-christmas-2014-03.png
文件 2713 2014-12-08 14:35 分层窗口\窗口01\bianping-christmas-2014-04.png
文件 6728 2014-12-08 14:35 分层窗口\窗口01\bianping-christmas-2014-05.png
文件 4593 2014-12-08 14:35 分层窗口\窗口01\bianping-christmas-2014-06.png
文件 5980 2014-12-08 14:35 分层窗口\窗口01\bianping-christmas-2014-07.png
文件 5750 2014-12-08 14:35 分层窗口\窗口01\bianping-christmas-2014-08.png
文件 7821 2014-12-08 14:35 分层窗口\窗口01\bianping-christmas-2014-09.png
文件 3029 2014-12-08 14:35 分层窗口\窗口01\bianping-christmas-2014-10.png
文件 4948 2014-12-08 14:35 分层窗口\窗口01\bianping-christmas-2014-11.png
文件 8584 2014-12-08 14:35 分层窗口\窗口01\bianping-christmas-2014-12.png
目录 0 2015-06-15 16:45 分层窗口\窗口01\Debug\
文件 5420 2014-12-08 14:34 分层窗口\窗口01\Debug\bianping-christmas-2014-01.png
文件 486400 2015-06-15 16:45 分层窗口\窗口01\Debug\vc120.idb
文件 315392 2015-06-15 16:45 分层窗口\窗口01\Debug\vc120.pdb
文件 57863 2015-06-15 16:45 分层窗口\窗口01\Debug\源.obj
文件 2171 2015-06-15 16:45 分层窗口\窗口01\Debug\窗口01.log
目录 0 2015-06-15 16:45 分层窗口\窗口01\Debug\窗口01.tlog\
............此处省略22个文件信息
相关资源
- 图像的点运算(包括图像反色,灰度
- OpenCV实现同一窗口显示多幅图片
- 鼠标和键盘钩子Hook,实现对窗口消息
- 1__窗口内第一个三角形.zip
- 数字地形分析ArcGis中的窗口分析
- MDI子窗口管理及子窗口创建
- 网速流量监控 悬浮窗口
- GoldFishProject 游动的金鱼 不规则窗口学
- 滑动窗口协议.zip
- Duilib做的登录窗口
- PyQ5基本窗口控件详解
- 北邮 计算机网络 滑动窗口协议 选择
- 办公室股票行情查看软件,可以调节
- 异形窗口与gif动画带透明背景的实现
- 计算机网络高级软件编程技术第10章
- 鼠标中键关窗口或网页
- d3d方块透视外部透明窗口
- windows 程序设计 高清版
- 模仿QQ登录窗口Qt
- 基于vlc sdk封装的多窗口监视器,播放
-
fr
ameLessWinApiQt无边框窗口调用winAP - 单一窗口 出口报关单整合申报 一键上
- 在子窗口中调用父窗口的成员函数的
- 编写一个Windows应用程序,要求在窗口
- CefSharp模仿浏览器Tab分页,刷新,删除
- (层级窗口与子窗口透明4中方法.zi
- Linux窗口程序设计-Qt4精彩分析 part02
- 用户登录系统+窗口跳转+事件处理
- QT样式(包含:系统托盘,独立标题栏
- DxWnd窗口化工具汉化版合集.part4
评论
共有 条评论