Announcement

Collapse
No announcement yet.

TIMER usage

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

  • TIMER usage

    This is the first time I've used a TIMER so I need some advice.
    Code:
    In WM_INITDIALOG I have
    
             SetTimer(CBHNDL,1,100,BYVAL 0)
    ---------------------------------------------------------------
    Controls 1501 to 1520 are a range of labels with %SS_NOTIFY I use like buttons
    
          CASE %WM_TIMER
            FOR J = 1501 TO 1520
              CONTROL HANDLE CBHNDL,J TO hctrl&
              IF hctrl& <> 0 THEN
                CONTROL REDRAW CBHNDL,J
              END IF  
            NEXT
    
    In %WM_CTLCOLORSTATIC I have
                CASE 1501 TO 1520
                  SetBkMode CBWPARAM, %Transparent
                  SetBkColor CBWPARAM, V_COLOR(15)
                  IF GetDlgCtrlID(CBLPARAM) = CUR_CTRL_ID&  THEN
                    SetCursor HandMousePointer
                    SelectObject CBWPARAM, hFontCap
                    SetTextColor CBWPARAM, V_COLOR(4) ' change red when over
                  ELSE
                    SelectObject CBWPARAM, hFontCap
                    SetTextColor CBWPARAM, V_COLOR(1) ' change back to blue
                  END IF
                  FUNCTION = GetStockObject(%NULL_BRUSH)
    
    In %WM_SETCURSOR I have
    
              CUR_CTRL_ID& = GetDlgCtrlID(CBWPARAM)
              IF CUR_CTRL_ID& >= 1501 AND CUR_CTRL_ID& <= 1520 THEN
                CONTROL HANDLE CBHNDL, CUR_CTRL_ID& TO CUR_CTRL&
                RedrawWindow  CUR_CTRL&, BYVAL 0, 0, %RDW_ERASE OR %RDW_INVALIDATE
                PRESS_BUTTON_ON = -1: PRV_BUT& = CUR_CTRL&
              ELSEIF ABS(CUR_CTRL_ID&) > 100000& AND PRESS_BUTTON_ON THEN
                RedrawWindow  PRV_BUT&, BYVAL 0, 0, %RDW_ERASE OR %RDW_INVALIDATE
                PRESS_BUTTON_ON = 0
              END IF
    
    In WM_DESTROY I have
    
            KillTimer(CBHNDL,1)
    This code causes the LABEL with the %SS_NOTIFY style to initially draw one color
    and turn to Red when the cursor is over it and the REDRAW turns it back to the
    original color if that control no longer has the cursor over it.

    Question: Does this use of the Timer cause any problems or is there a better
    way of doing this.

  • #2
    Other than forcing a lot of unnecessary redraws as implemented here, the use of a TIMER does not have any special problems associated with it.

    Your use of the timer here to repaint each of 20 controls ten times per second is somewhat curious.. there is no need to redraw those labels unless the cursor has moved or the text has changed; and if the cursor moves or the text changes, you should be getting the WM_CTLCOLORSTATIC message as part of the normal 'redraw required' notifications.

    Same when setting the cursor... if a redraw is required the system should generate the regular redraw notification messages and you can paint at that time.

    I think you might be trying to do too much yourself... let Windows figure out when to redraw and let you know at those times.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      I can get it to turn the control red by using SetCursor to detect when it is over the control but don't have a reliable way to tell when it's no longer over the control, thus the timer.

      I'm guessing I could use WM_MOUSEMOVE to set the timer instead of WM_INITDIALOG and kill it once the control has been redrawn back to it's non-hovered color.

      Also I'm only redrawing if the one of the buttons actually exists at any given time.

      In another program I used a sub class based on Kev Peel's code.

      Bob Mechler

      Comment


      • #4
        You might want to look at owner-drawn labels to do this.

        I know there are examples here. What I don't know is how DDT will like you interfering... except you can probably trick DDT into thinking it doesn't have to do anything by using

        CONTROL ADD "static" ....
        instead of
        CONTROL ADD LABEL ...

        For all DDT knows in this case, the control is a "thingamajig control."

        (As you'll probably recall, I'm not a DDT guy).

        MCM
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Some old code for a hover-like button:
          Code:
          '---------------------------------------------------------------
          #Compile Exe
          #Dim All
          #Include "win32api.inc"
          #Include "CommCtrl.inc"
          
          Global hButton As Dword, hDlg As Dword
          
          Function PaintButton(ByVal wMsg As Dword) As Long
            Local Pt As POINTAPI, Rc As RECT, Result As Dword, hDc As Dword
            Static OnButton As Dword, MouseDown As Dword
            GetCursorPos(Pt)
            ScreenToClient hDlg, Pt
            Result = ChildWindowFromPoint (hDlg, Pt)
            hDc = GetDc (hButton)
            GetClientRect(hButton,Rc)
            If (wMsg = %WM_LBUTTONDOWN) Or (wMsg = %WM_LBUTTONUP) Then OnButton = 0
            If hButton = Result Then
              If OnButton = 0 Then
                OnButton = 1
                If wMsg = %WM_LBUTTONDOWN Then
                  Control Set Text hDlg, 1001, "Button Down"
                  Control Set Color hDlg, 1001, RGB(255,255,255), RGB(90,115,205)
                  Control ReDraw hDlg, 1001
                  DrawEdge(hdc, Rc, %BDR_SUNKENINNER Or %BDR_SUNKENOUTER, %BF_RECT)
                  Beep
                Else
                  Control Set Text hDlg, 1001, "Button Up"
                  Control Set Color hDlg, 1001, RGB(255,255,255), RGB(7,15,105)
                  Control ReDraw hDlg, 1001
                  DrawEdge(hdc, Rc, %BDR_RAISEDINNER Or %BDR_RAISEDOUTER, %BF_RECT)
                End If
                If wMsg = %WM_MOUSEMOVE Then sndPlaySound "start.wav",0
             End If
            Else
              If OnButton = 1 Then OnButton = 0 : InValidateRect hButton, ByVal 0, ByVal 0
            End If
            ReleaseDc hButton, hDc
          End Function
          
          CallBack Function CbMain ()
            Select Case CbMsg
              Case %WM_LBUTTONDOWN, %WM_LBUTTONUP, %WM_MOUSEMOVE : PaintButton(CbMsg)
            End Select
          End Function
          
          Function PBMain As Long
            Dialog New 0,"Press to test...",200,200,105,80,%WS_SYSMENU To hDlg
            Control Add Label, hDlg, 1001, "Hover Button", 20,20,60,24, %SS_CENTER Or %SS_CENTERIMAGE
            Control Set Color hDlg, 1001, RGB(255,255,255), RGB(7,15,105)
            Dialog  Set Color hDlg, RGB(255,255,255), RGB(7,15,105)
            hButton = GetDlgItem(hDlg, 1001)
            Dialog Show Modal hDlg Call CbMain
          End Function
          Regards,
          Peter

          Comment


          • #6
            Hover Like Button

            Hi Peter;

            Apparently there is some difference between your copy of win32api and mine.

            In my copy function: ChildWindowFromPoint requires 3 arguments as follows:
            ChildWindowFromPoint(hDlg, x, y)

            Your code uses only 2 arguments:
            ChildWindowFromPoint(hDlg, Pt)
            And as written will not compile with PB 8.04.

            Comment


            • #7
              I changed the offending line...
              Code:
              '---------------------------------------------------------------
              #Compile Exe
              #Dim All
              #Include "win32api.inc"
              #Include "CommCtrl.inc"
              
              Global hButton As Dword, hDlg As Dword
              
              Function PaintButton(ByVal wMsg As Dword) As Long
                Local Pt As POINTAPI, Rc As RECT, Result As Dword, hDc As Dword
                Static OnButton As Dword, MouseDown As Dword
                GetCursorPos(Pt)
                ScreenToClient hDlg, Pt  ' [b]
                Result = ChildWindowFromPoint (hDlg, Pt.x, Pt.y) ' [/b]
                hDc = GetDc (hButton)    GetClientRect(hButton,Rc)
                If (wMsg = %WM_LBUTTONDOWN) Or (wMsg = %WM_LBUTTONUP) Then OnButton = 0
                If hButton = Result Then
                  If OnButton = 0 Then
                    OnButton = 1
                    If wMsg = %WM_LBUTTONDOWN Then
                      Control Set Text hDlg, 1001, "Button Down"
                      Control Set Color hDlg, 1001, RGB(255,255,255), RGB(90,115,205)
                      Control ReDraw hDlg, 1001
                      DrawEdge(hdc, Rc, %BDR_SUNKENINNER Or %BDR_SUNKENOUTER, %BF_RECT)
                      Beep
                    Else
                      Control Set Text hDlg, 1001, "Button Up"
                      Control Set Color hDlg, 1001, RGB(255,255,255), RGB(7,15,105)
                      Control ReDraw hDlg, 1001
                      DrawEdge(hdc, Rc, %BDR_RAISEDINNER Or %BDR_RAISEDOUTER, %BF_RECT)
                    End If
                    If wMsg = %WM_MOUSEMOVE Then sndPlaySound "start.wav",0
                 End If
                Else
                  If OnButton = 1 Then OnButton = 0 : InValidateRect hButton, ByVal 0, ByVal 0
                End If
                ReleaseDc hButton, hDc
              End Function
              
              CallBack Function CbMain ()
                Select Case CbMsg
                  Case %WM_LBUTTONDOWN, %WM_LBUTTONUP, %WM_MOUSEMOVE : PaintButton(CbMsg)
                End Select
              End Function
              
              Function PBMain As Long
                Dialog New 0,"Press to test...",200,200,105,80,%WS_SYSMENU To hDlg
                Control Add Label, hDlg, 1001, "Hover Button", 20,20,60,24, %SS_CENTER Or %SS_CENTERIMAGE
                Control Set Color hDlg, 1001, RGB(255,255,255), RGB(7,15,105)
                Dialog  Set Color hDlg, RGB(255,255,255), RGB(7,15,105)
                hButton = GetDlgItem(hDlg, 1001)
                Dialog Show Modal hDlg Call CbMain
              End Function__________________
              Regards,
              Peter
              Last edited by Peter Lameijn; 24 Apr 2008, 05:47 PM.
              Regards,
              Peter

              Comment


              • #8
                I don't see why you need a timer, but maybe I'm missing the point. Does this code do what you want?

                Code:
                #COMPILE EXE
                #DIM ALL
                
                #IF NOT %DEF(%WINAPI)
                    #INCLUDE "WIN32API.INC"
                #ENDIF
                %IDD_DIALOG1 =  101
                %IDC_LABEL1  = 1001
                %IDC_LABEL2  = 1002
                %IDC_LABEL3  = 1003
                %IDC_LABEL4  = 1004
                %IDC_LABEL5  = 1005
                %IDC_LABEL6  = 1006
                
                DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
                DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                
                '---------------------------------------------------
                MACRO MAKEPOINTS(lParam, pt)
                    pt.x = BITS%(LOWRD(lParam))
                    pt.y = BITS%(HIWRD(lParam))
                END MACRO
                '---------------------------------------------------
                
                CALLBACK FUNCTION ShowDIALOG1Proc()
                    LOCAL i, lCtlId AS LONG
                    STATIC LastCtl AS LONG
                    LOCAL hW AS DWORD
                    LOCAL pts AS points
                    
                    SELECT CASE AS LONG CBMSG
                        CASE %WM_INITDIALOG
                            FOR i = %IDC_LABEL1 TO %IDC_LABEL6
                                CONTROL SET COLOR CBHNDL, i, -1, %CYAN - 100 * i
                             NEXT
                            END SELECT
                        CASE %WM_MOUSEMOVE
                            makepoints(CBLPARAM, pts)
                            hW = ChildWindowFromPoint(CBHNDL, pts.x, pts.y)
                            lCtlId = getdlgctrlid(hW)
                            IF lCtlId <> lastCtl THEN
                                FOR i = %IDC_LABEL1 TO %IDC_LABEL6
                                    CONTROL SET COLOR CBHNDL, i, -1, %CYAN - 100 * i
                                NEXT
                                CONTROL SET COLOR CBHNDL, lCtlId, -1, %LTGRAY
                                CONTROL REDRAW CBHNDL, lCtlId
                                lastCtl = lCtlId
                            END IF
                    END SELECT
                END FUNCTION
                '------------------------------------
                FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                    LOCAL lRslt AS LONG
                    LOCAL hDlg  AS DWORD
                
                    DIALOG NEW hParent, "Bob Mechler's question", 159, 142, 161, 104, %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
                    CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "", 0, 0, 78, 33
                    CONTROL ADD LABEL, hDlg, %IDC_LABEL2, "", 0, 35, 78,33
                    CONTROL ADD LABEL, hDlg, %IDC_LABEL3, "", 0, 70, 78,33
                    CONTROL ADD LABEL, hDlg, %IDC_LABEL4, "", 82, 0, 78,33
                    CONTROL ADD LABEL, hDlg, %IDC_LABEL5, "", 82, 35, 78,33
                    CONTROL ADD LABEL, hDlg, %IDC_LABEL6, "", 82, 70, 78,33
                    DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                    FUNCTION = lRslt
                END FUNCTION
                '------------------------------
                FUNCTION PBMAIN()
                    ShowDIALOG1 %HWND_DESKTOP
                END FUNCTION

                Comment


                • #9
                  This may be a bit off....but if my foggy memory serves the source code forum has code for a "Mouse-Over" "Mouse-Leave" sort of events, without a timer checking...but then again its been a long day so I may be wrong (probably not)
                  Engineer's Motto: If it aint broke take it apart and fix it

                  "If at 1st you don't succeed... call it version 1.0"

                  "Half of Programming is coding"....."The other 90% is DEBUGGING"

                  "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                  Comment


                  • #10
                    Neither example works as I wanted it too.
                    The idea was not to react to the button click in any special way only to being over the button turning red and turning back blue when it wasn't over it. The setup is 8 or 9 labels acting as buttons that would turn red when the cursor was over them and back to blue when it was not.

                    The second example turns gray when the cursor is over and stays gray when it leaves until a redraw a good bit later.

                    The first example turns the first time you pass over the label but the color never changes when you are no longer over it, although otherwise it has some other cool effects.

                    Close tries though.

                    Bob Mechler

                    Comment


                    • #11
                      After further testing the first example can have the cursor pass over and it not do anything if it is moving a little fast.

                      Bob Mechler

                      Comment


                      • #12
                        Small tweek for CH's sample..
                        Code:
                        .. 
                                    IF lCtlId <> lastCtl THEN                       
                                        FOR i = %IDC_LABEL1 TO %IDC_LABEL6
                                            CONTROL SET COLOR CBHNDL, i, -1, %CYAN - 100 * i
                                            CONTROL REDRAW CBHNDL, i
                                        NEXT
                                        IF IsChild(CbHndl, hW) THEN 
                                            CONTROL SET COLOR CBHNDL, lCtlId, -1, %LTGRAY
                                            CONTROL REDRAW CBHNDL, lCtlId
                                        END IF
                                        lastCtl = lCtlId
                                    END IF
                        Rgds, Dave

                        Comment


                        • #13
                          Originally posted by Dave Biggs View Post
                          Small tweek
                          Thanks Dave, now all Bob has to do is change the colors!

                          Comment


                          • #14
                            >In my copy function: ChildWindowFromPoint requires 3 arguments as follows:
                            >ChildWindowFromPoint(hDlg, x, y)

                            >Your code uses only 2 arguments:
                            >ChildWindowFromPoint(hDlg, Pt)
                            >And as written will not compile with PB 8.04.
                            ..
                            I changed the offending line...
                            There is no "offense" here. There is only misunderstanding.

                            REFERENCE:
                            Defintion of POINTAPI from Win32API.INC 2-21-05
                            Code:
                            TYPE POINTAPI
                              x AS LONG
                              y AS LONG
                            END TYPE
                            "Official" MS-DOCUMENTATION of ChildWindowFromPoint function from SDK:
                            Code:
                            HWND ChildWindowFromPoint(
                                HWND hWndParent,
                                POINT Point
                            );
                            If attempting a verb-for-verb, statement-for-translation, that official definition would be experessed in PB syntax as:
                            Code:
                            DECLARE FUNCTION ChildWindowFromPoint LIB "USER32.DLL" ALIAS "ChildWindowFromPoint"  _ 
                                 (BYVAL hwndParent AS DWORD, [b]BYVAL PT AS POINTAPI[/b]) AS DWORD
                            However, Versions of the compilers prior to 7x - when the WIN32API.INC file was being developed - did not have the ability to accept a UDT parameter BY VALUE.

                            So what the PB 'converters' did was figure out what is actually required to be passed on the stack to the ChildWindowFromPoint function, and translate that into something the then-current PB compiler would support:
                            Code:
                            DECLARE FUNCTION ChildWindowFromPoint LIB "USER32.DLL" ALIAS "ChildWindowFromPoint"  _ 
                                 (BYVAL hwndParent AS DWORD, [b]BYVAL x AS LONG, BYVAL y AS LONG[/b]) AS DWORD
                            In either case, when called what the PB compiler will pass on the stack will be, in order
                            • Value of Hwnd, 32-bit integer
                            • Value of X, 32-bit integer
                            • Value of Y, 32-bit integer


                            The only difference in the generated code would be, if the "BYVAL PT AS POINTAPI" is the DECLARE statement you are using, it pushes SIZEOF(POINTAPI) [8 bytes] onto the stack all at once; when the DECLARE uses the seprate X and Y values, it pushes SIZEOF(X) [ 4 bytes], then pushes SIZEOF (Y) [another 4 bytes].

                            The difference in the generated code is (or should be) totally immaterial to the applications programmer, as long as your DECLARE is consistent with your CALL.

                            FWIW with 8x - which supports shared ALIASes - you can have your cake and eat it too....by DECLARING TWO functions....

                            Code:
                            DECLARE FUNCTION ChildWindowFromXy LIB "USER32.DLL" ALIAS "ChildWindowFromPoint"  _ 
                                 (BYVAL hwndParent AS DWORD, [b]BYVAL x AS LONG, BYVAL y AS LONG[/b]) AS DWORD
                            
                            DECLARE FUNCTION ChildWindowFromPointAPI LIB "USER32.DLL" ALIAS "ChildWindowFromPoint"  _ 
                                 (BYVAL hwndParent AS DWORD, [b]BYVAL PT AS POINTAPI[/b]) AS DWORD
                            ....and CALLing whichever function floats your boat at any particular time:
                            Code:
                                h =ChildWindowFromXY(hWnd, X, Y) 
                             ' OR 
                                h = ChildWindowFromPointAPI (hWnd, pt )
                            MCM
                            Last edited by Michael Mattias; 25 Apr 2008, 09:31 AM.
                            Michael Mattias
                            Tal Systems (retired)
                            Port Washington WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment


                            • #15
                              Very good tweak. I did have to move the items away from the edge of the dialog though. Going left with the mouse left the items on the left gray until I put some client area between the control and the edge of the dialog.

                              This is much better than using a timer.

                              Bob Mechler

                              Comment


                              • #16
                                Using Chris's example I changed one of the controls to a button and added

                                %BS_CENTER OR %BS_OWNERDRAW.

                                The button starts out blue and stays that way. Control id's unchanged.

                                I could get it to change to lt_gray if I put it on the click even of WM_COMMAND and it turned back to blue once not over it, but coming over it did not change.
                                Code:
                                #COMPILE EXE
                                #DIM ALL
                                
                                #IF NOT %DEF(%WINAPI)
                                    #INCLUDE "WIN32API.INC"
                                #ENDIF
                                %IDD_DIALOG1 =  101
                                %IDC_LABEL1  = 1001
                                %IDC_LABEL2  = 1002
                                %IDC_LABEL3  = 1003
                                %IDC_LABEL4  = 1004
                                %IDC_LABEL5  = 1005
                                %IDC_LABEL6  = 1006
                                
                                DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
                                DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                                
                                '---------------------------------------------------
                                MACRO MAKEPOINTS(lParam, pt)
                                    pt.x = BITS%(LOWRD(lParam))
                                    pt.y = BITS%(HIWRD(lParam))
                                END MACRO
                                '---------------------------------------------------
                                
                                CALLBACK FUNCTION ShowDIALOG1Proc()
                                    LOCAL i AS LONG, lCtlId AS LONG
                                    STATIC LastCtl AS LONG
                                    LOCAL hW AS DWORD
                                    LOCAL pts AS points
                                
                                    SELECT CASE AS LONG CBMSG
                                        CASE %WM_INITDIALOG
                                            FOR i = %IDC_LABEL1 TO %IDC_LABEL6
                                                CONTROL SET COLOR CBHNDL, i, -1, %CYAN - 100 * i
                                             NEXT
                                        CASE %WM_MOUSEMOVE
                                            makepoints(CBLPARAM, pts)
                                            hW = ChildWindowFromPoint(CBHNDL, pts.x, pts.y)
                                            lCtlId = getdlgctrlid(hW)
                                            IF lCtlId <> lastCtl THEN
                                                FOR i = %IDC_LABEL1 TO %IDC_LABEL6
                                                    CONTROL SET COLOR CBHNDL, i, -1, %CYAN - 100 * i
                                                    CONTROL REDRAW CBHNDL, i
                                                NEXT
                                                IF IsChild(CBHNDL, hW) THEN
                                                    CONTROL SET COLOR CBHNDL, lCtlId, -1, %LTGRAY
                                                    CONTROL REDRAW CBHNDL, lCtlId
                                                END IF
                                                lastCtl = lCtlId
                                            END IF
                                        CASE %WM_COMMAND
                                          IF CBCTLMSG = %BN_CLICKED AND CBCTL = %IDC_LABEL6 THEN
                                                    CONTROL SET COLOR CBHNDL, %IDC_LABEL6, -1, %LTGRAY
                                                    CONTROL REDRAW CBHNDL, %IDC_LABEL6
                                          END IF
                                   END SELECT
                                END FUNCTION
                                '------------------------------------
                                FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                                    LOCAL lRslt AS LONG
                                    LOCAL hDlg  AS DWORD,cnt AS LONG
                                
                                    DIALOG NEW hParent, "Bob Mechler's question", 300, 142, 250, 104, %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
                                    CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "", 50, 0, 78, 33
                                    CONTROL ADD LABEL, hDlg, %IDC_LABEL2, "", 50, 35, 78,33
                                    CONTROL ADD LABEL, hDlg, %IDC_LABEL3, "", 50, 70, 78,33
                                    CONTROL ADD LABEL, hDlg, %IDC_LABEL4, "", 142, 0, 78,33
                                    CONTROL ADD LABEL, hDlg, %IDC_LABEL5, "", 142, 35, 78,33
                                    CONTROL ADD BUTTON, hDlg, %IDC_LABEL6, "", 142, 70, 78,33,%BS_CENTER OR %BS_OWNERDRAW
                                    DIALOG SHOW MODELESS hDlg, CALL ShowDIALOG1Proc TO lRslt
                                    DO
                                      DIALOG DOEVENTS TO cnt&
                                    LOOP UNTIL cnt& = 0
                                    FUNCTION = lRslt
                                END FUNCTION
                                '------------------------------
                                FUNCTION PBMAIN()
                                    ShowDIALOG1 %HWND_DESKTOP
                                END FUNCTION

                                Comment


                                • #17
                                  If you want to do owner-draw, you need to process the WM_DRAWITEM notification.

                                  I also believe - but do not know for a fact - that using "CONTROL ADD BUTTON..." rather than "CONTROL ADD "button"..." is going to make DDT want to redraw that button, negating your drawing.

                                  I know there are examples of doing this here. Heck if Mr NO-GUI-SKILLS-AT-ALL (moi) did it, I'm positive you can.

                                  MCM
                                  Michael Mattias
                                  Tal Systems (retired)
                                  Port Washington WI USA
                                  [email protected]
                                  http://www.talsystems.com

                                  Comment


                                  • #18
                                    Originally posted by Michael Mattias View Post
                                    ...is going to make DDT want to redraw that button, negating your drawing.
                                    I don't think that DDT draws blue buttons, so my guess is the BS_OWNERDRAW takes it out of the loop.

                                    Comment

                                    Working...
                                    X