OPが編集。
私のプログラムは、多くのクリーンアップと再構築を必要としています。
別の投稿で、MFC DocView フレームワークを離れて、WinProc とメッセージ ループの方法に移行することについて質問しました (略して何と呼ばれますか?)。現時点では、Doc View にあるものをクリーンアップし、後で非 MFC に変換する必要があると考えています。My Document クラスには現在、ほとんど役に立たないものがあります。
開始する場所は InitInstance() 関数 (以下に投稿) だと思います。
この部分では:
POSITION pos=pDocTemplate->GetFirstDocPosition();
CLCWDoc *pDoc=(CLCWDoc *)pDocTemplate->GetNextDoc(pos);
ASSERT_VALID(pDoc);
POSITION vpos=pDoc->GetFirstViewPosition();
CChildView *pCV=(CChildView *)pDoc->GetNextView(vpos);
これは私には奇妙に思えます。私は 1 つのドキュメントと 1 つのビューしか持っていません。GetNextDoc() と GetNextView() を使用して逆方向に進んでいるように感じます。ばかげた類推を使用しようとすること。手に本を持っているようなものですが、本のタイトルがどのページにあるかを調べるには、その索引を調べなければなりません。自分のコードを恥ずかしく思うのはうんざりです。修正または安心、あるいはその両方が必要です。:)
また、すべてのアイテムは順不同です。それらをより標準的で、構造化された、または簡単な順序に並べ替えたいと思います。
すべての提案を歓迎します!
BOOL CLCWApp::InitInstance()
{
InitCommonControls();
if(!AfxOleInit())
return FALSE;
// Initialize the Toolbar dll. (Toolbar code by Nikolay Denisov.)
InitGuiLibDLL(); // NOTE: insert GuiLib.dll into the resource chain
SetRegistryKey(_T("Real Name Removed"));
// Register document templates
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CLCWDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CChildView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCmdLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
// The window frame appears on the screen in here.
if (!ProcessShellCommand(cmdInfo))
{
AfxMessageBox("Failure processing Command Line");
return FALSE;
}
POSITION pos=pDocTemplate->GetFirstDocPosition();
CLCWDoc *pDoc=(CLCWDoc *)pDocTemplate->GetNextDoc(pos);
ASSERT_VALID(pDoc);
POSITION vpos=pDoc->GetFirstViewPosition();
CChildView *pCV=(CChildView *)pDoc->GetNextView(vpos);
if(!cmdInfo.m_Fn1.IsEmpty() && !cmdInfo.m_Fn2.IsEmpty())
{
pCV->OpenF1(cmdInfo.m_Fn1);
pCV->OpenF2(cmdInfo.m_Fn2);
pCV->DoCompare(); // Sends a paint message when complete
}
// enable file manager drag/drop and DDE Execute open
m_pMainWnd->DragAcceptFiles(TRUE);
m_pMainWnd->ShowWindow(SW_SHOWNORMAL);
m_pMainWnd->UpdateWindow(); // paints the window background
pCV->bDoSize=true; //Prevent a dozen useless size calculations
return TRUE;
}
ありがとう