有时候很烦人,程序跑着跑着就重启了,这并不是因为程序崩了,而是在新版的visual studio中对MFC程序默认增加了一个功能:程序自动重启。要禁用它,只须在程序最开始继承自CWinApp的类的构造函数中将下面一句话注释掉:
1 2 | // support Restart Manager //m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; |
人,技术,生活。
有时候很烦人,程序跑着跑着就重启了,这并不是因为程序崩了,而是在新版的visual studio中对MFC程序默认增加了一个功能:程序自动重启。要禁用它,只须在程序最开始继承自CWinApp的类的构造函数中将下面一句话注释掉:
1 2 | // support Restart Manager //m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; |
西汉
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 高祖, 刘邦,前202-前195,8年 惠帝, 刘盈,前195-前188,8年 刘恭,前188-前184,5年,刘盈长子 刘弘,前184-前180,5年,刘盈四子,刘恭异母弟 文帝, 刘恒,前180-前157,24年,刘邦第四子,刘盈之弟 景帝, 刘启,前157-前141,17年,刘恒第五子,嫡长子 武帝, 刘彻,前141-前87,55年,刘启十子,建元/元光/元朔/元狩元鼎/元封 昭帝, 刘弗陵,前87-前74,14年,刘彻六子,始元/元凤/元平 海昏侯,刘贺,前74,27天,刘彻之孙(第五子的儿子),元平 宣帝, 刘询,前74-前49,26年,刘彻曾孙,本始/地节/元康/神爵/五凤/甘露/黄龙 元帝, 刘奭,前49-前33,17年,刘询长子,初元/永光/建昭/竟宁 成帝, 刘骜,前33-前7,27年,刘奭长子,建始/河平/阳朔/鸿嘉/永始/元延/绥和 哀帝, 刘欣,前7-前1,7年,刘奭之孙,刘骜之侄,建平/太初元将/元寿 平帝, 刘衎,前1-6,7年,刘奭之孙,元始 刘婴,6-85,3年,居摄/初始 |
东汉
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 光武帝,刘秀,25-57,33年,建武/建武中元 明帝, 刘庄,57-75,19年,永平 章帝, 刘炟,75-88,14年,建初/元和/章和 和帝, 刘肇,88-106,19年,永元/元兴 殇帝, 刘隆,106,8月,延平 安帝, 刘祜,106-125,20年,永初/元初/永宁/建光/延光 北乡侯,刘懿,125,7月,延光 顺帝, 刘保,125-144,20年,永建/阳嘉/永和/汉安/建康 冲帝, 刘炳,144-145,5月,永熹 质帝, 刘缵,145-146,2年,本初 桓帝, 刘志,146-168,23年,建和/和平/元嘉/永兴/永寿/延熹/永康 灵帝, 刘宏,168-189,22年,建宁/熹平/昭和/中平,董太后之子 刘辩,189,5月,光熹/昭宁,灵思皇后何氏之子 献帝, 刘协,189-220,32年,永汉/中平/初平/兴平/建安/延康,灵怀皇后王荣之子 |
ActivePerl-5.26.3.XXXX.msi安装后,命令行执行cpan,会出现如下提示而无法继续。
Can't locate Win32/Console.pm in @INC (need to install the Win32::Console module) (@INC contains: C:\Perl64\site\lib C:\Perl64\lib) at C:\Perl64\lib/ActivePerl/Config.pm line 400.
解决办法,修改C:\Perl64\lib\ActivePerl\Config.pm,大约在400行左右:
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | # Prevent calling Win32::Console::DESTROY on a STDOUT handle #my $console; sub _warn { # my($msg) = @_; # unless (-t STDOUT) { # print "\n$msg\n"; # return; # } # require Win32::Console; # unless ($console) { # $console = Win32::Console->new(Win32::Console::STD_OUTPUT_HANDLE()); # } # my($col,undef) = $console->Size; # print "\n"; # my $attr = $console->Attr; # $console->Attr($Win32::Console::FG_RED | $Win32::Console::BG_WHITE); # for (split(/\n/, "$msg")) { # $_ .= " " while length() < $col-1; # print "$_\n"; # } # $console->Attr($attr); # print "\n"; } |
直接双击运行bin/designer.exe会报如下错误:
This application failed to start because it could not find or load the Qt platform plugin "windows" in ...
解决办法是,在bin目录中新建qt.conf文件,其内容如下:
1 2 | [Paths] Prefix=d:/qt5.6.1.x64/ |
其中d:/qt5.6.1.x64/是根目录,该目录直接下面是bin目录及plugins目录。同时要注意这里的路径字符串中是Linux下的斜杠,不是Windows的反斜杠。
Oracle VM VirtualBox 管理器->菜单->管理->虚拟介质管理
当程序写得越来越大,进程占用的内存也就越来越多,调用popen时会返回空的FILE指针,网上说原因是system或popen这样的系统函数,其内部实现是调用fork函数创建子进程,创建过程中会复制父进程堆、栈等资源,这样就容易造成创建失败,返回NULL。
以下是我写的用vfork替换fork调用的Vpopen类。
Vpopen.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #pragma once #include <stdio.h> #include <sys/types.h> #include <unistd.h> class Vpopen { FILE *fp_; pid_t pid_; int pipeFd_[2]; public: Vpopen(); ~Vpopen(); FILE *open(const char *cmd, const char *flags); void close(); }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #define FILL_STYLE_VERTICAL 0 #define FILL_STYLE_HORIZONTAL 1 void fillGradientRect(HDC hdc, RECT *rc, COLORREF fromRGB, COLORREF toRGB, int fillStyle) { BITMAPINFO bmpInfo; memset(&bmpInfo, 0, sizeof(bmpInfo)); bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmpInfo.bmiHeader.biWidth = rc->right - rc->left; bmpInfo.bmiHeader.biHeight = rc->bottom - rc->top; bmpInfo.bmiHeader.biPlanes = 1; bmpInfo.bmiHeader.biBitCount = 32; bmpInfo.bmiHeader.biCompression = BI_RGB; BYTE *rgbBuffer = (BYTE *)malloc(bmpInfo.bmiHeader.biWidth * bmpInfo.bmiHeader.biHeight * 4); int width = bmpInfo.bmiHeader.biWidth; int height = bmpInfo.bmiHeader.biHeight; int rStart = fromRGB & 0xFF; int rEnd = toRGB & 0xFF; int gStart = (fromRGB & 0xFF00) >> 8; int gEnd = (toRGB & 0xFF00) >> 8; int bStart = (fromRGB & 0xFF0000) >> 16; int bEnd = (toRGB & 0xFF0000) >> 16; if (FILL_STYLE_VERTICAL == fillStyle) { double rStep = (rEnd - rStart) * 1.0 / height; double gStep = (gEnd - gStart) * 1.0 / height; double bStep = (bEnd - bStart) * 1.0 / height; for (int y = 0; y < height; y++) { BYTE r = (BYTE)(rStart + rStep * y); BYTE g = (BYTE)(gStart + gStep * y); BYTE b = (BYTE)(bStart + bStep * y); for (int x = 0; x < width; x++) { BYTE *p = rgbBuffer + ((height - y) * width - (width - x)) * 4; *p++ = b; *p++ = g; *p++ = r; } } } else { double rStep = (rEnd - rStart) * 1.0 / width; double gStep = (gEnd - gStart) * 1.0 / width; double bStep = (bEnd - bStart) * 1.0 / width; for (int x = 0; x < width; x++) { BYTE r = (BYTE)(rStart + rStep * x); BYTE g = (BYTE)(gStart + gStep * x); BYTE b = (BYTE)(bStart + bStep * x); for (int y = 0; y < height; y++) { BYTE *p = rgbBuffer + ((height - y) * width - (width - x)) * 4; *p++ = b; *p++ = g; *p++ = r; } } } StretchDIBits(hdc, rc->left, rc->top, width, height, 0, 0, width, height, rgbBuffer, &bmpInfo, DIB_RGB_COLORS, SRCCOPY); free(rgbBuffer); } void CMFCApplicationDlg::OnPaint() { CPaintDC dc(this); CRect rc(50, 50, 200, 200); fillGradientRect(dc.m_hDC, rc, RGB(255, 0, 255), RGB(0, 255, 0), FILL_STYLE_HORIZONTAL); CDialogEx::OnPaint(); } |
1 2 3 | ::ReleaseCapture(); ::SendMessage(m_hWnd, WM_NCLBUTTONDOWN, HTCAPTION, NULL); ::SendMessage(m_hWnd, WM_LBUTTONUP, NULL, NULL); |
对于popup style的窗体,要将其System Menu属性改为false,OnNcHitTest的返回正确值后,窗口才会改变大小。
响应WM_SIZING消息,消息函数中做如下处理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | void CDemoDlg::OnSizing(UINT fwSide, LPRECT pRect) { if (pRect->right - pRect->left < minWidth_) { if (fwSide == WMSZ_LEFT || fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_BOTTOMLEFT) { pRect->left = pRect->right - minWidth_; } else pRect->right = pRect->left + minWidth_; } if (pRect->bottom - pRect->top < memHdcHeight_) { if (fwSide == WMSZ_TOP || fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_TOPRIGHT) { pRect->top = pRect->bottom - minHeight_; } else pRect->bottom = pRect->top + minHeight_; } CDialogEx::OnSizing(fwSide, pRect); } |