Changing "Stupid" MessageRequester Behaviour

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
PureBaser
User
User
Posts: 33
Joined: Mon Apr 10, 2006 8:47 pm
Location: Berlin, Germany
Contact:

Changing "Stupid" MessageRequester Behaviour

Post by PureBaser »

Hello!

This is a bit complex Problem, so read only, if you've enough time and fun!


:arrow: IMPORTANT; This examples are valid only for 3.94, but I found the same Problem in PB4Beta10 (it's behavour is a bit other but not "correct")

First have a look on this code

Code: Select all

OpenWindow(0,300,300,300,300,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget,"Hallo")
  Repeat
  Event = WaitWindowEvent()
    Select Event
    Case #PB_Event_CloseWindow
    aw = MessageRequester("Info","Do you really want to close the windows?",0)            ; <-- The last value set the Option (COLUMN 1)
      If aw = 1           ; <-- The possible value(s) set the event (COLUMN 2)
      CloseWindow(0)
      End
      EndIf
    EndSelect
  ForEver
Now look at these table:

Options (COLUMNE 1)____________________Buttons-Event (COLUMNE 2)

0 = Ok_____________________________________1
1 = OK Cancel_______________________________1 2
2 = Cancel Retry Ignore_______________________3 4 5
3 = Yes No Cancel____________________________6 7 2
4 = Yes No__________________________________6 7
5 = Retry Cancel_____________________________4 2
6 = Cancel Retry Continue_____________________2 10 11

Do you understand the table? Here's a small explanation if you don't:

For example, we want a MessageRequester with Yes No - Buttons, we can write in Options the number 4 (the same like #PB_MessageRequester_YesNo). So we have two Buttons. The Button "Yes" have the value 6 and the Button "No" the value 7, how you can see in the table.

There are two Problems for me:

1) The "Yes","No","Ok" and "Ignore"-Buttons have always the same value (6,7,1,5) - thats defenitely Ok!
In Option (COLUMN 1) 2 and 5 the Cancel Button has the same Value (2) but in Option 3 you have to write value 3 for the Cancel Button - also another value for the same button!
The Same Problem has the Retry Button - in Option 2 and 5 its contains the value 4, but in Option 6 it needs the value 10 for call?!?!
It's an intention or a bug?!

Why it so and not always the same number for the same button? So you can introduce even constanst for the Button-event.

2) In the (German) Helpfile there are only listen three of the six (see COLUMN 1) options. Where are the 3 other? Why the 3 other options haven't constants?


I hope you understand the problem - I know, this English text is very hard readable...

My suggestion:

Add the other MessageRequester's like:

#PB_MessageRequester_OkCancel
#PB_MessageRequester_CancelRetryContinue
[...]

Give every button (Column 2) the same number and maybe a constant

e.g.

1 = OK = #PB_Event_Ok (or PB_Button_Ok or ....)
2 = Cancel = #PB_Event_Cancel
3 = Ignore = [...]
4 = Retry
5 = Continue
6 = Yes
7 = No


PUH I finished

Nice Week!
PB 4 | WinXP_SP2
Konne
Enthusiast
Enthusiast
Posts: 434
Joined: Thu May 12, 2005 9:15 pm

Post by Konne »

Sure a good idea but I hope (otherwise this would be stupid) it is a problem of the API and that PB is just giving the Flag to the API command.
Apart from that Mrs Lincoln, how was the show?
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post by Nik »

Code: Select all

OpenWindow(0,300,300,300,300,"Hallo",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
  Repeat
  Event = WaitWindowEvent()
    Select Event
    Case #PB_Event_CloseWindow
    aw = MessageBox_(0,"Do you really want to close the windows?","Info",0)            ; <-- The last value set the Option (COLUMN 1)
      If aw = 1           ; <-- The possible value(s) set the event (COLUMN 2)
      CloseWindow(0)
      End
      EndIf
    EndSelect
  ForEver
Here is the API Version of the code for PB 4 Beta 10
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

yes, it's a API behaviour.

in order to simplify the code, i always use #IDOK, #IDCANCEL, and so on...

Code: Select all

Select MessageRequester("Test", "Test", #MB_OK)
  Case #IDOK: Debug "ok"
EndSelect

Select MessageRequester("Test", "Test", #MB_YESNO)
  Case #IDYES: Debug "yes"
  Case #IDNO:  Debug "no"
EndSelect

Select MessageRequester("Test", "Test", #MB_YESNOCANCEL)
  Case #IDYES:    Debug "yes"
  Case #IDNO:     Debug "no"
  Case #IDCANCEL: Debug "cancel"
EndSelect

Select MessageRequester("Test", "Test", #MB_OKCANCEL)
  Case #IDOK:     Debug "ok"
  Case #IDCANCEL: Debug "cancel"
EndSelect

Select MessageRequester("Test", "Test", #MB_RETRYCANCEL)
  Case #IDRETRY:  Debug "retry"
  Case #IDCANCEL: Debug "cancel"
EndSelect

Select MessageRequester("Test", "Test", #MB_ABORTRETRYIGNORE)
  Case #IDABORT:  Debug "abort"
  Case #IDRETRY:  Debug "retry"
  Case #IDIGNORE: Debug "ignore"
EndSelect
So it's not cross-platform but it's much simpler.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
PureBaser
User
User
Posts: 33
Joined: Mon Apr 10, 2006 8:47 pm
Location: Berlin, Germany
Contact:

Post by PureBaser »

Good hint and thanks! Even more I know PB, it's more better than I believed to!
PB 4 | WinXP_SP2
Post Reply