Liberty BASIC Community Forum
« Disable dialog window crashes LB 4.04 »

Welcome Guest. Please Login or Register.
Nov 17th, 2017, 10:24pm


Rules|Home|Help|Search|Recent Posts|Notification

Problems installing Liberty BASIC? Read the Vista/Win7 Installation FAQ
Looking for a categorized List of Bug Reports? Visit the Liberty BASIC Bug Tracker

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 hotthread  Author  Topic: Disable dialog window crashes LB 4.04  (Read 774 times)
hooshnik
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 105
xx Re: Disable dialog window crashes LB 4.04
« Reply #15 on: Aug 2nd, 2016, 5:16pm »

I have decided to just disable the dialog windows with an API call. I try to ban the use of gosub/return from being used.

The point is I did not know from day #1 that when you write something in LB you are stuck with whichever way you choose to place you window event handling code otherwise you always have to keep on disabling all other windows whenever you want to show a functionized window to prevent the instruction pointer from going nuts. Instead of saying "branch label not found" and freaking out it should just ignore those events completely and write something in the error.log until all functionized windows are closed. It would save me some debugging time. smiley
« Last Edit: Aug 2nd, 2016, 5:18pm by hooshnik » User IP Logged

looking for file "include" support? Check out Aplomb Scribe http://libertybasic.conforums.com/index.cgi?action=display&board=open&num=1434746448
Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2282
xx Re: Disable dialog window crashes LB 4.04
« Reply #16 on: Aug 2nd, 2016, 8:47pm »

"Until all functionized windows are closed"


