KTools

just alpha test……


// KBFilter.cpp : Defines the entry point for the application.

//



#include “stdafx.h”

#include “KBFilter.h”

#define MAX_LOADSTRING 100



// GetDllVersion要用到的一个宏

#define PACKVERSION(major,minor) MAKELONG(minor,major)



#define TRAYICONID 1

#define SWM_TRAYMSG WM_APP



#define SWM_SHOW WM_APP + 1

#define SWM_HIDE WM_APP + 2

#define SWM_EXIT WM_APP + 3

#define SWM_ABOUT WM_APP + 4

#define SWM_KALL WM_APP + 5

#define SWM_KLWIN WM_APP + 6

#define SWM_KRWIN WM_APP + 7

#define SWM_KDOC WM_APP + 8

#define SWM_CALL WM_APP + 9

#define SWM_CSTI WM_APP + 10

#define SWM_CTOG WM_APP + 11

#define SWM_CFIL WM_APP + 12



// Global Variables:

HINSTANCE&nbsphInst;&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// current instance

TCHAR&nbspszTitle[MAX_LOADSTRING];&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// The title bar text

TCHAR&nbspszINI[256];&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// Ini file path

TCHAR&nbspszApp[260];&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// App to launch

HANDLE&nbsphThread;

HHOOK&nbspg_hKeyboardHook;&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// 全局键盘钩子

