LB Booster
General >> General Board >> Closing MainWin conditionally? http://lbb.conforums.com/index.cgi?board=general&action=display&num=1440959048 Closing MainWin conditionally?
Post by Monkfish on Aug 30th, 2015, 6:24pm
I know, I shouldn't be using MainWin
But is there a way to close MainWin without using the compiler instruction nomainwin?
I would like to close MainWin conditionally...
...or hide it or open it minimised.
Thank you
Re: Closing MainWin conditionally?
Post by Richard Russell on Aug 30th, 2015, 9:25pm
But is there a way to close MainWin without using the compiler instruction nomainwin? ...or hide it or open it minimised.
Reading between the lines, are you trying to discover the mainwin's window handle? With that you can easily close it, hide it, minimize it, move it etc. using regular Windows API calls.
You can get the mainwin's handle using an embedded BBC BASIC statement:
Code:
!hmainwin = @hwnd%
Richard.
Re: Closing MainWin conditionally?
Post by Monkfish on Aug 30th, 2015, 9:47pm
Thanks Richard. I knew there must be a way to do it.
Re: Closing MainWin conditionally?
Post by Monkfish on Aug 31st, 2015, 09:54am
In the end I used the CloseWindow function to minimise the window instead of the DestroyWindow function that kills the program. This is because I wanted to get rid of mainwin but still wanted to display a notice (using the LB "Notice" command). It still shows the window being minimized, but that's okay.
Re: Closing MainWin conditionally?
Post by Richard Russell on Aug 31st, 2015, 10:57am
In the end I used the CloseWindow function to minimise the window instead of the DestroyWindow function that kills the program.
There's no point in calling DestroyWindow, since END has the same effect (in a compiled EXE).
Personally I don't like calling CloseWindow simply because it is misleadingly named (it doesn't close the window). My preference is to call ShowWindow with the SW_MINIMIZE parameter because then it's obvious what you are doing.
Quote:
It still shows the window being minimized, but that's okay.
Wouldn't hiding the window be better?
Richard.
Re: Closing MainWin conditionally?
Post by Monkfish on Aug 31st, 2015, 3:01pm
Used the following. Thank you :)
Code:
calldll #user32, "ShowWindow", hmainwin as long, 0 as long, r as boolean
I think I need a reference book for all these API calls ;)