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

📄 mydraw.cpp

📁 wince42 开发的IE, 640X480, xscale平台,没有实现flash插件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	posx += (ICON_SEP+ICON_WIDTH);
	if( (m_status & HM_TONE_ST1) != 0 )
		ImgDrawItem(IDB_HINT41,ty,posx);
	else if( (m_status & HM_TONE_ST2) != 0 )
		ImgDrawItem(IDB_HINT42,ty,posx);
	else if( (m_status & HM_TONE_ST3) != 0 )
		ImgDrawItem(IDB_HINT43,ty,posx);
	else
		ImgDrawItem(IDB_HINT40,ty,posx);
//本日已有闹钟/备忘录今日有内容5
	posx += (ICON_SEP+ICON_WIDTH);
	if( (m_status & HM_CLOCK_ST1) != 0 )
		ImgDrawItem(IDB_HINT51,ty,posx);
	else if( (m_status & HM_CLOCK_ST2) != 0 )
		ImgDrawItem(IDB_HINT52,ty,posx);
	else if( (m_status & HM_CLOCK_ST3) != 0 )
		ImgDrawItem(IDB_HINT53,ty,posx);
	else
		ImgDrawItem(IDB_HINT50,ty,posx);
//版本升级信息6
	posx += (ICON_SEP+ICON_WIDTH);
	if( (m_status & HM_VERSON_ST1) != 0 )
		ImgDrawItem(IDB_HINT61,ty,posx);
	else if( (m_status & HM_VERSON_ST2) != 0 )
		ImgDrawItem(IDB_HINT62,ty,posx);
	else if( (m_status & HM_VERSON_ST3) != 0 )
		ImgDrawItem(IDB_HINT63,ty,posx);
	else
		ImgDrawItem(IDB_HINT60,ty,posx);
//设备损坏情况7
	posx += (ICON_SEP+ICON_WIDTH);
	if( (m_status & HM_DEVICEERR_ST1) != 0 )
		ImgDrawItem(IDB_HINT71,ty,posx);
	else
		ImgDrawItem(IDB_HINT70,ty,posx);
//报警信息8
	posx += (ICON_SEP+ICON_WIDTH);
	if( (m_status & HM_ALARM_ST1) != 0 )
		ImgDrawItem(IDB_HINT81,ty,posx);
	else if( (m_status & HM_ALARM_ST2) != 0 )
		ImgDrawItem(IDB_HINT82,ty,posx);
	else if( (m_status & HM_ALARM_ST3) != 0 )
		ImgDrawItem(IDB_HINT83,ty,posx);
	else if( (m_status & HM_ALARM_ST4) != 0 )
		ImgDrawItem(IDB_HINT84,ty,posx);
	else if( (m_status & HM_ALARM_ST5) != 0 )
		ImgDrawItem(IDB_HINT85,ty,posx);
	else
		ImgDrawItem(IDB_HINT80,ty,posx);
//未读的客服中心回复A
	posx += (ICON_SEP+ICON_WIDTH);
	if( (m_status & HM_SCEINFO_ST1) != 0 )
		ImgDrawItem(IDB_HINTA1,ty,posx);
	else
		ImgDrawItem(IDB_HINTA0,ty,posx);
