Announcement

Collapse
No announcement yet.

ButtonPlus in Source Code

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

    #21
    Playing around tonight with L's code, it turns out quite easy to incorporate into "regular' code. I recently posted a demo using arrays for buttons (less clumsy than equates in some situations) and folded button coloring into it pretty easily. The code is attached.

    ========================================
    "The only thing to do with good advice
    is pass it on.
    It is never any use to oneself."
    Oscar Wilde (1854-)
    ========================================
    Attached Files
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

    Comment


      #22
      CRC errors using WinZip and PkUnzip

      Testing: ButtonPlus.bas OK
      Testing: ButtonPlus.inc OK
      Testing: ButtonPlus.txt OK
      Testing: ButtonPlusDemo.bas OK
      Testing: ButtonPlusDemo.exe PKUNZIP: (W15) Warning! file fails CRC check
      Testing: ButtonPlusDemo.rc OK
      Testing: ButtonSpotDemo.bas OK
      Testing: ButtonSpotDemo.exe PKUNZIP: (W15) Warning! file fails CRC check
      Testing: ButtonSpotDemo.rc OK
      Testing: hi.ico PKUNZIP: (W15) Warning! file fails CRC check
      Testing: Spot.ico OK
      Testing: xptheme.xml OK

      Comment


        #23
        Ease of use is probably the only original thing in it! Just include the source file in your program specify the button as normal then set extra styles using calls to ButtonPlus. Trouble is, when there are lots of options, the ease of use tends to get lost in explaining the options.

        Mike, I don't know why you are getting CRC errors. Checks out OK here using 7-Zip (the archive was made using 7-Zip). Have you tried downloading again?
        - LJ

        Comment


          #24
          Same results. I only have WinZip and PkZip.

          PowerBASIC and related source code. Please do not post questions or discussions, just source code.


          7-Zip download:
          AVG immediately reported a virus on the download, ouch!
          Will not attempt using it.
          Last edited by Mike Doty; 27 May 2009, 08:21 AM.

          Comment


            #25
            I'm also using AVG. Just downloaded it myself from source files. No CRC errors. No viruses detected either on download or on specific test. I don't know what's going on. Anyone else have problems?
            - LJ

            Comment


              #26
              Ok here with both WinRar and IZArk

              WinRAR provides the full RAR and ZIP file support, can decompress CAB, GZIP and other archive formats

              IZArc is the easiest way to Zip, Unzip and Encrypt files for free


              (AVG too)
              Rgds, Dave

              Comment


                #27
                It unzipped fine here also. PKZip. Maybe something with virus checker?

                ==================
                Be civil to all;
                sociable to many;
                familiar with few.
                Ben Franklin
                ==================
                It's a pretty day. I hope you enjoy it.

                Gösta

                JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                Comment


                  #28



                  Tried on another machine using Vista 32-bit. Same problems.
                  Are we downloading the same file?

                  Comment


                    #29
                    Originally posted by Mike Doty View Post
                    http://www.powerbasic.com/support/pb...8&d=1224890038


                    Tried on another machine using Vista 32-bit. Same problems.
                    Are we downloading the same file?
                    Just dl'ed again, using your link Mike and it unzipped fine (didn't test every file but got no complaints from PKZip).

                    ===========================================
                    Treat the other man's faith gently;
                    it is all he has to believe with.
                    His mind was created for his own thoughts,
                    not yours or mine.
                    Henry S. Haskins
                    ===========================================
                    It's a pretty day. I hope you enjoy it.

                    Gösta

                    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                    Comment


                      #30
                      JFF, I was playing around with button coloring this evening and came across an interesting phenomenon: The colors in ButtonPlus don't exactly translate; ie Red is Orange, Black is White, ... See sample:

                      '
                      Code:
                      'PBWIN 9.01 - WinApi 05/2008 - XP Pro SP3
                      #Dim All 
                      #Compile Exe  
                      #Optimize SPEED
                      #Debug Display On'off for production code
                       
                      #Include "WIN32API.INC"
                      #Include "COMDLG32.INC"
                      #Include "InitCtrl.inc"
                      '
                       'these next included files can be found here: 
                       'http://www.powerbasic.com/support/pbforums/showthread.php?t=38904
                      #Include "C:\Only_My_Programs\Include Files\ButtonPlus.bas"
                      #Resource "C:\Only_My_Programs\Include Files\ButtonPlusDemo.pbr"
                      %Button_Ids_Start_At = 1000
                      %Id_Exit_Btn = 2000
                      '
                       Global hdlg As Dword
                      ' 
                      Macro Common_Locals 'Macro easier than retyping and maintains coding consistency
                        Local Dlg_hght, Dlg_Wd As Long 
                        Local Btn_bg_Colors() As Long 
                        Local clor, Id, Stile, Row, col, hght, wd, Longest,ctr, ln, ln1, i As Long
                        Local  l, s As String
                        
                         Dim Btn_bg_Colors(1 To 10)
                         Btn_bg_Colors(1) = %Black 
                         Btn_bg_Colors(2) = %Blue    
                         Btn_bg_Colors(3) = %Green   
                         Btn_bg_Colors(4) = %Cyan    
                         Btn_bg_Colors(5) = %Red     
                         Btn_bg_Colors(6) = %Magenta 
                         Btn_bg_Colors(7) = %Yellow  
                         Btn_bg_Colors(8) = %White   
                         Btn_bg_Colors(9) = %Gray    
                         Btn_bg_Colors(10) = %LtGray  
                       
                      End Macro  
                      '
                      CallBack Function Dialog_Processor              
                        Common_Locals                                           
                        Select Case CbMsg     'This is TO determine the message TYPE 
                           '       
                           Case %WM_INITDIALOG'<- Initialiaton when the program loads 
                           '
                           Case %WM_SYSCOMMAND 'Traps Any Alt key but only F4 closes              
                           '
                           Case %WM_COMMAND  'This processes command messages
                             Select Case CbCtl
                               Case %Id_Exit_Btn
                                 Select Case CbCtlMsg        
                                    Case 0
                                      Dialog End CbHndl 'Applikation beenden
                                 End Select
                             End Select
                        End Select
                      End Function
                      '
                      Function PBMain
                        Common_Locals
                        
                         Stile = Stile Or %WS_CAPTION
                         Stile = Stile Or %WS_SYSMENU
                         Stile = Stile Or %WS_THICKFRAME 
                         Stile = Stile Or %WM_HELP 
                         Stile = Stile Or %WS_Border  'doesn't do anything
                        Dlg_hght = 400
                        Dlg_Wd = 250
                         l$ = Space$(Dlg_Wd \ 8)  
                         CSet l$ = "Coloring Button Demo"
                        Dialog New Pixels, hdlg, l$, , , Dlg_Wd, Dlg_Hght, Stile To hdlg 'centered
                        Row = 10
                        col = 10
                        Wd = 100
                        Hght = 20
                        Stile = %ss_center
                        For ctr = LBound(Btn_bg_Colors())  To UBound(Btn_bg_Colors())
                          Clor = Btn_bg_Colors(ctr)    'bg color to use
                          Id = %Button_Ids_Start_At + ctr    
                          Control Add Label, hdlg, Id, "label", Col, Row, Wd, Hght, stile                
                            Control Set Color hdlg, Id, %White, Clor
                      '
                          Control Add Button, hdlg, Id + 100, "Button", col + wd + 10, row, Wd, Hght, 0 'style must be 0 or 1 - see docs in ButtonPlus.bas
                            ButtonPlus hDlg, Id + 100, %BP_FACE_COLOR, Clor
                          Row = Row + Hght + 5
                        Next ctr
                         
                                
                       
                         hght = 25   
                         Wd = Dlg_Wd - 20
                         Col = 10 'center
                      
                         Row = Dlg_hght - Hght - 2 'Just off bottom
                           Control Add Button, hdlg, %Id_Exit_Btn, "Run Rabbit Run.", col, row, Wd, Hght
                            ButtonPlus hDlg, %Id_Exit_Btn, %BP_FACE_COLOR, %Red
                            ButtonPlus hDlg, %Id_Exit_Btn, %BP_Text_COLOR, %Yellow
                        
                           Dialog Show Modal hDlg   Call Dialog_Processor
                      End Function  'Applikation beenden
                      '
                      Not complaining, just observing.

                      Also the Btn_Demo (attached below) I first posted has a serious error. The Big Dummy had dimmed the bg colors() as integer instead of long. The colors still don't come out right (bug in MY code for certain, but dogged if I can find it). Problem is unrelated to anomaly above, though.

                      ====================================
                      So often we rob tomorrow’s memories
                      by today’s economies.
                      John Mason Brown
                      ====================================
                      Attached Files
                      It's a pretty day. I hope you enjoy it.

                      Gösta

                      JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                      LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                      Comment


                        #31
                        %BLACK has a value of zero, which is being interpreted by ButtonPlus as "use or revert to the default". So, you have to use 1 or RGB(1,1,1) if you want black (or very close to it).

                        The other colors are not wrong, just subdued (alpha-blended with the underlying face color). Check out the %BP_FACE_BLEND parameter. If you want a solid face color, pass a %BP_FACE_BLEND value of 255. The default is 128, as explained in the text file.
                        - LJ

                        Comment


                          #32
                          Originally posted by Laurence Jackson View Post
                          ...
                          The other colors are not wrong, just subdued (alpha-blended with the underlying face color). Check out the %BP_FACE_BLEND parameter. If you want a solid face color, pass a %BP_FACE_BLEND value of 255. The default is 128, as explained in the text file.
                          RTFM, huh? Jeez, who'da thought? {just kidding} Did the trick L. I *love* ButtonPlus. Button coloring has long been yearned for in this pilothouse.

                          If any are interested, here's some BP macros I just put together:
                          Code:
                           
                          'Corrected Bp_Face_Black macro May 31
                          '
                          '************************  
                          '    Global bp_Hndl As Dword 'used for button coloring
                          '    Global bp_ctl  As Long 'used for button coloring
                           
                          Macro Bp_face_Black =  Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Black + 1 '   
                          Macro Bp_face_Blue =   Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Blue
                          Macro Bp_face_Green =  Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Green
                          Macro Bp_face_Cyan =   Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Cyan
                          Macro Bp_face_Red =    Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Red      
                          Macro Bp_face_Magenta = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Magenta
                          Macro Bp_face_Yellow = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Yellow
                          Macro Bp_face_White =  Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %White
                          Macro Bp_face_Gray =   Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Gray
                          Macro Bp_face_LtGray = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %LtGray
                          '
                          Macro Bp_text_Black =  ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Black    
                          Macro Bp_text_Blue =   ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Blue
                          Macro Bp_text_Green =  ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Green
                          Macro Bp_text_Cyan =   ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Cyan
                          Macro Bp_text_Red =    ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Red      
                          Macro Bp_text_Magenta = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Magenta
                          Macro Bp_text_Yellow = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Yellow
                          Macro Bp_text_White =  ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %White
                          Macro Bp_text_Gray =   ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Gray
                          Macro Bp_text_LtGray = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %LtGray
                          Macro Bp_text_Color =  ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, Clor
                          Macro Bp_No_Blend = ButtonPlus  bp_Hndl, bp_ctl, %BP_FACE_BLEND, 255 '1-255 transparency '255=true color
                          '
                          ' *******************************************************
                          '
                          ======================================
                          High thoughts must have high language.
                          Aristophanes
                          ======================================
                          Last edited by Gösta H. Lovgren-2; 31 May 2009, 09:33 PM. Reason: Corrected BP_Face_Black
                          It's a pretty day. I hope you enjoy it.

                          Gösta

                          JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                          LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                          Comment


                            #33
                            Originally posted by Laurence Jackson View Post
                            ...The other colors are not wrong, just subdued (alpha-blended with the underlying face color).
                            Not quarreling or trying to be picky, LJ, but I am curious as to why you would "subdue' colors as a default. I would have thought (and did) you would render them as true as possible and have the "subdue" as an option. It just doesn't seem logical to me.

                            Again I love ButtonPlus and am not criticizing (well maybe just a tad). It's so good I wouldn't be surprised to see some form of it be a part of PBWin10.

                            ============================================
                            People will not remember
                            what you did or what you said.
                            People will remember how you made them feel.
                            LadyHawke
                            ============================================
                            It's a pretty day. I hope you enjoy it.

                            Gösta

                            JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                            LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                            Comment


                              #34
                              Buttons face colors have a default 50% transparency basically for the same reason as Windows normally colors buttons some shade of gray and not black or white. I'll quote myself:

                              "First, primary colors on button faces tends to be a bit overpowering and gaudy. Second, when using XP-themed buttons, some degree of transparency is necessary to retain the proper effect of the buttons being pressed."

                              As I said in the source code, José Roca really deserves the credit for much of what is in there. All I really did is package it up (I do take credit for "the spot" though!).
                              - LJ

                              Comment


                                #35
                                Originally posted by Laurence Jackson View Post
                                Buttons face colors have a default 50% transparency basically for the same reason as Windows normally colors buttons some shade of gray and not black or white. I'll quote myself:

                                "First, primary colors on button faces tends to be a bit overpowering and gaudy. Second, when using XP-themed buttons, some degree of transparency is necessary to retain the proper effect of the buttons being pressed."
                                My point is making subjective decisions -"a bit overpowering and gaudy." - that should be left to the programmer. Some us just may be gaudy, you know.

                                As I said in the source code, José Roca really deserves the credit for much of what is in there. All I really did is package it up (I do take credit for "the spot" though!).
                                Okay, I see now. It's really Jose's fault {grin}. Haven't tried the BP "spot" yet though I will. Must admit I haven't always been successful in finding the "spot' in other areas of endeavor though. Hopefully finding BP's spot will be as much fun looking. {llaugh}

                                Again, thx for BP, LJ.

                                ======================
                                Different values make
                                for a richer world.
                                Unknown
                                ======================
                                Last edited by Gösta H. Lovgren-2; 31 May 2009, 09:34 PM. Reason: Wanted to be spot on
                                It's a pretty day. I hope you enjoy it.

                                Gösta

                                JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                                LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                                Comment


                                  #36
                                  Laurence, I fooled with the Spot stuff tonight but just couldn't get it to work {sigh}. Here's the code I tried (note correction needed in docs). The full code is attached.
                                  Code:
                                  '
                                  Macro Btn_Spot
                                    ButtonPlus hDlg, Id, %BP_SPOT_COLOR, %White '%Red
                                    ButtonPlus hDlg, Id, %BP_SPOT_BLEND, &HFF
                                    ButtonPlus hDlg, Id, %BP_SPOT_WIDTH, 16
                                    ButtonPlus hDlg, Id, %BP_SPOT_HEIGHT, 20
                                    ButtonPlus hDlg, Id, %BP_SPOT_POS, %BS_TOP + %BS_Left '<-- incorrect in docs - no BP_ for Top or Left 
                                  End Macro
                                  '

                                  Here's a link to the exe http://www.swedesdock.com/powerbasic...ing_Arrays.exe


                                  {Note I also colored the buttons in the Unicode example. Took all of five minutes to do. And most of them were consumed in testing artistic color choices. {grin}))


                                  ===========================================================
                                  "The reasonable man adapts to the world:
                                  The unreasonable man persists
                                  in trying to adapt the world to himself.
                                  Therefore, all progress depends upon the unreasonable man."
                                  -- George Bernard Shaw
                                  ===========================================================
                                  Attached Files
                                  Last edited by Gösta H. Lovgren-2; 31 May 2009, 10:20 PM. Reason: Executions, Execitement, exefun, ...
                                  It's a pretty day. I hope you enjoy it.

                                  Gösta

                                  JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                                  LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                                  Comment


                                    #37
                                    "...couldn't get it to work..." How did it fail? Your code seems to be working to me, so I need a bit more. If you are complaining about the spot sliding off the top of the button, that's by design to allow effects other than a circular or elliptical blob of color. The rules are not fully explained in the doc - sorry about that. Basically, if you want the whole spot on the button face, specify a smaller size and avoid TOP or BOTTOM.

                                    Yes, you're right. In the doc:

                                    ButtonPlus hDlg, %IDC_BUTTON, %BP_SPOT_POS, %TOP + %LEFT

                                    should be changed to:

                                    ButtonPlus hDlg, %IDC_BUTTON, %BP_SPOT_POS, %BS_TOP + %BS_LEFT
                                    - LJ

                                    Comment


                                      #38
                                      Originally posted by Laurence Jackson View Post
                                      "...couldn't get it to work..." How did it fail? Your code seems to be working to me, so I need a bit more.
                                      What I mean(t) is the spot never showed up, I was looking for it to show up afterr a button was clicked in the example.
                                      If you are complaining about the spot sliding off the top of the button, that's by design to allow effects other than a circular or elliptical blob of color. The rules are not fully explained in the doc - sorry about that. Basically, if you want the whole spot on the button face, specify a smaller size and avoid TOP or BOTTOM.
                                      The smaller size did the trick. I changed
                                      Code:
                                        ButtonPlus hDlg, Id, %BP_SPOT_WIDTH, 8'16
                                        ButtonPlus hDlg, Id, %BP_SPOT_HEIGHT, 10'20
                                      and it showed up fine. For the record I am not "complaining". Merely trying to get it to work for me. (At least I hope it doesn't appear as "complaining.) BP is very neat code and I would expect it to become widely adopted by the PB community.

                                      Updated:
                                      http://www.swedesdock.com/powerbasic/Btn_Demo_using_Arrays.exe


                                      (Note for some reason editor won't allow entire link here. You'll have to C&P it into your browser or use the one in a prv msg)

                                      Thx again.
                                      Last edited by Gösta H. Lovgren-2; 1 Jun 2009, 08:51 PM.
                                      It's a pretty day. I hope you enjoy it.

                                      Gösta

                                      JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                                      LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                                      Comment


                                        #39
                                        "Complaining" was just a poor choice of words, sorry! In your original example, I DID see the white spot when the button was pressed, but it was partially off the top of the button. Because it was a small vertical ellipse, it looked a bit wierd, but it was there.
                                        - LJ

                                        Comment


                                          #40
                                          LJ, I think there may be a problem in BP. I was playing around with Scott Slater's Butons in Listbox (neat idea) - http://www.powerbasic.com/support/pb...ad.php?t=40672 -

                                          And when I added BP, trying to scroll (see thread above) I would get a bunch of Error 9's. It didn't happen with Chris' code so that's what I posted there.

                                          The E9's went away when I commented out the %WM_VScroll in scott's first version.

                                          Code:
                                          'http://www.powerbasic.com/support/pbforums/showthread.php?t=40672
                                          'scott Slater
                                          #Compile Exe
                                          #Dim All
                                          #Optimize SPEED  'Fly baby Fly!!!
                                          #Debug Display On '<<<<<<<<<<<<<<< Remember to turn off for production code
                                           
                                          #Include "win32api.inc"
                                           'these next included files needed for button colors can be found here: 
                                           'http://www.powerbasic.com/support/pbforums/showthread.php?t=38904
                                          #Include "C:\Only_My_Programs\Include Files\ButtonPlus.bas"
                                          '#Resource "C:\Only_My_Programs\Include Files\ButtonPlusDemo.pbr"
                                          
                                           
                                          Global gOldLBProc As Dword
                                          '
                                          ' *******************************************************
                                          '
                                          Function  Btn_Set_Face_Color(ddlg As Dword, Id As Long, Btn_Color As Long) As Long
                                            ButtonPlus  ddlg, Id, %BP_FACE_BLEND, 255 'true color
                                             ButtonPlus dDlg, Id, %BP_FACE_COLOR, Btn_Color ' &H008FDF8F 
                                          End Function 
                                          '
                                          Function  Btn_Set_Text_Color(ddlg As Dword, Id As Long, Btn_Color As Long) As Long
                                             ButtonPlus dDlg, Id, %BP_Text_COLOR, Btn_Color ' &H008FDF8F 
                                          End Function 
                                          '
                                          ' *******************************************************
                                          '
                                          Function BtnLBproc(ByVal hWnd As Long, ByVal wMsg As Long, _
                                                                 ByVal wParam As Long, ByVal lParam As Long) As Long
                                            Local rc As RECT
                                           
                                            Select Case wMsg
                                           
                                                Case %WM_Command
                                                   If wParam > 200 Then 'Button ids
                                                      GetClientRect hWnd, rc
                                          '
                                          ' *******************************************************
                                          '
                                                      Btn_Set_Face_Color(hwnd, Wparam, %Black + 1)
                                                      Btn_Set_Text_Color(hwnd, Wparam, %Yellow)
                                                      Control ReDraw hwnd, Wparam
                                          '            MessageBox hWnd, "Button " & Format$(wParam - 200) & " clicked", "Button Click", 0
                                          '
                                          ' *******************************************************
                                          '
                                                   End If
                                                Case %WM_SETFONT   ' Don't accept font messages for this control
                                                   Exit Function
                                                Case %WM_DrawItem  ' Redraw entire listbox area
                                                   GetClientRect hWnd, rc
                                                   InvalidateRect hWnd, rc, 1
                                                Case %WM_VScroll   ' Redraw after scrolling
                                                   SendMessage hWnd, %WM_DrawItem, wParam, lParam
                                           '<<<<<<< crashes here - Error 9's with SendMessage
                                           '>>>>>>>>> Scrolls fine without but only scroll 10 buttons, not all 25
                                            End Select
                                            Function = CallWindowProc(gOldLBProc, hWnd, wMsg, wParam, lParam) 'process other messages
                                           
                                          End Function
                                           
                                          CallBack Function MainDlgProc
                                           
                                             Select Case CB.Msg
                                                Case %WM_Destroy
                                                   SetWindowLong GetDlgItem(CB.Hndl,100), %GWL_WNDPROC, gOldLBProc   ' unhook: restore original callback
                                                Case %WM_Command
                                                   Select Case CB.Ctl
                                                      Case %IdCancel
                                                         Dialog End CbHndl
                                                   End Select
                                             End Select
                                             
                                          End Function
                                           
                                          Function PBMain () As Long
                                           
                                             Local hDlg, hLst, hFnt, BtnID, YPos As Long
                                             Local n, Btn_Face_Color, Btn_Text_Color As Long
                                             
                                             Font New "Ariel", 10 To hFnt
                                           
                                             Dialog New 0, "Test Button List",,, 100, 140 To hDlg
                                           
                                             Control Add ListBox, hDlg, 100, , 10, 10, 75, 115, %WS_Child Or %LBS_NoSel Or _
                                                %WS_TabStop Or %LBS_DisableNoScroll Or %WS_VScroll, %WS_Ex_ClientEdge  ' use %LBS_NOSEL to prevent selecting "text area"
                                                
                                             Control Set Font hDlg, 100, hFnt                   ' set the font, so that the height is the will contain the added buttons; should use FontIndirect
                                             Control Handle hDlg, 100 To hLst                   ' listbox handle for hook
                                             gOldLBProc = GetWindowLong(hLst, %GWL_WNDPROC)     ' save original LB Callback
                                             SetWindowLong hLst, %GWL_WNDPROC, CodePtr(BtnLBproc) ' assign our Callback so we can intercept messages.
                                           
                                             ' add some buttons to the listbox area: parent dialog for buttons is hLst
                                             YPos = 2
                                             For BtnID = 201 To 225
                                                Control Add Button, hLst, BtnID, "Button " & Format$(BtnID-200), 5, YPos, 80, 28
                                          '
                                          ' *******************************************************
                                          '
                                                'set button colors
                                                Incr n
                                                If n > 3 Then n = 1
                                                Select Case n      
                                                  Case 1
                                                    Btn_Face_Color = %Red
                                                    Btn_Text_Color = %White
                                                  Case 2
                                                    Btn_Face_Color = %White
                                                    Btn_Text_Color = %Blue
                                                  Case 3
                                                    Btn_Face_Color = %Blue
                                                    Btn_Text_Color = %White
                                                End Select  
                                          '          Btn_Face_Color = %Red
                                          '          Btn_Text_Color = %White
                                                   Btn_Set_Face_Color(Hlst, BtnId, Btn_Face_Color)
                                                   Btn_Set_Text_Color(Hlst, BtnId, Btn_Text_Color)
                                                  
                                                ListBox Add hDlg, 100, " "
                                                YPos += 32
                                             Next BtnID
                                          '
                                          ' *******************************************************
                                          '
                                           
                                             Control Add Button, hDlg, %IdCancel, "Close", 25, 117, 50, 20
                                           
                                             Dialog Show Modal hDlg Call MainDlgProc
                                           
                                             Font End hFnt
                                           
                                          End Function
                                          The E9 may not be in your code, LJ but I thought I'd mention it in case it was.

                                          ==================================================
                                          Certainly virtue is like precious odors,
                                          most fragrant when they are incensed, or crushed:
                                          for prosperity doth best discover vice,
                                          but adversity doth best discover virtue.
                                          Sir Francis Bacon
                                          ==================================================
                                          It's a pretty day. I hope you enjoy it.

                                          Gösta

                                          JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                                          LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                                          Comment

                                          Working...
                                          X
                                          😀
                                          🥰
                                          🤢
                                          😎
                                          😡
                                          👍
                                          👎