IonicWind Software

IWBasic => Tutorials => Topic started by: Andy on February 17, 2018, 09:09:06 AM

Title: Using the SHOWWINDOW command
Post by: Andy on February 17, 2018, 09:09:06 AM
As most of you know, I've been (and will continue) to work on my custom menu library.

Early into this I came across something I'd seen once before - that was the whole window "disappearing" when I was only trying to hide a control or set of controls (not the window).

Here (from the custom menu library was the code):

for cwYloop = 0 to cwMenuCount
     for cwZloop = 1 to cwTotalMenuItems
          SHOWWINDOW,w1,@SWHIDE,cwMenuTltles[cwMenus[cwYloop]]
     next cwZloop
next cwYloop


The code should hide a set of controls associated with a menu title e.g. "File", but made the entire window disappear instead.

The last time I had this, somehow (whatever I must have done) solved it - but I never knew why.

Now, I understand a lot more about the IWB commands, and is what I found....

When I traced the value of the variable cwMenuTltles[cwMenus[cwYloop] I found it could be zero, so why would that make the window itself "vanish"?

Now, when I re-read the help file for the SHOWWINDOW command I realised that the control number was optional, in other words if you don't specify a specific control then it's taken as a zero.

In other words,

showwindow w1,@SWHIDE,0

is the same as

showwindow w1,@SWHIDE

Conclusion.

Always make sure, especially when hiding a group of controls with a variable that the variable is NOT zero.

My later code now looks like this:

for cwYloop = 0 to cwMenuCount
     for cwZloop = 1 to cwMenusCount[cwMenus[cwYloop]]
          SHOWWINDOW,w1,@SWHIDE,cwMenuTltles[cwMenus[cwYloop]]
     next cwZloop
next cwYloop


Or you could do this instead...


    if cwMenuTltles[cwMenus[cwYloop]] > 0
          SHOWWINDOW,w1,@SWHIDE,cwMenuTltles[cwMenus[cwYloop]]
    endif


Hope this little snippet helps in some way.

Andy.
:)