1.设置显示器分辨率void CMainFrame::SetStartMode(){ DEVMODE lpDevMode; lpDevMode.dmPelsHeight=768; lpDevMode.dmPelsWidth=1024; lpDevMode.dmDisplayFrequency=85;//设置显示频率 lpDevMode.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY; ChangeDisplaySettings(&lpDevMode,0); this->BringWindowToTop();}
2开机自动运行程序void CMainFrame::EnableAutoStart()//设置程序自动开机运行{ CString sPath; int nPos; HKEY RegKey; GetModuleFileName(NULL,sPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH); sPath.ReleaseBuffer(); nPos=sPath.ReverseFind('\\'); sPath=sPath.Left(nPos); CString lpszFile=sPath+"\\YbkDemo.exe"; CFileFind fFind; BOOL bSuccess; bSuccess=fFind.FindFile(lpszFile); fFind.Close(); if(bSuccess) { CString fullName; fullName=lpszFile; RegKey=NULL; RegOpenKey(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",&RegKey); RegSetValueEx(RegKey,"彭水白云监控系统",0,REG_SZ,(const unsigned char*)(LPCTSTR)fullName,fullName.GetLength()); this->UpdateData(FALSE); } else { ::AfxMessageBox("没找到执行程序,自动运行失败"); exit(0); }}//其中RegOpenKey()和RegSetValueEx()是修改注册表的函数。
3.触发VIEW的WM_PAINT消息,进行背景位图的显示void CYbkDemoView::OnPaint() { CPaintDC dc(this); // device context for painting CRect rect; GetClientRect(&rect); HBITMAP hbitmap; hbitmap=::LoadBitmap(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_MAIN)); HDC hMenDC=::CreateCompatibleDC(NULL); SelectObject(hMenDC,hbitmap); ::StretchBlt(dc.m_hDC,0,0,1024,768,hMenDC,0,0,1024,768,SRCCOPY); ::DeleteDC(hMenDC); ::DeleteObject(hbitmap);}
|