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

📄 logindlg.cpp

📁 控件串口简单事件触发,通过串口对控件进行通信
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// LoginDlg.cpp : implementation file
//

#include "stdafx.h"
#include "HTKJ.h"
#include "LoginDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLoginDlg dialog


CLoginDlg::CLoginDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CLoginDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLoginDlg)
	m_select = _T("");
	//}}AFX_DATA_INIT
	m_ShowTitle = TRUE;
	m_ReSizeFlag = FALSE;
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}


void CLoginDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLoginDlg)
	DDX_Control(pDX, IDC_EDIT2, m_b);
	DDX_Control(pDX, IDC_EDIT1, m_a);
	DDX_Control(pDX, IDC_COMBO1, m_combo);
	DDX_CBString(pDX, IDC_COMBO1, m_select);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLoginDlg, CDialog)
	//{{AFX_MSG_MAP(CLoginDlg)
		ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_NCLBUTTONDOWN()
	ON_WM_NCMOUSEMOVE()
	ON_WM_SYSCOMMAND()
	ON_WM_SIZE()
	ON_WM_MOUSEMOVE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLoginDlg message handlers

BOOL CLoginDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	extern	CHTKJApp theApp;
    /////add by xu in anhui ca /////////////////////

	HRESULT hr;
	_variant_t str;
	CString  sql;
	int i;
    sql.Format("select * from pfproject");
	hr=theApp.AdoRecordset->Open(_variant_t(sql),theApp.AdoConnection.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
	if(FAILED(hr))
	{
		AfxMessageBox("数据库无法连接!");
	}
      if(theApp.AdoRecordset->GetRecordCount()==0)
	  {
		AfxMessageBox("网点库为空,请联系相关部门!!");
		theApp.AdoRecordset->Close(); 
	  }
	  else 
	  {
        for(i=0;i<theApp.AdoRecordset->GetRecordCount();i++)
		{  
		   str=theApp.AdoRecordset->GetCollect("PJ_NAME");
           m_combo.AddString((char *)(_bstr_t)str);
            theApp.AdoRecordset->MoveNext();
		}
        m_combo.SetCurSel(0);
        theApp.AdoRecordset->Close();
	  }	

/////////////////////////////////

	switch(theApp.m_BaseFlag)
		{
	    case 0: {
			     HRESULT hr;
	            _variant_t str;
                 CString sql;
	             sql.Format("select * from pfopserver");
	             hr=theApp.AdoRecordset->Open(_variant_t(sql),theApp.AdoConnection.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
                 if(FAILED(hr))
				 {
		           AfxMessageBox("数据库无法连接!");
				 }
                else
				{
				  theApp.AdoRecordset->Close();
				}	       	   
			}	
		       break;
		case 2:	AfxMessageBox("初始化!");
				break;
			default:;
	}


	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CLoginDlg::OnOK() 
{
	// TODO: Add extra validation here
	extern CHTKJApp theApp;
     CString m_bursh,m_name,m_password,name,sql;
	 GetDlgItem(IDC_COMBO1)->GetWindowText(m_bursh);
	 GetDlgItem(IDC_EDIT2)->GetWindowText(m_name);
     GetDlgItem(IDC_EDIT1)->GetWindowText(m_password);
	 CString dbsrc;
	 HRESULT hr;
	 _variant_t str1;
	 UpdateData(true);
   //单位信息通过工作人员的前台程序的登陆来选择。
   // 	LPCTSTR pFileName = _T(".\\HTLineSys.ini");	    
   //	GetPrivateProfileString(_T("BIANHAO"),_T("QueHao"),_T("0102"),dbsrc.GetBuffer(20),20,pFileName); 
   //  dbsrc.ReleaseBuffer();
    //////////////////
    sql.Format("select PJ_id from pfproject where PJ_NAME='%s'",m_bursh);
	hr=theApp.AdoRecordset->Open(_variant_t(sql),theApp.AdoConnection.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
	if(FAILED(hr))
	{
		AfxMessageBox("数据库无法连接!");
	}
	if(theApp.AdoRecordset->GetRecordCount()==0)
	  {
      AfxMessageBox("网点库为空,请联系相关部门!");
	  theApp.AdoRecordset->Close(); 
	  }
	  else 
	  {
	  str1=theApp.AdoRecordset->GetCollect("PJ_id");
      dbsrc=(LPCTSTR)(_bstr_t)str1;
      theApp.AdoRecordset->Close();
	  }		 
	//////////////////
	  name=dbsrc+m_name;
	theApp.IDstr=name;
	sql.Format("select * from pfopserver where OP_serverno='%s' and OP_password='%s'",name,m_password);
	hr=theApp.AdoRecordset->Open(_variant_t(sql),theApp.AdoConnection.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
	if(FAILED(hr))
	{
		AfxMessageBox("数据库无法连接!");
	}
    if(theApp.AdoRecordset->GetRecordCount()==0)
	{
	  theApp.AdoRecordset->Close();
      theApp.m_BaseFlag=3;
	  CuoWUDlg CWDlg;
      int i=CWDlg.DoModal();
	  if(i==2)
	  {CDialog::OnCancel();}
	  if(i==1)
	  { m_b.SetFocus();}
	}
   else
   {
    theApp.AdoRecordset->Close();
    CDialog::OnOK();
 }
}
HCURSOR CLoginDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

LRESULT CLoginDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	LRESULT lrst=CDialog::DefWindowProc(message, wParam, lParam);
	
	if (!::IsWindow(m_hWnd))
		return lrst;
	
	if (message==WM_MOVE||message==WM_PAINT||message==WM_NCPAINT||message==WM_NCACTIVATE ||message == WM_NOTIFY)
	{
		CDC* pWinDC = GetWindowDC();
		if (pWinDC)
			DrawTitleBar(pWinDC);
		ReleaseDC(pWinDC);
	}
	return lrst;
}

void CLoginDlg::OnNcLButtonDown(UINT nHitTest, CPoint point) 
{
	
	CRect rtWnd;
	GetWindowRect(&rtWnd);

	//mouse坐标转化为本窗口坐标 重要
	point.x = point.x - rtWnd.left;
	point.y = point.y - rtWnd.top;
	//检测各按钮是否按到
	if (m_rtIcon.PtInRect(point))
		AfxMessageBox("没按到按钮");
	else
	{ 
		if (m_rtButtHelp.PtInRect(point))
		{
		SendMessage(WM_HELP);
		}
		else 
		{
			if (m_rtButtExit.PtInRect(point))
			{
				SendMessage(WM_CLOSE);
			}
			else 
			{
				if (m_rtButtMin.PtInRect(point))
				{
					m_ShowTitle = FALSE;
					SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, MAKELPARAM(point.x, point.y));
				}
				else 
				{
					if (m_rtButtMax.PtInRect(point))
					{
						m_ShowTitle = TRUE;
						if (IsZoomed())
							SendMessage(WM_SYSCOMMAND, SC_RESTORE, MAKELPARAM(point.x, point.y));
						else
						{
							SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, MAKELPARAM(point.x, point.y));
							Invalidate();
						}
					}
					else
					{
						if (!IsZoomed())
						{
							Default();						
						}
					}
				}
			}
		}
	}
}

void CLoginDlg::OnNcMouseMove(UINT nHitTest, CPoint point) 
{
/*	CDC* pDC = GetWindowDC();
	CDC* pDisplayMemDC=new CDC;
	pDisplayMemDC->CreateCompatibleDC(pDC);
	CBitmap* pBitmap = new CBitmap;
	CBitmap* pOldBitmap;
	CRect rtWnd, rtButton;
	if (pDC)
	{
		CString StrTemp = "";
		GetWindowRect(&rtWnd);
		//mouse坐标转化为本窗口坐标 重要
		point.x = point.x - rtWnd.left;
		point.y = point.y - rtWnd.top;
		//判断mouse是否移到系统按钮上
		if (m_rtButtExit.PtInRect(point))
		{
			pBitmap->LoadBitmap(IDB_EXIT_FOCUS);
			StrTemp = _T("关闭");
		}
		else
		{
			if(m_rtButtMin.PtInRect(point))
			{
				pBitmap->LoadBitmap(IDB_MIN_FOCUS);
				StrTemp = _T("最小化窗口");
			}
			else
			{
				if(m_rtButtMax.PtInRect(point))
				{

⌨️ 快捷键说明

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