C'est bon, je ne sais pas ce que j'ai fait, mais ca marche !
Autre question : Avec DialogBox, commen je peu modifier le texte d'un static de ce dialogue ?
Encore merci !
\* -- Seb [
Mail] [
Web] -- */
-------------------------------
Réponse au message :
-------------------------------
> D'accord, je vais essayé !
>
> Merci
>
> \* -- Seb [
Mail] [
Web] -- */
>
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > Et tu es certain que lhModule vaut 0, tu l'as teste et affiche pour certitude ?
> > Le but est bien d'avoir une AboutBox par dll ?
> > Faut donc qu'elle soit modale, habituel disons.
> > Faudra l'afficher avec DialogBoxParam().
> > Insiste un peu, si va toujours pas je te ferai un exemple complet mais pas avant ce soir ou demain, j'ai du taf.
> > BruNews, ciao...
> >
> >
> > -------------------------------
> > Réponse au message :
> > -------------------------------
> >
> > > Rien a faire, ca ne marche toujour pas. Voici mon code en entier :
> > >
> > > #define KRNLWINUX_API __declspec(dllexport) __stdcall
> > >
> > > #include "windows.h"
> > >
> > >
> > > typedef struct {
> > >
> > > char *Titre;
> > > char *CopyRight;
> > > char *Description;
> > > char *Version;
> > > char *App;
> > > char *Btn;
> > > HICON Icone;
> > >
> > > } LABOUTBOX;
> > >
> > > HINSTANCE lhModule;
> > >
> > > int WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, PVOID pReserved)
> > > {
> > >
> > > if(dwReason == DLL_PROCESS_ATTACH) lhModule = hInst;
> > >
> > > return 1;
> > >
> > > }
> > >
> > >
> > > BOOL __stdcall DialogProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
> > > {
> > >
> > > RECT rc;
> > > unsigned long Ret;
> > >
> > > switch(Msg) {
> > >
> > > case 0x0110:
> > >
> > > GetWindowRect(hWnd, &rc);
> > >
> > > SetWindowPos(hWnd, HWND_TOP, (GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2, (GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2, 0, 0, SWP_NOSIZE);
> > >
> > > return 1; // Initialisation du dialogue
> > >
> > > break;
> > >
> > > case 0x0138:
> > >
> > >
> > > Ret = SetTextColor((HDC) wParam, RGB(0, 255, 0));
> > > return Ret;
> > > break;
> > >
> > > case 0x0111: //Message de commande
> > >
> > >
> > > if (HIWORD(wParam) == 0) { //Si l'utilisateur à cliquer sur un bouton
> > >
> > >
> > > EndDialog(hWnd, TRUE); //On quitte
> > >
> > > }
> > >
> > > break;
> > >
> > > default: return 0;
> > >
> > > }
> > >
> > > }
> > >
> > >
> > > BOOL KRNLWINUX_API AboutBox(LABOUTBOX Opt)
> > > {
> > >
> > > HWND lHandle;
> > > HWND lHandleImg;
> > >
> > > lHandle = CreateDialog(lhModule, MAKEINTRESOURCE(101), 0, DialogProc);
> > >
> > > if (lHandle == NULL) return FALSE;
> > >
> > >
> > > lHandleImg = GetDlgItem(lHandle, 11);
> > >
> > > if (lHandleImg == NULL) return FALSE;
> > >
> > > SendMessage(lHandleImg, STM_SETIMAGE, IMAGE_ICON, (long) Opt.Icone);
> > >
> > > if (! SetWindowText(lHandle, strcat("A propos de ", Opt.Titre))) return FALSE;
> > >
> > > if (ShowWindow(lHandle, SW_SHOW)) return FALSE;
> > >
> > > return TRUE;
> > >
> > > }
> > >
> > > \* -- Seb [
Mail] [
Web] -- */
> > >
> > >
> > > -------------------------------
> > > Réponse au message :
> > > -------------------------------
> > >
> > > > Mets cela en point d'entree:
> > > > int WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, PVOID pReserved)
> > > > {
> > > > if(dwReason == DLL_PROCESS_ATTACH) lhModule = hInst;
> > > > return 1;
> > > > }
> > > > BruNews, ciao...
> > > >
> > > >
> > > > -------------------------------
> > > > Réponse au message :
> > > > -------------------------------
> > > >
> > > > > Voilà, g fait ca, mais rien a faire, lhModule reste nulle, je comprend pas.
> > > > >
> > > > > Si quelqu'un à la solution ...
> > > > >
> > > > > HINSTANCE lhModule;
> > > > >
> > > > > BOOL APIENTRY DllMain( HANDLE hModule,
> > > > > DWORD ul_reason_for_call,
> > > > > LPVOID lpReserved
> > > > > )
> > > > > {
> > > > > switch(ul_reason_for_call) {
> > > > >
> > > > > case DLL_PROCESS_ATTACH:
> > > > >
> > > > > lhModule = (HINSTANCE) hModule;
> > > > >
> > > > > break;
> > > > >
> > > > > }
> > > > >
> > > > > return TRUE;
> > > > > }
> > > > >
> > > > > \* -- Seb [
Mail] [
Web] -- */
> > > > >
> > > > >
> > > > > -------------------------------
> > > > > Réponse au message :
> > > > > -------------------------------
> > > > >
> > > > > > DllMain est appelee AVANT toute autre fonction de la dll.
> > > > > > 1ere raison sera PROCESS_ATTACH sinon ton prog n'accederait pas a la dll.
> > > > > > BruNews, ciao...
> > > > > >
> > > > > >
> > > > > > -------------------------------
> > > > > > Réponse au message :
> > > > > > -------------------------------
> > > > > >
> > > > > > > Mais c'est que je commence en c++, et je sais pas ce que tu me raconte là. Et la fonction DllMain est appelé après ma fonction, donc je n'ai pas le hinstance, et je c po commen faire. une idée ?
> > > > > > >
> > > > > > > \* -- Seb [
Mail] [
Web] -- */
> > > > > > >
> > > > > > >
> > > > > > > -------------------------------
> > > > > > > Réponse au message :
> > > > > > > -------------------------------
> > > > > > >
> > > > > > > > Enregistre ton HINSTANCE dans une variable quand reason est PROCESS_ATTACH.
> > > > > > > > BruNews, ciao...
> > > > > > > >
> > > > > > > >
> > > > > > > > -------------------------------
> > > > > > > > Réponse au message :
> > > > > > > > -------------------------------
> > > > > > > >
> > > > > > > > > Bonjour,
> > > > > > > > >
> > > > > > > > > J'aimerais comment récupérer le Hinstance lorsque l'on est dans une dll pour pouvoir utiliser la fonction CreateDialog.
> > > > > > > > >
> > > > > > > > > Merci
> > > > > > > > >
> > > > > > > > > \* -- Seb [
Mail] [
Web] -- */
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>