Accueil > Forum > > > > How do I create a modeless dialog in a DLL?
How do I create a modeless dialog in a DLL?
vendredi 26 mars 2004 à 23:56:59 |
How do I create a modeless dialog in a DLL?

dev2004
|
Originally posted by: H I have an MFC C++ dll, which is called from a C executable. I can create a modal dialog just fine, but I'm having trouble getting a modeless dialog. So far it appears for juct a few milliseconds then goes. I suspect that this is because it's going on the stack instead of the heap. Anyone out there know a simple answer? A chunk of code would be greatly appreciated as I'm new to all of this. Thanks,
|
|
samedi 27 mars 2004 à 13:06:41 |
Re : How do I create a modeless dialog in a DLL?

ymca2003
|
in the MFC Dll : one Dialog class : (the dialog is not destroyed when it receives OnCancel or OnOK, it is oly hidden, the object itself is destroyed in OnPostNCDestroy, the last message received). "Dlg.h" #ifndef AFX_DLG_H_INCLUDED_ #define AFX_DLG_H_INCLUDED_
class CDlg : public CDialog { public: CDlg(); BOOL Create(CWnd* pParent = NULL);
// Dialog Data //{{AFX_DATA(CDlg) enum { IDD = IDD_DIALOG }; //}}AFX_DATA
// Overrides //{{AFX_VIRTUAL(CDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); virtual void PostNcDestroy(); //}}AFX_VIRTUAL
// Generated message map functions protected: //{{AFX_MSG(CDlg) virtual void OnCancel(); virtual void OnOK(); //}}AFX_MSG DECLARE_MESSAGE_MAP() };
#endif // AFX_DLG_H_INCLUDED_
|
"Dlg.cpp" // Dlg.cpp : implementation file //
#include "StdAfx.h" #include "TestDll.h" #include "Dlg.h"
#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif
BEGIN_MESSAGE_MAP(CDlg, CDialog) //{{AFX_MSG_MAP(CDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP()
CDlg::CDlg() : CDialog() { //{{AFX_DATA_INIT(CDlg) //}}AFX_DATA_INIT }
void CDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDlg) //}}AFX_DATA_MAP }
BOOL CDlg::Create(CWnd* pParent /*= NULL*/) { if(!CDialog::Create(CDlg::IDD, pParent))return FALSE; return TRUE; }
void CDlg::OnCancel() { ShowWindow(SW_HIDE); }
void CDlg::OnOK() { ShowWindow(SW_HIDE); }
void CDlg::PostNcDestroy() { delete this; }
|
in the MFC Dll, on exported function (createDlg) "ImpExp.h" #ifndef IMPEXP_H #define IMPEXP_H
#ifdef TESTDLL_EXPORTS #define TESTDLL_API extern "C" __declspec(dllexport) #else #define TESTDLL_API extern "C" __declspec(dllimport) #endif
TESTDLL_API HWND __stdcall CreateDlg(HWND hWndParent);
#endif // IMPEXP_H
|
"TestDll.cpp" #define TESTDLL_EXPORTS #include "ImpExp.h" #include "Dlg.h"
TESTDLL_API HWND __stdcall CreateDlg(HWND hWndParent) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CDlg* pDlg = new CDlg(); if(!pDlg->Create(CWnd::FromHandle(hWndParent))) return NULL; return pDlg->m_hWnd; }
|
"Main.cpp" (link with the MFC dll .lib file) // Main.cpp : Defines the entry point for the application. //
#include "StdAfx.h" #include "resource.h" #include "..\ImpExp.h"
HWND hModelessDlg;
int CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { hModelessDlg = CreateDlg(hDlg); break; } case WM_DESTROY : { DestroyWindow(hModelessDlg); break; } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDCANCEL:EndDialog(hDlg, IDCANCEL); break; case IDOK:EndDialog(hDlg, IDOK); break; case IDC_SHOW: { ShowWindow(hModelessDlg, SW_SHOW); break; } case IDC_HIDE: { ShowWindow(hModelessDlg, SW_HIDE); break; } } } } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAINDIALOG), NULL, DlgProc); }
|
the IDD_MAINDIALOG Dialog contains 2 buttons IDC_SHOW and IDC_HIDE.
|
|
Cette discussion est classée dans : dll, dialog, of, create, modeless
Répondre à ce message
Sujets en rapport avec ce message
Probleme de Dialog VC++ [ par anaya ]
Bonjour,J'espere bien que vous allez m'aider, voila mon probleme:Mon programme marche a merveille avec Domodal(); mais moi je dois utiliser autre cho
Dialog dans DLL ? [ par Zootella ]
Hello all J'esseye d'utiliser dans mon programme une fenêtre dialog qui se trouve dans une dll, mais la fonction qui traite les message de la fenêtre
cree boite dialog dans DLL [ par bonjour__ ]
salut tous le monde.j'ai cherche comment cree les boite de dialog avec leur fonction procedure ( modale ou non )dans les fichier executable DLL .voici
Afficher un dialog modal dans une dll d'extension... [ par MadPlop ]
J'ai cree la DLL avec une classe de dialogue (avec la ressource de dialogue associee) et une autre classe. Les fonctions de ces classes fonctionnent s
probléme de dll [ par ffvf1er ]
salut a tous!!j'ai récupé le source "bmp2jpeg " de soldier8514 que je remercie.cette dll permet la conversion d'image, je les changé et adapté à mon p
probleme dll [ par spyanakine ]
salut j ai un pb avec une dll que j ai créé en fait dans cette dll j ai une boite de dialog avec un controle chart (mschrt20.ocx) lorsque j apelle cet
Dialog MFC d'une DLL dans une application non MFC [ par auwel ]
Voilà j'ai une dll (MFC partagée) qui contient une fonction permettant l'affichage d'une boîte de dialogue. Cette fonction fonctionne correctement si
ShowHTMLDialogEx + HTMLDLG_MODELESS modale ?! [ par HeavenForsaker ]
Bonjour,Je tente d'afficher une page HTML à l'intérieur d'une fenêtre, pour ce faire j'ai utilisé la fonction ShowHTMLDialogEx avec le flag HTMLDLG_MO
Ajout de reference [ par scortex84 ]
bonjour,Je ne connais absolument pas C++ mais je dois faire un petit projet avec (d'habitude je fais du C#, donc là ce n'est pas gagné...).J'ai donc m
Problème fonctions décorées dans une DLL [ par TryToHelpMe ]
Bonjour, je n'ai pas par habitude de demander de l'aide au premier problème rencontré. ( La preuve, je dois me recréer un compte à chaque fois que j'a
Livres en rapport
|
Derniers Blogs
[WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|