cs_jpeg
Messages postés40Date d'inscriptionlundi 17 décembre 2001StatutMembreDernière intervention25 février 2004
-
8 juil. 2002 à 11:54
frederic_bourgouin
Messages postés2Date d'inscriptionjeudi 13 novembre 2003StatutMembreDernière intervention25 février 2008
-
14 avril 2004 à 10:14
J'ai un problème concernant des ressources contenues dans une DLL MFC. Par exemple, lorsque je fais appel à une boite de dialogue contenue dans cette DLL, il arrive que ce soit une autre resource contenue dans l'éxécutable qui s'affiche. Le problème vient du fait que les deux resources (celle de l'EXE et celle de la DLL) possède le même ID (voir resource.h). La seule solution que j'ai trouvé consiste à faire attention que les deux resources.h possèdent des ID différents, ce qui n'est vraiment pas intéressant et ne fait que déplacer le pb.
Autre question : quelle est exactement, la différence entre les projets "Regular MFC DLL" et "MFC extension DLL" ?
Dans quel cas utiliser l'un plutôt que l'autre
frederic_bourgouin
Messages postés2Date d'inscriptionjeudi 13 novembre 2003StatutMembreDernière intervention25 février 2008 14 avril 2004 à 10:14
Bonjour,
moi aussi j'ai un problème avec les resources dans une dll:
Je ne sais pas comment utiliser une dialogbox(non modale) dans une dll Win32. La dll en elle même fonctionne puisque le debugger entre dans les fonctions exportées:
TEST_DLL1_API int fnTest_Dll1(void);
TEST_DLL1_API BOOL AboutBox (HINSTANCE hInstanceL, HWND hWndParentL);
(pour cela, j'ai ajouté le .lib, la dll et les headers des fonctions exportées dans le projet win32 utilisant la dll)
mais je souhaiterais que la fonction AboutBox(...) créé une boite de dialogue. J'utilise la fonction createdialog avec le nom de la resource dans la dll mais le getlastError récupère toujours l'erreur 0x0716=>code 1814=>ERROR_RESOURCE_NAME_NOT_FOUND.
ce code source n'est probablement pas adapté à ce que je veux faire mais si quelqu'un peut m'aider ....
merci d'avance
fred
=======================================================================
Sources de la dll
test_Dll1.h
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the TEST_DLL1_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// TEST_DLL1_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef TEST_DLL1_EXPORTS
#define TEST_DLL1_API __declspec(dllexport)
#else
#define TEST_DLL1_API __declspec(dllimport)
#endif
// This class is exported from the test_Dll1.dll
class TEST_DLL1_API CTest_Dll1 {
public:
CTest_Dll1(void);
// TODO: add your methods here.
};
MessageBox(NULL,"Coucou","About Box",MB_OK); //ça c'est OK
hwndInterf= CreateDialog(hInstance,/*(LPCTSTR)IDD_ABOUTBOX*/MAKEINTRESOURCE(101) //ici ya un soucis
,0,(DLGPROC)About);
erreur=GetLastError();
ShowWindow(hwndInterf,SW_SHOW );
return 1;
}
====================================================================================
Projet win32 utilisant la dll:
// Test_UtiliseDll1.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#include "Test_UtiliseDll1.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
HINSTANCE hinstLib;
HWND hwndx;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;