⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.cpp

📁 CSP settings tools. 用户创建XML完成手机相关配置。通过这个程序能够测试CSP的功能。
💻 CPP
字号:
#include "Util.h"
#include "stdlib.h"
#include "aygshell.h"
#ifdef _cplusplus
extern "C" {
#endif

DWORD GetSipHieght(RECT rcCtl)
{
	if(!IsThePlatform(POCKETPC))
		return 0;
	SIPINFO si={0};
	DWORD top = 0;
	si.cbSize = sizeof(SIPINFO);
	if(!SipGetInfo(&si))
		return top;
	if(si.fdwFlags &SIPF_ON)
	{
		top = si.rcSipRect.bottom - si.rcSipRect.top;
		rcCtl.bottom +=IndicatorHieght();
		rcCtl.top +=IndicatorHieght();
		if(si.rcSipRect.bottom <= rcCtl.top)
			return 0;

	}
	return top;
	//return 0;
}
BOOL ShowSIPAssociatedWithControl(HWND hWnd, UINT ID )
{
	SIPINFO si={0};
	RECT r,rcClient;
	ASSERT(hWnd != NULL);
	ASSERT(ID > 0);
	::GetClientRect(hWnd, &rcClient);
	si.cbSize = sizeof(SIPINFO);
	if(!SipGetInfo(&si))
		return FALSE;
	
	GetWindowRect(GetDlgItem(hWnd,ID),&r);
	if(r.bottom + si.rcSipRect.bottom - si.rcSipRect.top > rcClient.bottom && 
		r.top > si.rcSipRect.bottom - si.rcSipRect.top -IndicatorHieght())
	{
		si.rcSipRect.top = r.top - (si.rcSipRect.bottom -si.rcSipRect.top);
		si.rcSipRect.bottom = r.top;

	}
	else
	{
		DWORD h=  si.rcSipRect.bottom - si.rcSipRect.top;
		si.rcSipRect.bottom = si.rcVisibleDesktop.bottom;
		si.rcSipRect.top = si.rcSipRect.bottom -h;
	}
	si.fdwFlags |=SIPF_ON;
	if(!SipSetInfo(&si))
		return FALSE;
	return TRUE;

}
BOOL IsThePlatform(const wchar_t *type)
{
	wchar_t buf[64];
	SystemParametersInfo(SPI_GETPLATFORMTYPE,66,buf,TRUE);
	return (wcscmp(type,buf)==0)? TRUE: FALSE;
}

DWORD IndicatorHieght()
{
	RECT rc= {0};
	SystemParametersInfo(SPI_GETWORKAREA,sizeof(RECT),&rc,TRUE);
	return rc.top;
}
/**
 * Add notification icon
 *
 * \param hWnd[in] Handle to the window to receive command choices and dismiss. 
 *
 * \return TRUE if succeed, otherwise, FALSE is returned
 */ 
BOOL AddNotificationIcon(HWND hWnd,GUID clsid, UINT NOTIFY_ID, HINSTANCE hInst,UINT ICID, wchar_t * msg)
{
	SHNOTIFICATIONDATA ntData;
	memset(&ntData, 0, sizeof(SHNOTIFICATIONDATA));
	ntData.cbStruct = sizeof(SHNOTIFICATIONDATA);
	ntData.dwID     = NOTIFY_ID;
	ntData.npPriority = SHNP_INFORM;
	ntData.csDuration = 3;
	ntData.hicon      = (HICON)LoadImage (hInst, MAKEINTRESOURCE (ICID), IMAGE_ICON, 16,16,0);
	ntData.grfFlags   = SHNF_FORCEMESSAGE;
	ntData.clsid      = clsid;
	ntData.hwndSink   = hWnd;
	ntData.pszHTML    = L"<html><body><p>Device management operation is in progress. Do you want to cancel it? Press 'OK' button to cancel it.</p><p align right><input type=button name='cmd:10' value='OK'>&nbsp;<input type=button name='cmd:2' value='Cancel'></p></body></html>";
	ntData.pszTitle   = L"XMLConfig";
	ntData.lParam     = 0;
	//ntData.skm
	//ntData.
	//BOOL flag = ERROR_SUCCESS == SHNotificationAdd(&ntData);
	//int nErrNo = ::GetLastError();
	//return flag;

	return ERROR_SUCCESS == SHNotificationAdd(&ntData);
}

/**
 * Delete the notification ICON
 *
 * \param void
 *
 * \return void
 */
BOOL DeleteNotificationIcon(GUID in_clsid,UINT nid)
{
	SHNOTIFICATIONDATA shnd;
	CLSID clsid = in_clsid;
	LRESULT result;
	DWORD dwID = nid;

	memset(&shnd, 0, sizeof(shnd));
	shnd.cbStruct = sizeof(SHNOTIFICATIONDATA);
	result = SHNotificationGetData(&clsid,dwID,&shnd);
	if (ERROR_SUCCESS == result)
	{
		return ERROR_SUCCESS  == SHNotificationRemove(&clsid,dwID);
	}

	return FALSE;
}
#ifdef _cplusplus
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -