ホーム » VC (ページ 13)
「VC」カテゴリーアーカイブ
「応答なし」になり難くする
//*******************************************************************************
// 関数名 :時間がかかる時に,応答なしにならない様にする
// 作成日 :’07/10/05
//*******************************************************************************
BOOL WaitPeek (void)
{
MSG msg ;
::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE) ;
return TRUE ;
}
//*******************************************************************************
// 関数名 :時間がかかる時に他に制御を回す
// 作成日 :’95/12/05
//*******************************************************************************
BOOL Wait (void)
{
MSG msg ;
for (int msgCnt=0 ; msgCnt < 1000 ; msgCnt++) {
if (::PeekMessage(&msg ,NULL,0,0,PM_REMOVE)) {
if (msg.message == WM_QUIT) {
return FALSE ;
}
::TranslateMessage(&msg) ;
::DispatchMessage(&msg) ;
continue ;
}
break ;
}
return TRUE ;
}
2011/11/02 追加
//*******************************************************************************
// 関数名 :時間がかかった時に,不要なイベントをスキップする
// 作成日 :’11/03/31
//*******************************************************************************
inline
BOOL EatMessage (const HWND wnd=NULL,const UINT skipWM=WM_TIMER)
{
MSG eatMsg;
while(::PeekMessage(&eatMsg,wnd,skipWM,skipWM,PM_REMOVE)) ;
return TRUE ;
}
Shell_NotifyIcon
http://support.microsoft.com/kb/418138/ja
マウスの位置の取得
BOOL ::GetCursorPos(LPPOINT lpPoint) ;
http://cid-535f5973454c1292.office.live.com/self.aspx/.Public/MFC/NotifyI.hxx.txt
タスクバーのドキュメント
mk:@MSITStore:X:MSDNShellcc.chm::/platform/Shell/Shell_Int/Taskbar.htm
http://msdn.microsoft.com/ja-jp/library/cc144179(VS.85).aspx
hdc が拡張メタファイルのデバイスコンテキスト?
hdc が拡張メタファイルのデバイスコンテキストかどうかを調べるには、GetObjectType 関数
GetDeviceCaps
GetObjectType
x86 プロジェクトの x64 へのコピー
VC 6 以前から使用しているプロジェクトを,64 ビット用にコピーしてビルドすると以下のエラーになることがある.
1>—— ビルド開始: プロジェクト: Project, 構成: Release x64 ——
1>.x64_R10ProjectA.obj : fatal error LNK1112: モジュールのコンピューターの種類 ‘x64’ は対象コンピューターの種類 ‘X86’ と競合しています。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========
「プロジェクトのプロパティページ」の「構成プロパティ」-「リンカ」-「コマンドライン」の「追加オプション」にある "/MACHINE:I386" を削除する.
MFC ファイルハンドラの登録で MSB3075
ビルド時に以下のエラーとなる.
—— ビルド開始: プロジェクト: ???Handlers, 構成: Debug Win32 ——
???Handlers.vcxproj -> C:\Users\???\Documents\Visual Studio 2010\Projects\???\Debug\???Handlers.dll
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(732,5): warning MSB3075: コマンド “regsvr32 /s “C:\Users\???\Documents\Visual Studio 2010\Projects\???\Debug\???Handlers.dll”” はコード 5 で終了しました。このコマンドを実行するための十分な権限があるか確認してください。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(744,5): error MSB8011: 出力の登録に失敗しました。ユーザーごとのリダイレクトを有効にするか、引き上げられたアクセス許可を使用して、コマンド プロンプトからコンポーネントを登録してください。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========
VS 2010 を「管理者として実行」して起動する.
または,「管理者として実行」した「コマンドプロンプト」での「RegSvr32」.
通常の「コマンドプロンプト」では以下のエラーとなる.
[Window Title]
RegSvr32
[Content]
モジュール “C:\Users\???\Documents\Visual Studio 2010\Projects\???\Debug\???Handlers.dll” は読み込まれましたが、DllRegisterServer への呼び出しはエラー コード 0x80070005 により失敗しました。
この問題の詳細については、エラー コードを検索語として入力してオンラインで検索してください。
VC6 , VC8 リモートデバッグ
VC6
mk:@MSITStore:J:MSDNvccore.chm::/html/_core_setting_up_the_remote_debug_monitor.htm
http://support.microsoft.com/kb/241848/ja
https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/241848
以下のファイルをターゲット PC にコピー
1998-07-06 | 00:00 | 24,651 | MSVCMON.EXE |
2004-02-27 | 00:00 | 106,566 | DM.DLL |
2000-07-15 | 00:00 | 184,320 | MSDIS110.DLL |
2008-04-14 | 11:25 | 413,696 | MSVCP60.DLL |
2004-02-17 | 00:00 | 278,581 | MSVCRT.DLL |
2000-07-15 | 00:00 | 28,746 | TLN0T.DLL |
VC7
ms-help://MS.VSCC/MS.MSDNVS.1041/vsdebug/html/vctskInstallingRemoteDebugMonitor.htm
http://msdn.microsoft.com/ja-jp/library/aa291492(VS.71).aspx
C:\Program Files\Microsoft Visual Studio .NET\Common7\Packages\Debugger\
msvcmon.exe
msvcr70.dll
NatDbgTLNet.dll
NatDbgDM.dll
デバッグを開始できません.
プログラム ” を開始できません。
現在のユーザーのコンテキストで実行中のリモート コンピュータに MSVCMON がありません。
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Machine Debug Manager]
"AllowLaunchAsOtherUser"=dword:00000001
うまく起動できない.
VC8
http://msdn.microsoft.com/ja-jp/library/ey7ec813.aspx
http://msdn.microsoft.com/ja-jp/library/ey7ec813(VS.80).aspx
http://msdn.microsoft.com/ja-jp/library/bt727f1t(VS.80).aspx
MSVSMon.exe
DbgHelp.dll
MSDbgUI.dll
http://support.microsoft.com/kb/908099/ja
VC9
http://msdn.microsoft.com/ja-jp/library/bt727f1t.aspx
http://msdn.microsoft.com/ja-jp/library/bt727f1t(VS.100).aspx
MSVSMon.exe
VC7 マルチバイト→UNICODE
マルチバイトから UNICODE への変更で以下のエラーになることがある.
libcmtd.lib(wwincrt0.obj) : error LNK2019: 未解決の外部シンボル _wWinMain@16 が関数 _wWinMainCRTStartup で参照されました。
*.vcproj をエディタで開き,"$(NoInherit)" を削除.
VS 6 の SP の確認
VS 6 の SP の確認
http://support.microsoft.com/kb/316915/ja
https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/316915
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\6.0\ServicePacks
Ver. | SP | MFC | MSC | |
VS 6 | VC 6 | 6 | 0x0600 | 1200 |
VS .net | VC 7 | 1 | 0x0700 | 1300 |
VS 2003 | VC 7.1 | 1 | 0x0710 | 1310 |
VS 2005 | VC 8 | 1 | 0x0800 | 1400 |
VS 2008 | VC 9 | 1 | 0x0900 | 1500 |
複数のツールバーを横に並べて作成
//******************************************************************************* // 関数名 :ツールバーの作成の後処理 // 作成日 :’05/06/16 // 変更日 :’07/04/06 //******************************************************************************* // MFC\General\DockTool\MainFrm.cpp DockControlBarLeftOf より BOOL ToolBar::CreateDocking ( CFrameWnd* frameW, CToolBar* toolBar, UINT idr, CString title, UINT barID, CToolBar* last, const BOOL canFloat // フローティング可能かどうか ) { toolBar->SetWindowText(title) ; // ウィンドウタイトルの設定 // toolBar->SetBarStyle(toolBar->GetBarStyle()|CBRS_TOOLTIPS|CBRS_FLYBY) ; // ツール チップなどの付加 toolBar->EnableDocking(CBRS_ALIGN_ANY) ; // ドッキング可能に Resize(toolBar,idr) ; // ツールバーのリサイズ { // ツールバーの位置を決定する static CToolBar* LastToolBar = NULL ; // 前のツールバーの位置 if (last != NULL) { LastToolBar = last ; } // 前のツールバーが指定された if (LastToolBar == NULL || barID != 0) { CControlBar* pDockBar = frameW->GetControlBar(barID) ; if (pDockBar != NULL && canFloat) { frameW->DockControlBar(toolBar,barID) ; } } else { frameW->RecalcLayout() ; CRect rect ; LastToolBar->GetWindowRect(&rect); rect.OffsetRect(1,1); DWORD dw = LastToolBar->GetBarStyle(); UINT tBarID = 0 ; tBarID = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : tBarID ; tBarID = (dw&CBRS_ALIGN_BOTTOM && tBarID==0) ? AFX_IDW_DOCKBAR_BOTTOM : tBarID ; tBarID = (dw&CBRS_ALIGN_LEFT && tBarID==0) ? AFX_IDW_DOCKBAR_LEFT : tBarID ; tBarID = (dw&CBRS_ALIGN_RIGHT && tBarID==0) ? AFX_IDW_DOCKBAR_RIGHT : tBarID ; CControlBar* pDockBar = frameW->GetControlBar(tBarID) ; if (pDockBar != NULL && canFloat) { frameW->DockControlBar(toolBar,tBarID,&rect) ; } } LastToolBar = toolBar ; // 次のツールバーの位置を求めるために保存しておく } return TRUE ; }
http://cid-535f5973454c1292.skydrive.live.com/embedicon.aspx/.Public/MFC/ToolBar.hxx
ToolBar.hxx
2025/02/07 内容が古かったのと,不足していたため修正
MainFrm.h
class CMainFrame : public CFrameWnd
{
// ...
protected: // コントロール バー用メンバ
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
/////////////////////////////////////////////////////////////
CToolBar m_wndToolZoom ; // 拡大/縮小のツールバー
CToolBar m_wndToolEye1 ; // 視点変更のツールバー
CToolBar m_wndToolEye2 ; // 視点変更のツールバー
CToolBar m_wndToolEye3 ; // 視点変更のツールバー
CToolBar m_wndToolEye4 ; // 視点変更のツールバー
CToolBar m_wndToolEye5 ; // 視点変更のツールバー
CToolBar m_wndToolExp1 ;
CToolBar m_wndToolExp2 ;
CToolBar m_wndToolExp3 ;
/////////////////////////////////////////////////////////////
// ...
} ;
MainFrm.cpp
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
#ifdef _____
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // 作成に失敗
}
#endif
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // 作成に失敗
}
// TODO: ツール バーをドッキング可能にしない場合は以下の3行を削除してください。
// m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
// DockControlBar(&m_wndToolBar);
// 標準のツールバーの作成
if (!CreateToolBar(this,&m_wndToolBar, IDR_MAINFRAME,_T("標準"), AFX_IDW_DOCKBAR_TOP)) { return -1 ; }
/////////////////////////////////////////////////////////////
// if (!CreateToolBar(this,&m_wndToolZoom,IDR_TOOL_ZOOM,_T("拡大/縮小"), 0, &m_wndToolBar)) { return -1 ; }
if (!CreateToolBar(this,&m_wndToolEye1,IDR_TOOL_EYE1,_T("固定視点"), AFX_IDW_DOCKBAR_LEFT)) { return -1 ; }
// if (!CreateToolBar(this,&m_wndToolEye2,IDR_TOOL_EYE2,_T("視点変更"))) { return -1 ; }
// if (!CreateToolBar(this,&m_wndToolEye3,IDR_TOOL_EYE3,_T("視点移動"), 0, &m_wndToolBar)) { return -1 ; }
if (!CreateToolBar(this,&m_wndToolEye4,IDR_TOOL_EYE4,_T("アイソメ視点"),0, &m_wndToolEye1)) { return -1 ; }
// if (!CreateToolBar(this,&m_wndToolEye5,IDR_TOOL_EYE5,_T("目標点移動"), 0, &m_wndToolEye2)) { return -1 ; }
if (!CreateToolBar(this,&m_wndToolExp1,IDR_TOOL_EXP1,_T("出力1"), 0, &m_wndToolBar)) { return -1 ; }
if (!CreateToolBar(this,&m_wndToolExp2,IDR_TOOL_EXP2,_T("出力2"), 0, &m_wndToolExp1)) { return -1 ; }
if (!CreateToolBar(this,&m_wndToolExp3,IDR_TOOL_EXP3,_T("出力3"), 0, &m_wndToolExp2)) { return -1 ; }
/////////////////////////////////////////////////////////////
// ...
return 0;
}