Announcement

Collapse
No announcement yet.

Listbox background color change

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

  • Listbox background color change

    The following code has a listbox without the %WS_EX_CLIENTEDGE, background color set to TRANSPARENT.
    Dialog color is BLUE.
    When compiled and run, the listbox appears as I expect it to appear, however when I click on the scrollbar the background of the listbox changes color, to BLACK from BLUE.
    I've spent a lot time searching the forums but didn't find anything, not that it's not there, I just didn't find it if it is. I thought I'd seen something in there months ago but ...
    Why does the background color change to black?
    Is there a way to stop the background color from changing?

    Interestingly enough, I had been going to post a screen shot of the issue, using Ace WINSCREEN and when the area of the screen with the dialog on it was selected the background color reverted to the preset BLUE background.


    Code:
    #PBFORMS CREATED V1.51
    '--------------------------------------------------------------------------------------------------
    ' The first line in this file is a PB/Forms metastatement.
    ' It should ALWAYS be the first line of the file. Other   
    ' PB/Forms metastatements are placed at the beginning and 
    ' end of "Named Blocks" of code that should be edited     
    ' with PBForms only. Do not manually edit or delete these 
    ' metastatements or PB/Forms will not be able to reread   
    ' the file correctly.  See the PB/Forms documentation for 
    ' more information.                                       
    ' Named blocks begin like this:    #PBFORMS BEGIN ...     
    ' Named blocks end like this:      #PBFORMS END ...       
    ' Other PB/Forms metastatements such as:                  
    '     #PBFORMS DECLARATIONS                               
    ' are used by PB/Forms to insert additional code.         
    ' Feel free to make changes anywhere else in the file.    
    '--------------------------------------------------------------------------------------------------
    
    #COMPILE EXE
    #DIM ALL
    
    '--------------------------------------------------------------------------------------------------
    '   ** Includes **
    '--------------------------------------------------------------------------------------------------
    #PBFORMS BEGIN INCLUDES 
    #IF NOT %DEF(%WINAPI)
      #INCLUDE "WIN32API.INC"
    #ENDIF
    #PBFORMS END INCLUDES
    '--------------------------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------------------------
    '   ** Constants **
    '--------------------------------------------------------------------------------------------------
    #PBFORMS BEGIN CONSTANTS 
    %IDD_DIALOG1  =  101
    %IDC_LISTBOX1 = 1001
    #PBFORMS END CONSTANTS
    '--------------------------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------------------------
    '   ** Declarations **
    '--------------------------------------------------------------------------------------------------
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE FUNCTION SampleListBox(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL lCount AS LONG) AS _
      LONG
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    '--------------------------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------------------------
    '   ** Main Application Entry Point **
    '--------------------------------------------------------------------------------------------------
    FUNCTION PBMAIN()
      ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
    '--------------------------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------------------------
    '   ** CallBacks **
    '--------------------------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG1Proc()
    
      SELECT CASE AS LONG CBMSG
        CASE %WM_INITDIALOG
          ' Initialization handler
    
        CASE %WM_NCACTIVATE
          STATIC hWndSaveFocus AS DWORD
          IF ISFALSE CBWPARAM THEN
            ' Save control focus
            hWndSaveFocus = GetFocus()
          ELSEIF hWndSaveFocus THEN
            ' Restore control focus
            SetFocus(hWndSaveFocus)
            hWndSaveFocus = 0
          END IF
    
        CASE %WM_COMMAND
          ' Process control notifications
          SELECT CASE AS LONG CBCTL
            CASE %IDC_LISTBOX1
    
          END SELECT
      END SELECT
    END FUNCTION
    '--------------------------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------------------------
    '   ** Sample Code **
    '--------------------------------------------------------------------------------------------------
    FUNCTION SampleListBox(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL lCount AS LONG) AS LONG
      LOCAL i AS LONG
    
      FOR i = 1 TO lCount
        LISTBOX ADD hDlg, lID, USING$("Test Item #", i)
      NEXT i
    END FUNCTION
    '--------------------------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------------------------
    '   ** Dialogs **
    '--------------------------------------------------------------------------------------------------
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
      LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
      LOCAL hDlg  AS DWORD
    
      DIALOG NEW hParent, "TESTLBOXCOLOUR", 234, 118, 201, 121, %WS_POPUP OR %WS_BORDER OR _
        %WS_DLGFRAME OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR _
        %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
        %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
      DIALOG  SET COLOR    hDlg, %WHITE, RGB(0, 0, 128)
      CONTROL ADD LISTBOX, hDlg, %IDC_LISTBOX1, , 5, 5, 100, 80, %WS_CHILD OR %WS_VISIBLE OR _
        %WS_TABSTOP OR %WS_VSCROLL OR %LBS_SORT OR %LBS_NOTIFY, %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
        %WS_EX_RIGHTSCROLLBAR
      CONTROL SET COLOR    hDlg, %IDC_LISTBOX1, %YELLOW, -2
    #PBFORMS END DIALOG
    
      SampleListBox  hDlg, %IDC_LISTBOX1, 30
    
      DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    #PBFORMS END CLEANUP
    
      FUNCTION = lRslt
    END FUNCTION
    '--------------------------------------------------------------------------------------------------
    Rod
    In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

  • #2
    Rodney, the ...COLOR %YELLOW, -2 sets the background transparent. If you change it to %YELLOW, RGB(0, 0, 128) then you will get the right color. Don't know why -2 gives transparent in one context and black in another though!

    Comment


    • #3
      Now why didn't I think to do that?

      Thanks Chris

      Rod
      Rod
      In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

      Comment

      Working...
      X