create a dialog in a MFC application

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
saffari2005
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat Oct 21, 2006 11:04 am

create a dialog in a MFC application

Post by saffari2005 »

Hi
I read mfc sample in wxWindows. after that I tried to ignore wxapp and create dialog in mfc app.
now, I haven't any error but wxdialog don't be shown,I can't see it!
I have code like this in onCreate function in dialog based mfc application:

Code: Select all

pocwxWnd = new wxDialog(null,"Test", true );
I can only see cdialog !
Lloyd
Super wx Problem Solver
Super wx Problem Solver
Posts: 350
Joined: Wed May 03, 2006 2:36 pm
Location: India
Contact:

Post by Lloyd »

To see the dialog you have to use either
pocwxWnd->Show()
or
pocwxWnd->ShowModal()
saffari2005
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat Oct 21, 2006 11:04 am

Post by saffari2005 »

oh. yes!
Is there any way to create a wxwindow without parent in the CDialog like creat wxDialog?
Lloyd
Super wx Problem Solver
Super wx Problem Solver
Posts: 350
Joined: Wed May 03, 2006 2:36 pm
Location: India
Contact:

Post by Lloyd »

Sorry, I can't get you clearly.

If you want a window without parent, that what you mentioned as NULL in the wxDialog constructor!

I think you are an MFC programmer, thats why your code looks looks like that. You can go through the wx documnetation to know the arguments of the functions.
The wxDialog Constructor looks like this....
wxDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = "dialogBox")
So follow it to make the dialog
like

Code: Select all

wxDialog MyDialog(NULL,wxID_ANY,wxT("My Dialog"));
MyDialog.Show();
saffari2005
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat Oct 21, 2006 11:04 am

Post by saffari2005 »

yes, I'm mfc programmer but for my current project I'm trying to use mfc and wxwindow together.
I understand how to create dialog but now I have a mfc dialog and I want to create a wxwindow(not wxdilaog!) in it.but wxWindow constructor need a non Null parent, and I havent a wxwindow parent!
jb_coder
Super wx Problem Solver
Super wx Problem Solver
Posts: 267
Joined: Mon Oct 18, 2004 10:55 am

Post by jb_coder »

Doesn't the MFC sample show how to create a window without a parent? Look in the MyApp::CreateFrame() function. The sample looks a little confusing to me, but it looks like the #define START_WITH_MFC_WINDOW needs to be set to 1 to similate what you're trying to do with your application. If you set that to 1 and compile the sample, does it behave as you would expect? It might be work trying to make sure that your problem isn't an issue with wxWidgets/MFC rather than your code.
soaringhawkzf
Knows some wx things
Knows some wx things
Posts: 35
Joined: Sun Nov 12, 2006 4:54 am

Post by soaringhawkzf »

resouces in MFC exe and dll is conflict
the example to show dialog in dll:

extern "C" __declspec(dllexport) void Show()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CMyDialog dlg;
dlg.DoModal ();
}
saffari2005
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat Oct 21, 2006 11:04 am

Post by saffari2005 »

"CreateFrame" creates a frame ! but I need a window, however Frame is kind of window.as you know wxwindow can't be create without parent.can we use a way to solve this?
Post Reply