MFC 常用功能属性

//动态库弹出对话框

AFX_MANAGE_STATE(AfxGetStaticModuleState());

 

//获得系统时间

DWORD time_start = ::GetTickCount();
sTimeBegin.Format(_T("%d"), time_start);

SYSTEMTIME st;
GetLocalTime(&st);
pMe->sTimeBegin.Format(_T("%2d:%2d:%2d:%3d"), st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);

 

//通过HWND获得CWnd指针

HWND hWnd = GetSafeHwnd();

CWnd *pWnd = CWnd::FromHandle(hWnd);

 

//窗口拖动

afx_msg LRESULT OnNcHitTest(CPoint point);

LRESULT CDlgSetting::OnNcHitTest(CPoint point)
{
CRect rect;
GetWindowRect(&rect);
CRect rc(0,0,rect.Width()-m_imgCloseUp.GetWidth(),36);
ClientToScreen(&rc);
return rc.PtInRect(point) ? HTCAPTION : CDialog::OnNcHitTest(point);
}

//设置透明窗口

SetWindowLong(GetSafeHwnd(), GWL_EXSTYLE, GetWindowLong(GetSafeHwnd(), GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(0, 60, LWA_ALPHA);

//不占用焦点

SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,0x08000000L|GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE));

//TreePack_auto_file

注册表目标:HKEY_LOCAL_MACHINESOFTWARECLASSES.TP[][treepack_auto_file]

//_T not find

#include <tchar.h>

//strcpy warning

项目->属性->C/C++->Command Line->Additional Options中 添加 _CRT_SECURE_NO_WARNINGS 这个预定义。

//注册为可触摸窗口

RegisterTouchWindow(TRUE,0);

//获取屏幕尺寸

int iScreenWid = GetSystemMetrics(SM_CXSCREEN);
int iScreenHei = GetSystemMetrics(SM_CYSCREEN);
m_fRotateWid = iScreenWid / 1920.0;
m_fRotateHei = iScreenHei / 1080.0;

 

原文地址:https://www.cnblogs.com/waterair/p/6739171.html