Home > Software engineering >  Calling DLL dialog box as a child window, the debug assertions
Calling DLL dialog box as a child window, the debug assertions

Time:10-04

In the DLL is a dialog window class to call to create it, and make it as a child window (call the function in the first picture, parameter transfer this), the assertions in the create DLL dialog box, as shown in figure 2, excuse me expert how to solve this problem,

CodePudding user response:

Borrow the answer of
If your conversation is created in the dynamic library, should be a dynamic library AfxFindResourceHandle didn't load dynamic library resources, load is exe executable program resources,

Refer to
http://blog.csdn.net/mniwc/article/details/6748379

CodePudding user response:

Not as a child window before
Direct pDlg - & gt; Create (IDD) do not pass this pointer to the parent window ok

Pass this to conclude the

PDlg - & gt; Create (IDD, this action done in the middle of the DLL

CodePudding user response:

reference 1st floor qq_29700255 response:
borrow friend's answer
If your conversation is created in the dynamic library, should be a dynamic library AfxFindResourceHandle didn't load dynamic library resources, load is exe executable program resources,

Refer to
http://blog.csdn.net/mniwc/article/details/6748379


I am not very understand,
You this sentence "if your conversation is created in the dynamic library", emphasizes the dynamic or static links you?
Are implemented in a DLL class, create Dlg parent window just call the create function __declspec (dllexport) passed parent window parameters to his pointer
Reference is a little complicated, can I this problem under the simple explanation

CodePudding user response:

Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until we can read ,

CodePudding user response:

reference 4 floor zhao4zhong1 response:
collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand, until can read ,


Teacher, I did not understand till the end!!!!!!
The problem in:
Void CWnd: : AssertValid (const)
{
CHandleMap * pMap=afxMapHWND ();
ASSERT (pMap!=NULL);
}
This piece of the MAP table is empty ~ ~ ~

I am in
The CWnd call DLL of create (IDD)
 int CCalculator: : OnCreate (LPCREATESTRUCT LPCREATESTRUCT)//parent window create 
{
If (CBasicWnd: : OnCreate (lpCreateStruct)==1)
return -1;

M_Hwd=OpenCalculator (this);//create a DLL child window "-- -- -- -- -- - this transfer out assertion
return 0;
}


 # define DLLEXPORT extern "C" __declspec (DLLEXPORT) 
DLLEXPORT HWND OpenCalculator (CWnd * WND);


 HWND OpenCalculator (CWnd * WND) 
{
AFX_MANAGE_STATE (AfxGetStaticModuleState ());

PTD - & gt; Create (IDD_CALCULATOR_DIALOG, WND);
HWND HWND=pTD - & gt; GetSafeHwnd ();

Return the hWnd;
}

CodePudding user response:

Please check the return values of each function call
Caution is ship ten thousand,

Pay attention to the related scattered alignment with the order, lock/synchronization waiting, necessary

Synchronization Functions provides
The following functions provides are 2 in synchronization.

CancelWaitableTimer
CreateEvent
CreateMutex
CreateSemaphore
CreateWaitableTimer
DeleteCriticalSection
The EnterCriticalSection
The GetOverlappedResult
InitializeCriticalSection
InitializeCriticalSectionAndSpinCount
InterlockedCompareExchange
InterlockedDecrement
InterlockedExchange
InterlockedExchangeAdd
InterlockedIncrement
LeaveCriticalSection
MsgWaitForMultipleObjects
MsgWaitForMultipleObjectsEx
OpenEvent
OpenMutex
OpenSemaphore
OpenWaitableTimer
PulseEvent
QueueUserAPC
ReleaseMutex
ReleaseSemaphore
ResetEvent
SetCriticalSectionSpinCount
SetEvent
SetWaitableTimer
SignalObjectAndWait
TimerAPCProc
TryEnterCriticalSection
WaitForMultipleObjects
WaitForMultipleObjectsEx
The WaitForSingleObject
WaitForSingleObjectEx


"Windows core programming
"

CodePudding user response:

Zhao4zhong1
reference 4 floor response:
collapsed in the pop-up dialog box button to enter the corresponding debugging, press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand, until can read ,


Stack as follows, please miss zhao on a post analysis under

The CWnd: : AssertValid () line 890 + 25 bytes
AfxAssertValidObject (const CObject * 0 x0044b028 {CCalculator hWnd=0 x000108b8}, const char * 0 x5f4d1330 THIS_FILE, int 258) line 108
The CWnd: : CreateDlgIndirect (const DLGTEMPLATE * 0 x1006e700, CWnd * 0 x0044b028 {CCalculator hWnd=0 x000108b8}, HINSTANCE__ * 0 x10000000) line 260
CDialog: : CreateIndirect (const DLGTEMPLATE * 0 x1006e700, CWnd * 0 x0044b028 {CCalculator hWnd=0 x000108b8}, void * 0 x00000000, 0 x10000000 HINSTANCE__ *) line 223
CDialog: : CreateIndirect (void * 0 x1006e700, CWnd * 0 x0044b028 {CCalculator hWnd x000108b8}=0, 0 x10000000 HINSTANCE__ *) line 200 + 22 bytes
CDialog: : Create (const char * 0 x00000066, CWnd * 0 x0044b028 {CCalculator hWnd=0 x000108b8}) line 182 + 20 bytes
CDialog: : Create (unsigned int, 102, the CWnd * 0 x0044b028 {CCalculator hWnd=0 x000108b8}) line 543 + 29 bytes
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related