Page 1 of 1

Changing "Stupid" MessageRequester Behaviour

Posted: Mon Apr 17, 2006 9:38 pm
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!

Posted: Tue Apr 18, 2006 1:50 am
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.

Posted: Tue Apr 18, 2006 12:25 pm
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

Posted: Tue Apr 18, 2006 12:44 pm
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.

Posted: Tue Apr 18, 2006 9:30 pm
by PureBaser
Good hint and thanks! Even more I know PB, it's more better than I believed to!