*/
	return(TRUE);
}
LRESULT CMyDraw::TextOut()
{
	/*
	int len = _tcslen(m_title);
	HFONT hfont,oldfont;
	LOGFONT lf; 
    lf.lfHeight = 16; 
    lf.lfWidth = 0; 
    lf.lfEscapement = 0; 
    lf.lfOrientation = 0; 
    lf.lfWeight = FW_BOLD; 
    lf.lfItalic = 0; 
    lf.lfUnderline = 0; 
    lf.lfStrikeOut = 0; 
    lf.lfCharSet = ANSI_CHARSET; 
    lf.lfOutPrecision = OUT_DEFAULT_PRECIS; 
    lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; 
    lf.lfQuality = DEFAULT_QUALITY; 
    lf.lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; 
	memset(lf.lfFaceName,0,sizeof(lf.lfFaceName));
    //lstrcpy(lf.lfFaceName, fontStyle.lfFaceName); 
    hfont = CreateFontIndirect(&lf); 
    
	oldfont = (HFONT)SelectObject(m_hdc,hfont);
//	SIZE ss;
//	::GetTextExtentPoint(m_hdc,m_title,len,&ss);
	SetTextColor(m_hdc,RGB(255,255,255));
	SetBkMode(m_hdc,TRANSPARENT);
	if( m_dt == OTHER_TOOLBAR )
		DrawText(m_hdc,m_title,len,&m_rct,DT_RIGHT|DT_VCENTER);
	else	
		DrawText(m_hdc,m_title,len,&m_trct,DT_LEFT|DT_VCENTER);
	SelectObject(m_hdc,oldfont);
	DeleteObject(hfont);*/
	if( m_dt == OTHER_TOOLBAR )
		MyTextOut(m_hdc,m_rct,m_title,DT_RIGHT|DT_VCENTER);
	//else	
	//	MyTextOut(m_hdc,m_trct,m_title);
	if( m_dt == MAIN_STATUSBAR )
	{
		DrawTimeString(m_hdc);
		RefreshTemperature(m_hdc);
	}
	return(TRUE);
}
short CMyDraw::GetClickObjID(int xpos,int ypos)
{
	int iRes = -1;
	if( (m_dt & MAIN_TOOLBAR) != 0 )
	{
		int y1 = m_rct.top+(m_rct.bottom-m_rct.top - ICON_WIDTH)/2;
		int y2 = y1+ICON_WIDTH;
		if( ypos >= y1 && ypos <= y2 )
		{
			int x1 = ICON_LEFT_POS;
			int icount = 2;
			if( m_dt == MAIN_TOOLBAR )
				icount = TITILE_ICON_COUNT;	
			for( int i=0;i<icount;i++)
			{
				int x2 = x1+ICON_WIDTH;
				if( xpos >= x1 && xpos <= x2 )
				{
					iRes = i;
					break;
				}				
				if( OTHER_TOOLBAR == m_dt )
					x1 = x2+ICON_SEP*4;
				else
					x1 = x2+ICON_SEP;
			}
		}
	} else if( m_dt == MAIN_STATUSBAR )
	{
		int xpos1 = STATUSBAR_LEFT_POS;
		int xpos2 = xpos1+30;
		int xpos3 = STATUSBAR_LEFT_POS+60;
		int xpos4 = xpos3+30;
		if( xpos >= xpos1 && xpos <= xpos2 )
		{
			iRes = 1;
			//输入法
			int index = GetNoByMsgType(_mtIME);
			if( index > 0 )
				states[index] = !states[index];
		} else if( xpos >= xpos3 && xpos <= xpos4 )
		{
			//音量设置
			int index = GetNoByMsgType(_mtVolumeSet);
			if( index > 0 )
			{
				states[index] = !states[index];
				RunVolumeSet(states[index]);
			}
		} else if( xpos >= xpos2 && xpos <= xpos3 )
		{
			//网络设置
			RunNetWorkSet();
		} 
		else if( xpos >= 10 && xpos <= 40 )
			RunMouseAdjust();
		else if( xpos >= 40 && xpos <= 70 )
		{
			//RunKsdh();//iRes = 2;			
			int index = GetNoByMsgType(_mtNewVedioCall);
			if( index > 0 )
			{
				//printf("here,index=%d,s=%d\n",index,states[index]);
				if( states[index] == 2 )
					RunExe(index);
			}
		}
		RECT rct;
		GetTitleRect(rct);
		if( xpos > rct.left && xpos < rct.right )
		{
			////////
			RunNewsLink();
		}
		GetTempRect(rct);
		if( xpos > rct.left && xpos < rct.right )
		{
			//RunSystemTempSet();
		}
	}
	if( m_dt == MAIN_TOOLBAR )
	{		
		//printf("iRes=%d\n",iRes);
		if( iRes >= 0 && iRes < TITILE_ICON_COUNT-1 )	//
		{
			if( states[iRes] )
			{
				RunExe(iRes);
			} else
			{
				//::MessageBox(NULL,L"该栏目无信息!",L"提示",0);
			}
		}
	}
	return iRes;
}
void CMyDraw::GetTitleRect(RECT& rc)
{
	//rc = m_rct;
	rc.left = 76;
	rc.right = 418;
	rc.top = 8;
	rc.bottom = 26;
}
void CMyDraw::MyTextOut(HDC hdc,RECT rc,LPTSTR bText,DWORD style,COLORREF clr)
{	
	HFONT hfont,oldfont;
	LOGFONT lf; 
    lf.lfHeight = 16; 
    lf.lfWidth = 0; 
    lf.lfEscapement = 0; 
    lf.lfOrientation = 0; 
    lf.lfWeight = FW_BOLD; 
    lf.lfItalic = 0; 
    lf.lfUnderline = 0; 
    lf.lfStrikeOut = 0; 
    lf.lfCharSet = ANSI_CHARSET; 
    lf.lfOutPrecision = OUT_DEFAULT_PRECIS; 
    lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; 
    lf.lfQuality = DEFAULT_QUALITY; 
    lf.lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; 
	memset(lf.lfFaceName,0,sizeof(lf.lfFaceName));
    //lstrcpy(lf.lfFaceName, fontStyle.lfFaceName); 
    hfont = CreateFontIndirect(&lf); 
    
	oldfont = (HFONT)SelectObject(hdc,hfont);
//	SIZE ss;
//	::GetTextExtentPoint(m_hdc,m_title,len,&ss);
	//SetTextColor(hdc,RGB(255,255,255));
	SetTextColor(hdc,clr);
	SetBkMode(hdc,TRANSPARENT);
	int len = _tcslen(bText);
	DrawText(hdc,bText,len,&rc,style);//DT_LEFT|DT_VCENTER);
	SelectObject(hdc,oldfont);
	DeleteObject(hfont);
}
void CMyDraw::SetRectColor(COLORREF clr,HDC hdc,RECT rc)
{
	SetRectColor(clr,clr,hdc,rc);
}
void CMyDraw::SetRectColor(COLORREF clr,COLORREF Penclr,HDC hdc,RECT rc,int PenWidth)
{
	HPEN hpen,holdpen;
	hpen = CreatePen(PS_SOLID,PenWidth,Penclr);	
	holdpen = (HPEN)SelectObject(hdc,hpen);

	HBRUSH hbrush,holdbrush;
	hbrush = CreateSolidBrush(clr);
	holdbrush = (HBRUSH)SelectObject(hdc,hbrush);
	Rectangle(hdc,rc.left,rc.top,rc.right,rc.bottom);
	SelectObject(hdc,holdbrush);
	DeleteObject(hbrush);
	SelectObject(hdc,holdpen);
	DeleteObject(hpen);
}
void CMyDraw::RunExe(int index)
{
	if( index < 0 || index > ICONDATA_COUNT )
		return;
	if( states[index] )
	{
		if( _mtNewVedio == iconData1[index] || _mtNewVedioCall == iconData1[index] )
			if( states[index] != 2 )
				return;
		SHELLEXECUTEINFO sei;
		ZeroMemory(&sei, sizeof(sei));
		sei.cbSize = sizeof(sei);
		sei.fMask = SEE_MASK_NOCLOSEPROCESS;
		sei.lpVerb = _T("open");
		sei.nShow = SW_SHOW;
			//wchar_t path[200];
			wchar_t* path;
			wchar_t cmdline[200]={0};
			if( _mtNewVoiceMemo == iconData1[index] )
			{
				path = GetExeFilePathW(L"yyxx.exe");
				swprintf(cmdline,L"D");
			}else if( (_mtNewEmail <= iconData1[index] && _mtNewCommityReply >= iconData1[index])
				||(_mtNewClientCenterReply == iconData1[index]) )
			{
				CString szTitle=_T("电子邮件");
				//1	电子邮件
				//5	社区服务/小区公告	
				//7	社区服务/预约服务	
				//2	客服中心
				int ncmd = 1;
				if(_mtNewBulletion == iconData1[index])
				{
					ncmd = 5;szTitle=_T("小区公告");
				}
				if(_mtNewCommityReply == iconData1[index])
				{
					ncmd = 7;szTitle=_T("预约服务");
				}
				if(_mtNewClientCenterReply == iconData1[index])
				{
					ncmd = 2;szTitle=_T("客服中心");
				}
				path = GetExeFilePathW(L"myie.exe");
				swprintf(cmdline,L"%d %s",ncmd,szTitle);
			}
			else
			{
				path = GetExeFilePathW(L"tsxx.exe");
				swprintf(cmdline,L"%d",(int)iconData1[index]);
			}
			//rc = CreateProcess(path,NULL,NULL,NULL,false,0,NULL,NULL,NULL,&pi);			
			sei.lpFile = path;
			sei.lpParameters = cmdline;
		ShellExecuteEx(&sei);
	}
}
void CMyDraw::RunKsdh()
{
		SHELLEXECUTEINFO sei;
		ZeroMemory(&sei, sizeof(sei));
		sei.cbSize = sizeof(sei);
		sei.fMask = SEE_MASK_NOCLOSEPROCESS;
		sei.lpVerb = _T("open");
		sei.nShow = SW_SHOW;
			//wchar_t path[200];
			wchar_t* path = GetExeFilePathW(L"ksdh.exe");
			wchar_t cmdline[200]={0};
			swprintf(cmdline,L"T");
			//rc = CreateProcess(path,NULL,NULL,NULL,false,0,NULL,NULL,NULL,&pi);			
			sei.lpFile = path;
			sei.lpParameters = cmdline;
		ShellExecuteEx(&sei);
}
void CMyDraw::RunKsdj()
{
	static DWORD dwTime=0;
	if( (GetTickCount() - dwTime) < 30000 )		//30sec
	{		
		return;
	}
	dwTime = GetTickCount();
	SHELLEXECUTEINFO sei;
	ZeroMemory(&sei, sizeof(sei));
	sei.cbSize = sizeof(sei);
	sei.fMask = SEE_MASK_NOCLOSEPROCESS;
	sei.lpVerb = _T("open");
	sei.nShow = SW_SHOW;
//	wchar_t path[200];
	wchar_t* path = GetExeFilePathW(L"ksdh.exe");
	wchar_t cmdline[200]={0};
	swprintf(cmdline,L"D");
	sei.lpFile = path;
	sei.lpParameters = cmdline;
	ShellExecuteEx(&sei);
}
void CMyDraw::RunNewsLink()
{
		SHELLEXECUTEINFO sei;
		ZeroMemory(&sei, sizeof(sei));
		sei.cbSize = sizeof(sei);
		sei.fMask = SEE_MASK_NOCLOSEPROCESS;
		sei.lpVerb = _T("open");
		sei.nShow = SW_SHOW;
			//wchar_t path[200];
			wchar_t* path = GetExeFilePathW(L"myie.exe");
			wchar_t cmdline[200]={0};
			swprintf(cmdline,L"21 今日新闻");
			//rc = CreateProcess(path,NULL,NULL,NULL,false,0,NULL,NULL,NULL,&pi);			
			sei.lpFile = path;
			sei.lpParameters = cmdline;
		ShellExecuteEx(&sei);
}
/*
void CMyDraw::RunSystemTempSet()
{
		SHELLEXECUTEINFO sei;
		ZeroMemory(&sei, sizeof(sei));
		sei.cbSize = sizeof(sei);
		sei.fMask = SEE_MASK_NOCLOSEPROCESS;
		sei.lpVerb = _T("open");
		sei.nShow = SW_SHOW;
			//wchar_t path[200];
			wchar_t* path = GetExeFilePathW(L"tsxx.exe");
			wchar_t cmdline[200]={0};
			swprintf(cmdline,L"82 0");
			//rc = CreateProcess(path,NULL,NULL,NULL,false,0,NULL,NULL,NULL,&pi);			
			sei.lpFile = path;
			sei.lpParameters = cmdline;
		ShellExecuteEx(&sei);
}
*/
void CMyDraw::RunUpText()
{
	if( m_hwnd == NULL )
		return;
	HDC hdc = GetDC(m_hwnd);
	RECT rct;
	GetTitleRect(rct);
	//SetRectColor(RGB(0,0,0),hdc,rct);
	int ww = rct.right - rct.left;
	rct.left = rct.right - m_pos;
	MyTextOut(hdc,rct,m_title,DT_LEFT|DT_VCENTER,RGB(0,0,0));	
	if( m_pos + 8 > ww )
	{
		int ttt = wcslen(m_title);
		if( m_iRunTextOff >= ttt )
		{
			m_pos = 0;
			m_iRunTextOff = 0;

		}else
			m_iRunTextOff++;
	}else
		m_pos += 8;
	rct.left = rct.right - m_pos;
	//if( rct.right - rct.left > 
	//SetRectColor(RGB(0,0,0),hdc,rct);
	wchar_t* pp = m_title+m_iRunTextOff;
	MyTextOut(hdc,rct,pp);
	ReleaseDC(m_hwnd,hdc);	
}
void CMyDraw::ShowOneLineText(char* szInfo,char* szLastInfo)
{
	if( m_hwnd == NULL )
		return;
	HDC hdc = GetDC(m_hwnd);
	ShowOneLineText(hdc,szInfo,szLastInfo);
	ReleaseDC(m_hwnd,hdc);	
}
void CMyDraw::ShowOneLineText(HDC hdc,char* szInfo,char* szLastInfo)
{
	wchar_t szTemp[200]={0};
	RECT rct;
	GetTitleRect(rct);
	if( szLastInfo )
	{
		MultiByteToWideChar(CP_ACP, 0, szLastInfo,strlen(szLastInfo),
			szTemp, sizeof(szTemp));
		MyTextOut(hdc,rct,szTemp,DT_LEFT|DT_VCENTER,RGB(0,0,0));	
		memset(szTemp,0,sizeof(szTemp));
	}
	MultiByteToWideChar(CP_ACP, 0, szInfo,strlen(szInfo),
		szTemp, sizeof(szTemp));
	MyTextOut(hdc,rct,szTemp);
}
void CMyDraw::RefreshTitleText()
{	
	/*
	char* poldline = (char*)m_szRunUpText[m_nRunUpTextId];	
	if( 0 == m_nRunUpTextCount )
	{
		m_nRunUpTextId = 0;
	} else
	{
		m_nRunUpTextId++;
		if( m_nRunUpTextId <= 0 || m_nRunUpTextId > m_nRunUpTextCount )
			m_nRunUpTextId = 1;
	}
	char* pp = (char*)m_szRunUpText[m_nRunUpTextId];
	//printf(pp);
	ShowOneLineText(pp,poldline);*/
	RECT rct;
	GetTitleRect(rct);
	InvalidateRect(m_hwnd,&rct,TRUE);
}
void CMyDraw::RefreshTitleText(HDC hdc)
{
	char* poldline = (char*)m_szRunUpText[m_nRunUpTextId];	
	if( 0 == m_nRunUpTextCount )
	{
		m_nRunUpTextId = 0;
	} else
	{
		m_nRunUpTextId++;
		if( m_nRunUpTextId <= 0 || m_nRunUpTextId > m_nRunUpTextCount )
			m_nRunUpTextId = 1;
	}
	char* pp = (char*)m_szRunUpText[m_nRunUpTextId];
	//printf(pp);
	ShowOneLineText(hdc,pp,poldline);
}
void CMyDraw::ReadRunUpText()
{
	int ii = 0;
	if( 0 == m_szRunUpText[ii] )
	{
		char* pp  = new char[MAX_RUNUP_TEXT_SIZE];
		m_szRunUpText[ii] = (DWORD)pp;
		strcpy(pp,"欢迎使用普美科技出品的家庭数字助理系统");
	}
	FILE*fp = fopen("\\ipsm\\news.cfg","r+");
	if( fp )
	{
		//printf("read file ok\n");
		m_nRunUpTextCount = 0;
		char szTemp[MAX_RUNUP_TEXT_SIZE];
		while( fgets(szTemp,MAX_RUNUP_TEXT_SIZE,fp) )
		{
			if( ++ii > MAX_RUNUP_TEXT_COUNT )
				break;
			m_nRunUpTextCount++;
			char* pp=0;
			if( NULL == m_szRunUpText[ii] )
			{
				pp  = new char[MAX_RUNUP_TEXT_SIZE];
				memset(pp,0,sizeof(pp));
				m_szRunUpText[ii] = (DWORD)pp;
			} else
				pp = (char*)m_szRunUpText[ii];

			if( pp )
			{
				strcpy(pp,szTemp);
				char* kk = strchr(pp,'\r');
				if( kk ) {*kk = 0;}
				kk = strchr(pp,'\n');
				if( kk ) {*kk = 0;}
			}
			memset(szTemp,0,sizeof(szTemp));
		}
		fclose(fp);
	} else
	{
		//printf("read file error\n");
	}
}

⌨️ 快捷键说明

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