Announcement

Collapse
No announcement yet.

Updating Controls on Tabs

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

  • Updating Controls on Tabs

    How do you update the controls on an active Tab to reflect
    new values which are initiated from the parent window?
    I have a tab dialog with a bunch of option buttons
    and such. I also have an updown control on the parent window which
    gives the user the ability to select an index value. This index is used
    to set the control setting in the tab window. I basically need the
    equivalent to the VB "refresh" or something. I have tried sending the
    %WM_INITDIALOG message to the tab dialog, but this didn't work. I use the
    ShowWindow command, I can manually generate a WM_PAINT event, but this won't update
    my control settings, since all initial values are set in the %WM_INITDIALOG event.

    I hope this is clear enough, because I would have to post a sizable
    amount of code to give you something executable.

    Jeff

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

  • #2
    You should never generate your own %WM_PAINT and %WM_INITDIALOG messages - just think of them as "system messages"

    To force a window to be repainted, use InvalidateRect() followed by UpdateWindow(). Alternatively, you can just use RedrawWindow().

    If you just need the controls to be updated, UpdateWindow() by itself may be sufficient...




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

    Comment


    • #3
      Lance, thanks for the tip on the proper use of the WM_PAINT and WM_INITDIALOG events.
      However, when I use the RedrawWindow function, it does everything
      but clear the option buttons. I manually change the value for the option
      buttons in the code call from the parent window, but the previous selection
      state is maintained, ALONG with the new value. In other words, now I
      have two selected option buttons! I'm not sure why the options are refusing
      to change. They are a standard option button group.

      Here is my code call from the parent window. Perhaps I'm not using the
      RedrawWindow function correctly.

      Thanks,

      Jeff

      (BTW, how do I post code correctly so the indentation is maintained?)

      CASE %WM_VSCROLL
      SELECT CASE GetDlgCtrlId(CBLPARAM)
      CASE %IDC_SPIN2
      CONTROL SEND CBHNDL,%IDC_SPIN2,%UDM_GETPOS,0,0 TO series
      i = TabCtrl_GetCurSel(GetDlgItem(CBHNDL,%ID_TAB))
      SELECT CASE i
      CASE 0
      CONTROL SEND hWndTab(i + 1),%[email protected](series),%BM_SETCHECK,1,0
      CONTROL SEND hWndTab(i + 1),%ID_UPDOWN, %UDM_SETPOS, 0,@glgraph.gformat.linewidth(Series)
      END SELECT
      d&=RedrawWindow(hWndTab(i + 1),BYVAL 0,%NULL,%RDW_ERASE OR %RDW_INVALIDATE OR %RDW_UPDATENOW OR %RDW_ALLCHILDREN)


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

      Comment


      • #4
        Formatting info: http://www.powerbasic.com/support/forums/ubbcode.html

        Smilies info: http://www.powerbasic.com/support/forums/smilies.html

        Jeff, can you please post the whole source code as it is too difficult to diagnose *exactly* what else could be wrong with your program without seeing the whole context.

        For example, it is rare that you would need to force a standard control to redraw itself... I suspect you may have a message pump problem, you are not processing messages correctly, or something else is wrong in your code.



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

        Comment


        • #5
          Lance, thanks again for the reply. The complete source code for this
          module is thousands of lines long. So as a compromise, I have "gutted" the
          code to produce a test program which shows the problem.

          Code:
          #COMPILE EXE
          #REGISTER NONE
          #DIM ALL
          
          $INCLUDE "win32api.inc"
          $INCLUDE "comdlg32.inc"
          $INCLUDE "Commctrl.inc"
          %ID_TAB = 1001
          %IDC_STATIC = 1
          %IDC_RADIO1 = 1000
          %IDC_RADIO2 = 1001
          %IDC_RADIO3 = 1002
          %IDC_RADIO4 = 1003
          %IDC_RADIO5 = 1004
          %IDC_RADIO6 = 1005
          %IDC_RADIO7 = 1006
          %IDC_RADIO8 = 1007
          %IDC_RADIO9 = 1008
          %IDC_RADIO10= 1009
          %IDC_RADIO11 = 1010
          %IDC_RADIO12 = 1011
          %IDC_RADIO13 = 1012
          %IDC_RADIO14 = 1013
          %IDC_RADIO15 = 1014
          %IDC_RADIO16 = 1015
          %IDC_RADIO17 = 1016
          %IDC_RADIO18 = 1017
          %IDC_RADIO19 = 1018
          %IDC_RADIO20= 1019
          %IDC_RADIO21= 1020
          %IDC_RADIO22 = 1021
          %IDC_RADIO23 = 1022
          %IDC_RADIO24 = 1023
          %IDC_RADIO25 = 1024
          %IDC_RADIO26 = 1025
          %IDC_RADIO27 = 1026
          %IDC_RADIO28 = 1027
          %IDC_RADIO29 = 1028
          %IDC_RADIO30 = 1029
          %IDC_RADIO31= 1030
          %IDC_SPIN1 = 1100
          %IDC_SPIN2 = 1101
          %IDC_SPIN3 = 1102
          %IDC_SPIN4 = 1103
          %MAX_SPIN   = 20
          %MIN_SPIN   = 1
          %ID_LABEL1 = 1120
          %ID_LABEL2 = 1121
          %ID_LABEL3 = 1122
          %ID_LABEL4 = 1123
          %ID_UPDOWN  = 1100
          %IDC_BUTTON1=  1041
          %IDC_BUTTON2=  1042
          %IDC_BUTTON3=  1043
          %IDC_BUTTON4=  1044
          %IDC_CHECK1=   1060
          %IDC_CHECK2=   1061
          %IDC_CHECK3=   1062
          %IDC_CHECK4=   1063
          %IDC_CHECK5=   1064
          %IDC_TEXT1=   1070
          %IDC_TEXT2=   1071
          %IDC_COMBO1=   1080
          %IDC_COMBO2=   1081
          %IDC_EDIT1= 1130
          %IDC_EDIT2= 1131
          %IDC_EDIT3= 1132
          %IDC_EDIT4= 1133
          %IDC_TRACK1 = 2000
          %IDC_TRACK2 = 2001
          
          GLOBAL ColorSelection AS LONG
          GLOBAL mousex AS LONG,mousey AS LONG
          GLOBAL values() AS LONG
          GLOBAL linewidth() AS LONG
          GLOBAL linestyle() AS LONG
          GLOBAL LastIdx AS LONG, hWndTab() AS LONG
          GLOBAL Last_Idx AS LONG, hWnd_Tab() AS LONG
          GLOBAL Series AS LONG
          
          '****************** Functions Used By Multiple Dialogs *******************************
          
          FUNCTION LinePreview(BYVAL hdc&,BYVAL Style&,rc AS rect,BYVAL wdth&,BYVAL colr&) AS LONG
            LOCAL d&,brush&,oldbrush&,pen&,oldpen&,region&,oldregion&,lb AS logbrush
            LOCAL pt AS pointapi,r AS rect
            r= rc
            d&= inflaterect(r,-10,-10)
            brush&= CreateSolidBrush(RGB(255,255,255))
            oldbrush&= selectobject(hdc&,brush&)
            d& = GetClipRgn(hdc&, oldregion&)
            region& = CreateRectRgn(rc.nLeft,rc.nTop,rc.nRight,rc.nBottom)
            d& = SelectClipRgn(hdc&, region&)
            d&= rectangle(hdc&,rc.nleft,rc.ntop,rc.nright,rc.nbottom)
            lb.lbstyle= %BS_SOLID
            lb.lbcolor= colr&
            pen&= ExtCreatePen(%PS_GEOMETRIC OR style& OR %PS_ENDCAP_FLAT,wdth&,lb,0,BYVAL 0)
            oldpen&= selectobject(hdc&,pen&)
            d&= MoveToEX(hdc&,r.nleft,r.ntop,pt)
            d&= Lineto(hdc&,r.nright,r.nbottom)
            d&= DrawEdge(hdc&,rc,%EDGE_SUNKEN,%BF_RECT)
            d&= selectobject(hdc&,oldpen&)
            d&= deleteobject(pen&)
            d& = SelectClipRgn(hdc&, oldregion&)
            d&= deleteobject(region&)
            brush&= selectobject(hdc&,oldbrush&)
            d&= deleteobject(brush&)
          END FUNCTION
          
          FUNCTION MakeFont(BYVAL hwnd&,BYVAL Font AS STRING, BYVAL PointSize AS LONG,BYVAL Bold&,BYVAL Italic&,BYVAL Ul&) AS LONG
            LOCAL hDC AS LONG,d&
            LOCAL CyPixels AS LONG
            LOCAL lf AS logfont
            IF (bold&>0) THEN
              lf.lfweight= %FW_BOLD
              ELSE
                lf.lfweight= %FW_NORMAL
            END IF
            lf.lfunderline= ul&
            lf.lfitalic= italic&
            hDC = GetDC(hWnd&)
            lf.lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC,%LOGPIXELSY),72)
            ReleaseDC hWnd&, hDC
            FUNCTION = CreateFontindirect(lf)
          END FUNCTION
          
          SUB DrawColorRC SDECL ALIAS "DrawColorRC"(BYVAL hdc&,rc AS rect,BYVAL colr&)
            LOCAL brush&,brushold&,d&
            brush&= createsolidbrush(colr&)
            brushold&= selectobject(hdc&,brush&)
            d&= rectangle(hdc&,rc.nleft,rc.ntop,rc.nright,rc.nbottom)
            d& = DrawEdge(hdc&,rc,%EDGE_SUNKEN,%BF_RECT)
            d&= selectobject(hdc&,brushold&)
            d&= deleteobject(brush&)
          END SUB
          
          FUNCTION EnumFontsProc(pLogFont AS LOGFONT PTR, BYVAL pFontMetrics AS LONG, BYVAL dwFontType AS DWORD, BYVAL ghdlg AS LONG) AS LONG
            LOCAL tLogFont AS LOGFONT
            tLogFont = @pLogFont
            IF (dwFontType=%TRUETYPE_FONTTYPE) THEN
              COMBOBOX ADD ghdlg,%IDC_COMBO1, tLogFont.lfFaceName
            END IF
            FUNCTION = 1
          END FUNCTION
          
          
          '**************************** Series Properties Tab dialog *************************************
          
          FUNCTION SeriesPatterns(BYVAL hdc&,BYVAL Style&,rc AS rect,BYVAL colr&) AS LONG
            LOCAL h&,w&,count&,offset&,k AS LONG,d&,xx&,yy&
            LOCAL r AS rect,brush&,oldbrush&,region&,oldregion&
            xx&= rc.nright-rc.nleft
            yy&= rc.nbottom-rc.ntop
            h&= CLNG(.12*yy&)
            w&= CLNG(.12*xx&)
            count&= 1
            offset&= 1
            FOR k= 0 TO 7
              r.ntop= CLNG((.1+.21*(count&-1))*yy&)
              r.nleft= CLNG((.15+.132*(offset&-1))*xx&)
              r.nbottom= r.ntop+h&
              r.nright= r.nleft+w&
              count&= count&+1
              IF (count&>3) THEN
                 count&= 1
                 offset&= offset+2
              END IF
              SELECT CASE k
                CASE 0
                  brush&= createsolidbrush(colr&)
                CASE 1
                  brush&= createsolidbrush(RGB(255,255,255))
                CASE 2
                  brush&= createhatchbrush(%HS_HORIZONTAL,colr&)
                CASE 3
                  brush&= createhatchbrush(%HS_VERTICAL,colr&)
                CASE 4
                  brush&= createhatchbrush(%HS_FDIAGONAL,colr&)
                CASE 5
                  brush&= createhatchbrush(%HS_BDIAGONAL,colr&)
                CASE 6
                  brush&= createhatchbrush(%HS_CROSS,colr&)
                CASE 7
                  brush&= createhatchbrush(%HS_DIAGCROSS,colr&)
              END SELECT
              d& = GetClipRgn(hdc&, oldregion&)
              region& = CreateRectRgn(r.nLeft,r.nTop,r.nRight,r.nBottom)
              d& = SelectClipRgn(hdc&, region&)
              oldbrush&= selectobject(hdc&,brush&)
              d&= rectangle(hdc&,r.nleft,r.ntop,r.nright,r.nbottom)
              d&= selectobject(hdc&,oldbrush&)
              d&= deleteobject(brush&)
              d& = DrawEdge(hdc&,r,%EDGE_SUNKEN,%BF_RECT)
              d& = SelectClipRgn(hdc&, oldregion&)
              d&= deleteobject(region&)
            NEXT
          END FUNCTION
          
          
          CALLBACK FUNCTION SeriesProc1
            LOCAL a&,x&,y&,xx&,yy&,hdc&,k AS LONG,txt$,nm$,d&
            STATIC sysrc AS rect,rc AS rect
            STATIC lpps AS paintstruct
            LOCAL h&,w&,pen&,oldpen&,pt AS pointapi,brush&,OldBrush&
            LOCAL x1&,y1&,wdth&,lb AS logbrush
            LOCAL MN%,MX%,RANGE&
            STATIC index&
            SELECT CASE CBMSG
              CASE %WM_INITDIALOG
                CONTROL ADD FRAME,CBHNDL,%IDC_STATIC,"Line Style",12,5,88,107,,
                CONTROL ADD OPTION,CBHNDL,%IDC_RADIO11,"",18,23,12,9,%WS_CHILD OR %WS_GROUP,, 'CALL IDC_RADIO1_CB
                CONTROL ADD OPTION,CBHNDL,%IDC_RADIO12,"",18,40,12,9,%WS_CHILD,, 'CALL IDC_RADIO2_CB
                CONTROL ADD OPTION,CBHNDL,%IDC_RADIO13,"",18,57,12,9,%WS_CHILD,, 'CALL IDC_RADIO3_CB
                CONTROL ADD OPTION,CBHNDL,%IDC_RADIO14,"",18,73,12,9,%WS_CHILD,, 'CALL IDC_RADIO4_CB
                CONTROL ADD OPTION,CBHNDL,%IDC_RADIO15,"",18,90,12,9,%WS_CHILD,, 'CALL IDC_RADIO5_CB
                CONTROL ADD FRAME,CBHNDL,%IDC_STATIC,"Line Width",150,5,64,33,%WS_CHILD,
                CONTROL ADD LABEL,CBHNDL,%ID_LABEL1,"",163,19,38,12,%WS_CHILD,%WS_EX_CLIENTEDGE, 'CALL IDC_STATIC_CB
                CONTROL ADD "msctls_updown32", CBHNDL, %ID_UPDOWN, "", 0, 0, 8, 8,%WS_CHILD OR %WS_BORDER OR %WS_VISIBLE OR %UDS_WRAP OR %UDS_ARROWKEYS OR %UDS_ALIGNRIGHT OR %UDS_SETBUDDYINT
                CONTROL SEND CBHNDL, %ID_UPDOWN, %UDM_SETBUDDY, GetDlgItem(CBHNDL, %ID_LABEL1), 0&
                CONTROL SEND CBHNDL, %ID_UPDOWN, %UDM_SETRANGE, 0&, MAKLNG(%MAX_SPIN, %MIN_SPIN)
                CONTROL SEND CBHNDL,%IDC_RADIO11+LineStyle(series),%BM_SETCHECK,1,0
                CONTROL SEND CBHNDL,%ID_UPDOWN, %UDM_SETPOS, 0,values(Series)
              CASE %WM_NOTIFY
                DIM pNmUpDown AS NM_UPDOWN PTR
                pNmUpDown = CBLPARAM
                IF @pNmUpDown.hdr.code = %UDN_DELTAPOS THEN
                  SELECT CASE CBCTL
                    CASE %ID_UPDOWN
                      CONTROL SEND CBHNDL,CBCTL,%UDM_GETRANGE,0,0 TO range&
                      mn%= HIWRD(range&)
                      mx%= LOWRD(range&)
                      IF (@pNmUpDown.iPos + @pNmUpDown.iDelta>mx%) OR (@pNmUpDown.iPos + @pNmUpDown.iDelta<mn%)THEN
                        ELSE
                          linewidth(Series)[email protected] + @pNmUpDown.iDelta
                          hdc&= GetDC(CBHNDL)
                          d&= LINEPREVIEW(hdc&,linestyle(Series),rc,linewidth(Series),RGB(155,255,12))
                          releaseDC CBHNDL,hdc&
                      END IF
                  END SELECT
                END IF
              CASE %WM_PAINT
                DIALOG GET SIZE CBHNDL TO x&,y&
                DIALOG UNITS CBHNDL,x&,y& TO PIXELS xx&, yy&
                sysrc.ntop= 0
                sysrc.nleft= 0
                sysrc.nright = xx&
                sysrc.nbottom =yy&
                rc.nleft= .5*xx
                rc.ntop= .4*yy
                rc.nright= .95*xx
                rc.nbottom= .93*yy
                lpps.rcpaint= sysrc
                hdc&= beginpaint(CBHNDL,lpps)
                FOR k = 1 TO 5
                  SELECT CASE k
                    CASE 1
                      pen&= CreatePen(%PS_SOLID,1,0)
                    CASE 2
                      pen&= CreatePen(%PS_DASH,1,0)
                    CASE 3
                      pen&= CreatePen(%PS_DOT,1,0)
                    CASE 4
                      pen&= CreatePen(%PS_DASHDOT,1,0)
                    CASE 5
                      pen&= CreatePen(%PS_DASHDOTDOT,1,0)
                  END SELECT
                  oldpen&= selectobject(hdc&,pen&)
                  DIALOG UNITS CBHNDL,35,26+17*(k-1) TO PIXELS x1&, y1&
                  d&= MoveToEX(hdc&,x1,y1,pt)
                  d&= Lineto(hdc&,x1+75,y1)
                  d&= selectobject(hdc&,oldpen&)
                  d&= deleteobject(pen&)
                NEXT
                CONTROL GET TEXT CBHNDL,%ID_LABEL1 TO txt$
                linewidth(Series)= VAL(txt$)
                d&= LINEPREVIEW(hdc&,linestyle(Series),rc,linewidth(Series),RGB(155,255,12))
                hdc&= Endpaint(CBHNDL,lpps)
                FUNCTION= 1
              CASE %WM_COMMAND
                SELECT CASE CBCTL
                  CASE %IDC_RADIO11 TO %IDC_RADIO15
                    linestyle(Series)= CBCTL-%IDC_RADIO11
                  END SELECT
                hdc&= GetDC(CBHNDL)
                d&= LINEPREVIEW(hdc&,linestyle(Series),rc,linewidth(Series),RGB(155,255,12))
                releaseDC CBHNDL,hdc&
             END SELECT
          END FUNCTION
          
          CALLBACK FUNCTION SeriesProc
            LOCAL tie AS TC_ITEM, i AS LONG, Caption AS STRING
            LOCAL d&,nTabCh AS LONG,hdc&,lf AS logfont
            STATIC Brush AS LONG,hfont AS LONG
            nTabCh = 5
            SELECT CASE CBMSG
              CASE %WM_INITDIALOG
                DIM lb AS logbrush
                Lb.lbColor = %Yellow
                Brush = CreateBrushIndirect(Lb)
                REDIM hWndTab(1 TO nTabCh)
                FOR i = 1 TO nTabCh
                  DIALOG NEW CBHNDL, "",19,30, 227, 120, %DS_CONTROL OR %WS_CHILD TO hWndTab(i)
                  SELECT CASE i
                    CASE 1
                      DIALOG SHOW MODELESS hWndTab(i) CALL SeriesProc1
                      Caption = "Line Style"
                    CASE 2
                      DIALOG SHOW MODELESS hWndTab(i) 'CALL SeriesProc2
                      Caption = "Plot Symbols"
                    CASE 3
                      DIALOG SHOW MODELESS hWndTab(i) 'CALL SeriesProc3
                      Caption = "Fill Style "
                    CASE 4
                      DIALOG SHOW MODELESS hWndTab(i) 'CALL SeriesProc4
                      Caption = "Color"
                    CASE 5
                      DIALOG SHOW MODELESS hWndTab(i) 'CALL SeriesProc5
                      Caption = "Options"
                  END SELECT
                  IF i = LastIdx+1 THEN
                    ShowWindow hWndTab(i), %SW_SHOW
                    ELSE
                      ShowWindow hWndTab(i), %SW_HIDE
                  END IF
                  Tie.mask = %TCIF_TEXT OR %TCIF_IMAGE
                  tie.iImage = -1
                  tie.pszText = STRPTR(Caption)
                  TabCtrl_InsertItem GetDlgItem(CBHNDL, %ID_TAB), i, tie
                NEXT
                d&=TabCtrl_SetCurSel(GetDlgItem(CBHNDL,%ID_TAB),LastIdx)
                SetFocus GetDlgItem(CBHNDL, %ID_TAB)
            CASE %WM_DESTROY
                DeleteObject Brush
                deleteobject hfont
            CASE %WM_CTLCOLORSTATIC
                SELECT CASE GetDlgCtrlId(CBLPARAM)
                  CASE %ID_LABEL1
                    SetBkColor CBWPARAM,%Yellow
                    FUNCTION= Brush
                END SELECT
            CASE %WM_COMMAND
              SELECT CASE CBCTL
                 CASE= %IDC_BUTTON1
                   DIALOG END CBHNDL
              END SELECT
            CASE %WM_VSCROLL
              SELECT CASE GetDlgCtrlId(CBLPARAM)
               CASE %IDC_SPIN2
                 CONTROL SEND CBHNDL,%IDC_SPIN2,%UDM_GETPOS,0,0 TO series
                 i = TabCtrl_GetCurSel(GetDlgItem(CBHNDL,%ID_TAB))
                 SELECT CASE i
                   CASE 0
                     CONTROL SEND hWndTab(i + 1),%IDC_RADIO11+LineStyle(series),%BM_SETCHECK,1,0
                     CONTROL SEND hWndTab(i + 1),%ID_UPDOWN, %UDM_SETPOS, 0,linewidth(Series)
                   END SELECT
                 d&=RedrawWindow(hWndTab(i + 1),BYVAL 0,%NULL,%RDW_ERASE OR %RDW_INVALIDATE OR %RDW_UPDATENOW OR %RDW_ALLCHILDREN)
              END SELECT
            CASE %WM_NOTIFY
              LOCAL lpNmh AS NMHDR PTR
              lpNmh = CBLPARAM
              SELECT CASE @lpNmh.Code
                CASE %TCN_LAST TO %TCN_FIRST
                  SELECT CASE @lpNmh.idFrom
                    CASE %ID_TAB
                      SELECT CASE @lpNmh.Code
                        CASE %TCN_SELCHANGE
                          i = TabCtrl_GetCurSel(GetDlgItem(CBHNDL,%ID_TAB))
                          ShowWindow hWndTab(LastIdx + 1), %SW_HIDE
                          LastIdx = i
                          ShowWindow hWndTab(LastIdx + 1), %SW_SHOW
                      END SELECT
                    END SELECT
                  END SELECT
                END SELECT
          END FUNCTION
          
          FUNCTION SeriesProp SDECL ALIAS "SeriesProp" (BYVAL hWnd&,BYVAL currentseries AS LONG) EXPORT AS LONG
            LOCAL hDlg AS LONG
            LOCAL x&,y&
            InitCommonControls
            series= currentseries
            REDIM linestyle(6)
            REDIM values(6)
            REDIM linewidth(6)
            DIALOG NEW hwnd&, "Graph Series Properties",,, 265, 190,%WS_CAPTION, %WS_EX_CONTROLPARENT, TO hDlg
            CONTROL ADD "SysTabControl32", hDlg, %ID_TAB, "", 10, 10, 245, 150, %WS_CHILD OR %WS_VISIBLE
            CONTROL ADD BUTTON, hdlg, %IDC_BUTTON1, "&Close",200,165,55,16,%WS_CHILD
            CONTROL ADD LABEL,hdlg,%IDC_STATIC,"Current Plot Series:",17,168,38,20,,
            CONTROL ADD LABEL,hdlg,%ID_LABEL1,"",60,170,30,12,%WS_CHILD OR %SS_CENTER,%WS_EX_CLIENTEDGE, 'CALL IDC_STATIC_CB
            CONTROL ADD "msctls_updown32", hdlg, %IDC_SPIN2, "", 0, 0, 8, 8,%WS_CHILD OR %WS_BORDER OR %WS_VISIBLE OR %UDS_WRAP OR %UDS_ARROWKEYS OR %UDS_ALIGNRIGHT OR %UDS_SETBUDDYINT
            CONTROL SEND hdlg, %IDC_SPIN2, %UDM_SETBUDDY, GetDlgItem(hdlg, %ID_LABEL1), 0&
            CONTROL SEND hdlg, %IDC_SPIN2, %UDM_SETRANGE, 0&, MAKLNG(6,1)
            CONTROL SEND hdlg,%IDC_SPIN2, %UDM_SETPOS, 0,Series&
            DIALOG SHOW MODAL hDlg CALL SeriesProc
            FUNCTION= 1
          END FUNCTION
          
          
          FUNCTION PBMAIN
            dim d&
            d&= SeriesProp(0,1)
          END FUNCTION


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

          Comment


          • #6
            A couple of points. You need to reset all Option control before you
            mark a new one by code, otherwise you may end up with multiple Opts
            selected. Also, you'll get multiple %WM_VSCROLL messages at each
            click in the UpDown control.

            There is a Notify message to use, %UDN_DELTAPOS, but unfortunately,
            that one is triggered before the value is changed (Microsoft logic),
            so all you can do in this case, is to use it to set a flag that can
            be used to avoid multple %WM_VSCROLL messages.

            Suggestion: In the beginning of SeriesProc, declare a static LONG,
            for example STATIC UD AS LONG. Under %WM_NOTIFY, add %UDN_DELTAPOS,
            like:
            Code:
                SELECT CASE @lpNmh.Code
                  CASE %UDN_DELTAPOS : UD = %TRUE
            
                  CASE %TCN_LAST TO %TCN_FIRST
                    SELECT CASE @lpNmh.idFrom
                    ... etc
            'Under %WM_VSCROLL:
            Code:
                SELECT CASE GetDlgCtrlId(CBLPARAM)
                 CASE %IDC_SPIN2
                   IF UD THEN
                      UD = 0
                      CONTROL SEND CBHNDL,%IDC_SPIN2,%UDM_GETPOS,0,0 TO series
                      i = TabCtrl_GetCurSel(GetDlgItem(CBHNDL,%ID_TAB))
                      SELECT CASE i
                        CASE 0
                          LOCAL j AS LONG
                          FOR j = 0 TO 5 : CONTROL SEND hWndTab(i + 1), %IDC_RADIO11+j,%BM_SETCHECK,0,0 : NEXT
                          CONTROL SEND hWndTab(i + 1),%IDC_RADIO11+LineStyle(series),%BM_SETCHECK,1,0
                          CONTROL SEND hWndTab(i + 1),%ID_UPDOWN, %UDM_SETPOS, 0,linewidth(Series)
                      END SELECT
                      UpDateWindow hWndTab(i + 1)
                      d&=RedrawWindow(hWndTab(i + 1),BYVAL 0,%NULL,%RDW_ERASE OR %RDW_INVALIDATE OR %RDW_UPDATENOW OR %RDW_ALLCHILDREN)
                      FUNCTION = 0
                   END IF
                 END SELECT
            This will at least remove the multiple messages and fix so the
            Option control settings works. However, you really shouldn't
            need to update the entire Tab page dialog to see the changes.
            Can't you just update the actual drawing area instead, to avoid
            unnecessary flicker?


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

            Comment


            • #7
              Borje, excellent piece of detective work! That fixed it.
              Thanks a million.

              I didn't realize that you needed to reset the
              controls before you could change the option buttons by code.
              Unfortunately, I cannot reduce the redraw window on that one tab since
              the line preview area is owner-drawn, and requires a re-paint each
              time a setting change is made. However, I'm not sure if I have the best settings
              for the RedrawWindow function. I experimented with less invasive setting,
              and nothing seems to happen.

              Anyway, thanks again for the help.


              Jeff





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

              Comment


              • #8
                You are welcome.

                One little error of me there - you don't really have to reset all
                Option Checkboxes when you want to check a new one by code, only the
                one that currently is checked. I reset all just to make sure..

                Why not draw in an Image control or a Static Label with %SS_BITMAP
                set instead? That will allow you to refresh the drawing only in a
                better and smoother way.


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

                Comment


                • #9
                  Borje, I orginally investigated using image controls or labels as
                  a drawing area a while ago. However, I was not able to get all the mouse
                  movement notifications that you get with a dialog window. (Or at least I'm
                  not sure how to do it.) Although I don't specifically need all that for this
                  example, I try to reuse code, and technique whenever I can.

                  Jeff


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

                  Comment

                  Working...
                  X