MessageRequester constants

Just starting out? Need help? Post your questions and find answers here.
mestnyi
Addict
Addict
Posts: 1103
Joined: Mon Nov 25, 2013 6:41 am

MessageRequester constants

Post by mestnyi »

now it's the other way around, it works fine on Mac and Linux, but on Windows it gets mixed up.

Code: Select all

;\\                                       ; win ; mac & lin
; Debug #PB_MessageRequester_YesNoCancel  ; 3   ; 2
; Debug #PB_MessageRequester_YesNo        ; 4   ; 1
; Debug #PB_MessageRequester_Yes          ; 6   ; 6
; Debug #PB_MessageRequester_Error        ; 16  ; 8
; Debug #PB_MessageRequester_Warning      ; 48  ; 16
; Debug #PB_MessageRequester_Info         ; 64  ; 4
; 
; Debug ""
; Debug #PB_MessageRequester_Ok           ; 0   ; 0
; Debug #PB_MessageRequester_Cancel       ; 2   ; 2
; Debug #PB_MessageRequester_No           ; 7   ; 7
; 

Define Flag.q = #PB_MessageRequester_YesNoCancel|#PB_MessageRequester_Warning

If Flag & #PB_MessageRequester_Info
   Debug "#PB_MessageRequester_Info"
EndIf

If Flag & #PB_MessageRequester_Error
   Debug "#PB_MessageRequester_Error"
EndIf

If Flag & #PB_MessageRequester_Warning
   Debug "#PB_MessageRequester_Warning"
EndIf
User avatar
spikey
Enthusiast
Enthusiast
Posts: 778
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: MessageRequester constants

Post by spikey »

The values are not entirely bit-based. You can't do things like 'and mask' on them properly. Specifically, on Windows, #PB_MessageRequester_Warning has a two significant bit value not a single bit value and there is an overlap.

Code: Select all

Debug RSet(Bin(#PB_MessageRequester_Info), 8, "0")
Debug RSet(Bin(#PB_MessageRequester_Warning), 8, "0")
Debug RSet(Bin(#PB_MessageRequester_Error), 8, "0")
These values aren't intended to hang around to provide persistent state information. They're intended for transient and disposable dialogs.

(#PB_MessageRequester_Yes is an output value not an input one.)
mestnyi
Addict
Addict
Posts: 1103
Joined: Mon Nov 25, 2013 6:41 am

Re: MessageRequester constants

Post by mestnyi »

spikey wrote: Wed Dec 06, 2023 2:46 pm Specifically, on Windows, #PB_MessageRequester_Warning has a two significant bit value not a single bit value and there is an overlap.
exactly why is this so?
spikey wrote: Wed Dec 06, 2023 2:46 pm These values aren't intended to hang around to provide persistent state information. They're intended for transient and disposable dialogs.
https://www.purebasic.com/documentation ... ester.html
look at what is written in the help.
spikey wrote: Wed Dec 06, 2023 2:46 pm (#PB_MessageRequester_Yes is an output value not an input one.)
:shock:
User avatar
spikey
Enthusiast
Enthusiast
Posts: 778
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: MessageRequester constants

Post by spikey »

mestnyi wrote: Wed Dec 06, 2023 5:52 pm Exactly why is this so?
The values are inherited directly from the Windows API header files, because they will end up back in an API function at runtime. I assume that a similar rationale applies to the other operating systems too and this is where the slight variations creep in. They are just 'redecorated' in PureBasic format to present a consistent look for PB programmers in the source code. In this case the header is WinUser.h on Windows.
User avatar
mk-soft
Always Here
Always Here
Posts: 6329
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: MessageRequester constants

Post by mk-soft »

Only Windows ...

Code: Select all

Debug #PB_MessageRequester_Ok
Debug #MB_OK

Debug #PB_MessageRequester_YesNo
Debug #MB_YESNO

Debug #PB_MessageRequester_YesNoCancel
Debug #MB_YESNOCANCEL

r1 = MessageRequester("Only Windows", "Ok/Cancel", #MB_OKCANCEL)
Debug r1
Select r1
  Case #IDOK
    Debug "OK"
  Case #IDCANCEL
    Debug "Cancel"
EndSelect

r1 = MessageRequester("Only Windows", "Retry/Cancel", #MB_RETRYCANCEL)
Debug r1
Select r1
  Case #IDRETRY
    Debug "Retry"
  Case #IDCANCEL
    Debug "Cancel"
EndSelect
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply