Announcement

Collapse
No announcement yet.

Refresh Listbox ???

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

  • Refresh Listbox ???

    I'm trying to have the tabs in a listbox change on the resize message, so for a test I whipped up a quick dialog in easyGUI and set everything to look like one of the dialogs of an app I'm working on. next I set the list boxes to resize and all is fine. I set the tab stops and things are still good, import some dummy data and the tabs are fine... BUT after the text is in the window and I resize it, the only text that moves is the selected row or the top row. If I cover the dialog then uncover it (like a minimise) then all the text moves into place so the problem I'm having is that the screen itself is not refreshing.
    Is there a msg I can send to the listbox to refresh it? Thanks

    Here a working piece of code, just compile and your away. Click File->ImportFile to load dummy data then rezise the window and you'll see right away what I mean.

    Code:
    #Compile Exe
    #Include "win32api.inc"
    
    ' ----------------------------------------------------------
    %frm_Import_MnuFile                                  = 500
    ' ----------------------------------------------------------
    %frm_Import_MnuImportFile                            = 505
    %frm_Import_MnuSaveReport                            = 510
    %frm_Import_SEPARATOR_515                            = 515
    %frm_Import_MnuImpClose                              = 520
    
    ' ----------------------------------------------------------
    %frm_Import_MnuAction                                = 600
    ' ----------------------------------------------------------
    %frm_Import_Add_List_to_Domain                       = 605
    
    ' ----------------------------------------------------------
    %frm_Import_MnuHelp                                  = 700
    ' ----------------------------------------------------------
    %frm_Import_CSV_Format_Info                          = 705
    %FRM_IMPORT_LST_CSV            = 100
    %FRM_IMPORT_LST_RESULT         = 105
    ' --------------------------------------------------
    Declare Sub ShowDialog_frm_Import(ByVal hParent&)
    Declare CallBack Function frm_Import_DLGPROC
    ' --------------------------------------------------
    ' ------------------------------------------------
    
    Declare Sub frm_Import_MnuImportFile_Select()
    Declare Sub frm_Import_MnuSaveReport_Select()
    Declare Sub frm_Import_MnuImpClose_Select()
    Declare Sub frm_Import_Add_List_to_Domain_Select()
    Declare Sub frm_Import_CSV_Format_Info_Select()
    Declare CallBack Function CBF_FRM_IMPORT_LST_CSV()
    Declare CallBack Function CBF_FRM_IMPORT_LST_RESULT()
    
    
    ' (1) Put NEXT DIALOG Constant and Declare code after here :
    
    Global hfrm_Import&    ' Dialog handle
    ' Global Handles for menus
    Global hfrm_Import_Menu0&
    Global hfrm_Import_Menu1&
    Global hfrm_Import_Menu2&
    Global hfrm_Import_Menu3&
    
    Function PbMain() As Long
        Call ShowDialog_frm_Import(0)
    End Function
    
    ' (2) Put NEXT DIALOG Globals code after here :
    
    Sub ShowDialog_frm_Import(ByVal hParent&)
        Local Style&, ExStyle&
        Local N&, CT&        '  Variables used for Reading Data in Arrays for Listbox and Combobox
        '   hParent& = 0 if no parent Dialog
        Style& = %WS_CAPTION Or %WS_MINIMIZEBOX Or %WS_SYSMENU Or %DS_CENTER Or %WS_OVERLAPPEDWINDOW
        ExStyle& = 0
        Dialog New hParent&, "Import Users from CSV File", 0, 0,  200,  144, Style&, ExStyle& To hfrm_Import&
       ' EZLIB_FixSize hfrm_Import&, Style&, 1
        ' ---------------------------
        Menu New Bar To hfrm_Import_Menu0&
        ' ---------------------------
        Menu New Popup To hfrm_Import_Menu1&
        Menu Add Popup, hfrm_Import_Menu0& ,"&File", hfrm_Import_Menu1&, %MF_ENABLED
        ' - - - - - - - - - - - - - -
        Menu Add String, hfrm_Import_Menu1&, "&Import File",  %frm_Import_MnuImportFile, %MF_ENABLED
        Menu Add String, hfrm_Import_Menu1&, "&Save Report",  %frm_Import_MnuSaveReport, %MF_ENABLED
        Menu Add String, hfrm_Import_Menu1&, "-",  %frm_Import_SEPARATOR_515, %MF_ENABLED
        Menu Add String, hfrm_Import_Menu1&, "&Close",  %frm_Import_MnuImpClose, %MF_ENABLED
        Menu New Popup To hfrm_Import_Menu2&
        Menu Add Popup, hfrm_Import_Menu0& ,"&Action", hfrm_Import_Menu2&, %MF_ENABLED
        ' - - - - - - - - - - - - - -
        Menu Add String, hfrm_Import_Menu2&, "&Add List to Domain",  %frm_Import_Add_List_to_Domain, %MF_ENABLED
        Menu New Popup To hfrm_Import_Menu3&
        Menu Add Popup, hfrm_Import_Menu0& ,"&Help", hfrm_Import_Menu3&, %MF_ENABLED
        ' - - - - - - - - - - - - - -
        Menu Add String, hfrm_Import_Menu3&, "CSV Format Info",  %frm_Import_CSV_Format_Info, %MF_ENABLED
        Menu Attach hfrm_Import_Menu0&, hfrm_Import&
        ' Layer # 0
        ' - - - - - - - - - - - - - - - - - - - - - - - - -
        Dim LST_CSV_List(0) As Local String
        ' - - - - - - - - - - - - - - - - - - - - - - - - -
        Control Add ListBox, hfrm_Import&,  %FRM_IMPORT_LST_CSV, LST_CSV_List(), 0, 0, 200, 70, _
            %WS_CHILD Or %WS_VISIBLE Or %LBS_NOTIFY  Or %LBS_USETABSTOPS Or %LBS_NOINTEGRALHEIGHT Or %WS_VSCROLL Or %WS_TABSTOP, _
            %WS_EX_CLIENTEDGE Call CBF_FRM_IMPORT_LST_CSV
        ' - - - - - - - - - - - - - - - - - - - - - - - - -
        Dim LST_RESULT_List(0) As Local String
        ' - - - - - - - - - - - - - - - - - - - - - - - - -
        Control Add ListBox, hfrm_Import&,  %FRM_IMPORT_LST_RESULT, LST_RESULT_List(), 0, 72, 200, 72, _
            %WS_CHILD Or %WS_VISIBLE Or %LBS_NOTIFY  Or %LBS_USETABSTOPS Or %LBS_NOINTEGRALHEIGHT Or %WS_VSCROLL Or %WS_TABSTOP, _
            %WS_EX_CLIENTEDGE Call CBF_FRM_IMPORT_LST_RESULT
        Dialog Show Modal hfrm_Import& , Call frm_Import_DLGPROC
    End Sub
    
    ' *************************************************************
    '                             Dialog Callback Procedure
    '                             for Form frm_Import
    '                             uses Global Handle - hfrm_Import&
    ' *************************************************************
    
    CallBack Function frm_Import_DLGPROC
        Select Case CbMsg
            ' Common Windows Messages you may want to process
            ' -----------------------------------------------
            Case %WM_TIMER
            Case %WM_HSCROLL
            Case %WM_VSCROLL
            Case %WM_SIZE
                Local Dialog_H As Long
                Local Dialog_W As Long
                Local Pixel_H As Word
                Local Pixel_W As Word
                Dim lstTabs(4) As Long
                
                Pixel_H = HiWrd(CbLparam)
                Pixel_W = LoWrd(CbLparam)
                
                Dialog Pixels hfrm_Import&, Pixel_W, Pixel_H To Units Dialog_W, Dialog_H
                      
                'MsgBox Str$(Pixel_W  * 0.25)
                lsttabs(0) = Pixel_W * 0.10
                lsttabs(1) = Pixel_W * 0.20
                lsttabs(2) = Pixel_W * 0.30
                lsttabs(3) = Pixel_W * 0.40
                Control Send hfrm_Import&,  %FRM_IMPORT_LST_CSV, %LB_SETTABSTOPS ,4, VarPtr(lsttabs(0))
                Control Send hfrm_Import&,  %FRM_IMPORT_LST_CSV, %WM_PAINT,0,0
                Control Set Size hfrm_Import&, %FRM_IMPORT_LST_CSV, Dialog_W , Dialog_H /2
                Control Set Loc  hfrm_Import&, %FRM_IMPORT_LST_RESULT, 0, (Dialog_H /2) + 1
                Control Set Size hfrm_Import&, %FRM_IMPORT_LST_RESULT, Dialog_W , Dialog_H /2
            
            Case %WM_CLOSE
            Case %WM_DESTROY
            Case %WM_SYSCOMMAND
            'Case %WM_PAINT
            ' -----------------------------------------------
            'Case %WM_CTLCOLORMSGBOX , %WM_CTLCOLORBTN, %WM_CTLCOLOREDIT,_
            '     %WM_CTLCOLORSTATIC, %WM_CTLCOLORSCROLLBAR, %WM_CTLCOLORLISTBOX
            '    ' Control colors
            '    Select Case GetDlgCtrlID(CbLparam)
            '        Case Else
            '            Function=0
            '    End Select
            'Case %WM_NOTIFY
                'If EZLIB_IsTooltip(CbLparam) Then
               '     Select Case EZLIB_TooltipID(CbLparam)
               '         Case Else
               '     End Select
                'End If
                'If EZLIB_IsTab(CbLparam) Then
               '     Select Case EZLIB_TabID(CbLparam)
               '         Case Else
               '     End Select
               ' End If
            Case %WM_COMMAND
                ' Process Messages to Controls that have no Callback Function
                ' and Process Messages to Menu Items
                Select Case CbCtl
                    Case  %frm_Import_MnuImportFile                           ' Popup Menu Item Selected
                        frm_Import_MnuImportFile_Select
                    Case  %frm_Import_MnuSaveReport                           ' Popup Menu Item Selected
                        frm_Import_MnuSaveReport_Select
                    Case  %frm_Import_SEPARATOR_515                           ' Popup Menu Item Selected
    
                    Case  %frm_Import_MnuImpClose                             ' Popup Menu Item Selected
                        frm_Import_MnuImpClose_Select
                    Case  %frm_Import_Add_List_to_Domain                      ' Popup Menu Item Selected
                        frm_Import_Add_List_to_Domain_Select
                    Case  %frm_Import_CSV_Format_Info                         ' Popup Menu Item Selected
                        frm_Import_CSV_Format_Info_Select
                    Case Else
                End Select
            Case Else
        End Select
    End Function
    
    
    ' (3) Put NEXT DIALOG Creation / Dialog Procedure code after here :
    
    ' ------------------------------------------------
    Sub frm_Import_MnuImportFile_Select()
    
        Dim ImportList(5) As String
        Dim i As Long
        
        For I = 0 To 5
            ImportList(i) = "Column1" & Chr$(9) & "Column2" & Chr$(9) &  "Column3" & Chr$(9) & "Column4"
            ListBox Add hfrm_Import&,  %FRM_IMPORT_LST_CSV, ImportList(i)
        Next
        
        
    
    End Sub
    ' ------------------------------------------------
    
    ' ------------------------------------------------
    Sub frm_Import_MnuSaveReport_Select()
    
    End Sub
    ' ------------------------------------------------
    
    ' ------------------------------------------------
    Sub frm_Import_MnuImpClose_Select()
    
    End Sub
    ' ------------------------------------------------
    
    ' ------------------------------------------------
    Sub frm_Import_Add_List_to_Domain_Select()
    
    End Sub
    ' ------------------------------------------------
    
    ' ------------------------------------------------
    Sub frm_Import_CSV_Format_Info_Select()
    
    End Sub
    ' ------------------------------------------------
    
    ' ------------------------------------------------
    CallBack Function CBF_FRM_IMPORT_LST_CSV
        Local CVal&
        ' Return Current Selection in CVal&
        Control Send CbHndl , CbCtl, %LB_GETCURSEL, 0,0 To CVal&
        If CbCtlMsg=%LBN_SELCHANGE Then
    
        End If
        If CbCtlMsg=%LBN_DBLCLK Then
    
        End If
        If CbCtlMsg=%LBN_SETFOCUS Then
    
        End If
        If CbCtlMsg=%LBN_KILLFOCUS Then
    
        End If
    End Function
    ' ------------------------------------------------
    
    ' ------------------------------------------------
    CallBack Function CBF_FRM_IMPORT_LST_RESULT
        Local CVal&
        ' Return Current Selection in CVal&
        Control Send CbHndl , CbCtl, %LB_GETCURSEL, 0,0 To CVal&
        If CbCtlMsg=%LBN_SELCHANGE Then
    
        End If
        If CbCtlMsg=%LBN_DBLCLK Then
    
        End If
        If CbCtlMsg=%LBN_SETFOCUS Then
    
        End If
        If CbCtlMsg=%LBN_KILLFOCUS Then
    
        End If
    End Function
    ' ------------------------------------------------
    ------------------
    Paul Dwyer
    Network Engineer
    Aussie in Tokyo

  • #2
    I stuck this code into the wm_size section too and all works fine but now there is a flicker, is this one of this "well, you can't have it both ways" type situations or is there a better way of doing it than invalidating the region

    Code:
                Dim List1 As rect
                
                list1.ntop = 0
                list1.nleft = 0
                list1.nright = pixel_w
                list1.nbottom = pixel_H /2
    
                Call InvalidateRect(hfrm_Import& ,ByVal VarPtr(list1), %TRUE)
    ------------------
    Paul Dwyer
    Network Engineer
    Aussie in Tokyo

    Comment


    • #3
      Hi Paul;

      I tested your sample out. It is normal to resize the listbox inside
      the wm_size block, however, in DDT, Control Set Size may not be invalidating
      the window for you, so that is why when you added it yourself it appears
      to behave correctly. I don't see any flicker on my machine win98se,360mhz.

      Normally in SDK style, one would do this to achieve the same results,
      Code:
      CASE %WM_SIZE
          'adjust your size parameters first...
          Call MoveWindow ( hWndList, x,y,cx,cy,%TRUE )
      The %TRUE flag in the MoveWindow automatically refreshes your Listbox for you.

      HTH
      Regards,
      Jules

      Comment


      • #4
        Jules,

        This doesn't solve the problem. In fact while the repaint does happen, there is no invalidation of the listbox so it seems that it has to be invalidated. Using your move window code is exactly the same as my origional code with the bug.

        Thanks for the help though, I'm a little weak on SDK coding so it was good to see how it works. Any other ideas you have would be welcome though.

        Cheers

        ------------------
        Paul Dwyer
        Network Engineer
        Aussie in Tokyo

        Comment


        • #5
          It is usual to follow a call to InvalidateRect() with a call to UpdateWindow()... There are other tricks to, like using DeferWindowPos(), etc.

          If Windows has the "show Window contents while dragging" option enabled, you'll get to witness a lot of flicker from many applications. Flickerless resizing under all conditions is quite a science.

          BTW, you may want to test drive my resize custom control (RESIZE32.DLL) - it enables dialogs (DDT and RC) and conventional windows to auto-resize child controls, using either elastic or anchored resizing (or a combination of both!). Just add it to a window/dialog, or programmatically enable resizing for a given window/dialog with one call to the DLL.

          Email me privately, and I'll send you a fully functional demo (I don't have this up on a web site but that is likely to happen very soon). mailto:[email protected][email protected]</A>

          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


          • #6
            It can sometimes help to experiment with Class styles, via SetClassLong.
            I tried by adding %WS_CLIPCHILDREN to dialog style and changing some of
            the class members for the dialog's window class. Looking in Spyxx, it
            didn't have %CS_HREDRAW OR %CS_VREDRAW, which is why you had to invalidate
            controls yourself at resize.

            Following in PBMAIN, *without* the InvalidateRect code in WM_SIZE
            looks alright in my computer:
            Code:
                Style& = %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_SYSMENU OR %DS_CENTER OR _
                         %WS_OVERLAPPEDWINDOW OR %WS_CLIPCHILDREN
                ExStyle& = 0
                DIALOG NEW hParent&, "Import Users from CSV File", 0, 0,  200,  144, Style&, ExStyle& TO hfrm_Import&
                SetClassLong hfrm_Import&, %GCL_STYLE, %CS_HREDRAW OR %CS_HREDRAW OR %CS_PARENTDC OR %CS_DBLCLKS
                SetClassLong hfrm_Import&, %GCL_HBRBACKGROUND, %NULL
            ------------------

            Comment


            • #7
              Thank you all,

              I'll try these out when I get home.

              Lance, Are you a Kiwi are you?



              ------------------
              Paul Dwyer
              Network Engineer
              Aussie in Tokyo

              Comment


              • #8
                5th generation Kiwi! And yes, I telecommute.

                ------------------
                Lance
                PowerBASIC Support
                mailto:[email protected][email protected]</A>
                Lance
                mailto:[email protected]

                Comment


                • #9
                  NZ,

                  The best Lamb and Cheese in Japan. The Aussies ought to be doing the same thing... A bit slow off the mark perhaps, but then Thank god for Aussie Wine Exporters.

                  Get out of this office soon, so I can try some of this code posted here.


                  ------------------
                  Paul Dwyer
                  Network Engineer
                  Aussie in Tokyo

                  [This message has been edited by Paul Dwyer (edited April 18, 2001).]

                  Comment


                  • #10
                    Paul;

                    A simple technique that allows you to do complex things to a control
                    or Dialog and to reduce flicker is to use the WM_SETREDRAW message.

                    Code:
                    SendMessage hWnd, %WM_SETREDRAW, 0, 0 
                    ' make changes to the control or dialog who handle is hWnd
                    SendMessage hWnd, %WM_SETREDRAW, 1, 0 
                    ' now redraw the form by using InvalidateRect or RedrawWindow
                    By turning off the redraw state of a window you can resize it or do
                    anything else and the window will not redraw itself. This allows you
                    to do multiple actions on a window without generating any repainting
                    of the window. Once you have finished all the modifications you then
                    turn on the redraw state and force the window to repaint itself.

                    If a Dialog has its redraw state set to off, none of its controls will
                    repaint when modified. Its as if all the controls are turned off.

                    This is a common technique when making changes to controls like a
                    listbox. You can turn off the redraw state of the listbox, fill it
                    with items and turn on the redraw state and then force the listbox to
                    refresh itself.




                    ------------------
                    Chris Boss
                    Computer Workshop
                    Developer of "EZGUI"
                    http://cwsof.com
                    http://twitter.com/EZGUIProGuy

                    Comment


                    • #11
                      Paul;

                      I made a few changes that improves your Dialog :

                      Thre is a little bit of flicker from the listbox itself, since it
                      must repaint its own background when you modify it, but its better
                      than what you had.

                      Code:
                      #COMPILE EXE
                      #INCLUDE "win32api.inc"
                      
                      ' ----------------------------------------------------------
                      %frm_Import_MnuFile                                  = 500
                      ' ----------------------------------------------------------
                      %frm_Import_MnuImportFile                            = 505
                      %frm_Import_MnuSaveReport                            = 510
                      %frm_Import_SEPARATOR_515                            = 515
                      %frm_Import_MnuImpClose                              = 520
                      
                      ' ----------------------------------------------------------
                      %frm_Import_MnuAction                                = 600
                      ' ----------------------------------------------------------
                      %frm_Import_Add_List_to_Domain                       = 605
                      
                      ' ----------------------------------------------------------
                      %frm_Import_MnuHelp                                  = 700
                      ' ----------------------------------------------------------
                      %frm_Import_CSV_Format_Info                          = 705
                      %FRM_IMPORT_LST_CSV            = 100
                      %FRM_IMPORT_LST_RESULT         = 105
                      ' --------------------------------------------------
                      DECLARE SUB ShowDialog_frm_Import(BYVAL hParent&)
                      DECLARE CALLBACK FUNCTION frm_Import_DLGPROC
                      ' --------------------------------------------------
                      ' ------------------------------------------------
                      
                      DECLARE SUB frm_Import_MnuImportFile_Select()
                      DECLARE SUB frm_Import_MnuSaveReport_Select()
                      DECLARE SUB frm_Import_MnuImpClose_Select()
                      DECLARE SUB frm_Import_Add_List_to_Domain_Select()
                      DECLARE SUB frm_Import_CSV_Format_Info_Select()
                      DECLARE CALLBACK FUNCTION CBF_FRM_IMPORT_LST_CSV()
                      DECLARE CALLBACK FUNCTION CBF_FRM_IMPORT_LST_RESULT()
                      
                      
                      ' (1) Put NEXT DIALOG Constant and Declare code after here :
                      
                      GLOBAL hfrm_Import&    ' Dialog handle
                      ' Global Handles for menus
                      GLOBAL hfrm_Import_Menu0&
                      GLOBAL hfrm_Import_Menu1&
                      GLOBAL hfrm_Import_Menu2&
                      GLOBAL hfrm_Import_Menu3&
                      
                      FUNCTION PBMAIN() AS LONG
                          CALL ShowDialog_frm_Import(0)
                      END FUNCTION
                      
                      ' (2) Put NEXT DIALOG Globals code after here :
                      
                      SUB ShowDialog_frm_Import(BYVAL hParent&)
                          LOCAL Style&, ExStyle&
                          LOCAL N&, CT&        '  Variables used for Reading Data in Arrays for Listbox and Combobox
                          '   hParent& = 0 if no parent Dialog
                          Style& = %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_SYSMENU OR %DS_CENTER OR %WS_OVERLAPPEDWINDOW
                          ExStyle& = 0
                          DIALOG NEW hParent&, "Import Users from CSV File", 0, 0,  200,  144, Style&, ExStyle& TO hfrm_Import&
                         ' EZLIB_FixSize hfrm_Import&, Style&, 1
                          ' ---------------------------
                          MENU NEW BAR TO hfrm_Import_Menu0&
                          ' ---------------------------
                          MENU NEW POPUP TO hfrm_Import_Menu1&
                          MENU ADD POPUP, hfrm_Import_Menu0& ,"&File", hfrm_Import_Menu1&, %MF_ENABLED
                          ' - - - - - - - - - - - - - -
                          MENU ADD STRING, hfrm_Import_Menu1&, "&Import File",  %frm_Import_MnuImportFile, %MF_ENABLED
                          MENU ADD STRING, hfrm_Import_Menu1&, "&Save Report",  %frm_Import_MnuSaveReport, %MF_ENABLED
                          MENU ADD STRING, hfrm_Import_Menu1&, "-",  %frm_Import_SEPARATOR_515, %MF_ENABLED
                          MENU ADD STRING, hfrm_Import_Menu1&, "&Close",  %frm_Import_MnuImpClose, %MF_ENABLED
                          MENU NEW POPUP TO hfrm_Import_Menu2&
                          MENU ADD POPUP, hfrm_Import_Menu0& ,"&Action", hfrm_Import_Menu2&, %MF_ENABLED
                          ' - - - - - - - - - - - - - -
                          MENU ADD STRING, hfrm_Import_Menu2&, "&Add List to Domain",  %frm_Import_Add_List_to_Domain, %MF_ENABLED
                          MENU NEW POPUP TO hfrm_Import_Menu3&
                          MENU ADD POPUP, hfrm_Import_Menu0& ,"&Help", hfrm_Import_Menu3&, %MF_ENABLED
                          ' - - - - - - - - - - - - - -
                          MENU ADD STRING, hfrm_Import_Menu3&, "CSV Format Info",  %frm_Import_CSV_Format_Info, %MF_ENABLED
                          MENU ATTACH hfrm_Import_Menu0&, hfrm_Import&
                          ' Layer # 0
                          ' - - - - - - - - - - - - - - - - - - - - - - - - -
                          DIM LST_CSV_List(0) AS LOCAL STRING
                          ' - - - - - - - - - - - - - - - - - - - - - - - - -
                          CONTROL ADD LISTBOX, hfrm_Import&,  %FRM_IMPORT_LST_CSV, LST_CSV_List(), 0, 0, 200, 70, _
                              %WS_CHILD OR %WS_VISIBLE OR %LBS_NOTIFY  OR %LBS_USETABSTOPS OR %LBS_NOINTEGRALHEIGHT OR %WS_VSCROLL OR %WS_TABSTOP, _
                              %WS_EX_CLIENTEDGE CALL CBF_FRM_IMPORT_LST_CSV
                          ' - - - - - - - - - - - - - - - - - - - - - - - - -
                          DIM LST_RESULT_List(0) AS LOCAL STRING
                          ' - - - - - - - - - - - - - - - - - - - - - - - - -
                          CONTROL ADD LISTBOX, hfrm_Import&,  %FRM_IMPORT_LST_RESULT, LST_RESULT_List(), 0, 72, 200, 72, _
                              %WS_CHILD OR %WS_VISIBLE OR %LBS_NOTIFY  OR %LBS_USETABSTOPS OR %LBS_NOINTEGRALHEIGHT OR %WS_VSCROLL OR %WS_TABSTOP, _
                              %WS_EX_CLIENTEDGE CALL CBF_FRM_IMPORT_LST_RESULT
                          DIALOG SHOW MODAL hfrm_Import& , CALL frm_Import_DLGPROC
                      END SUB
                      
                      ' *************************************************************
                      '                             Dialog Callback Procedure
                      '                             for Form frm_Import
                      '                             uses Global Handle - hfrm_Import&
                      ' *************************************************************
                      
                      CALLBACK FUNCTION frm_Import_DLGPROC
                      LOCAL RFlag&
                          SELECT CASE CBMSG
                              ' Common Windows Messages you may want to process
                              ' -----------------------------------------------
                              CASE %WM_TIMER
                              CASE %WM_HSCROLL
                              CASE %WM_VSCROLL
                              CASE %WM_SIZE
                                  LOCAL Dialog_H AS LONG
                                  LOCAL Dialog_W AS LONG
                                  LOCAL Pixel_H AS WORD
                                  LOCAL Pixel_W AS WORD
                                  DIM lstTabs(4) AS LONG
                      
                                  Pixel_H = HIWRD(CBLPARAM)
                                  Pixel_W = LOWRD(CBLPARAM)
                      
                                  DIALOG PIXELS hfrm_Import&, Pixel_W, Pixel_H TO UNITS Dialog_W, Dialog_H
                      
                                  'MsgBox Str$(Pixel_W  * 0.25)
                                  lsttabs(0) = Pixel_W * 0.10
                                  lsttabs(1) = Pixel_W * 0.20
                                  lsttabs(2) = Pixel_W * 0.30
                                  lsttabs(3) = Pixel_W * 0.40
                                  ' -------------------------------------------------
                                   SendMessage hfrm_Import&, %WM_SETREDRAW, 0,0
                                  ' -------------------------------------------------
                                  CONTROL SEND hfrm_Import&,  %FRM_IMPORT_LST_CSV, %LB_SETTABSTOPS ,4, VARPTR(lsttabs(0))
                                  CONTROL SEND hfrm_Import&,  %FRM_IMPORT_LST_CSV, %WM_PAINT,0,0
                                  CONTROL SET SIZE hfrm_Import&, %FRM_IMPORT_LST_CSV, Dialog_W , Dialog_H /2
                                  CONTROL SET LOC  hfrm_Import&, %FRM_IMPORT_LST_RESULT, 0, (Dialog_H /2) + 1
                                  CONTROL SET SIZE hfrm_Import&, %FRM_IMPORT_LST_RESULT, Dialog_W , Dialog_H /2
                                  ' -------------------------------------------------
                                  SendMessage hfrm_Import&, %WM_SETREDRAW, 1,0
                                  RFlag&=%RDW_INVALIDATE OR %RDW_ALLCHILDREN
                                  RedrawWindow hfrm_Import&, BYVAL %NULL, %NULL, RFlag&
                                  ' -------------------------------------------------
                      
                              CASE %WM_CLOSE
                              CASE %WM_DESTROY
                              CASE %WM_SYSCOMMAND
                              'Case %WM_PAINT
                              ' -----------------------------------------------
                              'Case %WM_CTLCOLORMSGBOX , %WM_CTLCOLORBTN, %WM_CTLCOLOREDIT,_
                              '     %WM_CTLCOLORSTATIC, %WM_CTLCOLORSCROLLBAR, %WM_CTLCOLORLISTBOX
                              '    ' Control colors
                              '    Select Case GetDlgCtrlID(CbLparam)
                              '        Case Else
                              '            Function=0
                              '    End Select
                              'Case %WM_NOTIFY
                                  'If EZLIB_IsTooltip(CbLparam) Then
                                 '     Select Case EZLIB_TooltipID(CbLparam)
                                 '         Case Else
                                 '     End Select
                                  'End If
                                  'If EZLIB_IsTab(CbLparam) Then
                                 '     Select Case EZLIB_TabID(CbLparam)
                                 '         Case Else
                                 '     End Select
                                 ' End If
                              CASE %WM_COMMAND
                                  ' Process Messages to Controls that have no Callback Function
                                  ' and Process Messages to Menu Items
                                  SELECT CASE CBCTL
                                      CASE  %frm_Import_MnuImportFile                           ' Popup Menu Item Selected
                                          frm_Import_MnuImportFile_Select
                                      CASE  %frm_Import_MnuSaveReport                           ' Popup Menu Item Selected
                                          frm_Import_MnuSaveReport_Select
                                      CASE  %frm_Import_SEPARATOR_515                           ' Popup Menu Item Selected
                      
                                      CASE  %frm_Import_MnuImpClose                             ' Popup Menu Item Selected
                                          frm_Import_MnuImpClose_Select
                                      CASE  %frm_Import_Add_List_to_Domain                      ' Popup Menu Item Selected
                                          frm_Import_Add_List_to_Domain_Select
                                      CASE  %frm_Import_CSV_Format_Info                         ' Popup Menu Item Selected
                                          frm_Import_CSV_Format_Info_Select
                                      CASE ELSE
                                  END SELECT
                              CASE ELSE
                          END SELECT
                      END FUNCTION
                      
                      
                      ' (3) Put NEXT DIALOG Creation / Dialog Procedure code after here :
                      
                      ' ------------------------------------------------
                      SUB frm_Import_MnuImportFile_Select()
                      
                          DIM ImportList(5) AS STRING
                          DIM i AS LONG
                      
                          FOR I = 0 TO 5
                              ImportList(i) = "Column1" & CHR$(9) & "Column2" & CHR$(9) &  "Column3" & CHR$(9) & "Column4"
                              LISTBOX ADD hfrm_Import&,  %FRM_IMPORT_LST_CSV, ImportList(i)
                          NEXT
                      
                      END SUB
                      ' ------------------------------------------------
                      
                      ' ------------------------------------------------
                      SUB frm_Import_MnuSaveReport_Select()
                      
                      END SUB
                      ' ------------------------------------------------
                      
                      ' ------------------------------------------------
                      SUB frm_Import_MnuImpClose_Select()
                      
                      END SUB
                      ' ------------------------------------------------
                      
                      ' ------------------------------------------------
                      SUB frm_Import_Add_List_to_Domain_Select()
                      
                      END SUB
                      ' ------------------------------------------------
                      
                      ' ------------------------------------------------
                      SUB frm_Import_CSV_Format_Info_Select()
                      
                      END SUB
                      ' ------------------------------------------------
                      
                      ' ------------------------------------------------
                      CALLBACK FUNCTION CBF_FRM_IMPORT_LST_CSV
                          LOCAL CVal&
                          ' Return Current Selection in CVal&
                          CONTROL SEND CBHNDL , CBCTL, %LB_GETCURSEL, 0,0 TO CVal&
                          IF CBCTLMSG=%LBN_SELCHANGE THEN
                      
                          END IF
                          IF CBCTLMSG=%LBN_DBLCLK THEN
                      
                          END IF
                          IF CBCTLMSG=%LBN_SETFOCUS THEN
                      
                          END IF
                          IF CBCTLMSG=%LBN_KILLFOCUS THEN
                      
                          END IF
                      END FUNCTION
                      ' ------------------------------------------------
                      
                      ' ------------------------------------------------
                      CALLBACK FUNCTION CBF_FRM_IMPORT_LST_RESULT
                          LOCAL CVal&
                          ' Return Current Selection in CVal&
                          CONTROL SEND CBHNDL , CBCTL, %LB_GETCURSEL, 0,0 TO CVal&
                          IF CBCTLMSG=%LBN_SELCHANGE THEN
                      
                          END IF
                          IF CBCTLMSG=%LBN_DBLCLK THEN
                      
                          END IF
                          IF CBCTLMSG=%LBN_SETFOCUS THEN
                      
                          END IF
                          IF CBCTLMSG=%LBN_KILLFOCUS THEN
                      
                          END IF
                      END FUNCTION
                      ' ------------------------------------------------

                      ------------------
                      Chris Boss
                      Computer Workshop
                      Developer of "EZGUI"
                      http://cwsof.com
                      http://twitter.com/EZGUIProGuy

                      Comment


                      • #12
                        I've found a way to completely eliminate the list boxes flicker, although is not too simple.

                        You need an %LBS_OWNERDRAWFIXED listbox, and draw the listbox itmes by ExtTextOut (with the %ETO_OPAQUE flag set) - this way the rows will be updated foreground and background the same time. This operation can be done more than one time, to divide the item into the needed tabs.
                        The default background erasing for the listbox can be eliminated responding to the %WM_CTLCOLORLISTBOX, and returning a NULL_BRUSH. There is only one problem more: the part of the listbox left free - that is, the unused entries.
                        Code:
                        CASE %WM_CTLCOLORLISTBOX  
                        GetClientRect hListBox, r
                        i = ( SendMessage( hListBox, %LB_GETCOUNT, 0, 0 ) - _
                              SendMessage( hListBox, %LB_GETTOPINDEX, 0, 0 ) ) * RowHeight
                        IF i < r.nBottom THEN
                          r.nTop = i
                          hDc = GetDc( hListBox )
                          ExtTextOut hDc, r.nLeft, r.nTop, %ETO_OPAQUE OR %ETO_CLIPPED, r, "", 0, BYVAL %null
                          ReleaseDc hListBox, hDc
                        END IF
                        FUNCTION = GetStockObject( %NULL_BRUSH )
                        EXIT FUNCTION
                        Hope this will be useful for someone.

                        ------------------


                        [This message has been edited by Aldo Cavini (edited April 18, 2001).]
                        Rgds, Aldo

                        Comment


                        • #13
                          THANK YOU!!!!

                          Chris, That's good enough and what I was looking for. Aldo, I'll take a closer look at your code but I don't really understand it at this stage. Thank's though because it gives me a point of improvement for later.


                          There are some real SDK geniuses at this site aren't there!



                          ------------------
                          Paul Dwyer
                          Network Engineer
                          Aussie in Tokyo

                          Comment


                          • #14
                            Paul,

                            I has been too concise. To do what I stated you need to:

                            1 - Create the listbox with the LBS_OWNERDRAWFIXED and LBS_HASSTRINGS flags set. Apart from the listbox drawing, you will not need to modify your code.
                            2 - Set the row height responding to the WM_MEASUREITEM. This message is sent only once after the listbox creation.
                            3 - Respond to the WM_DRAWITEM messages. This message gives you a device context and a rectangle with the coordinates of the row to paint. You must select the text and background colors to respond to the ODA_SELECT flag; then use ExtTextOut with ETO_OPAQUE to paint the entire row (you get the text to paint using the LB_GETTEXT message to the listbox).
                            4 - Respond to the WM_CTLCOLORLISTBOX message as I stated above.

                            Hope I have been clearer.
                            Aldo

                            ------------------


                            [This message has been edited by Aldo Cavini (edited April 19, 2001).]
                            Rgds, Aldo

                            Comment


                            • #15
                              Thanks Aldo,

                              I'll try it this weekend. I have been using Criss's code and the List box is good but the section of dialog between the list boxes that looks like a bar doesn't redraw properly and overwrites. I will try your code. I'll probably use a combination. This has been a very goos learning experience.

                              Cheers

                              ------------------
                              Paul Dwyer
                              Network Engineer
                              Aussie in Tokyo

                              Comment

                              Working...
                              X