Author Topic: Parent Window for DoModal() ??  (Read 5456 times)

Alhexx

  • *
  • Posts: 1894
    • View Profile
    • http://www.alhexx.com
Parent Window for DoModal() ??
« on: 2002-08-24 10:48:40 »
Okay, here's my problem:
I wanted to move some of Ultima's dialogs into a VC++ DLL, b'cause of better data type check and etc. However, I wanted to call the dialog via DoModal() and *BANG* - it crashed... :(
I've been debugging the dll and I've found out that it has got to do with the dialogs parent window. Well, if you call a Dialog via DoModal() in a C++ app, then it has it parent window - the mainframe.
However, if you call it from a DLL, I will have to specify the parent window manually, but how??

Okay, here's the code I used:
I've got a Dialog and its Class CDiaVert. The window will be created by a global function called DiaAddVertex by Ultima:

Code: [Select]
// Add New Vertex Dialog Function
int APIENTRY DiaAddVertex(int *iNumVertex, ff7_vertex *pVertex, ff7_color *pColor)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CDiaVert VertDia;
VertDia.SetData( iNumVertex, pVertex, pColor);
if(VertDia.DoModal() != IDOK)
{
return -1;
}
else
{
VertDia.GetData(iNumVertex, pVertex, pColor);
return 0;
}
}


Okay, passing Ultima's main window handle to the DLL should be no problem, but how do I tell the DoModal()-Function to use this handle??

 - Alhexx

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
Parent Window for DoModal() ??
« Reply #1 on: 2002-08-26 11:27:36 »
it should go like this:

Code: [Select]

{
   CDiaVert *VertDia;
   VertDia = new CDiaVert( IDD_OF_DIALOG_RESOURCE, handle_to_parent_window );
   VertDia->SetData();
   if( VertDia->DoModal() != IDOK ) {

   }

   delete VertDia;
}


'this' can be used as handle_to_parent_window
but i dont know if it'll help you, because i tried it also with NULL and it worked for me ... i would tell more if i would see it on my own.

Alhexx

  • *
  • Posts: 1894
    • View Profile
    • http://www.alhexx.com
Parent Window for DoModal() ??
« Reply #2 on: 2002-08-26 13:29:21 »
Hm .. that sounds interesting. I'll try it out. Thanx.

(1 more to go...)

 - Alhexx