声明:
extern "C"
{
extern __declspec(dllexport) void DBAssert_Imp();
};实现:
BOOL CALLBACK DLLProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch( uMsg )
{
case WM_INITDIALOG:
ShowWindow( hWnd, SW_NORMAL );
UpdateWindow( hWnd );
break;
case WM_COMMAND:

exit(1);
break;
}

return TRUE;
}extern "C"
{
__declspec(dllexport) void DBAssert_Imp()
{
HINSTANCE hInst = ::GetModuleHandle( _T("TestDLL.dll") );
if( NULL == hInst )
{
return;
} DialogBox( hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DLLProc );
}
};
调用:
extern "C"
{
#include "..\\TestDLL\DBAssert.hpp"
};#pragma comment( lib, "..\\Debug\\TestDll.lib")
int _tmain(int argc, _TCHAR* argv[])
{
DBAssert_Imp(); return 0;
}
为什么显示不正常呢?是这个样子的:
如果看不到图片的话:
http://www.bababian.com/picturedetail.sl?pictureID=E043CACF7E49F81AA2317C84E9EBAC04DT就只能看到两个按钮。其它部分都瞧不见。该如何修改呢?

解决方案 »

  1.   

    BOOL CALLBACK DLLProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
    {
        switch( uMsg )
        {
        case WM_INITDIALOG:
            ShowWindow( hWnd, SW_NORMAL );
            UpdateWindow( hWnd );
            break;
        case WM_COMMAND:
            
            exit(1);
            break;
        }
        
        return TRUE;  //应该改为return FALSE
    }
    摘自MSDN:
    DialogProc Return Values
    Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not. If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response to the message.
    可见return TRUE导致窗口消息的默认处理被跳过了
      

  2.   

    摘自MSDN: 
    DialogProc Return Values 
    Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not. If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response to the message. 
    可见return TRUE导致窗口消息的默认处理被跳过了学习了.