Announcement

Collapse
No announcement yet.

Can someone explain these lines to me

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can someone explain these lines to me

    Can someone explain to me what the two lines of code that I have isolated inside the asterisk box actually do. It has something to do with %MB_DEFBUTTON but i can't figure it out.
    1st how does i get its value, I know what lStyle is but what is &H0000000F, likewise how does j get its value and what is &H00000F00.

    Thanks everyone.


    Code:
    Code:
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "win32api.inc"
    '#RESOURCE ICON, a,        "E:\GDrive\SPFLite10\Resource File\SPFLite10.ICO"
    
    '----- MyMsgBox Equates
    ENUM MyMsgBox_equates SINGULAR
    MMB_Dlg = 9800
        MMB_Msg              ' Return Codes
    MMB_OK               '  1  %IDOK
    MMB_Cancel           '  2  %IDCANCEL
    MMB_Abort            '  3  %IDABORT
    MMB_Retry            '  4  %IDRETRY
    MMB_Ignore           '  5  %IDIGNORE
    MMB_Yes              '  6  %IDYES
    MMB_No               '  7  %IDNO
    MMB_TryAgain         ' 10  %IDTRYAGAIN
    MMB_Continue         ' 11  %IDCONTINUE
    MMB_Icon
    END ENUM
    
    FUNCTION PBMAIN () AS LONG
       LOCAL i AS LONG
       LOCAL mt AS STRING
    mt = "\KYou want to save this record"+$CRLF+"to the yarn data file?"+$CRLF+"(YES) = Save"+$CRLF+ _
    "(NO) = Discard"
    i = MyMsgBox(mt, %MB_YESNO OR %MB_ICONQUESTION, "Some kind of Title", 12)
    MSGBOX "Returned: " + FORMAT$(i)
    END FUNCTION
    ' "Some sample \RRed \Btext"
    
    FUNCTION MyMsgBox(mTxt AS STRING, OPT mStyle AS LONG, OPT mTitle AS STRING, OPT mpitch AS LONG, OPT mBG AS LONG) AS LONG
    '---------- Private MSGBOX equivalent with color/Font size support
    'mTxt     Text of the message
    '         Default text color is %RGB_BLUE.
    '         Change anywhere with embedded \x where
    '         x can be: "K" - %RGB_BLACK       "G" - %RGB_GREEN       "B" - %RGB_BLUE
    '                   "R" - %RGB_RED         "O" - %RGB_ORANGE      "I" - %RGB_INDIGO
    '                   "P" - %RGB_DEEPPINK    "W" - %RGB_WHITE       "Y" - %RGB_GRAY
    '         e.g.  "This message has a \GGreen \Band \RRed \Bword in it"
    '
    'mStyle   Supports
    '         %MB_OK                %MB_YESNO             %MB_OKCANCEL
    '         %MB_RETRYCANCEL       %MB_YESNOCANCEL       %MB_ABORTRETRYIGNORE
    '         %MB_CANCELTRYCONTINUE
    '
    '         %MB_ICONERROR         %MB_ICONSTOP          %MB_ICONHAND
    '         %MB_ICONEXCLAMATION   %MB_ICONINFORMATION   %MB_ICONQUESTION
    '         %MB_ICONWARNING       %MB_ICONASTERISK      %MB_USERICON
    '
    '         %MB_DEFBUTTON1        %MB_DEFBUTTON2        %MB_DEFBUTTON3
    'mTitle   Text for popup box Title
    'mPitch   Size of Font for the message text
    'mBG      Color for message Background (Default is %RGB_BEIGE
    
    REGISTER i AS LONG
    REGISTER j AS LONG
    LOCAL mlist(), t, t2, bTxt, lTitle AS STRING
    LOCAL hmsg, hIcon, hFont, hFontB AS DWORD
    LOCAL lResult, ChrX, ChrY, TxtX, TxtY, NumLines AS LONG
    LOCAL x, y, w, h, clr, lStyle, lPitch, lBG, bID, bDef, bLoc AS LONG
    
    '----- Get parameters and build fonts
    lStyle = IIF(ISMISSING(mStyle), %MB_OK OR %MB_USERICON, mStyle)' Get Style if provided
    lTitle = IIF$(ISMISSING(mTitle), "", mTitle)                   ' Get Title if provided
    lPitch = IIF(ISMISSING(mpitch), 11, mpitch)                    ' Get pitch if provided
    lBG    = IIF(ISMISSING(mBG), %RGB_BEIGE, mBG)                  ' Get BG color if provided
    FONT NEW "Segoe UI SemiBold", lPitch TO hFont                  ' Build our Font
    FONT NEW "Segoe UI SemiBold", 12 TO hFontB                     ' Build our Font for button text
    
       '----- Build an empty dialog to get font sizes
    DIALOG NEW PIXELS, 0, lTitle, 0, 0, 20, 20,%WS_SYSMENU TO hmsg ' Create the Dialog
    DIALOG SET COLOR hMsg, %RGB_BLUE, lBG                          ' Set color
    CONTROL ADD GRAPHIC, hmsg, %MMB_msg, "", 0, 0, 10, 10          ' Add the graphic text area
    GRAPHIC ATTACH hmsg, %MMB_msg                                  ' Attach it
    GRAPHIC COLOR %RGB_RED, lBG                                    ' Set default color
    GRAPHIC SET FONT hfont                                         ' Set it to our Font
    ChrX = GRAPHIC(CHR.SIZE.X)                                     ' Get the average character width
    ChrY = GRAPHIC(CHR.SIZE.Y)                                     ' Get the average character height
    
       '----- Calc width based on the supplied text
    NumLines = PARSECOUNT(mTxt, $CRLF)                             ' Get the Maximum line length
    REDIM mlist(NumLines)                                          '
    PARSE mTxt, mlist(), $CRLF                                     '
    FOR i = 0 TO NumLines                                          '
    j = GRAPHIC(TEXT.SIZE.X, mlist(i))                          '
    TxtX = MAX(j, TxtX)                                         '
    NEXT i                                                         '
    
    TxtX += 70: TxtX = MAX(txtX, 340)                              ' Add 70 for Icon + Left/Right margins; ensure size for buttons
    TxtY = MAX((ChrY * (NumLines) + 10), 40)                       ' Get total height for all lines - Minimum 40 for Icon
    
       '----- Resize now to actual size needed
    DIALOG SET CLIENT hmsg, TxtX, TxtY + 60                        ' Resize dialog (+ 30 for buttons)
    CONTROL SET SIZE hmsg, %MMB_msg, TxtX, TxtY                    ' Resize the text area
    
    
       '----- Print the text finally
    FOR i = 0 TO NumLines     ' Print text now
    GRAPHIC SET POS (50, IIF(NumLines = 1, (40 - ChrY) / 2, i * ChrY))  ' Set position of 1 line beside the Icon
    t = mlist(i)                                                ' Get a working copy
    IF LEN(t) = 0 THEN GRAPHIC PRINT: ITERATE FOR               ' Skip null lines
    x = 1                                                       ' Start at the left
    DO WHILE x <= LEN(t)                                        ' While still stuff in t
    y = INSTR(x, t, "\")                                     ' Look for a color change
    IF y = 0 THEN GRAPHIC PRINT MID$(t, x);: ITERATE FOR     ' No change, print remainder of line
    IF y > x THEN GRAPHIC PRINT MID$(t, x TO y - 1);         ' Print up to the \
    t2 = MID$(t, y + 1, 1)                                   ' Extract the color character
    clr = SWITCH(t2 = "O", %RGB_ORANGE, t2 = "B", %RGB_BLUE,     t2 = "R", %RGB_RED, _
    t2 = "G", %RGB_GREEN,  t2 = "P", %RGB_DEEPPINK, t2 = "I", %RGB_INDIGO, _
    t2 = "K", %RGB_BLACK,  t2 = "W", %RGB_WHITE,    t2 = "Y", %RGB_GRAY)
    GRAPHIC COLOR clr, lBG                                   ' Set the new color
    x = y + 2                                                ' Step over \x
    LOOP                                                        ' Continue on this string
    NEXT i                                                         ' Loop back for next line
    
       '----- Position the dialog
    DESKTOP GET CLIENT TO w, h                                     '
    x = (w - TxtX) / 2                                             '
    y = (h - (TxtY + 30)) / 2                                      '
    DIALOG SET LOC hMsg, x, y                                      '
    
    ' *********************************************
    ' *  i = lStyle AND &H0000000F              *                    ' Isolate low nibble for button
    ' *  j = lStyle AND &H00000F00              *                    ' Isolate 3rd nibble for button default
    ' *********************************************
    
       '----- Add whatever buttons are needed
    h = TxtY + 5
       i = lStyle AND &H0000000F                                      ' Isolate low nibble for button
    j = lStyle AND &H00000F00                                      ' Isolate 3rd nibble for button default
    
    IF i = %MB_YESNOCANCEL THEN
          IF j = %MB_DEFBUTTON1 OR j = 0 THEN                         ' Button 1 (or null request)
    bID = %MMB_Yes:      bTxt = "Yes":       bLoc = 50:  bDef = %True:  GOSUB BtnDef
             bID = %MMB_No:       bTxt = "No":        bLoc = 160: bDef = %False: GOSUB BtnDef
             bID = %MMB_Cancel:   bTxt = "Cancel":    bLoc = 270: bDef = %False: GOSUB BtnDef
    ELSEIF j = %MB_DEFBUTTON2 THEN                              ' Button 2
    bID = %MMB_Yes:      bTxt = "Yes":       bLoc = 10:  bDef = %False: GOSUB BtnDef
             bID = %MMB_No:       bTxt = "No":        bLoc = 120: bDef = %True:  GOSUB BtnDef
             bID = %MMB_Cancel:   bTxt = "Cancel":    bLoc = 230: bDef = %False: GOSUB BtnDef
    ELSE                                                        ' Button 3
    bID = %MMB_Yes:      bTxt = "Yes":       bLoc = 10:  bDef = %False: GOSUB BtnDef
             bID = %MMB_No:       bTxt = "No":        bLoc = 120: bDef = %False: GOSUB BtnDef
             bID = %MMB_Cancel:   bTxt = "Cancel":    bLoc = 230: bDef = %True:  GOSUB BtnDef
    END IF                                                      '
    ELSEIF i = %MB_ABORTRETRYIGNORE THEN
          IF j = %MB_DEFBUTTON1 OR j = 0 THEN                         ' Button 1 (or null request)
    bID = %MMB_Abort:    bTxt = "Abort":     bLoc = 10:  bDef = %True:  GOSUB BtnDef
             bID = %MMB_Retry:    bTxt = "Retry":     bLoc = 110: bDef = %False: GOSUB BtnDef
             bID = %MMB_Ignore:   bTxt = "Ignore":    bLoc = 230: bDef = %False: GOSUB BtnDef
    ELSEIF j = %MB_DEFBUTTON2 THEN                              ' Button 2
    bID = %MMB_Abort:    bTxt = "Abort":     bLoc = 10:  bDef = %False: GOSUB BtnDef
             bID = %MMB_Retry:    bTxt = "Retry":     bLoc = 110: bDef = %True:  GOSUB BtnDef
             bID = %MMB_Ignore:   bTxt = "Ignore":    bLoc = 230: bDef = %False: GOSUB BtnDef
    ELSE                                                        ' Button 3
    bID = %MMB_Abort:    bTxt = "Abort":     bLoc = 10:  bDef = %False: GOSUB BtnDef
             bID = %MMB_Retry:    bTxt = "Retry":     bLoc = 120: bDef = %False: GOSUB BtnDef
             bID = %MMB_Ignore:   bTxt = "Ignore":    bLoc = 230: bDef = %True:  GOSUB BtnDef
    END IF                                                      '
    ELSEIF i = %MB_CANCELTRYCONTINUE THEN
          IF j = %MB_DEFBUTTON1 OR j = 0 THEN                         ' Button 1 (or null request)
    bID = %MMB_Cancel:   bTxt = "Cancel":    bLoc = 10:  bDef = %True:  GOSUB BtnDef
             bID = %MMB_TryAgain: bTxt = "Try Again": bLoc = 120: bDef = %False: GOSUB BtnDef
             bID = %MMB_Continue: bTxt = "Continue":  bLoc = 230: bDef = %False: GOSUB BtnDef
    ELSEIF j = %MB_DEFBUTTON2 THEN                              ' Button 2
    bID = %MMB_Cancel:   bTxt = "Cancel":    bLoc = 10:  bDef = %False: GOSUB BtnDef
             bID = %MMB_TryAgain: bTxt = "Try Again": bLoc = 120: bDef = %True:  GOSUB BtnDef
             bID = %MMB_Continue: bTxt = "Continue":  bLoc = 230: bDef = %False: GOSUB BtnDef
    ELSE                                                        ' Button 3
    bID = %MMB_Cancel:   bTxt = "Cancel":    bLoc = 10:  bDef = %False: GOSUB BtnDef
             bID = %MMB_TryAgain: bTxt = "Try Again": bLoc = 120: bDef = %False: GOSUB BtnDef
             bID = %MMB_Continue: bTxt = "Continue":  bLoc = 230: bDef = %True:  GOSUB BtnDef
    END IF                                                      '
    ELSEIF i = %MB_YESNO THEN
          IF j = %MB_DEFBUTTON1 OR j = 0 THEN                         ' Button 1 (or null request)
    bID = %MMB_Yes:      bTxt = "Yes":       bLoc = 50:  bDef = %True:  GOSUB BtnDef
             bID = %MMB_No:       bTxt = "No":        bLoc = 160: bDef = %False: GOSUB BtnDef
    ELSEIF j = %MB_DEFBUTTON2 THEN                              ' Button 2
    bID = %MMB_Yes:      bTxt = "Yes":       bLoc = 50:  bDef = %False: GOSUB BtnDef
             bID = %MMB_No:       bTxt = "No":        bLoc = 160: bDef = %True:  GOSUB BtnDef
    END IF                                                      '
    ELSEIF i = %MB_RETRYCANCEL THEN
          IF j = %MB_DEFBUTTON1 OR j = 0 THEN                         ' Button 1 (or null request)
    bID = %MMB_Retry:    bTxt = "Retry":     bLoc = 10:  bDef = %True:  GOSUB BtnDef
             bID = %MMB_Cancel:   bTxt = "Cancel":    bLoc = 120: bDef = %False: GOSUB BtnDef
    ELSEIF j = %MB_DEFBUTTON2 THEN                              ' Button 2
    bID = %MMB_Retry:    bTxt = "Retry":     bLoc = 10:  bDef = %False: GOSUB BtnDef
             bID = %MMB_Cancel:   bTxt = "Cancel":    bLoc = 120: bDef = %True:  GOSUB BtnDef
    END IF                                                      '
    ELSEIF i = %MB_OKCANCEL THEN
          IF j = %MB_DEFBUTTON1 OR j = 0 THEN                         ' Button 1 (or null request)
    bID = %MMB_OK:       bTxt = "OK":        bLoc = 10:  bDef = %True:  GOSUB BtnDef
             bID = %MMB_Cancel:   bTxt = "Cancel":    bLoc = 120: bDef = %False: GOSUB BtnDef
    ELSEIF j = %MB_DEFBUTTON2 THEN                              ' Button 2
    bID = %MMB_OK:       bTxt = "OK":        bLoc = 10:  bDef = %False: GOSUB BtnDef
             bID = %MMB_Cancel:   bTxt = "Cancel":    bLoc = 120: bDef = %True:  GOSUB BtnDef
    END IF                                                      '
    ELSE
    bID = %MMB_OK:          bTxt = "OK":        bLoc = 120:  bDef = %True:  GOSUB BtnDef
    END IF
       DIALOG POST hMsg, %WM_CHANGEUISTATE, MAKLNG(%UIS_CLEAR, %UISF_HIDEFOCUS OR %UISF_HIDEACCEL), 0
    
    '----- Add icon
    h = lStyle AND &H000000F0                                      ' Isolate Icon portion
    IF h = 0 THEN h = %MB_USERICON                                 ' Provide a default
    IF h = %MB_USERICON THEN                                       ' The user version?
    CONTROL ADD IMAGEX, hMsg, %MMB_Icon, "a", 10, 8, 32, 32, %SS_ICON
       ELSE                                                           ' Do the standard Icons
    CONTROL ADD LABEL,  hMsg, %MMB_Icon, "",  10, 8, 0, 0, %SS_ICON
    i = 0: j = %MB_OK                                           '
    SELECT CASE AS LONG h                                       '
    CASE %MB_ICONERROR, %MB_ICONHAND, %MB_ICONSTOP           '
    i = 103: j = %MB_ICONHAND                             '
    CASE %MB_ICONQUESTION                                    '
    i = 102: j = %MB_ICONQUESTION                         '
    CASE %MB_ICONWARNING, %MB_ICONEXCLAMATION                '
    i = 101: j = %MB_ICONEXCLAMATION                      '
    CASE %MB_ICONINFORMATION, %MB_ICONASTERISK               '
    i = 104: j = %MB_ICONASTERISK                         '
    END SELECT                                                  '
    hIcon = LoadImage(BYVAL 0, BYVAL i, %IMAGE_ICON, 32, 32, 0)
    SendDlgItemMessage hMsg, %MMB_Icon, %STM_SETIMAGE, %IMAGE_ICON, hIcon
    
    END IF                                                         '
    
       '----- Finally we can display it
    DIALOG SHOW MODAL hmsg, CALL MyMsgBoxproc() TO lResult         ' Go display it
    FONT END hfont                                                 ' Destroy our font
    FUNCTION = lResult                                             ' Pass back result
    EXIT FUNCTION
    
    BtnDef:
    CONTROL ADD BUTTON, hMsg, bID, bTxt, bLoc, h, 90, 40, IIF(bDef, %BS_DEFAULT, 0)
    CONTROL SET FONT hMsg, bID, hFontB                             ' Set Button font
    IF bDef THEN CONTROL SET FOCUS hMsg, bID                       ' Set focus if default
    RETURN                                                         ' Done
    END FUNCTION
    
    CALLBACK FUNCTION MyMsgBoxProc() AS LONG
    LOCAL RC AS LONG
       SELECT CASE CB.MSG
          CASE %WM_COMMAND
             IF CB.CTLMSG = %BN_CLICKED THEN                          ' If button clicked,
    SELECT CASE CB.CTL                                    ' Return with which one
    CASE %MMB_OK:      RC = %IDOK
                   CASE %MMB_Yes:     RC = %IDYES
                   CASE %MMB_No:      RC = %IDNO
                   CASE %MMB_Cancel:  RC = %IDCANCEL
                   CASE %MMB_Abort:   RC = %IDABORT
                   CASE %MMB_Retry:   RC = %IDRETRY
                   CASE %MMB_Ignore:  RC = %IDIGNORE
                   CASE %MMB_TryAgain:RC = %IDTRYAGAIN
                   CASE %MMB_Continue:RC = %IDCONTINUE
                END SELECT
                DIALOG END CB.HNDL, RC
    END IF
        END SELECT
    END FUNCTION
    

  • #2
    &H0000000F and &H00000F00 are masks.
    i will get a copy of bits 0 to 3 from lStyle, all other bits are "masked" out.
    j will get a copy of bits 8 to 11 from lStyle, all other bits are "masked" out.

    Because of the bitwise logical AND, only "1" bits in both lStyle AND the mask are a "1" in the result.

    For example lStyle = &h00600504
    i will be &h00000004 and j will be &h00000500 after those two lines run.

    It is like (reverse of) putting tape on something before painting. Only where there is no tape will get paint.

    Cheers,
    Dale

    Comment


    • #3
      The first IF after those two lines is "= %MB_YESNOCANCEL"

      %MB_YESNOCANCEL has a value of &h003. The other styles in the combined style would prevent that IF from ever being true if not masked out.

      %MD_DEFBUTTON1 = &h000
      %MD_DEFBUTTON2 = &h100
      %MD_DEFBUTTON3 = &h200

      These could not be detected if low nibble (3 in this case) is not masked out.

      Cheers.
      Dale

      Comment


      • #4
        Mr. Dale
        Thank you very much for your answers I really appreciate it, but actually I still don't fully understand those 2 lines. Let me say what I do understand and maybe you can then make my dumb mind comprehend them. I do understand that to get i lStyle and &H0000000F has to be true but WHAT IS THE VALUE of &H0000000F. I know he is using j number to determine which button is the default. So j = lStyle and &H00000F00 and both have to be true, again what is the value of &H00000F00. Also where did he come up with these numbers, are they hex or what.



        Comment


        • #5
          Mr. Dale
          I forgot to ask you suppose you want the 2nd button or the 3rd button to be the default what would you do?

          Comment


          • #6
            Does this help you visualize what is happening?
            we are MASKING out all the bits we don't care about so we can check if the one we do care about are set to 1.
            "WHAT IS THE VALUE of &H0000000F" it's F in hex, 15 dec. chosen by programmer to mask out/in what you need.


            Code:
            lStyle        = &H00600504    0000 0000 0110 0000 0000 0101 0000 0100    (6292740 decimal)
            AND mask      = &H00000F00    0000 0000 0000 0000 0000 1111 0000 0000    ( 3840 decimal)
                            ------------- ----------------------------------------
            j             = $H00000500    0000 0000 0000 0000 0000 0101 0000 0000    ( 1280 decimal)
            
            
            lStyle        = &H00600504    0000 0000 0110 0000 0000 0101 0000 0100    (6292740 decimal)
            AND mask      = &H00000F00    0000 0000 0000 0000 0000 0000 0000 1111    ( 15 decimal)
                           ------------- ----------------------------------------
            i             = $H00000004    0000 0000 0000 0000 0000 0000 0000 0100    ( 4 decimal)
            Last edited by Rod Macia; 25 Jun 2020, 09:31 PM.

            Comment


            • #7
              Don't know about "MyMSGBOX, but PB MSGBOX or Windows MESSAGEBOX I would change style
              from
              %MB_YESNO
              OR %MB_ICONQUESTION
              to
              %MB_YESNO OR %MB_ICONQUESTION OR %MB_DEFBUTTON2
              to make NO the default button.

              You have to have 3 buttons to make third button the default. YES/NO is only 2.

              Cheers,
              Dale

              Comment


              • #8
                Also where did he come up with these numbers, are they hex or what.
                Windows calculator has a 'Programmer' option that converts these numbers from on form of HEX, DEC, OCT, BIN to another of them. Win10 anyway, but I seem to recall on Win7 as well.
                Rod
                I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                Comment


                • #9
                  Mr Rod Macia
                  How did you arrive at lStyle = &H00600504. I still don't understand how he got the default button to be button number one.

                  Mr. Dale
                  Yes that works for MyMsgBox as well. That was easy huh.

                  Mr. Rodney
                  Thanks that helps a lot by using that calculator.

                  Comment


                  • #10
                    Originally posted by Leroy Hindman View Post
                    Mr Rod Macia
                    How did you arrive at lStyle = &H00600504. I still don't understand how he got the default button to be button number one.
                    I think default button to be number one is the default behavior when omitted. see PB help on MSGBOX function

                    To change to another you just OR the one you want.
                    %MB_YESNO OR %MB_ICONQUESTION OR %MB_DEFBUTTON2

                    "How did you arrive at lStyle = &H00600504"
                    I just took Dale's value from post#2

                    but iStyle gets value from function mStyle, and if not assign defaults to %MB_OK OR %MB_USERICON

                    FUNCTION MyMsgBox(mTxt AS STRING, OPT mStyle AS LONG, OPT mTitle AS STRING, OPT mpitch AS LONG, OPT mBG AS LONG) AS LONG

                    lStyle = IIF(ISMISSING(mStyle), %MB_OK OR %MB_USERICON, mStyle)



                    if you want to know what %MB_OK OR %MB_USERICON are equal to:

                    Code:
                    #COMPILE EXE
                    #DIM ALL
                    
                    FUNCTION PBMAIN () AS LONG
                    LOCAL lNum AS DWORD
                    lnum = %MB_USERICON OR %MB_OK ' put equate to test here
                    
                    MSGBOX "Dec " +FORMAT$(lnum) + $CRLF _
                    +"Hex " + HEX$(lnum,8) + $CRLF _
                    +"Bin " + BIN$ (lnum, 32)
                    
                    END FUNCTION
                    Last edited by Rod Macia; 25 Jun 2020, 09:35 PM.

                    Comment


                    • #11
                      Originally posted by Rod Macia View Post
                      Code:
                      lStyle   = &H00600504 0000 0000 0110 0000 0000 0101 0000 0100 (6292740 decimal)
                      AND mask = &H00000F00 0000 0000 0000 0000 0000 1111 0000 0000 ( 3840 decimal)
                      ------------- ----------------------------------------
                             j = $H00000500 0000 0000 0000 0000 0000 0101 0000 0000 ( 1280 decimal)
                      
                      
                      lStyle   = &H00600504 0000 0000 0110 0000 0000 0101 0000 0100 (6292740 decimal)
                      AND mask = &H00000F00 0000 0000 0000 0000 0000 0000 0000 1111 ( 15 decimal)
                      ------------- ----------------------------------------
                             i = $H00000004 0000 0000 0000 0000 0000 0000 0000 0100 ( 4 decimal)
                      Typo! Should be &H0000000F

                      Comment


                      • #12
                        Rod,Dale,Rodney and Stuart:

                        I Think I got it now, see the attached file. I couldn't get it to format properly by doing a copy to here. Open with Notepad

                        Untitled.txt
                        Attached Files

                        Comment


                        • #13
                          Sh*t guys the attachment is so screwed up you can't read it. Sorry I will try to get a copy you can read. I had to do a copy in Notepad couldn't get the underline and color to work. The new file "Untitled.Txt" should be so you can read it.

                          Thanks ever so much for all your help.

                          Comment


                          • #14
                            Originally posted by Leroy Hindman View Post
                            Sh*t guys the attachment is so screwed up you can't read it. Sorry I will try to get a copy you can read. I had to do a copy in Notepad couldn't get the underline and color to work. The new file "Untitled.Txt" should be so you can read it.

                            Thanks ever so much for all your help.
                            You mean this:

                            Code:
                             i = lStyle AND &H0000000F
                            
                                                DEC.              BINARY OR BITS
                             %MB_YESNO        =  4 = 0000 0000 0000 0000 0000 0000 0000 0100
                             %MB_ICONQUESTION = 32 = 0000 0000 0000 0000 0000 0000 0010 0000
                             &H0000000F       = 15 = 0000 0000 0000 0000 0000 0000 0000 1111
                                           i =  4  = 0000 0000 0000 0000 0000 0000 0000 0100   (4) in decimal
                            
                            
                             j = lStyle AND &H00000F00
                            
                                                DEC.           BINARY OR BITS
                             %MB_YESNO        =  4 = 0000 0000 0000 0000 0000 0000 0000 0100
                             %MB_ICONQUESTION = 32 = 0000 0000 0000 0000 0000 0000 0010 0000
                             &H00000F00    =  3840 = 0000 0000 0000 0000 0000 1111 0000 0000  
                                         j =    0  = 0000 0000 0000 0000 0000 0000 0000 0000    (0) in decimal

                            Comment


                            • #15
                              Stuart:

                              Yes, is this correct in how those 2 lines of code work. I did another using %MB_YESNO OR %MB_ICONQUESTION OR %MB_DEFBUTTON2 and it worked out to 256 decimal for variable j which is the decimal for %MB_DEFBUTTON2. I took Rodney's advice and used the Microsoft calculator to convert to binary after making each one print out in decimal.

                              BTW the first one i posted I did in OpenOffice Text Editor so I could underline and use colors on the reverent bits and when I posted it the thing was so screwed up it would have been hard to read. I did another in NotePad and that is the one you opened.

                              This is the most wonderful Forum because of all you guys helping like you do.
                              Thanks again.

                              Comment


                              • #16
                                Yes, that's how it works. You've got it!.

                                Here's a little demo that may help to see what is happening:

                                '
                                Code:
                                #COMPILE EXE
                                #DIM ALL
                                FUNCTION PBMAIN () AS LONG
                                    LOCAL dwFlag AS DWORD
                                    dwFlag = %MB_DEFBUTTON2 OR %MB_YESNO OR %MB_ICONWARNING
                                    ? "Dec: " & STR$(dwFlag) & " Hex: &H" & HEX$(dwFlag,4) & $CRLF & "Bin: " & strBinary(dwFlag) & $CRLF & $CRLF & _
                                      "If flag set, ANDing returns the flag value, if not set ANDing returns 0" &  $CRLF & _
                                      "DefButton1:" & STR$(dwFlag AND %MB_DEFBUTTON1) & $CRLF & _
                                      "DefButton2:" & STR$(dwFlag AND %MB_DEFBUTTON2) & $CRLF & _
                                      "YESNO:" & STR$(dwFlag AND %MB_YESNO) & $CRLF & _
                                      "OKCANCEL:" & STR$(dwFlag AND %MB_OKCANCEL)
                                
                                END FUNCTION
                                
                                FUNCTION strBinary(d AS DWORD) AS STRING
                                    LOCAL s,s2 AS STRING
                                    LOCAL x AS LONG
                                    s = BIN$(d,32)
                                    s2 = LEFT$(s,4) & " "
                                    FOR x = 1 TO 6
                                       s2 += MID$(s, 1 + x * 4,4) & " "
                                    NEXT
                                    s2 += RIGHT$(s,4)
                                    FUNCTION = s2
                                END FUNCTION
                                '
                                ---------------------------
                                PowerBASIC
                                ---------------------------
                                Dec: 308 Hex: &H0134
                                Bin: 0000 0000 0000 0000 0000 0001 0011 0100

                                If flag set, ANDing returns the flag value, if not set ANDing returns 0
                                DefButton1: 0
                                DefButton2: 256
                                YESNO: 4
                                OKCANCEL: 0
                                ---------------------------
                                OK
                                ---------------------------



                                Comment

                                Working...
                                X