モードレスダイアログの動作が,…
VC 7 以降,MDI AP のモードレスダイアログが独立して動作してしまう現象があった.
その AP は,VC 4 の頃作成したもので CMainFrame::OnCreate 内でモードレスダイアログを作成している.
VC 6 までは特に問題なかったが,VC 7 以降タスクバーにアイコンが 2 つ存在する状態になってしまっていた.
過去に何度か対応方法を調べたが,わからずそのままとなっていた.
今日別の事を調べていて,「モードレスダイアログで親子にならなくする」方法が目に留まった.
CDialog::Create で,デフォルトの NULL ではなく,GetDesktopWindow() を与えるというもの.
VC 7 AP のダイアログの情報を,Spy++ で見ると,親ウィンドウが (なし) になっている.
今度はデバッガで,Create の付近を追いかけると AfxGetMainWnd() で NULL がかえっている.
ThrdCore.cpp より
CWnd* CWinThread::GetMainWnd()
{
if (m_pActiveWnd != NULL)
return m_pActiveWnd;
if (m_pMainWnd != NULL)
return m_pMainWnd;
return CWnd::GetActiveWindow();
}
CXxxApp::InitInstance で以下の部分を修正.
CMainFrame* pMainFrame = new CMainFrame;
m_pMainWnd = pMainFrame; // ここを追加
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
CSplitterWnd – 2
SDI で,MDI の「新しいウィンドウを開く」で 4 つのビューを表示した様な動作が欲しかったので,調べてみた.
動的な分割ウィンドウである程度の所まではできそう.
1. MainFrm.h の CMainFrame に以下を追加. CSplitterWnd m_wndSplitter; virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); 2. CMainFrame::OnCreateClient の追加. BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { { if (!m_wndSplitter.Create(this,2, 2,CSize(10, 10), pContext, WS_CHILD | WS_VISIBLE /* | WS_HSCROLL | WS_VSCROLL */ | SPLS_DYNAMIC_SPLIT)) { TRACE0("Failed to create split bar "); return FALSE; } return TRUE; } } スクロールバーを付加したくなかったので,6 つ目のウィンドウスタイルを変更している. テスト用に分割動作をコマンドとして実装. void CMainFrame::OnSplit() { if (IsSplit) { if (m_wndSplitter.GetColumnCount() > 1) { m_wndSplitter.DeleteColumn(1) ; } if (m_wndSplitter.GetRowCount() > 1) { m_wndSplitter.DeleteRow (1) ; } IsSplit = !IsSplit ; } else { CRect rect ; m_wndSplitter.GetClientRect(&rect) ; if (m_wndSplitter.GetColumnCount() == 1) { m_wndSplitter.SplitColumn(rect.Width ()/2) ; } if (m_wndSplitter.GetRowCount() == 1) { m_wndSplitter.SplitRow (rect.Height()/2) ; } IsSplit = !IsSplit ; } }
2 x 2 の分割ウィンドウのコントロールの ID (Spy++ で確認)
左上(0,0) E900 AFX_IDW_PANE_FIRST
右上(0,1) E901
左下(1,0) E910
右下(1,1) E911
ビューの OnDraw を以下の様に書き換えると
void CSpltWView::OnDraw(CDC* pDC) { int row = -1 ; int clm = -1 ; CMainFrame* mw = (CMainFrame*)AfxGetMainWnd() ; CSplitterWnd* sw = &mw->m_wndSplitter ; CString str ; if (sw->IsChildPane(this,&row,&clm)) { int id = sw->IdFromRowCol(row,clm) ; CString tmp1 ; tmp1.Format(_T("row = %d , clm = %d"),row,clm) ; CString tmp2 ; tmp2.Format(_T("IdFromRowCol = %04X"), id) ; str += tmp1 + _T("\r\n") ; str += tmp2 + _T("\r\n") ; } { UINT nID = GetDlgCtrlID() ; CString tmp ; tmp.Format(_T("GetDlgCtrlID = %04X"),nID) ; str += tmp + _T("\r\n") ; } { CWnd* pw = GetParent() ; CString tmp1 ; tmp1.Format(_T("Splitter = %08x "),sw->GetSafeHwnd()) ; CString tmp2 ; tmp2.Format(_T("Parent = %08x "),pw->GetSafeHwnd()) ; str += tmp1 + _T("\r\n") ; str += tmp2 + _T("\r\n") ; } CRect rect ; GetClientRect(rect) ; rect.top = rect.left = 10 ; pDC->DrawText(str,rect,0) ; }
MFC の ソースを眺めていると CView::GetParentSplitter があったので,間接的にはそれを使えば良さそう.
ビューでどの位置かを求めるだけなら, short texNo = 0 ; { UINT nID = GetDlgCtrlID() ; switch (nID) { case AFX_IDW_PANE_FIRST + 0x00 : texNo = 1 ; break ; case AFX_IDW_PANE_FIRST + 0x01 : texNo = 2 ; break ; case AFX_IDW_PANE_FIRST + 0x10 : texNo = 3 ; break ; case AFX_IDW_PANE_FIRST + 0x11 : texNo = 4 ; break ; } }
‘THIS_FILE’ がシンタックスエラーを…
今まで通っていたプロジェクトで,
ComPrj03.cpp
c:\…\memory(16) : error C2061: 構文エラー : 識別子 ‘THIS_FILE’ がシンタックスエラーを起こしました。
c:\…\memory(17) : error C2091: 関数は関数を返せません。
c:\…\memory(17) : error C2809: ‘operator new’ に仮引数リストがありません。
c:\…\memory(20) : error C2954: テンプレートの定義はネストできません。
cl.exe の実行エラー
ComPrj03.obj – エラー 4、警告 0
ソースの先頭付近に #include <memory> を追加.
#include “StdAfx.h”
#include “ComPrj00.hpp”
#include <memory>
2019/01/18
--------------------構成: MkZIP2 - Win32 Release-------------------- コンパイル中... MkZIP2.cpp リンク中... MkZIP2.exe - エラー 0、警告 0 --------------------構成: MkZIP2 - Win32 Debug-------------------- コンパイル中... MkZIP2.cpp c:\program files\microsoft visual studio\vc98\include\memory(16) : error C2061: 構文エラー : 識別子 'THIS_FILE' がシンタックスエラーを起こしました。 c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2091: 関数は関数を返せません。 c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2809: 'operator new' に仮引数リストがありません。 c:\program files\microsoft visual studio\vc98\include\memory(20) : error C2954: テンプレートの定義はネストできません。 cl.exe の実行エラー MkZIP2.exe - エラー 4、警告 0
#include “stdafx.h”
#include “MkZIP2.h”
#include <ShlObj.h>
#import <Shell32.dll> // named_guids
//#include <memory>
エラーになるのはデバッグ版のビルド.リリース版では通る.
#include <memory> を有効に.
2023/03/24
#define new DEBUG_NEW より後にインクルードしているとうまくない error C2061 , C2091 , C2809 , C2556
時刻の同期
6/20 に HDL-Z2WM2C2 を追加した.
ソースファイルの保管のサーバとしての利用で,Win7 USB 2 HDD と比べても遜色ない.
ひとつ気になることが,思っていたよりファンの音がうるさい.
先日,クライアントの PC と WSS で,時間が少しずれていたので time.windows.com で時刻を合わせた.
今日時刻を見てみると 10 秒位の差ができてしまっている.
もう少し精度が欲しかったので検索すると,
インターネット時刻機能のポーリング間隔を調整する方法
Windowsの時計がずれる / 自動で正確に合わせる小技 (Windows 7/8.1編)
これらを参考にさせてもらって,1 日に 1 回程度の設定とした.
Polymorphism
class iDocCSV1 : public iDocText {
…
virtual long GetFieldNo (c_tstring& fieldName) const { return FNoNOP ; }
…
} ;
c_tstring fieldName となっていた.
TextureTo_1::MakeCSV1 でタプルクォーテーションでうまく括られない.閉じる ‘\”‘ が付加されない.
da.push_back(::QuotM_Add_Auto( GetPath () ) ;
原因はよくわかってないが,LPCTSTR 版を利用することで対応.
da.push_back(::QuotM_Add_Auto( GetPath ().c_str()) ) ;
MakeCSV1 を切り出してコンソール AP としてテストしたが,期待した動作となり原因は掴めてない.
2014/06/25
また次の様なコードで,STL 版ではうまく動作していない.
{
tstring str ;
str += tt1->GetName() + _T(“\r\n”) ;
str += tt1->GetPath() + _T(“\r\n”) ;
str += tt1->GetPathPNG()+ _T(“\r\n”) ;
str += tt1->GetPathTGA()+ _T(“\r\n”) ;
m_TexPath1 = str.c_str() ;
}
MFC 版では OK .
{
CString str ;
str += tt1->GetName ().c_str() + CString(_T(“\r\n”)) ;
str += tt1->GetPath ().c_str() + CString(_T(“\r\n”)) ;
str += tt1->GetPathPNG ().c_str() + CString(_T(“\r\n”)) ;
str += tt1->GetPathTGA ().c_str() + CString(_T(“\r\n”)) ;
m_TexPath1 = str ;
}
2014/06/27
また,::String_Join_Line でうまく結合されなかった.
デバッガで調べると,サイズは確保されいる.メモリの内容をよーく見てみると,途中に ” が入っている.
原因は,MFC を利用しない方法で書き直した ::DropFilesTo のバグ.
ファイル名の最後に余分な ‘\0’ が付加されていた.
VC 6 MFC サポートのコンソール AP で,C4786
c:\program files\microsoft visual studio\vc98\include\utility(123) :
warning C4786: ‘std::vector<std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >,std::allocator<std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > >’ :
デバッグ情報で識別子が 255 文字に切り捨てられました。
StdAfx.h の #include <iostream> より前に,以下を追加して対応.
#pragma warning (disable : 4786 ) #include <utility> // #pragma warning (default : 4786 )
MFC DLL → Static – 2
VC 6 などで生成したプロジェクトを,VC 7 ~ VC 11 まで順に変換して利用してきたもの.
「共有 DLL で MFC を使う」から「スタティック ライブラリで MFC を使用する」に変更してビルドすると,
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\afx.h(24):
fatal error C1189: #error : Building MFC application with /MD[d]
(CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
プロジェクトの「プロパティページ」-「構成プロパティ」-「C/C++」-「コード生成」-「ランタイム ライブラリ」を
「マルチスレッド DLL (/MD)」から「マルチスレッド (/MT)」に変更.
ビルドは通る様になったが,起動時メインフレーム表示直後にアプリケーションエラー.
プロジェクトのプロパティで,「リンカ」-「デバッグ」-「デバッグ情報の生成」で「はい (/DEBUG)」に.
ビルドして実行すると,
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\mfc\docsingl.cpp
CSingleDocTemplate::SetDefaultTitle(CDocument* pDocument) の
ENSURE(strDocName.LoadString(AFX_IDS_UNTITLED));
プロジェクトのプロパティ,「リソース」-「プリプロセッサの定義」に “_AFXDLL;” があったので削除.
2021/02/17
VC 7 以降に変換した段階で,ソースの「プリプロセッサの定義」が引き継がれてしまう?
そのため,それは削除した方が良さそう.
* 間違ってプロジェクトの「プリプロセッサの定義」を削除しないこと.
VC 12 LNK1104 , VC 14.2 LNK2019
NICONI SOLID
ニコニ立体で表示可能な OBJ のメモ
データは 100x100x100 の立方体.Cube_obj.zip
いろいろいじってたら,立方体があるのはわかる様になった.
(背景の色を指定して,スケーリングを 0.1 ,視野角を大きく)
どうも,大きすぎる様なので -1 ~ 1 の範囲の立方体に編集.Cube_2.zip
テクスチャがうまく張り付かないので,OBJ や MTL をいろいろ編集…
MTL 内の newmtl とそれに続く名称との間のスペースが 1 つでないとうまくないみたい.Cube_3.zip
はっきりわからないが,4 を超える多角形の面が表示できない?
Win7 srv 2021
VirtualPC の Win 7 で,
ログの名前: System
ソース: srv
日付: 2014/04/25 10:33:13
イベント ID: 2021
タスクのカテゴリ: なし
レベル: 警告
キーワード: クラシック
ユーザー: N/A
コンピューター: DevS
説明:
サーバーは 60 秒間に 1 回、作業項目を割り当てることができませんでした。
検索すると,イベント ID 2021 およびイベント ID 2022 のトラブルシューティング方法.
メモリを 512 M だったのを 1024 に.
同じ様な状況下で 2021 は出ていないので,ひとまず様子見.
2014/05/22 追記
頻度はかなり減ったが,5/19 ~ 5/21 で何度かログが残っている.
VC 11 , 12
AtlGetCommCtrlVersion が,GetCommCtrlVersion になっている.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlbase.h 7505:
inline HRESULT AtlGetCommCtrlVersion(
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\mfc\winutil.cpp 243:
HRESULT GetCommCtrlVersion(
VC 12 の標準のインストールでは MBCS.exe が作成できない.
MSDN マルチバイト文字セット (MBCS) のサポート
—— ビルド開始: プロジェクト:ccVer, 構成:Debug Win32 ——
ccVer.cpp
_WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
c:\program files\windows kits\8.1\include\um\winnt.h(340):
error C2146: 構文エラー : ‘;’ が、識別子 ‘PVOID64’ の前に必要です。
c:\program files\windows kits\8.1\include\um\winnt.h(340):
error C4430: 型指定子がありません – int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
c:\program files\windows kits\8.1\include\um\winnt.h(12333):
error C2146: 構文エラー : ‘;’ が、識別子 ‘Buffer’ の前に必要です。
c:\program files\windows kits\8.1\include\um\winnt.h(12333):
error C4430: 型指定子がありません – int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========
DX90SDK\Include が含まれていたのが原因.
c:\program files\microsoft visual studio 12.0\vc\include\xtgmath.h(206):
warning C4003: マクロ ‘round’ に指定された実引数の数が少なすぎます。
c:\program files\microsoft visual studio 12.0\vc\include\xtgmath.h(206):
error C2059: 構文エラー : ‘(‘
c:\program files\microsoft visual studio 12.0\vc\include\xtgmath.h(206):
error C2062: 型 ‘double’ は不要です。
c:\program files\microsoft visual studio 12.0\vc\include\xtgmath.h(224):
fatal error C1070: ソース ファイル ‘c:\…\vc\include\xtgmath.h’ 中で #if と #endif が対応していません。
Scale.hxx 等に定義されている #define round(v,p) … が影響していると思われる.
C99 になったことによる影響?
_MSC_VER はソースの先頭でも定義されているが,_MFC_VER は Afx.h の後でないと正しく取れない?
よく考えれば当然のこと?
MFC 11 で CFileStatus が変更された.
MFC 10 では, struct CFileStatus { CTime m_ctime; // creation date/time of file CTime m_mtime; // last modification date/time of file CTime m_atime; // last access date/time of file ULONGLONG m_size; // logical size of file in bytes BYTE m_attribute; // logical OR of CFile::Attribute enum values BYTE _m_padding; // pad the structure to a WORD TCHAR m_szFullName[_MAX_PATH]; // absolute path name #ifdef _DEBUG void Dump(CDumpContext& dc) const; #endif }; MFC 11 struct CFileStatus { CTime m_ctime; // creation date/time of file CTime m_mtime; // last modification date/time of file CTime m_atime; // last access date/time of file ULONGLONG m_size; // logical size of file in bytes DWORD m_attribute; // logical OR of CFile::Attribute enum values TCHAR m_szFullName[_MAX_PATH]; // absolute path name #ifdef _DEBUG void Dump(CDumpContext& dc) const; #endif };
Visual Studio 2012 の更新プログラムの概要
Visual Studio 2012 の更新プログラム 4
Download Center Visual Studio 2012 Update 4
VC 2012 で作成した exe は,Win XP で実行できない?
Visual Studio 2012 で Windows XP をターゲットとする Visual C++ アプリケーションを作成する方法
Wikipedia Microsoft Visual C++
Visual Studio 2012 更新プログラム 4 の Visual C++ 再頒布可能パッケージ
Visual Studio 2013 の Visual C++ 再頒布可能パッケージ
プロジェクトをサーバにコピーして,VC 8 でビルドすると
cl : コマンド ライン error D8022 : ‘\\devs\…\ArcEdit\Debug.080\RSP0000264523920.rsp’ を開けません
ローカルのプロジェクトは OK.
また,VC 6 なども C2039 はあるが,それなりに通る.
\\devs\…\helpvsty.hxx(57) : error C2039: ‘AtlGetCommCtrlVersion’ :
‘`global namespace” のメンバではありません。
これは,#define GetCommCtrlVersion AtlGetCommCtrlVersion としている所を,関数にして回避.
… GetCommCtrlVersion (…) { return AtlGetCommCtrlVersion (…) ; }
VC 7.1 と VC 8 で,ネットワーク上のプロジェクトをビルドするとうまくない様なので,中間ファイルの指定を変更.
.\$(ConfigurationName) を c:\Temp\$(ProjectName)\$(ConfigurationName) としてみた.
これにより,rsp や obj などが C:\Temp\…\Debug\ 以下になりうまく通る.
検索すると,.\$(ConfigurationName)\ の様に最後に ‘\’ を付ければ通るとのこと.
Error D8022 – can’t open .RSP file
2014/04/17
今までバックアップを取ったりする時に不要なファイルを消していたが,プロジェクトの設定などを変更してみた.
中間ディレクトリとデバッグ版の出力ディレクトリを c:\Temp\$(ProjectName)\$(ConfigurationName)\ に.
VC 10 以降で,フォールバック位置を指定(sdf , ipch の位置の指定).
VC 11 で,
LibHasp_Windows.lib(wurzl37.obj) : error LNK2026: モジュールは SAFESEH イメージには安全ではありません。
「リンカ」-「詳細設定」-「安全な…」の「はい (/SAFESEH)」をクリア.
C1083 msxml.dll
WinXP + VC 2005 環境のプロジェクトを,Win7 + VC 2008 でビルドすると,
\\devxp\…\xml_ms_.hxx(15) : fatal error C1083: タイプ ライブラリ ファイルを開けません。
‘msxml.dll’: No such file or directory
検索すると,
XML file parsing in Visual Studio 2008 & Windows 7
2014/08/19 追記
Win8 + VC 2012 でビルドすると
\\DevS\…\Xml_MS_.hxx(329): error C2039: ‘CLSID_DOMDocument’ : ‘MSXML2’ のメンバーではありません。
これで良いのかはわかってないが,#define CLSID_DOMDocument CLSID_DOMDocument60 を追加.
#if (_WIN32_WINNT >= 0x0600)
#import <msxml6.dll> named_guids
#define MSXML MSXML2
#define CLSID_DOMDocument CLSID_DOMDocument60
#else
#import <msxml.dll> named_guids
#endif
2019/06/29 Win10 VC 2005 で C1083 msxml.dll
2019/01 C++ と STL の範囲で書き直し
three.js
three.js の動作環境の作成のメモ
three.js の左の github から.
Usage の Download the minified library and …. の minified library を右クリックするなどしてダウンロード.
C:\Users\Public\Documents\WebGL\Three_js\three.min.js として保存.
This code creates a scene, …… in the document.body element. の下のスクリプトを Test3js.htm などとして保存.
その html の前の方と後ろの方を編集.
<!DOCTYPE html>
<html lang=”ja”>
<head><meta charset=”UTF-8″></head>
<body>
<script src=”three.min.js”> </script>
<script>
var camera, scene, renderer;
…
function init() {
…
renderer.render( scene, camera );
}
</script>
</body>
</html>
iPhone 3D – 5
110 ページまでやってのエラー.
/…/S_Wire/ApplicationEngine.cpp:57:14: Assigning to ‘ISurface *’ from incompatible type ‘Cone *’
…
/…/S_Wire/ApplicationEngine.cpp:62:14: Assigning to ‘ISurface *’ from incompatible type ‘MobiusStrip *’
ParametricSurface.hpp の ParametricSurface の定義で public ISurface が抜けていた.
ApplicationEngine.cpp::: Reference to type ‘const std::vector’ could not bind to an rvalue of type ‘Visual *’
どうも,107 ページで与えているのが Visual になってるが,vector<Visual> となる様に変更.
void ApplicationEngine::Render () const {
vector<Visual> visuals ;
Visual visual ;
visual.Color = m_Spinning ? vec3(1,1,1) : vec3(0,1,1) ;
visual.LowerLeft = ivec2(0,48) ;
visual.ViewportSize = ivec2(320,432) ;
visual.Orientation = m_Orientation ;
// m_RenderingEngine->Render(&visual) ;
visuals.push_back(visual) ;
m_RenderingEngine->Render(visuals) ;
}
今度はリンクエラー “ES1::CreateRenderingEngine()”, referenced from:
これは,タイプミス.e が抜けている.
IRenderingEngine* CreateRenderingEngine () {
return new RenderingEngine() ;
}
頂点法線の計算
今まで GL_FLAT で処理していたので面の法線を利用していた.
そのため,既に法線の情報が設定されたデータでうまく表示できてないものがあった.
glShadeModel(GL_SMOOTH) として,頂点に対して法線を設定することによりそれなりに表示する様にはなった.
これらのデータの様に,頂点の法線を求める必要が出てきた.
ここ(スムージング角度)を参考にさせてもらい,何とかそれなりに表示できる様になった.
GeForce GT 630 に変更
T5400 のグラフィックボードを Quadro FX 570 から GeForce GT 630 に変更.
サウンドデバイスが見つからない状態になり,音が出なくなった.
セットアップ時だったか,ボードのサウンド機能を利用する様な表示があった様な?
音が出ないことはそれほど問題ないと思っていたが,Skype などが出来ない.
それとは別の要因だが CD ドライブが開かなくなってしまった.以前から調子が悪かった.
グラフィックのドライバを何とか入れ直し,設定などを見たが,特に設定はなさそう.
検索すると,BIOS の設定で回避できるとある.
Auto から On にして,再起動.
すると,音は出る様になったが,表示が…
さらに再起動して,それなりの動作となった.