Improvement: Add a popup window to show details

This commit is contained in:
yuanyuanxiang
2025-06-15 16:57:32 +08:00
parent 95f808214c
commit 9f47a908d6
7 changed files with 212 additions and 19 deletions

View File

@@ -78,17 +78,20 @@ CMy2015RemoteApp theApp;
// CMy2015RemoteApp <20><>ʼ<EFBFBD><CABC>
std::string GetPwdHash();
BOOL CMy2015RemoteApp::InitInstance()
{
#ifndef _DEBUG
m_Mutex = CreateMutex(NULL, FALSE, "YAMA.EXE");
if (ERROR_ALREADY_EXISTS == GetLastError())
{
CloseHandle(m_Mutex);
m_Mutex = NULL;
return FALSE;
std::string masterHash(skCrypt(MASTER_HASH));
if (GetPwdHash() != masterHash) {
m_Mutex = CreateMutex(NULL, FALSE, "YAMA.EXE");
if (ERROR_ALREADY_EXISTS == GetLastError())
{
CloseHandle(m_Mutex);
m_Mutex = NULL;
return FALSE;
}
}
#endif
SetUnhandledExceptionFilter(&whenbuged);

View File

@@ -44,6 +44,7 @@
#define UM_ICONNOTIFY WM_USER+100
#define TIMER_CHECK 1
#define TIMER_CLOSEWND 2
typedef struct
{
@@ -387,6 +388,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
ON_COMMAND(ID_ONLINE_H264_DESKTOP, &CMy2015RemoteDlg::OnOnlineH264Desktop)
ON_COMMAND(ID_WHAT_IS_THIS, &CMy2015RemoteDlg::OnWhatIsThis)
ON_COMMAND(ID_ONLINE_AUTHORIZE, &CMy2015RemoteDlg::OnOnlineAuthorize)
ON_NOTIFY(NM_CLICK, IDC_ONLINE, &CMy2015RemoteDlg::OnListClick)
END_MESSAGE_MAP()
@@ -518,6 +520,7 @@ VOID CMy2015RemoteDlg::InitControl()
g_Column_Online_Width+=g_Column_Data_Online[i].nWidth;
}
m_CList_Online.ModifyStyle(0, LVS_SHOWSELALWAYS);
m_CList_Online.SetExtendedStyle(style);
for (int i = 0; i < g_Column_Count_Message; ++i)
@@ -572,9 +575,10 @@ VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName
}
LeaveCriticalSection(&m_cs);
CString install = v[6].empty() ? "?" : v[6].c_str(), path = v[4].empty() ? "?" : v[4].c_str();
CString install = v[RES_INSTALL_TIME].empty() ? "?" : v[RES_INSTALL_TIME].c_str();
CString path = v[RES_FILE_PATH].empty() ? "?" : v[RES_FILE_PATH].c_str();
CString data[ONLINELIST_MAX] = { strIP, strAddr, "", strPCName, strOS, strCPU, strVideo, strPing,
ver, install, startTime, v[0].empty() ? "?" : v[0].c_str(), path };
ver, install, startTime, v[RES_CLIENT_TYPE].empty() ? "?" : v[RES_CLIENT_TYPE].c_str(), path };
auto id = CONTEXT_OBJECT::CalculateID(data);
bool modify = false;
CString loc = GetClientMapData(id, MAP_LOCATION);
@@ -586,7 +590,7 @@ VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName
}
}
data[ONLINELIST_LOCATION] = loc;
ContextObject->SetClientInfo(data);
ContextObject->SetClientInfo(data, v);
ContextObject->SetID(id);
EnterCriticalSection(&m_cs);
@@ -947,6 +951,22 @@ void CMy2015RemoteDlg::OnTimer(UINT_PTR nIDEvent)
MessageBox("请及时对当前主控程序授权: 在工具菜单中生成口令!", "提示", MB_ICONWARNING);
}
}
if (nIDEvent == TIMER_CLOSEWND) {
DeletePopupWindow();
}
CDialogEx::OnTimer(nIDEvent);
}
void CMy2015RemoteDlg::DeletePopupWindow() {
if (m_pFloatingTip)
{
if (::IsWindow(m_pFloatingTip->GetSafeHwnd()))
m_pFloatingTip->DestroyWindow();
SAFE_DELETE(m_pFloatingTip);
}
KillTimer(TIMER_CLOSEWND);
}
@@ -1933,7 +1953,7 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
strVideo = m_settings.DetectSoftware ? "" : LoginInfor->bWebCamIsExist ? "" : "";
strAddr.Format("%d", nSocket);
auto v = LoginInfor->ParseReserved(10);
auto v = LoginInfor->ParseReserved(RES_MAX);
AddList(strIP,strAddr,strPCName,strOS,strCPU,strVideo,strPing,LoginInfor->moduleVersion,LoginInfor->szStartTime, v, ContextObject);
delete LoginInfor;
return S_OK;
@@ -2391,6 +2411,20 @@ BOOL CMy2015RemoteDlg::PreTranslateMessage(MSG* pMsg)
return TRUE;
}
if ((pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_RBUTTONDOWN) && m_pFloatingTip)
{
HWND hTipWnd = m_pFloatingTip->GetSafeHwnd();
if (::IsWindow(hTipWnd))
{
CPoint pt(pMsg->pt);
CRect tipRect;
::GetWindowRect(hTipWnd, &tipRect);
if (!tipRect.PtInRect(pt)){
DeletePopupWindow();
}
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}
@@ -2840,3 +2874,60 @@ void CMy2015RemoteDlg::OnOnlineAuthorize()
memcpy(bToken+1, &days, sizeof(days));
SendSelectedCommand(bToken, sizeof(bToken));
}
void CMy2015RemoteDlg::OnListClick(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMITEMACTIVATE pNMItem = (LPNMITEMACTIVATE)pNMHDR;
if (pNMItem->iItem >= 0)
{
// 获取数据
CONTEXT_OBJECT* ctx = (CONTEXT_OBJECT*)m_CList_Online.GetItemData(pNMItem->iItem);
CString res[RES_MAX];
CString startTime = ctx->GetClientData(ONLINELIST_LOGINTIME);
ctx->GetAdditionalData(res);
// 拼接内容
CString strText;
std::string expired = res[RES_EXPIRED_DATE];
expired = expired.empty() ? "" : " Expired on " + expired;
strText.Format(_T("文件路径: %s%s\r\n系统信息: %s 位 %s 核心 %s GB\r\n启动信息: %s %s"),
res[RES_PROGRAM_BITS].IsEmpty() ? "" : res[RES_PROGRAM_BITS] + "", res[RES_FILE_PATH],
res[RES_SYSTEM_BITS], res[RES_SYSTEM_CPU], res[RES_SYSTEM_MEM], startTime, expired.c_str());
// 获取鼠标位置
CPoint pt;
GetCursorPos(&pt);
// 清理旧提示
DeletePopupWindow();
// 创建提示窗口
m_pFloatingTip = new CWnd();
int width = res[RES_FILE_PATH].GetLength() * 10;
width = min(max(width, 360), 800);
CRect rect(pt.x, pt.y, pt.x + width, pt.y + 50); // 宽度、高度
BOOL bOk = m_pFloatingTip->CreateEx(
WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE,
_T("STATIC"),
strText,
WS_POPUP | WS_VISIBLE | WS_BORDER | SS_LEFT | SS_NOTIFY,
rect,
this,
0);
if (bOk)
{
m_pFloatingTip->SetFont(GetFont());
m_pFloatingTip->ShowWindow(SW_SHOW);
SetTimer(TIMER_CLOSEWND, 5000, nullptr);
}
else
{
SAFE_DELETE(m_pFloatingTip);
}
}
*pResult = 0;
}

