📄 interface.h
字号:
#ifndef INTERFACE_H
#define INTERFACE_H
#include<windows.h>
#include<string.h>
#include"set.h"
#define DOCK_LEFT 1
#define DOCK_RIGHT 2
#define DOCK_TOP 4
#define DOCK_BOTTOM 8
#define NODOCK 16
#define DOCK_HIDE 20
#define DOCK_POPUP 21
#define WM_POPIN 1000
#define WM_PARENTPOSCHANGED 1001
#define WM_DWPOSCHANGED 1002
#define STATE_IN 1
#define STATE_OUT 2
class WndInfo
{
public:
UINT DockStyle;
int DockType;
bool AutoHide;
char Name[256];
WNDPROC lpfnWndProc;
int State;
HWND hWnd;
int X,Y;
int Width,Height;
bool AdjustFlag;
int GetState(){return State;}
WndInfo(HWND hwnd,char *name,
int x,int y,int width,int height,int docktype,UINT dockstyle,
WNDPROC lpfnwndproc,bool af)
{
AutoHide=true;
hWnd=hwnd;
strncpy(Name,name,256);
X=x;Y=y;
Width=width;Height=height;
AdjustFlag=af;
switch(docktype)
{
case DOCK_LEFT:
DockType=DOCK_LEFT;
break;
case DOCK_RIGHT:
DockType=DOCK_RIGHT;
break;
case DOCK_BOTTOM:
DockType=DOCK_BOTTOM;
break;
case DOCK_TOP:
DockType=DOCK_TOP;
break;
}
DockStyle=dockstyle;
lpfnWndProc=lpfnwndproc;
State=DOCK_HIDE;
}
bool operator==(const WndInfo& w)
{
if(hWnd==w.hWnd)
return true;
return false;
}
int GetNameLength(){return strlen(Name)*8+20;}
char *GetName(){return Name;}
};
class DockCtrl
{
static bool IsClassRegistered;
static HMENU hMenu;
protected:
set<WndInfo> Container;
HWND Parent;
int State;
int Focus;
bool DWLButtonFlag;
int DWLx,DWLy;
int Prevx,Prevy;
int Left,Top,Bottom,Right;
int YPos;
void DrawDragBorder(HWND hwnd,int x,int y);
void DrawXorFrame( RECT rect, BOOL fDocked);
WndInfo* GetWI(HWND hwnd);
WndInfo* GetWI(char *wndname);
int GetCtrlWndLength();
void SetWindowState(HWND hwnd);
bool GetBRect(HWND hwnd,int x,int y,RECT &Brect);
void GetClientRect(RECT &rect)
{
::GetClientRect(Parent,&rect);
rect.left-=Left;
rect.right-=Right;
rect.top-=Top;
rect.bottom-=Bottom;
}
void OnDWDraw(HDC hdc,HWND hwnd);
void OnDWLButtonDown(HWND hwnd,WPARAM wParam,LPARAM lParam);
void OnDWLButtonUp(HWND hwnd,WPARAM wParam,LPARAM lParam);
void OnDWMouseMove(HWND hwnd,WPARAM wParam,LPARAM lParam);
void OnLButtonDown(HWND hwnd,WPARAM wParam,LPARAM lParam);
void OnMouseMove(HWND hwnd,WPARAM wParam,LPARAM lParam);
void OnDraw(HDC hdc);
LRESULT WndProc(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
LRESULT CtrlWndProc(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
//消息处理函数管理函数
static LRESULT CALLBACK CtrlWindowProc(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
bool RegisterClass(HINSTANCE);
public:
HWND hWnd;
DockCtrl(){State=STATE_OUT;Focus=-1;DWLButtonFlag=false;}
virtual ~DockCtrl(){}
bool CreateEx(HINSTANCE hInst,HWND parent,RECT prect,int ypos);
bool Add(HINSTANCE hInst,char* name,
int x,int y,int width,int height,UINT DockType,UINT DockStyle,
WNDPROC lpfnwndproc,bool af);
void PopIn(HWND hwnd);
void PopUp(HWND hwnd);
void PopUp(char *wndname)
{
WndInfo* WI;
WI=GetWI(wndname);
if(WI!=NULL)
PopUp(WI->hWnd);
}
void Delete(HWND hwnd);
void GetDisRect(HWND hwnd);
void AdjustWnd();
bool CreateEx();
void GetRect(RECT &rect);
void GetWndRect(HWND hwnd,RECT *rect)
{
WndInfo *WI;
WI=GetWI(hwnd);
rect->left=2;
rect->right=WI->Width-20;
rect->top=30;
rect->bottom=WI->Height-10;
}
BOOL ShowWindow(int nCmdShow) const
{
return ::ShowWindow(hWnd, nCmdShow);
}
//更新窗口
BOOL UpdateWindow(void) const
{
return ::UpdateWindow(hWnd);
}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -