
c++学习问题记录
shandiantianying
这个作者很懒,什么都没留下…
展开
-
两时间比较
#include #include #include using namespace std;float DiffTime(unsigned ty1, unsigned th1, unsigned ty2, unsigned th2){struct tm tm1, tm2;time_t tt1, tt2;float dt;转载 2014-02-28 14:41:15 · 824 阅读 · 0 评论 -
tm ,time_t,SYSTEMTIME转换
time_t tmToTime_t(char * dt){tm timeinfo;sscanf_s(dt, "%d-%d-%d %d:%d:%d",&timeinfo.tm_year, &timeinfo.tm_mon, &timeinfo.tm_mday,&timeinfo.tm_hour, &timeinfo.tm_min, &timeinfo.tm_sec);ti原创 2014-02-28 09:41:48 · 2526 阅读 · 0 评论 -
c++构造函数初始化列表
class F{public:F(int a);int m;};F::F(int a) :m(a){cout }int main(void){ F *f = new F(100);delete(f);}原创 2014-01-10 11:49:57 · 654 阅读 · 0 评论 -
MFC资源文件切换
AFX_MANAGE_STATE(AfxGetStaticModuleState()); TTest *Tet = new TTest(); Tet->Create(IDD_DIALOGTEST, NULL); Tet->ShowWindow(SW_SHOW);原创 2014-01-08 15:54:31 · 772 阅读 · 0 评论 -
win32 自定义控件使用,必须要将自定义控件style = 0x50010000 0x50010000是三个样式的组合
// Win32Project12.cpp : 定义应用程序的入口点。//#include "stdafx.h"#include "Win32Project12.h"#define MAX_LOADSTRING 100#define IDC_OKBTN 200// 全局变量: HINSTANCE hInst; // 当前实例TCHAR szT原创 2014-01-03 09:14:39 · 2645 阅读 · 0 评论 -
win32 WM_DESTROY 和 WM_NCDESTROY.
WM_DESTROY与WM_NCDESTROY在窗口销毁时有两个紧密关联的 windows 消息, 就是 WM_DESTROY 和 WM_NCDESTROY.区别就是 WM_DESTROY 消息是在窗口销毁动作序列中的开始被发送的, 而 WM_NCDESTROY 消息是在结尾. 这在你的窗口拥有子窗口时是个重大区别. 如果你有一个带子窗口的父窗口, 那么消息的发送序列 (在没有怪诞原创 2013-12-31 17:49:24 · 978 阅读 · 0 评论 -
wiin32 想找目录下文件
case WM_COMMAND:if (LOWORD(wParam) == IDOK){search = L"E:\\Form\\*.png";WIN32_FIND_DATA fdd;HANDLE AFind = FindFirstFile(search, &fdd);TCHAR * s = NULL;if (AFind != INVALID_HANDLE_VALUE)原创 2013-12-31 16:46:11 · 531 阅读 · 0 评论 -
修改dialog上ico hwnd ---- hinstance
SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_SMALL)));原创 2013-12-30 16:45:24 · 577 阅读 · 0 评论 -
win32 linkcontrol使用
//设置值 wstring link = L"link.append(curMessage->url.c_str());link.append(L"\">");link.append(curMessage->url.c_str());link.append(L"");SetWindowText(GetDlgItem(hwnd, IDC_SYSLINK), link.c_st原创 2013-12-26 21:25:13 · 1061 阅读 · 0 评论 -
gdi画图拉伸
// 让其平铺拉伸(默认为渐变拉伸)ImageAttributes ImgAtt;ImgAtt.SetWrapMode(WrapModeTileFlipXY);RectF rcDrawRect;rcDrawRect.X=0;rcDrawRect.Y=0;rcDrawRect.Width=100;rcDrawRect.Height=100;g.DrawImage(m_原创 2013-12-26 20:10:59 · 835 阅读 · 0 评论 -
文本重影
case WM_CTLCOLORSTATIC://static窗体透明i = GetWindowLong((HWND) lParam, GWL_ID); //获取窗口控制项ID ////根据所获取的id依次更改文字颜色 switch (i){case 120:SetTextColor((HDC) wParam, RGB(255, 255,原创 2013-12-26 17:56:35 · 786 阅读 · 0 评论 -
HBRUSH的使用
HBRUSH hbr;第一种: hbr= CreateSolidBrush(RGB(255,0,0)); //单色的画刷第二种: hbr= (HBRUSH)GetStockObject(BLACK_BRUSH); //只能取特定颜色的画刷,如BLACK_BRUSH,GRAY_BRUSH等刷第三种: hbr= CreatePatternBrush(HBITMAP hb原创 2013-12-26 17:39:44 · 1164 阅读 · 0 评论 -
win32 listview,combox使用
HWND hwndList = GetDlgItem(hDlg, IDC_LIST_ALLMESSAGE);HWND hwndCombox = GetDlgItem(hDlg, IDC_COMBOSTATE);switch (message) {case WM_INITDIALOG:SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE原创 2013-12-25 16:56:44 · 2107 阅读 · 0 评论 -
c++中日期转换
#include "time.h"#include "stdio.h"int main(void){char now[64];struct tm newtime;time_t timep;errno_t err;timep = 1386691200;err = localtime_s(&newtime, &timep);strftime(now, 64, "原创 2013-12-23 15:41:06 · 803 阅读 · 0 评论 -
c++日期转换
#include #include #include using namespace std;void GetDay(int days, int &month, int&mDay, bool bLeap){int dayCount[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };if (b原创 2013-12-22 20:01:38 · 894 阅读 · 0 评论 -
得到window区域位置
1、全屏显示int full_x = GetSystemMetrics(SM_CXSCREEN);int full_y = GetSystemMetrics(SM_CYSCREEN);::SetWindowPos(hWnd,HWND_TOPMOST,0,0,full_x,full_y,0 ); 2、工作区显示 RECT rt; SystemParametersI转载 2013-12-21 16:38:55 · 549 阅读 · 0 评论 -
_access判断文人提否存在
_access使用方法path文件或目录路径。mode读/写属性。0仅存在2只读4只读6读取和写入BOOLEAN CheckFileExists(char * fileOrDirName){ if (_access(fileOrDirName, 0) == 0) //文件或目录存在 { return true; } return false;原创 2013-12-18 13:04:56 · 548 阅读 · 0 评论 -
c++控件播放flash
容器-插件基础:为在一个窗口中嵌入一个Activex的话,就需要创建一个Container Window,然后创建被嵌入的Activex,然后通过上述的接口建立容器与Activex直接的联系。在ATL中使用CAxHostWindow封装 了Activex容器,并进一步使用CAxWindow类来简化控件容器的操作。Activex嵌入主要代码1.内嵌Activex的创建转载 2013-12-18 09:41:07 · 1046 阅读 · 0 评论 -
c++播放flash
#include int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show) {MSG msg = { 0 }; void* init = GetProcAddress(LoadLibrary("atl"), "AtlAxWinInit"); _asm call init;//CreateW原创 2013-12-17 21:40:47 · 827 阅读 · 0 评论 -
消息分流器简单代码
消息分流器原理,这里不细说,可以google中查询,,以下提供短小代码实现下#include #define chHANDLE_DLGMSG(hwnd, message, fn) case (message): return (SetDlgMsgResult(hwnd, uMsg, HANDLE_##message((hwnd), (wParam), (lParam), (fn))))原创 2013-12-13 11:50:48 · 886 阅读 · 0 评论 -
win32多线程非阻塞与阻塞
typedef struct CjThreadData{ LPVOID fw; LPCTSTR getUrl; HANDLE hFile;}CJTHREADDATA,*PCJTHREADDATA;HANDLE hFile;::HANDLE hThreadArray[1];::PCJTHREADDATA pCjThreadData;::DWO原创 2013-12-06 16:02:26 · 868 阅读 · 0 评论 -
CAxWindow
#include "stdafx.h"#include "Win32Project11.h"#include CComModule _Module;#include #include #include HWND hWnd = NULL;static TCHAR szAppName [] = TEXT("WebBrowser");static TCHAR sz原创 2013-12-06 12:35:55 · 2205 阅读 · 0 评论 -
WebBrowser插件使用分享
WebBrowser插件使用分享 互联网的普及使用户非常熟悉基于浏览器的操作界面,对传统GUI模式应用的界面提出了更高的要求,希望能够具有类似于网页程序的表达力、易用性。对于Windows平台的GUI应用程序,WebBrowser插件是一个很好的解决方案,使用该插件相当在程序中嵌入了一个浏览器窗口,通过该窗口中可以充分利用IE内核的强大功能。 程序嵌入WebBrowser时,逻辑上转载 2013-12-05 16:12:42 · 4947 阅读 · 0 评论 -
static控件透明
case WM_CTLCOLORSTATIC://static窗体透明SetBkMode((HDC) wParam, TRANSPARENT);return (BOOL) ((HBRUSH) GetStockObject(NULL_BRUSH));原创 2013-12-03 09:48:15 · 513 阅读 · 0 评论 -
获取文件长度
int main(void){ FILE* file; fopen_s(&file, "bv.rar", "ab"); fseek(file, SEEK_CUR, SEEK_END); int fsize = ftell(file); cout }原创 2013-11-30 15:22:35 · 550 阅读 · 0 评论 -
fopen打开文件方式
fopen打开文件方式 最近写一个文件操作类,fopen的参数着实让我搞了半天,因为以前就是固定的方式读写文件的,现在要做灵活了,所以就有些参数理解不够准确。以下是关于mode参数的定义。'r' 只读方式打开,将文件指针指向文件头,如果文件不存在,则File返回空。'r+' 读写方式打开,将文件指针指向文件头,如果文件不存在,则File返回空。 'w' 写入方式打开转载 2013-11-30 15:00:46 · 1236 阅读 · 0 评论 -
string转换为LPCWSTR
LPCWSTR stringToLPCWSTR(std::string orig){size_t origsize = orig.length() + 1;const size_t newsize = 100;size_t convertedChars = 0;wchar_t *wcstring = (wchar_t *) malloc(sizeof(wchar_t) *(or转载 2013-11-26 17:35:54 · 5325 阅读 · 0 评论 -
用explicit禁止默认转换
用explicit禁止默认转换默认转换带来一定的方便,同时也造成不必要的失误,为了防止失误,可以在构造函数前加“explicit”。#include #include using namespace std;class classA { int x;public: explicit classA(int x) { this->x = x; } exp转载 2013-10-25 09:19:47 · 663 阅读 · 0 评论 -
c++中template使用
#include using namespace std;templateT min(T a[],int n){int i;T minv = a[0];for(i = 1; i{if(minv >a[i])minv = a[i];}return minv;}int main(void){int a[] = {1,3,0原创 2013-10-23 14:37:03 · 510 阅读 · 0 评论 -
Qt提示 "Could not connect to AppWrapper, Please make sure TCP port 12005 is not blocked"解决方法
在安装目录下新建一个文件,重命名为 qtappwrapper.exe.config在copy如下内容,保存重启vs原创 2013-10-18 02:58:09 · 5765 阅读 · 1 评论 -
c++线程
DWORD WINAPI Func1Proc(LPVOID lpParamter);DWORD WINAPI Func2Proc(LPVOID lpParameter);int main(void){HANDLE hThread1;HANDLE hThread2;hThread1 = CreateThread(NULL,0,Func1Proc,NULL,0,NULL原创 2013-09-04 14:19:56 · 601 阅读 · 0 评论 -
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is
//定义指针函数typedef int(*DLLFUNC)(int,int);int main(void){DLLFUNC dllfunc;HINSTANCE hinstance = LoadLibrary("main.dll");// try//{if(hinstance != NULL){dllfunc = (DLLFUNC)GetProcAdd原创 2013-09-04 11:16:23 · 17092 阅读 · 3 评论 -
c++ deque使用
int _tmain(int argc, _TCHAR* argv[]){//estimate(5,betsy);// estimate(5,pam);deque deq(20); //创建一个20个元素的双端队列deque::iterator pos;int i;for ( i = 0; i {deq[i] = i;}/*for(i = 0;原创 2013-08-30 17:17:13 · 2108 阅读 · 0 评论 -
c++ ado连接fatal error C1083: 无法打开类型库文件:“msado15.dll”
fatal error C1083: 无法打开类型库文件:“msado15.dll”提示无法打开msado15.dll,需要在安装目录下找到msado15.dll放到debug目录下即可原创 2013-08-30 15:33:10 · 7639 阅读 · 0 评论 -
c++Sdk
#include #include using namespace std;HINSTANCE g_hInstance;HWND hEdit, hButton;static const char* CLASS_NAME = "MYCLASS";HFONT SetMyFont(HDC hdc,LPCTSTR face ,int width,int height原创 2013-08-30 14:10:42 · 790 阅读 · 0 评论 -
#include 后还是提示string str;string未定义的标识符
#include 还是提示未定义标识符,是因为没有使用using namespace std;原创 2013-08-22 10:22:31 · 16868 阅读 · 0 评论 -
c++ jsoncpp操作
#include #include "json.h"#include #include using namespace std;int ParaseJsonFormFile(string filename){Json::Reader reader; //解析json要用到Json::ReaderJson::Value root;//Json原创 2013-08-20 17:16:11 · 1065 阅读 · 0 评论 -
c++ void*无类型指针
void* data;string strname = "abcdef!";data = &strname;string n1 = static_cast(data)->substr(0);cout << n1 << endl;原创 2013-08-20 11:07:39 · 623 阅读 · 0 评论 -
c++ _forceinline
C++提供了内联函数,目的是为了提高函数的执行效率。内联函数在函数声明前面加上关键字inline 就可以了 如:inline int FunctionOne(int x); 在VC++中可使用另一关键字_forceinline 代替inline 关键字.这个关键字将命令编译器跳过一般的ROI 分析(Return On Investment --一种编程缩略语),将所对应的代转载 2013-08-20 10:38:51 · 7491 阅读 · 0 评论 -
Sublime Text2编辑C++代码
1.先安装gccG++,sublimebin Text22.将gcG++安装的bin路径,设置到系统环境变量path中3.到Tools -> Build System -> New Build System在新打开的文件里面输入下面的内容然后保存。{"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"]原创 2013-08-16 09:30:29 · 506 阅读 · 0 评论