View File

@@ -171,9 +171,12 @@ public:
VOID MessageHandle(CONTEXT_OBJECT* ContextObject);
VOID SendSelectedCommand(PBYTE szBuffer, ULONG ulLength);
// <20><>ʾ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
CWnd* m_pFloatingTip=nullptr;
CListCtrl m_CList_Online;
CListCtrl m_CList_Message;
void DeletePopupWindow();
CStatusBar m_StatusBar; //״̬<D7B4><CCAC>
CTrueColorToolBar m_ToolBar;
@@ -246,4 +249,5 @@ public:
afx_msg void OnOnlineH264Desktop();
afx_msg void OnWhatIsThis();
afx_msg void OnOnlineAuthorize();
void OnListClick(NMHDR* pNMHDR, LRESULT* pResult);
};

View File

@@ -214,6 +214,7 @@ enum IOType
typedef struct CONTEXT_OBJECT
{
CString sClientInfo[ONLINELIST_MAX];
CString additonalInfo[RES_MAX];
SOCKET sClientSocket;
WSABUF wsaInBuf;
WSABUF wsaOutBuffer;
@@ -245,16 +246,22 @@ typedef struct CONTEXT_OBJECT
for (int i = 0; i < ONLINELIST_MAX; i++) {
sClientInfo[i].Empty();
}
for (int i = 0; i < RES_MAX; i++) {
additonalInfo[i].Empty();
}
CompressMethod = COMPRESS_ZSTD;
Parser.Reset();
bLogin = FALSE;
m_bProxyConnected = FALSE;
}
VOID SetClientInfo(const CString(&s)[ONLINELIST_MAX]){
VOID SetClientInfo(const CString(&s)[ONLINELIST_MAX], const std::vector<std::string>& a = {}) {
for (int i = 0; i < ONLINELIST_MAX; i++)
{
sClientInfo[i] = s[i];
}
for (int i = 0; i < a.size(); i++) {
additonalInfo[i] = a[i].c_str();
}
}
PBYTE GetBuffer(int offset) {
return InDeCompressedBuffer.GetBuffer(offset);
@@ -268,6 +275,12 @@ typedef struct CONTEXT_OBJECT
CString GetClientData(int index) const{
return sClientInfo[index];
}
void GetAdditionalData(CString(&s)[RES_MAX]) const {
for (int i = 0; i < RES_MAX; i++)
{
s[i] = additonalInfo[i];
}
}
void CancelIO() {
SAFE_CANCELIO(sClientSocket);
}