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

📄 userchoice.cpp

📁 电脑编程技巧和源码。很不错的。
💻 CPP
字号:
// UserChoice.cpp : implementation file
//

#include "stdafx.h"
#include "Monitor.h"
#include "UserChoice.h"
#include "MonitorDoc.h"
#include "TypeButton.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CUserChoice dialog


CUserChoice::CUserChoice(CWnd* pParent /*=NULL*/)
	: CDialog(CUserChoice::IDD, pParent)
{
	//{{AFX_DATA_INIT(CUserChoice)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CUserChoice::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUserChoice)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUserChoice, CDialog)
	//{{AFX_MSG_MAP(CUserChoice)
	ON_WM_CREATE()
	ON_NOTIFY_EX( TTN_NEEDTEXT,0,OnToolTipNotify)
	ON_NOTIFY_EX_RANGE( TTN_SHOW, 0, 0xFFFF, OnShowToolTip ) 
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUserChoice message handlers

int CUserChoice::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	CRect r;
	CWnd *pP;
	pP=((CMonitorApp*)AfxGetApp())->pMainFrame;
	pP->GetClientRect(r);
	pP->ClientToScreen(r);
	SetWindowText((LPCTSTR)ThisUser->Name);
	MoveWindow(r.right-250-25,r.top/2,250,r.bottom-r.top/2);
	
	return 0;
}

BOOL CUserChoice::SetData(CXhinfo *User,CObArray *Types)
{
	ThisUser=User;
	TypeList=Types;
	iTypeNumber=Types->GetSize();
	CTypeValue *pOneValue;
	int i;
	for(i=0;i<iTypeNumber;i++)
	{
		pOneValue=new CTypeValue;
		UserValueList.Add(pOneValue);
	}

	int iSelected=ThisUser->InfoArray.GetSize();
	for(i=0;i<iSelected;i++)
	{
		CTypeValue *p=(CTypeValue*)ThisUser->InfoArray.GetAt(i);
		pOneValue=(CTypeValue*)UserValueList.GetAt(p->iKey);
		*pOneValue=*p;
	}
	return TRUE;
}

BOOL CUserChoice::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	EnableToolTips();
	CTypeInfo *pOneType;
	CTypeValue *pOneValue;
	CString strOneType;
	CRect myRect;
	int p=0;
	for(int i=0;i<(iTypeNumber/3)+1;i++)
	{
		if(p>=iTypeNumber) break;
		for(int j=0;j<3;j++)
		{
			if(p>=iTypeNumber) break;
			pOneType=(CTypeInfo*)TypeList->GetAt(i*3+j);
			strOneType=pOneType->sEName;
			pOneValue=(CTypeValue*)UserValueList.GetAt(i*3+j);
			CTypeButton *newbutton = new CTypeButton;
			myRect=CRect(9+j*82,10+i*30,9+j*82+60,10+i*30+25);
			newbutton->Create( (LPCTSTR)strOneType,WS_VISIBLE|WS_CHILD|WS_TABSTOP
				|BS_PUSHBUTTON|BS_OWNERDRAW,myRect,this,IDC_BUTTONES+i*3+j);
			if(pOneValue->iKey>-1)
			{
				newbutton->SetTextColor(RGB(255,0,0));
			}
			else
			{
				newbutton->SetTextColor(RGB(0,0,0));
			}
			TypeButtons.SetAtGrow(i*3+j,newbutton);
			p++;
		}
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL CUserChoice::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
	CTypeValue *pOneValue;
	CString End,Begin,date="";
	TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
	UINT nID =pNMHDR->idFrom;
	nID = ::GetDlgCtrlID((HWND)nID);
	pOneValue=(CTypeValue*)UserValueList.GetAt(nID-200);

	if(pOneValue->iKey>-1)
	{
		Begin=pOneValue->Begin.Format("开始日期%Y/%m/%d");
		End=pOneValue->End.Format("结束日期%Y/%m/%d");
		date=Begin +"   "+End;
	}
	int length=date.GetLength();
	for(int i=0;i<length;i++)
	{
		pTTT->lpszText[i]=date.GetAt(i);
	}
	pTTT->lpszText[length]=0;
	return TRUE;
}

BOOL CUserChoice::OnShowToolTip( UINT id, NMHDR* pNotifyStruct, LRESULT* result )
{
	::SendMessage( pNotifyStruct->hwndFrom, TTM_SETDELAYTIME,TTDT_AUTOPOP, MAKELPARAM(30000,0)); 
	return TRUE;
} 

⌨️ 快捷键说明

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