VCer代码 VCer开源 VCer文章 VCer工具 VCer知道 VCer词典 VCer读书 VCer论坛   站点首页 我要张贴 控制面板
VCer代码 VCer开源 VCer文章 VCer工具 VCer知道 VCer词典 VCer读书 VCer论坛   站点首页 我要张贴 控制面板

目前位置: VCer资源中心 >>> VCer代码 >>> C++/MFC基础
我也来贴上一段经典代码吧!>>>


虚拟键盘代码Virtual-Key Codes
 
The following table shows the symbolic constant names, hexadecimal values, and mouse or keyboard equivalents for the virtual-key codes used by the system. The codes are listed in numeric order. Virtual-Key Codes -------------------------------------------------------------------------------- The following table shows the symbolic constant names, hexadecimal values, and mouse or keyboard equivalents for the virtual-key codes used by the system. The codes are listed in numeric order. Constants VK_LBUTTON (01) Left mouse button VK_RBUTTON (02) Right mouse button VK_CANCEL (03) Control-break proce ...
作者:不祥 bluejoe张贴于2007-01-10 13:19:17.0,共阅读3015次,回复0
用API 作简繁体转换
 
1. 输入Big5字符,返回Gb简体字符 //--------------------------------------------------------------------------- //函数输入Big5字符,返回Gb简体字符 //--------------------------------------------------------------------------- AnsiString __fastcall Big2Gb(AnsiString sBig) { char* pszBig5=NULL; //Big5编码的字符 wchar_t* wszUnicode=NULL; //Unicode编码的字符 char* pszGbt=NULL; //Gb编码的繁体字符 char* pszGbs=NULL; //Gb编码的简体字符 AnsiString sGb; //返回的字符串 int iLen=0; //需要转换的字符数 pszBig5=sBig.c_str(); //读入需要转换的字符参数 //计算转换的字符数 iLen=MultiByteToWideChar (950 ...
作者:不祥 bluejoe张贴于2006-11-10 16:40:26.0,共阅读2779次,回复1
求救
 
fatal error C1083: Cannot open precompiled header file: 'Debug/zhpp.pch': No such file or directory 我在编译的时候总是通不过,错误指向"#include "stdafx.h" 请问哪位高手能告诉我为什么总是编译不了的呢?
作者:不祥 zhpeng1983张贴于2006-10-26 20:52:57.0,共阅读1864次,回复1
求矩阵行列式算法
 
我写了个求矩阵行列式的函数,如下: Determinant(double &det) { //calculate the determinant of this matrix if(m_nCols != m_nRows) Error(CString("it is'nt a square matrix"));//can called with this if(m_nCols == 1) {det = m_pData[0]; return;} else if(m_nCols == 2) {det=(m_pData[0]*m_pData[3] - m_pData[1]*m_pData[2]);return;} int sign = 1; det = 0.0; int i; double temp; Matrix<T> subMat; subMat.m_nCols = m_nCols-1; subMat.m_nRows = m_nRows-1; subMat.m_pData = new T[subMat.m_nCols*subMat.m_nRows]; for(i=0; i<m_nCols-2; i++) ...
作者:不祥 kalven张贴于2004-04-22 16:11:41.0,共阅读5803次,回复6
Faq:请教链接错误2005
 
问题: 在头文件中定义了几个变量, 如int bOrientationStarting; int bObstacleStarting; int bImageProcStarting;当其他多个文件需要包含了该h文件时出现以下链接错误: MainFrm.obj : error LNK2005: "int bObstacleStarting" (?bObstacleStarting@@3HA) already defined in AudioManView.obj MainFrm.obj : error LNK2005: "int bOrientationStarting" (?bOrientationStarting@@3HA) already defined in AudioManView.obj MainFrm.obj : error LNK2005: "int bImageProcStarting" (?bImageProcStarting@@3HA) already defined in AudioManView.obj ...... 这是犯了 ...
作者:不祥 zhnajiao张贴于2004-05-28 09:13:10.0,共阅读3261次,回复1
发个完整的数字手表的代码,大家给点意见。
 
给点意见。 /*---------------------------------------------------------------------------------------- CurosrBlock.c CursorBlock.c Display how to cursor (C)HuZengQiang 2004 ----------------------------------------------------------------------------------------*/ #include <windows.h> /*------------------------------------------------------------------------------------- constant number ------------------------------------------------------------------------------------*/ #define ID_TIMER 1 ...
作者:不祥 imperial张贴于2004-08-31 16:23:24.0,共阅读3074次,回复2
关于遍历目录的问题求救!~
 
我是个初学者,请给我讲解的详细一些。谢谢了。 我从网上找了个 “遍历目录查找文件”的例子,照着做了一个,编译后在没有pagefile.sys的目录下查找文件运行很正常,一旦在有pagefile.sys的目录下(如:c:\)查找文件,就出现窗口闪一下就消失了。 我是个初学者,请给我讲解的详细一些。谢谢了。 一下是代码: void CSearchDlg::OnButtonSearch() { // TODO: Add your control notification handler code here char szFilename[80]; //字符串szFilename表示要查找的文件名 strcpy(szFilename,"RamCleaner.exe"); _chdir("d:\\disktop_bak\\"); //进入要查找的路径(也可以是某一具体的目录) //查找文件,如果查到则显示文件的路径全名 Search_Directory(szFilename); //CsearchDlg类的一个成员函数 MessageBox("查找文件完毕."); //显示查找完毕的信息 } void CSearchDlg::Search_Directory(char *szFilename) { lo ...
作者:不祥 ymchinabye张贴于2004-09-02 14:59:47.0,共阅读2255次,回复1
Faq:如何遍历整个目录
 
提问用户 主题 提问状态 yugiant(小鱼儿) 如何遍历整个目录 已解决 问题解答归纳: BOOL DeleteCurFolder(CString folder) /***************************************************************** 作用:清空文件夹,预防可能产生的bug % 返回值:bool true-success,false-fail % 关键函数:CFildFind::FindFile % 关键变量:folder 对应文件夹 % 作者:张奇 % 修改时间:2002-10-10 ...
作者:不祥 xler张贴于2004-05-21 10:19:39.0,共阅读2628次,回复0
解高斯方程组算法(自己写的和清华教材上的比较)
 
重点是方程组类Linequ的方法 Solve(),解法一是清华教材《C++语言程序设计》郑莉等编的算法,好像有错(反正测试计算出来试错的main()为测试码),且不怎么明白!于是自己写了个,自己命名为逐行消去法!请大家看看!呵呵写得不好请帮忙改进!// Linqu.h //Begin of file Linequ.h #ifndef LINQU_H #define LINQU_H #include <iostream.h> #include <math.h> class Matrix //The definition of basic class { public: //Interface for outside Matrix(int dim=2); //Constructor ~Matrix(); //Destructor void setMatrix(double* rmatr); //Initialize Matrix void printM(); //Display Matrix protected: int index; ...
作者:不祥 barco张贴于2004-05-17 23:36:27.0,共阅读2546次,回复3
用默认浏览器打开 URL
 
HKEY hkRoot,hSubKey; //定义注册表根关键字及子关键字 char ValueName[256]; unsigned char DataValue[256]; unsigned long cbValueName=256; unsigned long cbDataValue=256; char ShellChar[256]; //定义命令行 DWORD dwType; //打开注册表根关键字 if(RegOpenKey(HKEY_CLASSES_ROOT,NULL,&hkRoot)==ERROR_SUCCESS) { //打开子关键字 if(RegOpenKeyEx(hkRoot, "htmlfile\\shell\\open\\command", 0, KEY_ALL_ACCESS, &hSubKey)==ERROR_SUCCESS) { //读取注册表,获取默认浏览器的命令行 RegEnumValue(hSubKey, 0, ValueName, &cbValueName, NULL, &dwType, DataValue, &cb ...
作者:不祥 Bccv张贴于2004-03-30 16:44:19.0,共阅读2420次,回复1
将普通字符串转化为Unicode编码
 
该函数在偶的手机程序里面用过,字符串的长度就是sEncodes.GetLength() / 2(支持中英文混排)。CString CMobile::String2HEX(CString sSource) { _bstr_t bstrSMS(sSource); int nSMSLength = bstrSMS.length(); wchar_t * pwc = (wchar_t *)bstrSMS; CString sEncode; for(int i = 0; i < nSMSLength; i++) { CString sHex; sHex.Format(_T("%04X"), pwc[i]); sEncode += sHex; } return sEncode; }
作者:不祥 bluejoe张贴于2004-04-18 10:40:12.0,共阅读2005次,回复0
统计中英文字符混合片断的字符数
 
CString strTxt; //需要统计的片断 int Lenth = strTxt.GetLength(); int nELenth = 0; //英文 int nCLenth = 0; //中文 int nTotalLenth = 0;////总共字数 for(int i=0;i<Lenth;i++) { char c = strTxt.GetAt(i); //中文字符 if(c<0||c>255) continue; //英文字符 else nELenth ++; } //计算中文字符数 nCLenth = (Lenth-nELenth)/2;
作者:不祥 Bccv张贴于2004-03-30 09:59:44.0,共阅读1641次,回复1
十进制/十六进制/二进制字串转化
 
//十进制->二进制 CString DecimalToBinary(CString strDecimal) { int nDecimal = atoi(strDecimal.GetBuffer(0)); int nYushu; //&Oacute;à&Ecirc;&yacute; int nShang; //&Eacute;&Igrave; CString strBinary = ""; char buff[2]; CString str = ""; BOOL bContinue = TRUE; while(bContinue) { nYushu = nDecimal%2; nShang = nDecimal/2; sprintf(buff,"%d",nYushu); str = strBinary; strBinary.Format("%s%s",buff,str); nDecimal = nShang; if(nShang==0) bContinue = FALSE; } return strBinary; } //十六进制到二进制 CString HexToBinary(CString strHex) { int nLen ...
作者:不祥 Bccv张贴于2004-03-30 10:02:56.0,共阅读3032次,回复1
Serial Number 生成器
 
class CSerialNumber { public: CString XOR(LPCTSTR sSource, LPCTSTR sXOR); bool IsValid(LPCTSTR sSource, LPCTSTR sSN, int nMethod = 0); CString Generate(LPCTSTR sSource, int nMethod = 0); //生成注册码 CSerialNumber(); virtual ~CSerialNumber(); }; CSerialNumber::CSerialNumber() { } CSerialNumber::~CSerialNumber() { } CString CSerialNumber::Generate(LPCTSTR sSource, int nMethod) { //将用户名换算成15位注册码 double Num1, Num2, Num3; char sn[16] = {0}; Num1 = 0; Num2 = 0; Num3 = 0; int len = strlen(sSource); if(len) { for(int i = ...
作者:不祥 bluejoe张贴于2004-04-10 11:15:51.0,共阅读1857次,回复0
键盘VK值列表
 
/* * Virtual Keys, Standard Set */ #define VK_LBUTTON 0x01 #define VK_RBUTTON 0x02 #define VK_CANCEL 0x03 #define VK_MBUTTON 0x04 /* NOT contiguous with L & RBUTTON */ #define VK_BACK 0x08 #define VK_TAB 0x09 #define VK_CLEAR 0x0C #define VK_RETURN 0x0D #define VK_SHIFT 0x10 #define VK_CONTROL 0x11 #define VK_MENU 0x12 #define VK_PAUSE 0x13 #define VK_CAPITAL 0x14 #define VK_KANA 0x15 #define VK_HANGEUL 0x15 /* old name - should be here fo ...
作者:不祥 bluejoe张贴于2004-03-11 09:09:55.0,共阅读1544次,回复0
CWin32Exception源码
 
class CWin32Exception : public CException { public: int ReportError(UINT nType = MB_OK, UINT nMessageID = 0); BOOL GetErrorMessage( LPTSTR lpszError, UINT nMaxError, PUINT pnHelpContext = NULL); void ParseError(); DWORD m_nErrorCode; CString m_sErrorName; CString m_sErrorDescription; CString m_sErrorLabel; CWin32Exception(DWORD nErrorCode); virtual ~CWin32Exception(); private: }; CWin32Exception::CWin32Exception(DWORD nErrorCode) { ASSERT(nErrorCode); m_nErrorCode = nErrorCode; ParseError(); ::Logger.Log("发生系统错误:%s", m_sErrorLabel); } CWin32Excep ...
作者:不祥 bluejoe张贴于2004-03-06 17:12:52.0,共阅读2197次,回复0
洗牌程序
 
int No[54]; int Which = 0, Total = 54; //初始化牌 for(int i = 0; i < 54; i++) No[i] = -1; srand((unsigned)time(NULL)); for(Which = 0; Which < 54; Which ++) { i = rand()*Total / RAND_MAX; int k = 0; int m = 0; while(true) { //该牌没有设置 if(No[m] < 0) k ++; if(k > i) break; m ++; } No[m] = Which; Total --; }
作者:不祥 bluejoe张贴于2004-02-25 11:50:41.0,共阅读1896次,回复0

页次: 2/2页 记录总数37 9 7 [ 1 2 3 4 5 6 7 8 9 10 ] 8 :