
如圖,我想要在基于對話框的MFC程式實作可停靠的浮動視窗。現在實作的情況是:在主對話框呼叫派生自CFrameWndEx的MainFrame類然后create。然后主對話框、MainFrame同時都在,
這時候應該把主對話框隱藏了還是把MainFrame貼到主對話框里?請問該怎么做?因為主對話框還要做別的控制元件操作之類的。
還有這種情況關閉程式會報很多錯,該怎么辦?
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp(136) : AppMsg - Warning: calling DestroyWindow in CDialog::~CDialog --
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp(137) : AppMsg - OnDestroy or PostNcDestroy in derived class will not be called.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp(815) : AppMsg - Warning: calling DestroyWindow in CWnd::~CWnd; OnDestroy or PostNcDestroy in derived class will not be called.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp(815) : AppMsg - Warning: calling DestroyWindow in CWnd::~CWnd; OnDestroy or PostNcDestroy in derived class will not be called.
0x10340F6C (mfc120ud.dll) (DOCKDLG_DLG.exe 中)處的第一機會例外: 0xC0000005: 讀取位置 0x00000001 時發生訪問沖突。
0x10340F6C (mfc120ud.dll) (DOCKDLG_DLG.exe 中)處有未經處理的例外: 0xC000041D: 用戶回呼期間遇到未經處理的例外。。
HEAP[DOCKDLG_DLG.exe]: Invalid address specified to RtlValidateHeap( 011F0000, 0104EFD8 )
DOCKDLG_DLG.exe 已觸發了一個斷點。
Debug Assertion Failed!
Program: D:\priject\DOCKDLG_DLG\Debug\DOCKDLG_DLG.exe
File: f:\dd\vctools\crt\crtw32\misc\dbgheap.c
Line: 1322
Expression: _CrtIsValidHeapPointer(pUserData)
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
Detected memory leaks!
Dumping objects ->
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxvisualmanagerwindows.cpp(35) : {266} client block at 0x01212EB0, subtype c0, 348 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CMFCVisualManagerWindows object at $01212EB0, 348 bytes long
d:\priject\dockdlg_dlg\dockdlg_dlg\dockdlg_dlg.cpp(59) : {166} client block at 0x011F6138, subtype c0, 12 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $011F6138, 12 bytes long
{165} client block at 0x01207840, subtype c0, 204 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $01207840, 204 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : {159} normal block at 0x01207610, 90 bytes long.
Data: < $ $ > A0 D7 B4 0F 24 00 00 00 24 00 00 00 01 00 00 00
Object dump complete.
這個功能有沒有大佬實作過?可不可以給個原始碼學習下啊?
https://bbs.csdn.net/topics/398058778
這是我上一篇帖子,自己回復不了了,所以另外開新帖
uj5u.com熱心網友回復:
還是我本來這種想給基于對話框加浮動視窗的想法就是錯的?uj5u.com熱心網友回復:
那個 CMyframe 的父視窗是 對話框 。大小要 小于 對話框 !uj5u.com熱心網友回復:
if (!m_mainFrame.Create(NULL, _T("TEST"), WS_OVERLAPPEDWINDOW, CRect(0, 0, 100, 100)))
{
TRACE0("未能創建輸出視窗/n");
return FALSE;
}
請問這個CMyframe的Create怎樣創建成子視窗呢?
uj5u.com熱心網友回復:
m_pMyFrame = new CFrameWnd;m_pMyFrame->Create(0,"", WS_CHILD, rc, this);
uj5u.com熱心網友回復:
CRect rectDlg;
GetClientRect(rectDlg);
MainFrame *m_pMyFrame = new MainFrame;
m_pMyFrame->Create(0, _T(""), WS_CHILD, rectDlg, this);
m_pMyFrame->ShowWindow(SW_SHOW);
我這樣之后成功了

但是當我拖動視窗第二次的時候程式中斷了(拖動、雙擊停靠、再拖動、再停靠這樣正常;只有拖動一次后再接著拖動一次就中斷了),大佬幫忙看看

