Friday, May 15, 2015
Customized Batch for LEd
LEd Pre-Config.rar: User1 is the customized batch for compiling pdf through tex->dvi->ps->pdf. It runs bibtex also, and it cleans the output files at the end.
Preparing Chinese in LaTeX
\usepackage{CJKutf8}
\begin{CJK}{UTF8}{bsmi}
中文
\input{ChinesePage}
\end{CJK}
You may need a UTF8 text editor to edit Chinese. LEd cannot do it, but you may use other text editor (e.g., notepad++) to edit Chinese, and then use \input{} to include the words.
Use gbsn instead of bsmi for simplified Chinese.
\begin{CJK}{UTF8}{bsmi}
中文
\input{ChinesePage}
\end{CJK}
You may need a UTF8 text editor to edit Chinese. LEd cannot do it, but you may use other text editor (e.g., notepad++) to edit Chinese, and then use \input{} to include the words.
Use gbsn instead of bsmi for simplified Chinese.
Determine the class of an object at run time
For simplicity, in order to check the class of an derived object is the class I want by a parent object, we can use the code like this:
#include <typeinfo>
if (!strcmp(typeid(*obj).name(), "class MyClass")) printf("It is MyClass!\n");
more details on typeid Reference
#include <typeinfo>
if (!strcmp(typeid(*obj).name(), "class MyClass")) printf("It is MyClass!\n");
more details on typeid Reference
error MSB8031: Building an MFC project for a non-Unicode character set is deprecated. You must change the project property to Unicode or download an additional library.
It dues to the MFC support for multi-byte character set (MBCS) is deprecated in Visual Studio 2013, and it can be solved by installing the Multibyte MFC Library for Visual Studio 2013 in
http://www.microsoft.com/en-us/download/confirmation.aspx?id=40770
more details on Visual C++ Team Blog
http://www.microsoft.com/en-us/download/confirmation.aspx?id=40770
more details on Visual C++ Team Blog
fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt.
This error appear because you have installed higher version of Visual C++ while compiling a lower version (e.g., VC2010).
One easy way to solve this problem (for VC2010) is to rename C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe
more details on howtofix
One easy way to solve this problem (for VC2010) is to rename C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe
more details on howtofix
Get today date in dd/mm/yyyy
#include <time.h>
time_t now = time( &now ) ;
struct tm* local_time = new tm( ) ;
local_time = localtime( &now ) ;
char buffer[20] = { '\0' } ;
strftime( buffer, BUFSIZ, "%d/%m/%Y", local_time ) ;
delete local_time;
more details on strftime Reference
time_t now = time( &now ) ;
struct tm* local_time = new tm( ) ;
local_time = localtime( &now ) ;
char buffer[20] = { '\0' } ;
strftime( buffer, BUFSIZ, "%d/%m/%Y", local_time ) ;
delete local_time;
more details on strftime Reference
Easy way to count the processing time
#include <time.h>
clock_t time = clock();
...
time = clock()-time;
printf("time in seconds: %ds\n",time/CLOCKS_PER_SEC);
printf("time in milliseconds: %dms\n",time);
more details on clock
clock_t time = clock();
...
time = clock()-time;
printf("time in seconds: %ds\n",time/CLOCKS_PER_SEC);
printf("time in milliseconds: %dms\n",time);
more details on clock
Open a console window
AllocConsole(); //open the console window
freopen ("CONOUT$", "w", stdout); //set output available to this console
freopen("CONIN$","r",stdin); //set input avaiable to this console
more details on freopen Reference
freopen ("CONOUT$", "w", stdout); //set output available to this console
freopen("CONIN$","r",stdin); //set input avaiable to this console
more details on freopen Reference
Error: the application has failed to start because its side by side configuration is incorrect.
If you have met this error when you are running your distributed program in other machine,
One of the reasons is version mis-match. Someone may ask you to download the vcredist_x86.exe
from microsoft, but it maybe hard to find the right version.
Another method is to directly install the vcredist_x86.exe from your VC directory.
For VC 2005, probably the file is located at
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86\vcredist_x86.exe
just copy this file to antoher machine and install it, it will then solve the version problem.
more details on Redistributing Visual C++ Files
One of the reasons is version mis-match. Someone may ask you to download the vcredist_x86.exe
from microsoft, but it maybe hard to find the right version.
Another method is to directly install the vcredist_x86.exe from your VC directory.
For VC 2005, probably the file is located at
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86\vcredist_x86.exe
just copy this file to antoher machine and install it, it will then solve the version problem.
more details on Redistributing Visual C++ Files
Get System Window Resolution
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
more details on GetSystemMetrics Function
int cy = GetSystemMetrics(SM_CYSCREEN);
more details on GetSystemMetrics Function
List Directory
Get the header file "msdirent.h" from Internet or download here
you may put it in VC directory or just put it in your project folder.
Here is a sample program made by VC2005 to list out what is inside a directory. [download]
more details on C++ Forum
you may put it in VC directory or just put it in your project folder.
Here is a sample program made by VC2005 to list out what is inside a directory. [download]
more details on C++ Forum
Memory leak tracking for the "new" operator
Add these code on the top of the file that you would like to track memory leak in.
#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#endif
#define new DBG_NEW
#endif // _DEBUG
After that, debugger will displays memory leak information in the output window after the program finished.
#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#endif
#define new DBG_NEW
#endif // _DEBUG
After that, debugger will displays memory leak information in the output window after the program finished.
Get pointers in MFC
1) Get CApp in anywhere:
AfxGetApp();
2) Get CDoc in CView:
CYouSDIDoc *pDoc=GetDocument();
3) Get CMainFrame in CApp:
the variable m_pMainWnd in CWinApp
or in anywhere:
CMainFrame *pMain =(CMainFrame *)AfxGetMainWnd();
4) Get CMainFrame in CView:
CMainFrame *pMain=(CMaimFrame *)AfxGetApp()->m_pMainWnd;
5) Get CView:
CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;
CyouView *pView=(CyouView *)pMain->GetActiveView();
6) Get CDoc:
CDocument * pCurrentDoc =(CFrameWnd *)m_pMainWnd->GetActiveDocument();
7) Get CStatusBar and CToolBar:
CStatusBar * pStatusBar=(CStatusBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR);
CToolBar * pToolBar=(CtoolBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_TOOLBAR);
8) Get Menu in Mainframe:
CMenu *pMenu=m_pMainWnd->GetMenu();
AfxGetApp();
2) Get CDoc in CView:
CYouSDIDoc *pDoc=GetDocument();
3) Get CMainFrame in CApp:
the variable m_pMainWnd in CWinApp
or in anywhere:
CMainFrame *pMain =(CMainFrame *)AfxGetMainWnd();
4) Get CMainFrame in CView:
CMainFrame *pMain=(CMaimFrame *)AfxGetApp()->m_pMainWnd;
5) Get CView:
CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;
CyouView *pView=(CyouView *)pMain->GetActiveView();
6) Get CDoc:
CDocument * pCurrentDoc =(CFrameWnd *)m_pMainWnd->GetActiveDocument();
7) Get CStatusBar and CToolBar:
CStatusBar * pStatusBar=(CStatusBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR);
CToolBar * pToolBar=(CtoolBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_TOOLBAR);
8) Get Menu in Mainframe:
CMenu *pMenu=m_pMainWnd->GetMenu();
Subscribe to:
Posts (Atom)