August 18, 2019, 03:23:14 pm


Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........

Using the SHOWWINDOW command

Started by Andy, February 17, 2018, 09:09:06 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


February 17, 2018, 09:09:06 am Last Edit: February 17, 2018, 09:10:40 am by Andy
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):

Code Select
for cwYloop = 0 to cwMenuCount
     for cwZloop = 1 to cwTotalMenuItems
     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


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:

Code Select
for cwYloop = 0 to cwMenuCount
     for cwZloop = 1 to cwMenusCount[cwMenus[cwYloop]]
     next cwZloop
next cwYloop

Or you could do this instead...

Code Select

    if cwMenuTltles[cwMenus[cwYloop]] > 0

Hope this little snippet helps in some way.


Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.