STICKYKEYS&nbspg_StartupStickyKeys&nbsp=&nbsp{

TOGGLEKEYS&nbspg_StartupToggleKeys&nbsp=&nbsp{

FILTERKEYS&nbspg_StartupFilterKeys&nbsp=&nbsp{

NOTIFYICONDATA&nbspstNID;&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// 托盘图标所要结构



bool&nbspg_bAutoExit;

// 保存几个屏蔽状态的bool变量

bool&nbspg_bLWin;

bool&nbspg_bRWin;

bool&nbspg_bDoc;

bool&nbspg_bSti;

bool&nbspg_bTog;

bool&nbspg_bFil;



// Forward declarations of functions included in this code module:

DWORD&nbsp&nbsp&nbsp&nbspGetDllVersion(LPCTSTR);

LRESULT&nbspCALLBACK&nbsp&nbsp&nbsp&nbspDlgProc(HWND,&nbspUINT,&nbspWPARAM,&nbspLPARAM);

LRESULT&nbspCALLBACK&nbsp&nbsp&nbsp&nbspLowLevelKeyboardProc(int,&nbspWPARAM,&nbspLPARAM);

void&nbsp&nbsp&nbsp&nbspAllowAccessibilityShortcutKeysS(bool);

void&nbsp&nbsp&nbsp&nbspAllowAccessibilityShortcutKeysT(bool);

void&nbsp&nbsp&nbsp&nbspAllowAccessibilityShortcutKeysF(bool);

void&nbsp&nbsp&nbsp&nbspShowContextMenu(HWND);

void&nbsp&nbsp&nbsp&nbspUpdateToolTip();

void&nbsp&nbsp&nbsp&nbspUpdateAccKeys();

void&nbsp&nbsp&nbsp&nbspOnSelectApp(HWND);

void&nbsp&nbsp&nbsp&nbspRunApp(HWND);

VOID&nbspWINAPI&nbspOnMeasureItem(HWND,&nbspLPMEASUREITEMSTRUCT);

VOID&nbspWINAPI&nbspOnDrawItem(HWND,&nbspLPDRAWITEMSTRUCT);



int&nbspAPIENTRY&nbsp_tWinMain(HINSTANCE&nbsphInstance,

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspHINSTANCE&nbsphPrevInstance,

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspLPTSTR&nbsp&nbsp&nbsp&nbsplpCmdLine,

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspint&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspnCmdShow)

{

&nbsp&nbsp&nbsp&nbsp&nbsp// TODO: Place code here.

&nbsp&nbsp&nbsp&nbspMSG&nbspmsg;

&nbsp&nbsp&nbsp&nbsphInst&nbsp=&nbsphInstance;



&nbsp&nbsp&nbsp&nbsp// Initialize global strings

&nbsp&nbsp&nbsp&nbspLoadString(hInstance,&nbspIDS_APP_TITLE,&nbspszTitle,&nbspMAX_LOADSTRING);

&nbsp&nbsp&nbsp&nbsp// 初始化,从INI文件中读取设置

&nbsp&nbsp&nbsp&nbspGetCurrentDirectory(

&nbsp&nbsp&nbsp&nbsplstrcat(szINI,_T(\\Config.ini));

&nbsp&nbsp&nbsp&nbspGetPrivateProfileString(_T(AUTORUN),_T(APP),_T(),szApp,

&nbsp&nbsp&nbsp&nbspg_bAutoExit&nbsp=&nbspGetPrivateProfileInt(_T(AUTORUN),_T(AUTOEXIT),1,szINI)==1?

&nbsp&nbsp&nbsp&nbsp//TCHAR szBuf[20];

&nbsp&nbsp&nbsp&nbsp//RtlZeroMemory(&szBuf,sizeof(szBuf)/sizeof(TCHAR));

&nbsp&nbsp&nbsp&nbspg_bLWin&nbsp=&nbspGetPrivateProfileInt(_T(KEYS),_T(LWIN),1,szINI)==1?

&nbsp&nbsp&nbsp&nbspg_bRWin&nbsp=&nbspGetPrivateProfileInt(_T(KEYS),_T(RWIN),1,szINI)==1?

&nbsp&nbsp&nbsp&nbspg_bDoc&nbsp=&nbspGetPrivateProfileInt(_T(KEYS),_T(DOC),1,szINI)==1?

&nbsp&nbsp&nbsp&nbspg_bFil&nbsp=&nbspGetPrivateProfileInt(_T(ACCS),_T(FIL),1,szINI)==1?

&nbsp&nbsp&nbsp&nbspg_bSti&nbsp=&nbspGetPrivateProfileInt(_T(ACCS),_T(STI),1,szINI)==1?

&nbsp&nbsp&nbsp&nbspg_bTog&nbsp=&nbspGetPrivateProfileInt(_T(ACCS),_T(TOG),1,szINI)==1?



&nbsp&nbsp&nbsp&nbsp// Save the current sticky/toggle/filter key settings so they can be restored them later

&nbsp&nbsp&nbsp&nbspSystemParametersInfo(SPI_GETSTICKYKEYS,

&nbsp&nbsp&nbsp&nbspSystemParametersInfo(SPI_GETTOGGLEKEYS,

&nbsp&nbsp&nbsp&nbspSystemParametersInfo(SPI_GETFILTERKEYS,



&nbsp&nbsp&nbsp&nbsp// Perform application initialization:

&nbsp&nbsp&nbsp&nbspInitCommonControls();

&nbsp&nbsp&nbsp&nbsp// 挂钩键盘

&nbsp&nbsp&nbsp&nbspg_hKeyboardHook&nbsp=&nbspSetWindowsHookEx(WH_KEYBOARD_LL,&nbsp&nbspLowLevelKeyboardProc,&nbspGetModuleHandle(NULL),&nbsp0&nbsp);

&nbsp&nbsp&nbsp&nbspUpdateAccKeys();

&nbsp&nbsp&nbsp&nbsp// 创建对话框但不显示,做接受托盘图标事件和设置用

&nbsp&nbsp&nbsp&nbspHWND&nbsphDlg&nbsp=&nbspCreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOGMAIN),NULL,(DLGPROC)DlgProc);



&nbsp&nbsp&nbsp&nbspZeroMemory(&stNID,

&nbsp&nbsp&nbsp&nbspULONGLONG&nbspullVersion&nbsp=&nbspGetDllVersion(_T(Shell32.dll));



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspstNID.cbSize&nbsp=



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspstNID.cbSize&nbsp=&nbspNOTIFYICONDATA_V2_SIZE;



&nbsp&nbsp&nbsp&nbspstNID.hWnd&nbsp=&nbsphDlg;

&nbsp&nbsp&nbsp&nbspstNID.uID&nbsp=&nbspTRAYICONID;

&nbsp&nbsp&nbsp&nbspstNID.uFlags&nbsp=&nbspNIF_ICON|NIF_MESSAGE|NIF_TIP;

&nbsp&nbsp&nbsp&nbspstNID.hIcon&nbsp=&nbspLoadIcon(hInst,MAKEINTRESOURCE(IDI_KBFILTER));

&nbsp&nbsp&nbsp&nbspstNID.uCallbackMessage&nbsp=&nbspSWM_TRAYMSG;

&nbsp&nbsp&nbsp&nbsp//lstrcpyn(stNID.szTip, _T(“Time flies like an arrow but\n fruit flies like a banana!”), sizeof(stNID.szTip)/sizeof(TCHAR));

&nbsp&nbsp&nbsp&nbspShell_NotifyIcon(NIM_ADD,&stNID);

&nbsp&nbsp&nbsp&nbspUpdateToolTip();

&nbsp&nbsp&nbsp&nbsp//(int)DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOGMAIN),NULL,(DLGPROC)DlgProc);

&nbsp&nbsp&nbsp&nbsp// Main message loop:



&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp//if (!IsDialogMessage(msg.hwnd,&msg))

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp//{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspTranslateMessage(&msg);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspDispatchMessage(&msg);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp//}

&nbsp&nbsp&nbsp&nbsp}

&nbsp&nbsp&nbsp&nbsp// free icon handle如果在消息循环前des的话,后面修改会导致图标消失



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspstNID.hIcon&nbsp=&nbspNULL;

&nbsp&nbsp&nbsp&nbspWritePrivateProfileString(_T(KEYS),_T(LWIN),g_bLWin?_T(1):_T(0),szINI);

&nbsp&nbsp&nbsp&nbspWritePrivateProfileString(_T(KEYS),_T(RWIN),g_bRWin?_T(1):_T(0),szINI);

&nbsp&nbsp&nbsp&nbspWritePrivateProfileString(_T(KEYS),_T(DOC),g_bDoc?_T(1):_T(0),szINI);

&nbsp&nbsp&nbsp&nbspWritePrivateProfileString(_T(ACCS),_T(STI),g_bSti?_T(1):_T(0),szINI);

&nbsp&nbsp&nbsp&nbspWritePrivateProfileString(_T(ACCS),_T(FIL),g_bFil?_T(1):_T(0),szINI);

&nbsp&nbsp&nbsp&nbspWritePrivateProfileString(_T(ACCS),_T(TOG),g_bTog?_T(1):_T(0),szINI);

&nbsp&nbsp&nbsp&nbsp// 还原辅助功能屏蔽

&nbsp&nbsp&nbsp&nbspg_bSti&nbsp=

&nbsp&nbsp&nbsp&nbspg_bTog&nbsp=

&nbsp&nbsp&nbsp&nbspg_bFil&nbsp=

&nbsp&nbsp&nbsp&nbspUpdateAccKeys();

&nbsp&nbsp&nbsp&nbsp// 卸载钩子

&nbsp&nbsp&nbsp&nbspUnhookWindowsHookEx(g_hKeyboardHook);



}



DWORD&nbspGetDllVersion(LPCTSTR&nbsplpszDllName)

{

&nbsp&nbsp&nbsp&nbspHINSTANCE&nbsphinstDll;

&nbsp&nbsp&nbsp&nbspDWORD&nbspdwVersion&nbsp=&nbsp0;



&nbsp&nbsp&nbsp&nbsp/* For security purposes, LoadLibrary should be provided with a

fully-qualified path to the DLL. The lpszDllName variable should be

tested to ensure that it is a fully qualified path before it is used. */

&nbsp&nbsp&nbsp&nbsphinstDll&nbsp=&nbspLoadLibrary(lpszDllName);





&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspDLLGETVERSIONPROC&nbsppDllGetVersion;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsppDllGetVersion&nbsp=&nbsp(DLLGETVERSIONPROC)GetProcAddress(hinstDll,DllGetVersion);



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp/* Because some DLLs might not implement this function, you

must test for it explicitly. Depending on the particular

DLL, the lack of a DllGetVersion function can be a useful

indicator of the version. */





&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspDLLVERSIONINFO&nbspdvi;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspHRESULT&nbsphr;



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspZeroMemory(&dvi,

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspdvi.cbSize&nbsp=



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsphr&nbsp=&nbsp(*pDllGetVersion)(&dvi);





&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspdwVersion&nbsp=&nbspPACKVERSION(dvi.dwMajorVersion,&nbspdvi.dwMinorVersion);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspFreeLibrary(hinstDll);

&nbsp&nbsp&nbsp&nbsp}



}



//

// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)

//

// PURPOSE: Processes messages for the main dialog window.

//

//

LRESULT&nbspCALLBACK&nbspDlgProc(HWND&nbsphDlg,&nbspUINT&nbspmessage,&nbspWPARAM&nbspwParam,&nbspLPARAM&nbsplParam)

{



&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbspcase WM_INITDIALOG:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSetWindowText(hDlg,szTitle);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSendMessage(hDlg,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(IDI_KBFILTER)));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSendMessage(hDlg,WM_SETICON,ICON_SMALL,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(IDI_KBFILTER)));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSetDlgItemText(hDlg,IDC_APP,szApp);



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSendMessage(GetDlgItem(hDlg,IDC_AUTOEXIT),BM_SETCHECK,BST_CHECKED,NULL);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspRunApp(hDlg);



&nbsp&nbsp&nbsp&nbspcase SWM_TRAYMSG:



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspcase WM_LBUTTONDOWN:



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspShowWindow(hDlg,&nbspSW_HIDE);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspShowWindow(hDlg,&nbspSW_RESTORE);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspcase WM_RBUTTONDOWN:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspcase WM_CONTEXTMENU:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspShowContextMenu(hDlg);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}



&nbsp&nbsp&nbsp&nbspcase WM_MEASUREITEM:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspOnMeasureItem(hDlg,&nbsp(LPMEASUREITEMSTRUCT)&nbsplParam);





&nbsp&nbsp&nbsp&nbspcase WM_DRAWITEM:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspOnDrawItem(hDlg,&nbsp(LPDRAWITEMSTRUCT)&nbsplParam);





/*

case WM_MENUCHAR:

//TCHAR chKey = LOWORD(wParam);

return MAKELRESULT(1, MNC_EXECUTE);

break;*/



&nbsp&nbsp&nbsp&nbspcase WM_COMMAND:



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspcase IDC_SELECT:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspOnSelectApp(hDlg);



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspcase IDC_RUNNOW:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspRunApp(hDlg);



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspcase IDOK:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// 为了防止特殊情况还要再get一次

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspGetDlgItemText(hDlg,IDC_APP,szApp,

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspWritePrivateProfileString(_T(AUTORUN),_T(APP),szApp,szINI);



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspg_bAutoExit&nbsp=

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspWritePrivateProfileString(_T(AUTORUN),_T(AUTOEXIT),_T(1),szINI);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspg_bAutoExit&nbsp=

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspWritePrivateProfileString(_T(AUTORUN),_T(AUTOEXIT),_T(0),szINI);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspMessageBox(hDlg,_T(保存成功!),_T(消息),MB_ICONINFORMATION);



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspcase IDCANCEL:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspShowWindow(hDlg,SW_HIDE);



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}



&nbsp&nbsp&nbsp&nbspcase WM_SYSCOMMAND:



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspShowWindow(hDlg,&nbspSW_HIDE);



&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}



&nbsp&nbsp&nbsp&nbspcase WM_CLOSE:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// 关闭设置窗口并不结束程序

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspShowWindow(hDlg,SW_HIDE);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp//DestroyWindow(hDlg);



&nbsp&nbsp&nbsp&nbspcase WM_DESTROY:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspstNID.uFlags&nbsp=&nbsp0;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspShell_NotifyIcon(NIM_DELETE,&stNID);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspPostQuitMessage(0);



&nbsp&nbsp&nbsp&nbsp}



}

VOID&nbspWINAPI&nbspOnMeasureItem(HWND&nbsphwnd,&nbspLPMEASUREITEMSTRUCT&nbsplpmis)

{

&nbsp&nbsp&nbsp&nbsp// 根据文字设定DC长宽

&nbsp&nbsp&nbsp&nbsp//TCHAR szText[0x10];

&nbsp&nbsp&nbsp&nbsp//lstrcpy(szText,(TCHAR*)lpmis->itemData);

&nbsp&nbsp&nbsp&nbspHDC&nbsphdc&nbsp=&nbspGetDC(hwnd);

&nbsp&nbsp&nbsp&nbspSIZE&nbspsize;

&nbsp&nbsp&nbsp&nbspGetTextExtentPoint32(hdc,&nbsp(TCHAR*)lpmis>itemData,lstrlen((TCHAR*)lpmis>itemData),&size);

&nbsp&nbsp&nbsp&nbsp//if(lstrcmp(szText,_T(“-“))==0)



&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsplpmis>itemHeight&nbsp=&nbspsize.cy2;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsplpmis>itemWidth&nbsp=&nbspsize.cx;

&nbsp&nbsp&nbsp&nbsp}



&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsplpmis>itemHeight&nbsp=&nbspsize.cy+6;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsplpmis>itemWidth&nbsp=&nbspsize.cx+5;

&nbsp&nbsp&nbsp&nbsp}

}

VOID&nbspWINAPI&nbspOnDrawItem(HWND&nbsphwnd,&nbspLPDRAWITEMSTRUCT&nbsplpdis)

{

&nbsp&nbsp&nbsp&nbsp// 保存以前的文字前背景色

&nbsp&nbsp&nbsp&nbspCOLORREF&nbspclrPrevText,clrPrevBkgnd;

&nbsp&nbsp&nbsp&nbsp// 处理文字坐标变量

&nbsp&nbsp&nbsp&nbspint&nbspx,y;

&nbsp&nbsp&nbsp&nbsp// Set the appropriate foreground and background colors.



&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// 创建新笔刷,并保存原设置

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspHBRUSH&nbsphbrush,&nbsphbrushOld;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspHPEN&nbsphpen,&nbsphpenOld;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// Create a pen.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsphpen&nbsp=&nbspCreatePen(PS_SOLID,&nbsp1,&nbspRGB(0,110,233));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// Create a brush.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsphbrush&nbsp=&nbspCreateSolidBrush(RGB(200,221,255));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// Select the new pen and brush, and then draw.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsphpenOld&nbsp=&nbsp(HPEN)SelectObject(lpdis>hDC,&nbsphpen);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsphbrushOld&nbsp=&nbsp(HBRUSH)SelectObject(lpdis>hDC,hbrush);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// 画出带边框的矩形

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspRectangle(lpdis>hDC,&nbsplpdis>rcItem.left,lpdis>rcItem.top,lpdis>rcItem.right,lpdis>rcItem.bottom);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// Do not forget to clean up.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSelectObject(lpdis>hDC,&nbsphpenOld);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspDeleteObject(hpen);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSelectObject(lpdis>hDC,&nbsphbrushOld);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspDeleteObject(hbrush);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// 设置文字前背景色

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspclrPrevText&nbsp=&nbspSetTextColor(lpdis>hDC,RGB(0,&nbsp0,&nbsp0));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspclrPrevBkgnd&nbsp=&nbspSetBkColor(lpdis>hDC,RGB(200,221,255));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp//clrPrevText = SetTextColor(lpdis->hDC,GetSysColor(COLOR_MENUTEXT));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp//clrPrevText = SetTextColor(lpdis->hDC,GetSysColor(COLOR_HIGHLIGHTTEXT));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp//clrPrevBkgnd = SetBkColor(lpdis->hDC,GetSysColor(COLOR_HIGHLIGHT));

&nbsp&nbsp&nbsp&nbsp}



