lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Scuri – thank you.

 

>> You will have to do it using "iup.SetAttribute(ih, "NATIVEPARENT", hWnd)". 

 

I had already tried that and it didn’t work, but the problem was that I had pushed hWnd onto the stack as an integer.  I had assumed that it would be automatically converted to the required type.  When I switched to pushing it onto the stack (in my C++ code) as light-user-data, it then worked.

 

As regards the other issues: I had been hoping that I could integrate IUP windows and dialogs with native windows and dialogs.  That still seems possible but more complicated than I’d hoped.  One example is this: I’d like to be able to display floating IUP windows modelessly – i.e. without preventing other interaction within my main application.  I had thought that I could define callbacks into the lua script which my C++ program would call if the script needed to close its IUP windows, or update them, or whatever.  However, I can’t see how to do this because the IUP windows seem to need iup.MainLoop() to be called, and doesn’t exit from that until the IUP windows close.  My application assumes that it controls the main message pump (e.g. for idle-time processing).  Is there any way of letting both message loops work in tandem so to speak?

 

Simon

 

From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On Behalf Of Antonio Scuri
Sent: 11 June 2019 8:21 PM
To: Lua mailing list
Subject: Re: IUP question: how can I make IUP dialogs float in front of other application windows and/or be modal with respect to them?

 

  Hi,

 

  You have two different problems. They have separate solutions. 

 

> I noticed that there is also a PARENTDIALOG attribute at least for IUP dialog objects.  But I can’t work out how to use this either.  Is it assuming that the parent dialog is another IUP dialog object? 

 

  Yes, in this case the attribute points to the name of another IUP dialog.

 

 

> I tried using IUP dialogs and setting the NATIVEPARENT attribute, having setup  the value of my application’s main windows HWND as a (global) integer within the Lua environment.  None of the ways I tried of setting the NATIVEPARENT attribute worked, and I’m not sure if that is what I’m supposed to be doing anyway.

 

  That's the solution I would give to you regarding the IUP dialogs to be in front of your native dialogs (not related to the modal problem). So probably setting the attribute failed. Since this attribute must be a pointer to the HWND, it must be an usedata in Lua. And this will not work for a regular "ih.nativeparent = hWnd" call. You will have to do it using "iup.SetAttribute(ih, "NATIVEPARENT", hWnd)". 

 

 

> I also tried using the SIMULATEMODAL attribute.  Like PARENTDIALOG that only seems applicable to dialog objects, and not ‘Alarm’ or ‘GetParam’.  But in any case, I couldn’t get it to work either. 

 

  IupAlarm and IupGetParam internally use IupDialogs, but both are functions that create and show pre-defined dialogs. Usually they are configured through a callback (IupGetParam) or global attributes (IupAlarm). Although they are not NATIVEPARENT friendly. It will be not simple to use NATIVEPARENT with them, but it is possible, at least for IupGetParam.

 

  SIMULATEMODAL will automatically disable other IupDialogs so IupShow can be used. IupPopup does the same. So in both cases, they will work for IupDialogs only. 

 

  So if you want IUP dialogs to be "modal" regarding the native dialogs too you will have to manually disable other native dialogs before running the script, or at least before running a script that needs that. We have two internal global callbacks that can help, they are called before and after a modal dialog is displayed, they are GLOBALENTERMODAL_CB and GLOBALLEAVEMODAL_CB. They are not available in Lua. They could be implemented in the C part of your application. 

 

Best,

Scuri

 

 

Em ter, 11 de jun de 2019 às 13:41, Simon Orde <SimonOrde@family-historian.co.uk> escreveu:

Hi

 

I use LUA as an embedded scripting language to support user-created plugins within my Windows Visual C++ application.  I want my users to be able to display IUP windows and dialogs within a LUA plugin.   My application has windows and dialogs of its own.  If I run a Lua plugin that displays any kind of dialog (e.g. by using iup.GetParam or iup.Alarm say), the IUP Help for both GetParam and Alarm says that they will display a “modal dialog”.  However, the dialog that is displayed is not modal – or not at least with respect to my other windows and dialogs.   All the existing windows and dialogs within my application continue to be accessible and enabled, and if I click on any one of them, the IUP dialog will disappear behind my application window.  The only way I can prevent this is to disable all my application windows and dialogs before running the plugin, and re-enable them afterwards.  However, that is not a good solution for me for a number of reasons – not least that it doesn’t fully prevent the IUP dialog accidentally ending up behind my application windows.  It just makes it less likely to happen by the user clicking on one of my windows.

 

I would like to find some way of making IUP dialogs properly modal with respect to my other application windows.  I would also like to find some way of supporting IUP windows that are not modal, but nevertheless float in front of my other application windows – and without having to make them always-on-top type of windows.

 

I tried using IUP dialogs and setting the NATIVEPARENT attribute, having setup  the value of my application’s main windows HWND as a (global) integer within the Lua environment.  None of the ways I tried of setting the NATIVEPARENT attribute worked, and I’m not sure if that is what I’m supposed to be doing anyway.

 

I noticed that there is also a PARENTDIALOG attribute at least for IUP dialog objects.  But I can’t work out how to use this either.  Is it assuming that the parent dialog is another IUP dialog object?

 

I also tried using the SIMULATEMODAL attribute.  Like PARENTDIALOG that only seems applicable to dialog objects, and not ‘Alarm’ or ‘GetParam’.  But in any case, I couldn’t get it to work either.  E.g. I tried this:

 

require( "iuplua" )

 

vbox = iup.vbox { iup.label {title="Label"}, iup.button { title="Test" } }

dlg = iup.dialog{vbox; title="Dialog", SIMULATEMODAL=true}

dlg:show()

 

if (iup.MainLoopLevel()==0) then

  iup.MainLoop()

end

 

That doesn’t work.

 

All help with this very much appreciated – especially actually lua code examples!  Thank you.

 

Simon