Merci, j'ai donc testé ceci :
Code de la Dll :
#include <windows.h>
#include "resource.h"
LRESULT CALLBACK AppDlgProc(HWND Dlg,UINT message,WPARAM wParam,LPARAM lParam);
HINSTANCE hDll;
int __stdcall Dialog()
{
DialogBoxParam(hDll, (LPCTSTR)IDD_APP, NULL, &AppDlgProc), 0);
return 0;
}
LRESULT CALLBACK AppDlgProc(HWND Dlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int Select;
switch(message)
{
case WM_COMMAND:
Select=LOWORD(wParam);
switch(Select)
{
case IDOK:
MessageBox(0, "ok", "Test", 0);
return TRUE;
case IDCANCEL:
EndDialog(Dlg,Select);
PostQuitMessage(0);
return TRUE;
}
default:
return FALSE;
}
}
Code de l'exe:
#include <windows.h>
typedef BOOL (*FONCTION) (void);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HINSTANCE hDll = LoadLibrary("Dll.dll");
FONCTION fDialog = (FONCTION)GetProcAddress(hDll, (LPCSTR)"Dialog");
fDialog();
return 0;
}
Mais la fenêtre n'apparait pas une fois le programme éxecuté.
Aussi j'ai dû changer la ligne :
DialogBoxParam(hDll, (LPCTSTR)IDD_APP, NULL, &AppDlgProc), 0);
par :
DialogBoxParam(hDll, (LPCTSTR)IDD_APP, NULL, reinterpret_cast<DLGPROC>(&AppDlgProc), 0);
Sinon il ne compilait pas, pourquoi ?
Voilà