Author |
Topic: Closing MainWin conditionally? (Read 621 times) |
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Closing MainWin conditionally?
« Thread started 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
|
« Last Edit: Aug 30th, 2015, 7:14pm by Monkfish » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Closing MainWin conditionally?
« Reply #1 on: Aug 30th, 2015, 9:25pm » |
|
on Aug 30th, 2015, 6:24pm, Monkfish wrote: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: Richard.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Closing MainWin conditionally?
« Reply #2 on: Aug 30th, 2015, 9:47pm » |
|
Thanks Richard. I knew there must be a way to do it.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Closing MainWin conditionally?
« Reply #3 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.
|
« Last Edit: Aug 31st, 2015, 09:55am by Monkfish » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Closing MainWin conditionally?
« Reply #4 on: Aug 31st, 2015, 10:57am » |
|
on Aug 31st, 2015, 09:54am, Monkfish wrote: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.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Closing MainWin conditionally?
« Reply #5 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 ;)
|
|
Logged
|
|
|
|
|