&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// draw the left gray part first

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspHBRUSH&nbsphbrush,&nbsphbrushOld;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// Create a brush.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsphbrush&nbsp=&nbspCreateSolidBrush(RGB(236,233,217));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// Select the new pen and brush, and then draw.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsphbrushOld&nbsp=&nbsp(HBRUSH)SelectObject(lpdis>hDC,hbrush);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp__asm

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsppush&nbspesi

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsppush&nbspebx

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspmov&nbspesi,

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsplea&nbspebx,[esi]lpdis.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsppush&nbsp[ebx]RECT.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsppush&nbspebx

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsplpdis>rcItem.right&nbsp=&nbsplpdis>rcItem.left+GetSystemMetrics(SM_CXMENUCHECK)+9;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspFillRect(lpdis>hDC,&lpdis>rcItem,hbrush);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp__asm&nbsppop&nbspebx

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp__asm&nbsppop&nbsp[ebx]RECT.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp__asm&nbsppush&nbsp[ebx]RECT.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp__asm&nbsppush&nbspebx

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsplpdis>rcItem.left&nbsp+=&nbspGetSystemMetrics(SM_CXMENUCHECK)+9;

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspFillRect(lpdis>hDC,&lpdis>rcItem,(HBRUSH)(COLOR_WINDOW+1));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp__asm

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsppop&nbspebx

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsppop&nbsp[ebx]RECT.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsppop&nbspebx

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsppop&nbspesi

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp}

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp// Do not forget to clean up.

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSelectObject(lpdis>hDC,&nbsphbrushOld);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspDeleteObject(hbrush);

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspclrPrevText&nbsp=&nbspSetTextColor(lpdis>hDC,GetSysColor(COLOR_MENUTEXT));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspclrPrevBkgnd&nbsp=&nbspSetBkColor(lpdis>hDC,RGB(255,&nbsp255,&nbsp255));

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp//clrPrevBkgnd = SetBkColor(lpdis->hDC,GetSysColor(COLOR_MENU));

&nbsp&nbsp&nbsp&nbsp}

&nbsp&nbsp&nbsp&nbsp// Determine where to draw and leave space for a check mark.

&nbsp&nbsp&nbsp&nbspx&nbsp=&nbsplpdis>rcItem.left;

&nbsp&nbsp&nbsp&nbspy&nbsp=&nbsplpdis>rcItem.top;

&nbsp&nbsp&nbsp&nbspx&nbsp+=&nbspGetSystemMetrics(SM_CXMENUCHECK)+

文字加密小工具v2

请输入要加密的内容

加密    全选    撤销    关闭

博主友情提示:

如在您的评论中需要提及如QQ号、微信号、电子邮件地址或其他隐私敏感信息,欢迎通过>>博主专用加密工具v2<<加密后发布,原文只有博主可以看到。