This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ClassA | |
| { | |
| public: | |
| static bool IsValidHandle( HANDLE handle ) | |
| { | |
| //return handle != INVALID_HANDLE_VALUE; | |
| return handle != INVALID_HANDLE_VALUE && handle != nullptr; | |
| //return handle != nullptr; | |
| } | |
| // ハンドルの複製をどうするかは何のハンドルかに依存するのでここでは言及しない |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // リソースファイル上はこんな感じで格納 | |
| // #define IDB_PNG 12345 | |
| // IDB_PNG PNG "res\\png.png" | |
| Gdiplus::Bitmap* LoadPngFromResource( HINSTANCE hInst, UINT resID ) | |
| { | |
| HRSRC hResInfo = FindResource( hInst, MAKEINTRESOURCE(resID), _T("PNG") ); | |
| HGLOBAL hResImage = LoadResource( hModule, hResInfo ); | |
| DWORD size = SizeofResource( hModule, hResInfo ); | |
| const BYTE* srcImage = static_cast<const BYTE*>( LockResource( hResImage ) ); | |
| IStreamPtr ptrStream( SHCreateMemStream( srcImage, size ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int RunMessageLoop() | |
| { | |
| MSG msg; | |
| while( GetMessage( &msg, nullptr, 0, 0 ) ) | |
| { | |
| TranslateMessage( &msg ); | |
| DispatchMessage( &msg ); | |
| } | |
| return msg.wParam; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int RunMessageLoop() | |
| { | |
| MSG msg; | |
| do{ | |
| if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) ) | |
| { | |
| if( msg.message != WM_QUIT && !PreTranslateMessage( &msg ) ) | |
| { | |
| TranslateMessage( &msg ); | |
| DispatchMesage( &msg ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int RunMessageLoop() | |
| { | |
| MSG msg = { 0 }; | |
| BOOL ret; | |
| while( (ret=GetMessage( &msg, nullptr, 0, 0 )) != 0 ) | |
| { | |
| if( ret == -1 ) | |
| { | |
| // 必要に応じてエラー処理を施す。場合によっては終了する | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <map> | |
| #include <functional> | |
| // waitActions に登録する例は載せていない(通常は、排他制御して追加処理するのが良い) | |
| std::map<HANDLE, std::function<bool(bool,bool&)>> waitActions; | |
| DWORD APIENTRY SetupWaitHandles( HANDLE* waitHandles, DWORD capacityCount ) | |
| { | |
| DWORD waitCount = 0; | |
| if( capacityCount > 0 ) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| local, | |
| object, | |
| uuid(00000000-0000-0000-C000-000000000046), | |
| pointer_default(unique) | |
| ] | |
| interface IUnknown | |
| { | |
| typedef [unique] IUnknown *LPUNKNOWN; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | |
| <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | |
| <application> | |
| <!-- Windows Vista --> | |
| <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" /> | |
| <!-- Windows 7 --> | |
| <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" /> | |
| <!-- Windows 8 --> | |
| <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void APIENTRY CountColors( CWnd* pParent, CListCtrl& lc, LPCTSTR imagePath, std::map<COLORREF, size_t>& numColors ) | |
| { | |
| // InsertItem するときに使う情報(コールバックでテキスト表示するのでデータはLPARAMだけ) | |
| LVITEM item{}; | |
| item.mask = LVIF_PARAM|LVIF_TEXT; | |
| // テキストデータはその都度生成する(メモリイメージ省略のため) | |
| item.cchTextMax = 0; | |
| item.pszText = LPSTR_TEXTCALLBACK; | |
| // メッセージポンプが動かない版 WM_SETCURSOR されるとマウスカーソルが戻るためメッセージポンプが動く場合はセットしない |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void CSampleDlg::OnOK() | |
| { | |
| // いろいろ前処理 | |
| CProgressDlg dlg; // 非同期処理で対応できるように修正したプログレス表示クラス | |
| auto task = concurrency::create_task( [&]() | |
| { | |
| return CountCharInFile( dlg, m_targetPath, m_numbers ); | |
| } ).then( [&]( bool result ) | |
| { | |
| dlg.PostMessage( WM_CLOSE ); |