然后除錯資訊是
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\objcore.cpp(76) : AppMsg - ASSERT_VALID fails with NULL pointer.
Debug Assertion Failed!
Program: C:\WINDOWS\SYSTEM32\mfc120ud.dll
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxpane.cpp
Line: 129
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
Detected memory leaks!
Dumping objects ->
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxdragframeimpl.cpp(122) : {663} client block at 0x012BD408, subtype c0, 848 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CDockablePane object at $012BD408, 848 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\plex.cpp(29) : {661} normal block at 0x0129CFD0, 124 bytes long.
Data: < ) + > 00 00 00 00 E0 CF 29 01 00 00 00 00 08 CA 2B 01
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\plex.cpp(29) : {645} normal block at 0x012BD350, 124 bytes long.
Data: < ( + > 00 00 00 00 00 00 00 00 00 00 00 00 28 C8 2B 01
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxpaneframewnd.cpp(1939) : {644} client block at 0x012BC828, subtype c0, 48 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $012BC828, 48 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\plex.cpp(29) : {642} normal block at 0x012BD100, 124 bytes long.
Data: < 1' > 00 00 00 00 00 00 00 00 00 00 00 00 9C 31 27 01
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\plex.cpp(29) : {639} normal block at 0x012BD1B8, 124 bytes long.
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 F8 0C 05 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxpanecontainermanager.cpp(76) : {635} client block at 0x012BD028, subtype c0, 156 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CPaneContainer object at $012BD028, 156 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxtooltipmanager.cpp(70) : {634} client block at 0x012BCD60, subtype c0, 144 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CToolTipCtrl object at $012BCD60, 144 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxmultipaneframewnd.cpp(25) : {631} client block at 0x012BCA08, subtype c0, 468 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CMultiPaneFrameWnd object at $012BCA08, 468 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\plex.cpp(29) : {560} normal block at 0x012BC8E0, 124 bytes long.
Data: < + 1' > 00 00 00 00 FC C8 2B 01 00 00 00 00 9C 31 27 01
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxpanecontainermanager.cpp(76) : {555} client block at 0x012BC750, subtype c0, 156 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CPaneContainer object at $012BC750, 156 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxpanecontainermanager.cpp(31) : {554} client block at 0x0129CAE8, subtype c0, 80 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CPaneContainerManager object at $0129CAE8, 80 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxpanedivider.cpp(24) : {553} client block at 0x0129D088, subtype c0, 348 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CPaneDivider object at $0129D088, 348 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\plex.cpp(29) : {550} normal block at 0x012BC698, 124 bytes long.
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 F8 0C 05 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\plex.cpp(29) : {372} normal block at 0x0129D2F0, 124 bytes long.
Data: < ) > 00 00 00 00 00 00 00 00 00 00 00 00 80 D2 29 01
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxpaneframewnd.cpp(1939) : {371} client block at 0x0129D280, subtype c0, 48 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $0129D280, 48 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxpanecontainermanager.cpp(76) : {363} client block at 0x0129CEF8, subtype c0, 156 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CPaneContainer object at $0129CEF8, 156 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxtooltipmanager.cpp(70) : {362} client block at 0x0129CC30, subtype c0, 144 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CToolTipCtrl object at $0129CC30, 144 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxmultipaneframewnd.cpp(25) : {359} client block at 0x0129C8D8, subtype c0, 468 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CMultiPaneFrameWnd object at $0129C8D8, 468 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxtooltipmanager.cpp(70) : {337} client block at 0x0129C568, subtype c0, 144 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CToolTipCtrl object at $0129C568, 144 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxdockablepane.cpp(3119) : {336} client block at 0x0129C4F8, subtype c0, 48 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $0129C4F8, 48 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\array_o.cpp(110) : {335} normal block at 0x0129C4A8, 20 bytes long.
Data: < ) 8 ) ) > C8 C3 29 01 38 C4 29 01 F8 C4 29 01 CD CD CD CD
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxdockablepane.cpp(3118) : {334} client block at 0x0129C438, subtype c0, 48 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $0129C438, 48 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxdockablepane.cpp(3117) : {332} client block at 0x0129C3C8, subtype c0, 48 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $0129C3C8, 48 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxdragframeimpl.cpp(122) : {330} client block at 0x0129BFA8, subtype c0, 848 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CDockablePane object at $0129BFA8, 848 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxtooltipmanager.cpp(70) : {307} client block at 0x01273B20, subtype c0, 144 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CToolTipCtrl object at $01273B20, 144 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxdockablepane.cpp(3119) : {306} client block at 0x01273AB0, subtype c0, 48 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $01273AB0, 48 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\array_o.cpp(110) : {305} normal block at 0x01273A60, 20 bytes long.
Data: < 9' 9' :' > 80 39 27 01 F0 39 27 01 B0 3A 27 01 CD CD CD CD
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxdockablepane.cpp(3118) : {304} client block at 0x012739F0, subtype c0, 48 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $012739F0, 48 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxdockablepane.cpp(3117) : {302} client block at 0x01273980, subtype c0, 48 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $01273980, 48 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxvisualmanagerwindows.cpp(35) : {266} client block at 0x012735E8, subtype c0, 348 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CMFCVisualManagerWindows object at $012735E8, 348 bytes long
d:\priject\dockdlg_dlg\dockdlg_dlg\dockdlg_dlgdlg.cpp(103) : {264} client block at 0x01272D80, subtype c0, 2088 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CFrameWndEx object at $01272D80, 2088 bytes long
d:\priject\dockdlg_dlg\dockdlg_dlg\dockdlg_dlg.cpp(59) : {166} client block at 0x012560C0, subtype c0, 12 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $012560C0, 12 bytes long
{165} client block at 0x01267730, subtype c0, 204 bytes long.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dumpcont.cpp(23) : atlTraceGeneral - a CObject object at $01267730, 204 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : {159} normal block at 0x01267500, 90 bytes long.
Data: < D $ $ > A0 D7 44 10 24 00 00 00 24 00 00 00 01 00 00 00
Object dump complete.
uj5u.com熱心網友回復:
點“重試”看 堆疊(我(vc6)沒有 環境,不能給代碼)
uj5u.com熱心網友回復:

大佬這樣嗎?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/200391.html
標籤:基礎類
上一篇:VS2019 前處理器定義
下一篇:用死回圈后繪圖框無回應