What happens then? Do all events that were "missed" during that time fire again? And if they do, is there a limit to how many events can queue up? (spoiler alert: there has to be, otherwise you'd eventually hit the memory limit and crash for running out of memory.)

This causes another problem. Your other windows might fall into the "not responding" tag from Windows, or it might not, depending on how LB handles it.

Also, is it alright to expect the rest of your windows to fall into the "X is not responding" greyed-out box that Windows draws for unresponsive applications? The reason that box appears is because the application controlling it is not processing window messages at that time. Should LB stop processing window messages for outside-of-scope windows and cause this to happen?

If it doesn't stop processing window messages, and it's saving all the events to play later, that brings up another issue: input state. The state of the mouse/keyboard/etc. If you don't process those inputs at the time of the window message, you lose the context of the inputs.

If you lose that context, then the saved/queued events won't be very useful, beyond the basic "click" events(which is, admittedly, most of what people need). Anything else that requires extra detail, such as needing to know what key is pressed, or needing to know where the mouse is, will be impossible.

Maybe LB saves that with the queued message. (Even more memory taken up!) In that case, you can get away with reading keystrokes using LB-provided input functions, or with knowing the position of the mouse pointer at the time the event was triggered. Hopefully you don't need anything else beyond that, though, because that's only available to the Windows API, and what you'll get back from the API calls will NOT match what you'll get back from LB functions in this case because, for the rest of the system, time has moved on. It's your window that's lagging behind!

(Note: Windows actually does maintain a message queue for each window, and that queue does include input state at the time of the message. If your program is delayed in processing a message, many Windows API calls will return information based on your current message state, that the actual state of the system, until all messages are processed. However, LB processed the Windows message queue for you! That hidden queue/buffer is gone!)


Or maybe the events just never trigger. LB processes the Windows queue behind your back to prevent the "not responding" thing, but your code never gets the events. In that case, your customers have to deal with all of the non-functionized windows in your program just not doing anything when they try to interact with it. It's disabled in all but appearance, and you can bet that will confuse people.

You did state "ignore those events completely", so I'm guessing that's your intention; however, the windows will still appear to be enabled, and I guarantee customers will get confused because it's not doing anything. That's why disabling a window changes it's appearance as well: to indicate that that window is (temporarily) unusable.
« Last Edit: Aug 2nd, 2016, 8:48pm by Chris Iverson » User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar

author of Liberty BASIC


Homepage PM


Posts: 2833
xx Re: Disable dialog window crashes LB 4.04
« Reply #17 on: Aug 3rd, 2016, 10:19am »

Are we talking about opening, managing and closing a window all inside of a single SUB?

Like this?

Code:
  call openWindow
  print "done"
  end

sub openWindow

    button #w.doNotice, "Notice", [doNotice], UL, 10, 40
    textbox #w.text, 10, 10, 250, 25
    open "dialog" for dialog_modal as #w
    #w "trapclose [quit]"
    wait

[doNotice]
    #w.text "!contents? text$";
    notice text$
    wait

[quit]
    close #w

end sub
 


Obviously this has to be done with some care. In particular it works best if there is only one main program window, and only one popup modal dialog open at a time.

Otherwise I don't think this approach has much to recommend it.

-Carl
User IP Logged

author of Liberty BASIC
http://www.libertybasic.com
hooshnik
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 105
xx Re: Disable dialog window crashes LB 4.04
« Reply #18 on: Aug 5th, 2016, 12:20pm »

on Aug 3rd, 2016, 10:19am, CarlGundel wrote:
Are we talking about opening, managing and closing a window all inside of a single SUB?

Like this?

Code:
  call openWindow
  print "done"
  end

sub openWindow

    button #w.doNotice, "Notice", [doNotice], UL, 10, 40
    textbox #w.text, 10, 10, 250, 25
    open "dialog" for dialog_modal as #w
    #w "trapclose [quit]"
    wait

[doNotice]
    #w.text "!contents? text$";
    notice text$
    wait

[quit]
    close #w

end sub
 




Yes and no. Yes for putting the window inside a function. No for having branch labels as event handlers. If I am using functionized windows in certain places and the event handlers (for buttons) for those are pointing to other subs. Does that make any difference?
« Last Edit: Aug 5th, 2016, 12:20pm by hooshnik » User IP Logged

looking for file "include" support? Check out Aplomb Scribe http://libertybasic.conforums.com/index.cgi?action=display&board=open&num=1434746448
hooshnik
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 105
xx Re: Disable dialog window crashes LB 4.04
« Reply #19 on: Aug 5th, 2016, 12:22pm »

on Aug 2nd, 2016, 8:47pm, Chris Iverson wrote:
That's why disabling a window changes it's appearance as well: to indicate that that window is (temporarily) unusable.


So if I use the API call it will also turn the window gray? I thought you needed another API call for that?
User IP Logged

looking for file "include" support? Check out Aplomb Scribe http://libertybasic.conforums.com/index.cgi?action=display&board=open&num=1434746448
Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2282
xx Re: Disable dialog window crashes LB 4.04
« Reply #20 on: Aug 5th, 2016, 1:32pm »

on Aug 5th, 2016, 12:22pm, hooshnik wrote:
So if I use the API call it will also turn the window gray? I thought you needed another API call for that?


Yes. The EnableWindow() API is what's used to mark a window as enabled/disabled to the window manager itself. (LB will issue an EnableWindow() call on your behalf if you use the #win, "disable", etc. commands.)

The window manager itself is in charge of default UI apperance/dpslay(e.g. regular buttons, etc) as well as drawing/displaying the non-client area(the border/titlebar of the window). When the window manager sees your window is disabled, it draws an alternate version that is greyed out. This all happens for you automatically. All you have to do is hint to the window manager that the window is disabled. Using the EnableWindow() API does that.
« Last Edit: Aug 5th, 2016, 1:33pm by Chris Iverson » User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
hooshnik
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 105
xx Re: Disable dialog window crashes LB 4.04
« Reply #21 on: Aug 5th, 2016, 2:53pm »

Not once have I ever seen a grayed out window with LB on any platform. I wonder what the heck is going on huh
User IP Logged

looking for file "include" support? Check out Aplomb Scribe http://libertybasic.conforums.com/index.cgi?action=display&board=open&num=1434746448
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5560
xx Re: Disable dialog window crashes LB 4.04
« Reply #22 on: Aug 5th, 2016, 3:23pm »

Perhaps we should see some code, a simple example of what you are doing. You have been asked several times.

Perhaps this is not a bug and you should post in the coding board.

Post code that shows how you establish two windows and how you move between the two.
User IP Logged

Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2282
xx Re: Disable dialog window crashes LB 4.04
« Reply #23 on: Aug 5th, 2016, 9:32pm »

on Aug 5th, 2016, 2:53pm, hooshnik wrote:
Not once have I ever seen a grayed out window with LB on any platform. I wonder what the heck is going on huh


Forgive me, I was misremembering things. Disabling individual controls(whether by using !DISABLE or EnableWindow()) WILL cause them to appear differently, but it looks like a disabled top level window just can't be focused on, and simply appears to be a non-active window.
User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
hooshnik
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 105
xx Re: Disable dialog window crashes LB 4.04
« Reply #24 on: Aug 8th, 2016, 11:23am »

on Aug 5th, 2016, 3:23pm, Rod wrote:
Perhaps we should see some code, a simple example of what you are doing. You have been asked several times.

Perhaps this is not a bug and you should post in the coding board.

Post code that shows how you establish two windows and how you move between the two.


Ok.

mixing 'functionized' and standard windows
http://libertybasic.conforums.com/index.cgi?board=LB3&action=display&num=1470673339
User IP Logged

looking for file "include" support? Check out Aplomb Scribe http://libertybasic.conforums.com/index.cgi?action=display&board=open&num=1434746448
Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Liberty BASIC Community Wiki
Wikispaces
Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls