• 大小: 1.56MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-03
  • 语言: 其他
  • 标签: 窗口  

资源简介

使用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个文件信息

评论

共有 条评论