Code/C C++ (18) 썸네일형 리스트형 Display Number on Tray Icon LRESULT CMainFrame::OnUserTray(WPARAM wParam, LPARAM lParam) { CMenu menu, *pSubMenu; if (LOWORD(lParam) == WM_LBUTTONDOWN) { CString str("369048"); CString str1 = str.Left(3); CString str2 = str.Right(3); LPTSTR pstr1 = str1.GetBuffer(str1.GetLength()); LPTSTR pstr2 = str2.GetBuffer(str2.GetLength()); LPWSTR wstr1 = new WCHAR[4]; LPWSTR wstr2 = new WCHAR[4]; int len1 = MultiByteToWideChar(CP_AC.. [C++/CLI] Marshalling : System::String^ <-> const char* #include #include using namespace System; using namespace msclr::interop; int main(array ^args) { { // System::String^ to const char* marshal_context^ context = gcnew marshal_context(); String^ message = gcnew String("System::String^ to const char*"); const char* result = context->marshal_as(message); puts(result); delete context; } { // const char* to System::String^ const char* message = "cons.. [C++] polymorphism.h #pragma once #include #include #include #ifdef _UNICODE #define tcout wcout #define tcin wcin #else #define tcout cout #define tcin cin #endif #ifdef _UNICODE #define tstring wstring #else #define tstring string #endif #ifdef _UNICODE #define tregex wregex #define tcmatch wcmatch #define tsmatch wsmatch #else #define tregex regex #define tcmatch cmatch #define tsmatch smatch #endif [C++] How to: Convert Between Various String Types 'CString' to 'std::string': CString cs("Hello"); std::string s((LPCTSTR)cs); 'std::string' to 'CString': std::string s("Hello"); CString cs(s.c_str()); 1. CString -> std::string CString str = "hello"; std::string stdStr = str.GetBuffer(0); 2. std::string -> CString std::string stdStr = "hello"; CString str = stdStr.c_str(); How to: Convert Between Various String Types http://msdn.microsoft.com/l.. [C++] vector shared_ptr sample #include #include #include #include #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { vector svec; svec.push_back(shared_ptr(new string("aaa"))); svec.push_back(shared_ptr(new string("bbb"))); svec.push_back(shared_ptr(new string("ccc"))); for(vector::iterator it = svec.begin(); it != svec.end(); it++) cout [MFC] Simplified MFC Structure MyFC.h #pragma once #include #include #ifndef AFXAPI #define AFXAPI __stdcall #endif //////////////////////////////////////// class CFrameWnd { public: CFrameWnd(); BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName); BOOL ShowWindow(int nCmdShow); void UpdateWindow(); private: HWND m_hWnd; }; //////////////////////////////////////// class CWinApp { public: CWinApp(); virtual BOOL InitIns.. [MFC] Simplest MFC Program #include class CMyWinApp : public CWinApp { public: BOOL InitInstance() { CFrameWnd *pFrameWnd = new CFrameWnd; m_pMainWnd = pFrameWnd; pFrameWnd->Create(0, TEXT("Hello")); // calls ::RegisterClass & ::CreateWindow pFrameWnd->ShowWindow(SW_SHOW); // calls ::ShowWindow pFrameWnd->UpdateWindow(); // calls ::UpdateWindow return TRUE; } }; CMyWinApp theApp; class CFrameWnd : public CWnd CFrameWnd::C.. [C++] Regular Expressions Class: regex #pragma once #include #include #include #include #include #ifdef _UNICODE #define tcout wcout #define tcin wcin #define tstring wstring #else #define tcout cout #define tcin cin #define tstring string #endif #ifdef _UNICODE #define tregex wregex #define tcmatch wcmatch #define tsmatch wsmatch #else #define tregex regex #define tcmatch cmatch #define tsmatch smatch #endif using namespace std; voi.. 이전 1 2 3 다음