MessageBox failed

Just starting out? Need help? Post your questions and find answers here.
HotteHC
User
User
Posts: 19
Joined: Fri Feb 29, 2008 7:44 am

MessageBox failed

Post 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).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: MessageBox failed

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: MessageBox failed

Post 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.
BERESHEIT
HotteHC
User
User
Posts: 19
Joined: Fri Feb 29, 2008 7:44 am

Re: MessageBox failed

Post by HotteHC »

OK.
Thanks for the answers and good to know ! ;)
mfg Christian
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Re: MessageBox failed

Post 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.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: MessageBox failed

Post 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 ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: MessageBox failed

Post by c4s »

Offtopic:

@PB
Found your forum password again? ;)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: MessageBox failed

Post 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! :lol:
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: MessageBox failed

Post by rsts »

PB wrote: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! :lol:
:lol: :lol:

welcome back :D
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: MessageBox failed

Post 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.
quidquid Latine dictum sit altum videtur
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Re: MessageBox failed

Post 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.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: MessageBox failed

Post by freak »

Why should this be a PB issue? It only happens when the PB function is _not_ used.
quidquid Latine dictum sit altum videtur
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Re: MessageBox failed

Post 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.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: MessageBox failed

Post 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.
quidquid Latine dictum sit altum videtur
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Re: MessageBox failed

Post 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?
Post Reply