How to display a modal dialogwindow from XPorted VO Code?

This forum is meant for questions and discussions about the X# language and tools
Post Reply
stefan.ungemach
Posts: 71
Joined: Thu Jul 15, 2021 10:46 am
Location: Germany

How to display a modal dialogwindow from XPorted VO Code?

Post by stefan.ungemach »

I have a simple modal window which inherited from a DialogWIndow in VO code. The modal behaviour comes from the constructor:

CLASS KOBOptionBox_vo INHERIT DIALOGWINDOW 
        CONSTRUCTOR(oParent,uExtra)  
        LOCAL DIM aBrushes[1] AS OBJECT
        
        SELF:PreInit(oParent,uExtra)
        SUPER(oParent,ResourceID{"KOBOptionBox_vo",_GetInst()},TRUE)


Unfortunately the window opens with :Show(SHOWCENTERED), but closes immediately. Before designing a whole new user interface: Is there any simple thing I did wrong?
        ...

 
User avatar
robert
Posts: 4552
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

How to display a modal dialogwindow from XPorted VO Code?

Post by robert »

Stefan,
Is there a postinit method for the window? Does it get called?
Maybe there is an exception. Can you add a try .. catch around the call to Show() to see if an exception occurs?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
stefan.ungemach
Posts: 71
Joined: Thu Jul 15, 2021 10:46 am
Location: Germany

How to display a modal dialogwindow from XPorted VO Code?

Post by stefan.ungemach »

Robert,

the PostInit is called. The window gets displayed as well (which I can prove both by the debugger and by commenting the last line here:

oDlg := KOBMsgOptionBox{ oWin }
oDlg:Caption := cCaption
oDlg:TextZeilen := aMsg
oDlg:ID := cDialogKennungFuerAutoAntwort
oDlg:EscapeErlaubt := FALSE
oDlg:OldStyleFontSet := aFixedFont
oDlg:BitmapNameFuerFarbe := cBitmap
oDlg:Show(SHOWCENTERED)
// oDlg:destroy()

Problem is: it's not modal. In VO, the program execution halts after the show until the window is closed. In X# execution continues immediately, the destroy() is called and the window gone.
User avatar
robert
Posts: 4552
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

How to display a modal dialogwindow from XPorted VO Code?

Post by robert »

Stefan,
Can you send us an example so we can test it?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
stefan.ungemach
Posts: 71
Joined: Thu Jul 15, 2021 10:46 am
Location: Germany

How to display a modal dialogwindow from XPorted VO Code?

Post by stefan.ungemach »

Robert,

an example would be too complex - but the problem is solved. I didn't have an app object, thus no message loop (this worked fine for Xported server apps without any GUI). After inserting 
IF getAppObject() == NULL_OBJECT
        VOGUIClasses.Functions.__WCInitCriticalSections()
        VOGUIClasses.Functions.__InitFunctionPointer()
        VOGUIClasses.Functions.__WCRegisterCustomControl()
        VOGUIClasses.Functions.__InitClassPointer()
        VOGUIClasses.Functions.__WCRegisterMMContWindow()
        VOGUIClasses.Functions.__InitTheme()
        App{}
    ENDIF 
and 
            IF !empty( getAppObject() ) 
                getAppObject():Exec( EXECWHILEEVENT )
            ENDIF
before my test code, the modal windows (custom message boxes) appear. I hope this was the right approach ;)




 
Post Reply