Open Dialog in DLL

Just starting out? Need help? Post your questions and find answers here.
wombats
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Dec 29, 2011 5:03 pm

Open Dialog in DLL

Post by wombats »

I am trying to create a DLL that opens and manages the events for a Dialog. However, when using the DLL created from the following code, the host application's events don't seem to be processed.

What am I doing wrong?

Code: Select all

Runtime Procedure test()
  MessageBox_(#Null, "test", "test", 0)
EndProcedure

ProcedureDLL MyFunction(handle.i)

  #XmlEncoding = #PB_UTF8
  
  #Dialog = 0
  #Xml = 0
  
  XML$ = "<window id='#PB_Any' name='test' text='test' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
         "  <panel>" +
         "    <tab text='First tab'>" +
         "      <vbox expand='item:2'>" +
         "        <hbox>" +
         "          <button text='button 1'/>" +
         "          <checkbox text='checkbox 1'/>" +
         "          <button text='button 2' onevent='test()'/>" +
         "        </hbox>" +
         "        <editor text='content' height='150'/>" +
         "      </vbox>" +
         "    </tab>" +
         "    <tab text='Second tab'>" +
         "    </tab>" +
         "  </panel>" +
         "</window>"
  
  If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
    
    If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test", 0, 0, #PB_Ignore, #PB_Ignore, handle)
      
      Repeat 
        Select WaitWindowEvent(10) 
          Case #PB_Event_CloseWindow 
            quit = 1
        EndSelect 
      Until quit = 1
      
    Else  
      Debug "Dialog error: " + DialogError(#Dialog)
    EndIf
  Else
    Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
  EndIf
  
EndProcedure
User avatar
HeX0R
Addict
Addict
Posts: 992
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Open Dialog in DLL

Post by HeX0R »

Keep the Eventloop in the main program and work with BindEvents.
Post Reply