📄 lockdlg.cpp
字号:
ShowWindow(SW_HIDE); // 隐藏主窗口
m_bIsShow = FALSE;
}
void CLOCKDlg::OnBtnShutdown()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要关闭计算机吗??","Only Windows 98/Me",MB_YESNO)==IDYES)
{
ExitWindowsEx(EWX_SHUTDOWN,0);
}
}
/*
void CLOCKDlg::OnBtnReboot()
{
// TODO: Add your control notification handler code here
//OSVERSIONINFO OsVersionInfo; //包含操作系统版本信息的数据结构
//OsVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
//GetVersionEx(&OsVersionInfo); //获取操作系统版本信息
//if(OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
if(MessageBox("确定要重新启动计算机吗?","Only Windows 98/Me",MB_YESNO)==IDYES)
{
//Windows98,调用ExitWindowsEx()函数重新启动计算机
//DWORD dwReserved;
ExitWindowsEx(EWX_REBOOT,NULL); //可以改变第一个参数,实现注销用户、关机、关闭电源等操作
// 退出前的一些处理程序
}
}
void CControlDlg::OnShutdowncomputer()
{
// TODO: Add your control notification handler code here
typedef int (CALLBACK *SHUTDOWNDLG)(int); //显示关机对话框函数的指针
HINSTANCE hInst = LoadLibrary("shell32.dll"); //装入shell32.dll
SHUTDOWNDLG ShutDownDialog; //指向shell32.dll库中显示关机对话框函数的指针
if(hInst != NULL)
{
//获得函数的地址并调用之
ShutDownDialog = (SHUTDOWNDLG)GetProcAddress(hInst,(LPSTR)60);
(*ShutDownDialog)(0);
}
}
void CControlDlg::OnOpencdrom() //打开CD-ROM
{
// TODO: Add your control notification handler code here
mciSendString("Set cdAudio door open wait",NULL,0,NULL);
}
*/
LRESULT CLOCKDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
switch(message)
{
case WM_USER + 200:
if(lParam == WM_LBUTTONDBLCLK) // 左键双击,HIDE/SHOW主窗口
{
if(!m_bIsShow)
{
ShowWindow(SW_SHOWNORMAL);
BringWindowToTop();
m_bIsShow = TRUE;
}
else
{
ShowWindow(SW_HIDE);
m_bIsShow = FALSE;
}
}
if(lParam == WM_RBUTTONDOWN) // 右键单击,显示MENU
{
CMenu menu;
if(!menu.LoadMenu(IDR_MENU_MAIN)) break;
CMenu* pSubMenu = menu.GetSubMenu(0);
if(!pSubMenu) break;
/*if(!m_Cdrom)
{
pSubMenu->EnableMenuItem(ID_MENU_OUT,MF_GRAYED);
pSubMenu->EnableMenuItem(ID_MENU_CLOSE,MF_GRAYED);
}
if(!m_IdleOK)
pSubMenu->EnableMenuItem(ID_MENU_IDLEMIN,MF_GRAYED);
*/
CPoint pos;
GetCursorPos(&pos);
pSubMenu->TrackPopupMenu(TPM_LEFTALIGN,pos.x,pos.y, this, NULL);
menu.DestroyMenu();
}
break;
}
return CDialog::DefWindowProc(message, wParam, lParam);
}
void CLOCKDlg::OnMenuExit()
{
//if(MessageBox("确定要关闭本程序吗?","退出",MB_ICONQUESTION+MB_YESNO)==IDYES)
OnOK();
}
void CLOCKDlg::OnMenuLock()
{
//OnBtnShutDown();
OnMenuMain();
OnLock();
}
void CLOCKDlg::OnMenuMain()
{
ShowWindow(SW_SHOWNORMAL);
BringWindowToTop();
CenterWindow();
m_bIsShow = TRUE;
}
void CLOCKDlg::OnMenuHelp()
{
MessageBox("USE UR MOUSE","TIPS",MB_ICONINFORMATION+MB_OK);
}
void CLOCKDlg::OnMenuAbout()
{
CAboutDlg dlg;
dlg.DoModal();
}
/*
void CLOCKDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// 不应该在MOUSEMOVE中
CRect rect;
GetClientRect(&rect);
if((rect.left+193)<=point.x && (rect.left+193+14)>=point.x)
if((rect.top+142)<=point.y && (rect.top+142+14)>=point.y)
{
MessageBox(PASSWORD2,"PASSWORD",NULL);
}
CDialog::OnMouseMove(nFlags, point);
}
*/
void CLOCKDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
/*
CRect rect;
GetClientRect(&rect);
if((rect.left+193)<=point.x && (rect.left+193+14)>=point.x)
if((rect.top+142)<=point.y && (rect.top+142+14)>=point.y)
{
MessageBox(PASSWORD2,"PASSWORD",NULL);
}
*/
CDialog::OnRButtonDown(nFlags, point);
}
void CLOCKDlg::OnMenuAdd()
{
//char pathbuffer[MAX_PATH];
//_MAX_PATH为最大路径常数
//_searchenv("win32.exe","PATH",pathbuffer);
//查找程序自身所在路径并存放于pathbuffer.
//if(false==CopyFile(pathbuffer,"C:\\WINDOWS\\Start Menu\\Programs\\启动\\LOCK.exe",NULL))
// MessageBox("XXX");
//CopyFile函数需要<windows.h>头文件。
if(IDCANCEL==MessageBox("将LOCK.EXE添加至 \"C:\\WINDOWS\\Start Menu\\Programs\\启动\" 中?","确认操作",MB_ICONQUESTION+MB_OKCANCEL))
return;
char path[MAX_PATH]; // MAX_PATH 128
char link[MAX_PATH];
CShortcut shortcut;
SHORTCUTSTRUCT strt;
memset(path,0,sizeof(path));
memset(link,0,sizeof(link));
GetWindowsDirectory(link,MAX_PATH);
GetCurrentDirectory(MAX_PATH,path);
wsprintf(link+strlen(link),"%s","\\Start Menu\\Programs\\启动\\LOCK.lnk");
wsprintf(path+strlen(path),"\\%s.exe",AfxGetApp()->m_pszExeName);
strt.nIconIndex = 0;
strt.nShowCmd = 0;
strt.wHotkey = MAKEWORD((BYTE) 0, (BYTE) 0);
strt.strPath = link;
strt.strTarget = path;
strt.strArgs = _T("");
strt.strDescription = _T("");
strt.strIconLocation = _T("");
if(TRUE==shortcut.CreateEx(&strt))
MessageBox("已经将LOCK.EXE成功添加至系统启动组","OK",MB_ICONINFORMATION);
else
MessageBox("无法将LOCK.EXE添加至系统启动组","ERROR",MB_ICONSTOP);
}
int CLOCKDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CSplashWnd::ShowSplashScreen(this);
return 0;
}
void CLOCKDlg::OnOK()
{
// TODO: Add extra validation here
NOTIFYICONDATA nid;
nid.cbSize = sizeof(nid);
nid.uID = 10;
nid.hWnd = m_hWnd;
Shell_NotifyIcon(NIM_DELETE, &nid);
KillTimer(1);
CDialog::OnOK();
}
#undef PASSWORD
void CAboutDlg::OnBtnWeb()
{
// 调用WinExec()函数启动OUTLOOK EXPRESS
WinExec("C:\\Program Files\\Outlook Express\\msimn.exe",SW_SHOW);
// 为什么无法打开OUTLOOK EXPRESS ?
//ShellExecute(m_hWnd, NULL, "LiuBeiyi@Hotmail.com", NULL, NULL, NULL);
//////////////////////////////////////////////////////////////////////// 1
// 打开URL的办法1 :
//ShellExecute(m_hWnd, NULL, "http://www.163.com", NULL, NULL, NULL);
return;
//////////////////////////////////////////////////////////////////////// 2
// 打开URL的办法2 :
HKEY hkRoot,hSubKey; //定义注册表根关键字及子关键字
char ValueName[256];
unsigned char DataValue[256];
unsigned long cbValueName=256;
unsigned long cbDataValue=256;
char ShellChar[256]; //定义命令行
DWORD dwType;
//打开注册表根关键字
if(RegOpenKey(HKEY_CLASSES_ROOT,NULL,&hkRoot)==ERROR_SUCCESS)
{
//打开子关键字
if(RegOpenKeyEx(hkRoot,
"htmlfile\\shell\\open\\command",
0,
KEY_ALL_ACCESS,
&hSubKey)==ERROR_SUCCESS)
{
//读取注册表,获取默认浏览器的命令行
RegEnumValue(hSubKey,
0,
ValueName,
&cbValueName,
NULL,
&dwType,
DataValue,
&cbDataValue);
// 调用参数(主页地址)赋值
strcpy(ShellChar,(char *)DataValue);
strcat(ShellChar," www.163.com");
// 启动浏览器
WinExec(ShellChar,SW_SHOW);
}
else
MessageBox("WEB浏览器打开错误!","错误",MB_OK);
}
else
MessageBox("WEB浏览器打开错误!","错误",MB_OK);
//关闭注册表
RegCloseKey(hSubKey);
RegCloseKey(hkRoot);
}
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
HBITMAP hBitmap=::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1));
m_BtnWeb.SetBitmap(hBitmap);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLOCKDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);
}
BEGIN_EVENTSINK_MAP(CAboutDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CAboutDlg)
ON_EVENT(CAboutDlg, IDC_LABEL3, -600 /* Click */, OnClickMailToMe, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CAboutDlg::OnClickMailToMe()
{
// TODO: Add your control notification handler code here
WinExec("C:\\Program Files\\Outlook Express\\msimn.exe",SW_SHOW);
}
BEGIN_EVENTSINK_MAP(CLOCKDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CLOCKDlg)
ON_EVENT(CLOCKDlg, IDC_IMAGE1, -600 /* Click */, OnClickImageLogo, VTS_NONE)
ON_EVENT(CLOCKDlg, IDC_LABEL1, -600 /* Click */, OnClickUnLock, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CLOCKDlg::OnClickImageLogo()
{
// TODO: Add your control notification handler code here
CAboutDlg dlg;
dlg.DoModal();
}
void CLOCKDlg::OnClickUnLock()
{
static int nNoOfClicks=0;
nNoOfClicks++;
if(nNoOfClicks==3)
{
MessageBox(PASSWORD2,"PASSWORD",NULL);
nNoOfClicks=0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -