Page 1 of 2
MessageBox failed
Posted: Mon Jul 05, 2010 10:37 am
by HotteHC
Hi at all.
It seems like there is a bug with the MessageBox_() API-Function.
The following could doesn't show the MessageBox :
Code: Select all
If MessageBox_(#Null,"Do you want Fullscreen?","Mode",#MB_YESNO|#MB_ICONQUESTION) = #IDNO
fullscreen = #False
Endif
If you do a MessageRequester-Call before, the MessageBox_ shows correctly.
Code: Select all
MessageRequester("","")
If MessageBox_(#Null,"Do you want Fullscreen?","Mode",#MB_YESNO|#MB_ICONQUESTION) = #IDNO
fullscreen = #False
Endif
I'm using PB 4.5(x86) but it also failed with the PB 4.4(x86).
Re: MessageBox failed
Posted: Mon Jul 05, 2010 11:18 am
by PB
Your first standalone snippet works fine here. Have you tried it with a clean PureBasic install? Which OS are you using, etc?
It's definitely not a bug though, as I've been using MessageBox like that in my apps for many previous versions of PureBasic.
Re: MessageBox failed
Posted: Mon Jul 05, 2010 11:23 am
by netmaestro
The Common Controls library must be initialized, just starting with a bare api command like that is hit-or-miss at best. The call to MessageRequester is telling PB you're doing something requiring an InitComonControlsEx_() and so it's allowing it to work. Not a bug in PureBasic.
Re: MessageBox failed
Posted: Mon Jul 05, 2010 11:25 am
by HotteHC
OK.
Thanks for the answers and good to know !
mfg Christian
Re: MessageBox failed
Posted: Mon Jul 05, 2010 11:55 am
by Edwin Knoppert
netmaestro wrote:The Common Controls library must be initialized, just starting with a bare api command like that is hit-or-miss at best. The call to MessageRequester is telling PB you're doing something requiring an InitComonControlsEx_() and so it's allowing it to work. Not a bug in PureBasic.
Why?
The common messagebox() does not require common controls.
Re: MessageBox failed
Posted: Mon Jul 05, 2010 12:13 pm
by gnozal
Edwin Knoppert wrote:netmaestro wrote:The Common Controls library must be initialized, just starting with a bare api command like that is hit-or-miss at best. The call to MessageRequester is telling PB you're doing something requiring an InitComonControlsEx_() and so it's allowing it to work. Not a bug in PureBasic.
Why?
The common messagebox() does not require common controls.
It seems to be necessary if you compile with manifest and run the exe on a windows with themes enabled...
Maybe because themes use COMCTL32.DLL ?
Re: MessageBox failed
Posted: Mon Jul 05, 2010 12:56 pm
by c4s
Offtopic:
@PB
Found your forum password again?

Re: MessageBox failed
Posted: Mon Jul 05, 2010 1:59 pm
by PB
Hehe, yeah, it's easy enough to get the forum to change it again.

You should see a milder PB from now on, thanks to the lobotomy!

Re: MessageBox failed
Posted: Mon Jul 05, 2010 2:25 pm
by rsts
Re: MessageBox failed
Posted: Mon Jul 05, 2010 2:26 pm
by freak
Edwin Knoppert wrote:netmaestro wrote:The Common Controls library must be initialized, just starting with a bare api command like that is hit-or-miss at best. The call to MessageRequester is telling PB you're doing something requiring an InitComonControlsEx_() and so it's allowing it to work. Not a bug in PureBasic.
Why?
The common messagebox() does not require common controls.
There is no official documentation about it afaik, but there are many discussions about this issue on the net:
http://www.google.de/search?q=MessageBo ... onControls
If you use MessageRequester(), PB makes sure that InitCommonControls is called on program start, that is why it works then.
@PB: welcome back.
Re: MessageBox failed
Posted: Mon Jul 05, 2010 4:01 pm
by Edwin Knoppert
Themed controls require the common controls lib to be loaded.
When the app is themed the msbox button may no get loaded for example (and Windows exits this functionality?).
I ever had this issue with the lcc compiler having a manifest, after some testing i discovered the initc.. need's to be invoked.
This may be your issue as well, iow it may not be a msgbox issue but an incorrect theming handling in PureBasic?
But that i don't know.
Re: MessageBox failed
Posted: Mon Jul 05, 2010 4:48 pm
by freak
Why should this be a PB issue? It only happens when the PB function is _not_ used.
Re: MessageBox failed
Posted: Mon Jul 05, 2010 6:23 pm
by Edwin Knoppert
It's only an issue if things are (not) handled like i explained.
If you add a manifest it is required to load the common controls, maybe nnot initialise it but at least load.
That is what i discovered about theming and if i am wrong let me know.., and yes i expect a compiler following the rules.
Anyway this still may be another issue.
>Why should this be a PB issue? It only happens when the PB function is _not_ used.
That be so if you don't think outside the box.
Re: MessageBox failed
Posted: Mon Jul 05, 2010 6:45 pm
by freak
It is not the compiler's job to do this for you.
You can go two routes here:
- decide you want PB to handle things for you and use the PB function MessageRequester() (then InitCommonControls() is called for you)
- decide you want to do things yourself and call the MessageBox() API (then you have to call InitCommonControls() yourself).
You cannot decide you want to do stuff yourself and then complain that PB isn't doing things for you. If you want to use API,
you also have to make sure everything is initialized the way you need it. This isn't PB's job.
Re: MessageBox failed
Posted: Mon Jul 05, 2010 7:17 pm
by Edwin Knoppert
Note that i still assume this is related to theming..
No, in this case you are wrong imo.
Once the theming manifest is set by the compiler (via its settings) it should implement theming correctly and not half-way.
By adding the manifest you give the assumtion that everything is ok while it's not.
Anyway, odd that the internal function does something extra...? (sounds like jim'll fix-it mode)
Hope to hear about this soon as well.
Besides what other api may fail?