Announcement

Collapse
No announcement yet.

How to get an immediate Redraw

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

  • How to get an immediate Redraw

    How can I force an an immediate Redraw?

    Code:
     '       Control ReDraw hdlg, Id
        Control Send hdlg, Id, ReDraw, 0, 0 '<<<<<<<<< How to do this?
    Control Redraw is a low priority?

    ===========================
    "Sex:
    The pleasure is momentary,
    The position ridiculous,
    The expense damnable."
    Lord Chesterfield
    ===========================
    It's a pretty day. I hope you enjoy it.

    Gösta

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

  • #2
    InvalidateRect followed by UpdateWindow.

    UpdateWindow will send the WM_PAINT to the control's message procedure rather than queuing it in the application.

    Code:
           InvalidateRect hWndControl, ByVal %Null, %TRUE
           UpdateWindow hWndControl
    Paul Squires
    FireFly Visual Designer (for PowerBASIC Windows 10+)
    Version 3 now available.
    http://www.planetsquires.com

    Comment


    • #3
      Originally posted by Paul Squires View Post
      InvalidateRect followed by UpdateWindow.

      UpdateWindow will send the WM_PAINT to the control's message procedure rather than queuing it in the application.

      Code:
             InvalidateRect hWndControl, ByVal %Null, %TRUE
             UpdateWindow hWndControl
      Thanks Paul but that doesn't do it either. Her's what I'm trying to do. Put a string in a label. then constantly change the text color. Sort of like it gradually appears (then gradually disappears)

      Here's the first go at some code:

      Bummer - won't Insert again. Will try later. (Code is attached instead) -Hmmph - now Insert works.

      '
      Code:
      'PBWIN 9.01 - WinApi 05/2008 - XP Pro SP3
      #Dim All 
      #Compile Exe  
      #Optimize SPEED
      #Debug Display On '<<<<<<<<<<<<<<< Remember to turn off for 
      production code
      #Include "WIN32API.INC"
      #Include "COMDLG32.INC"
      #Include "InitCtrl.inc"
      '
        Global hdlg As Dword                
        Global g_Start_bg_Color, g_Start_fg_Color As Long
      %Id_Label = 1000
      '
      Macro aa_Common_Locals
        Local hfont12, hfont16, hfont20, hfont24 As Long 
        Local ctr1, ctr, clor, Id, Row, col, stile, ht, wd As Long
        Local hx, s As String
        Local r, g, b As Byte
       Font New "Comic Sans MS", 12 To hfont12
       Font New "Comic Sans MS", 16 To hfont16
       Font New "Comic Sans MS", 20 To hfont20
       Font New "Comic Sans MS", 24 To hfont24        
      End Macro
      '
      Function Show_Msg (m As String) As Long
        aa_common_Locals
        Id = %Id_Label  
        hx$ = Hex$(g_Start_fg_Color, 6)
        r = Val(Left$(hx$, 2))
        g = Val(Mid$(hx$, 3, 2))
        b = Val(Right$(hx$, 2))
        For ctr = 0 To 255
          Control Set Text hdlg, %Id_label, m$
          r = r + ctr
          b = b + ctr
          clor = RGB(r, g, b)              
          Control Set Color hdlg, Id,  clor, g_Start_bg_Color
      '       Control ReDraw hdlg, Id
      '    Control Send hdlg, Id, ReDraw, 0, 0 '<<<<<<<<< How to do this???
             'Paul Squires
             InvalidateRect hdlg, "", %TRUE 'False no work either
             UpdateWindow hdlg           
             
          'delay between updates
          Sleep 1
          'For ctr1 = 1 To 1000000: Next ctr1
        Next ctr
       ? "Done" 
      End Function
      '
      CallBack Function Dialog_Processor
        Select Case CbMsg     'This is TO determine the message TYPE 
           '       
           Case %WM_INITDIALOG'<- Initialiaton when the program loads 
           '
           Case %WM_SYSCOMMAND 'Traps Any Alt key but only F4 closes        
            
           '
           Case %WM_COMMAND  'This processes command messages
             Select Case CbCtl
               'Case %Id_
                 Select Case CbCtlMsg
                 End Select
             End Select
        End Select
      End Function
      '
      Function PBMain
        aa_common_locals
       g_Start_fg_Color = &hffffff '&hFFD7D7
       g_Start_bg_Color = g_Start_bg_Color '&hFFD7D7
        
       s$ = "With malice toward None, " & $CrLf & _ 
             "With charity For All,  " & $CrLf & _ 
             "With firmness in the Right  " & $CrLf & _ 
             "As God gives us to see the Right,  " & $CrLf & _ 
             "Let us strive on to finish the work we are in,  " & $CrLf & _ 
             "To bind up the nation's wounds,  " & $CrLf & _ 
             "To care for him who shall have borne the battle  " & $CrLf & 
      _ 
             "And for his widow and his orphan,  " & $CrLf & _ 
             "To do all which may achieve and cherish  " & $CrLf & _ 
             "A just and lasting peace among ourselves  " & $CrLf & _ 
             "And with all nations." 
             
      
        ht = 540
        wd = 700
        Dialog New Pixels, hdlg, Space$(60) & "Lincoln's Second Inagural 
      Address", , , wd, ht To hdlg
            Dialog Set Color hdlg,  g_Start_fg_Color, g_Start_bg_Color
       wd = Wd - 20
       ht = ht - 20
       Row = 40
       Col = 10
       Id = %Id_Label  
       Stile = %SS_Center
        Control Add Label, hdlg, Id, s$, col, row, wd, ht, stile
        Control Set Font hdlg, Id, hfont20
        Control Set Color hdlg, Id,  g_Start_fg_Color, g_Start_bg_Color
        Control ReDraw hdlg, Id
        Dialog ReDraw hdlg' Tried this but no difference
        
        Call Show_Msg(s$)
      
           Dialog Show Modal hDlg   Call Dialog_Processor      
           
           
      End Function 'Applikation beenden
      '
      Attached Files
      It's a pretty day. I hope you enjoy it.

      Gösta

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

      Comment


      • #4
        I'm not a DDT man but I do notice that you are calling your ShowMsg function prior to even displaying the dialog as modal.

        You could try creating a user message and PostMessage that message to you callback during the WM_INITDIALOG message.

        Something like this maybe:

        %MSG_USER_SHOWMSG = %WM_USER + 1

        Code:
        CallBack Function Dialog_Processor
          Select Case CbMsg     'This is TO determine the message TYPE 
             '       
        
             Case %MSG_USER_SHOWMSG
               Local s As String
               s$ = "With malice toward None, " & $CrLf & _ 
                     "With charity For All,  " & $CrLf & _ 
                     "With firmness in the Right  " & $CrLf & _ 
                     "As God gives us to see the Right,  " & $CrLf & _ 
                     "Let us strive on to finish the work we are in,  " & $CrLf & _ 
                     "To bind up the nation's wounds,  " & $CrLf & _ 
                     "To care for him who shall have borne the battle  " & $CrLf & _ 
                     "And for his widow and his orphan,  " & $CrLf & _ 
                     "To do all which may achieve and cherish  " & $CrLf & _ 
                     "A just and lasting peace among ourselves  " & $CrLf & _ 
                     "And with all nations." 
               
                Call Show_Msg(s$)
        
             Case %WM_INITDIALOG'<- Initialiaton when the program loads 
                PostMessage hDlg, %MSG_USER_SHOWMSG, 0,0
        Paul Squires
        FireFly Visual Designer (for PowerBASIC Windows 10+)
        Version 3 now available.
        http://www.planetsquires.com

        Comment


        • #5
          Gösta
          When I run this, the first thing that shows up is the "Done" MSGBOX and when that is closed the dialog appears in its final form, that is, I get to see only magenta text on a black background.
          Rod
          I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

          Comment


          • #6
            Originally posted by Paul Squires View Post
            I'm not a DDT man but I do notice that you are calling your ShowMsg function prior to even displaying the dialog as modal.
            Quite right, Paul. Thanks. I put in a button that calls Show_Msg and now everything is hunky doryish. Now all that's left is to get the code to act/show like I want (an almost never won battle for me. {sigh})

            =====================================================
            "I myself have never been able to find out precisely
            what feminism is;
            I only know that people call me a feminist
            whenever I express sentiments that differentiate me
            from a doormat or a prostitute."
            Rebecca West (1913)
            =====================================================
            It's a pretty day. I hope you enjoy it.

            Gösta

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

            Comment


            • #7
              Here's (starting) code

              ''
              Code:
              'PBWIN 9.01 - WinApi 05/2008 - XP Pro SP3
              #Dim All 
              #Compile Exe  
              #Optimize SPEED
              #Debug Display On '<<<<<<<<<<<<<<< Remember to turn off for production code
              '
              #Include "WIN32API.INC"
              #Include "COMDLG32.INC"
              #Include "InitCtrl.inc"
              '
              '
              ' *******************************************************
              '
              '
               'this next included file needed for button colors can be found here: 
               'http://www.powerbasic.com/support/pbforums/showthread.php?t=38904
              #Include "C:\Only_My_Programs\Include Files\ButtonPlus.bas"
              '
              ' *******************************************************
              '
                Global hdlg As Dword                
                Global g_Start_bg_Color, g_Start_fg_Color As Long
              '
              %Id_Label   = 1000
              %Msg_Btn_Id = 2000
              '
              Macro aa_Common_Locals
                Local hfont12, hfont16, hfont20, hfont24 As Long 
                Local slp, wd1, ht1, ctr1, ctr, clor, Id, Row, col, stile, ht, wd As Long
                Local hx, s As String
                Local r, g, b As Byte
               Font New "Comic Sans MS", 12 To hfont12
               Font New "Comic Sans MS", 16 To hfont16
               Font New "Comic Sans MS", 20 To hfont20
               Font New "Comic Sans MS", 24 To hfont24        
              End Macro
              '
              Function Show_Msg (m As String) As Long
                aa_common_Locals
                Local hx1 As String
               m$ = "With malice toward None, " & $CrLf & _ 
                     "With charity For All,  " & $CrLf & _ 
                     "With firmness in the Right  " & $CrLf & _ 
                     "As God gives us to see the Right,  " & $CrLf & _ 
                     "Let us strive on to finish the work we are in,  " & $CrLf & _ 
                     "To bind up the nation's wounds,  " & $CrLf & _ 
                     "To care for him who shall have borne the battle  " & $CrLf & _ 
                     "And for his widow and his orphan,  " & $CrLf & _ 
                     "To do all which may achieve and cherish  " & $CrLf & _ 
                     "A just and lasting peace among ourselves  " & $CrLf & _ 
                     "And with all nations." 
              '       
                Id = %Id_Label  
                hx$ = Hex$(g_Start_fg_Color, 6)
                r = Val("&h" & Left$(hx$, 2))
                g = Val("&h" & Mid$(hx$, 3, 2))
                b = Val("&h" & Right$(hx$, 2))
                  Control Set Color hdlg, Id, g_Start_bg_Color, g_Start_bg_Color
                  Control Set Text hdlg, Id, m$ 
              '
                slp = 100 'Sleep time - 100 seems good but still flickers
              '
                For ctr = 0 To 255
                  r = ctr
                  b = ctr
                  g = ctr
                  clor = Bgr(r, g, b)       
                  hx$ = Hex$(g, 2)       
                  hx1$ = hx1$ & hx$ & " " 
               
                  Dialog Set Text hdlg, Using$("# Color = "  & Right$(Hx1$, 30), ctr) 'just to watch working
                  Control Set Color hdlg, Id,  clor, g_Start_bg_Color
                    Control ReDraw hdlg, Id
              '    Control Send hdlg, Id, ReDraw, 0, 0 '<<<<<<<<< How to do this???
                     'Paul Squires
              '       InvalidateRect hdlg, "", %TRUE 'False no work either
              '       UpdateWindow hdlg           
              '       
                  'delay between redraws
                  Sleep slp
                Next ctr 
              ' 
               'now fade out  
                 Reset hx1$
                 For ctr = 255 To 0 Step -1 'Step 5
                  r = ctr
                  b = ctr
                  g = ctr
                  clor = Bgr(r, g, b)       
                  hx$ = Hex$(g, 2)       
                  hx1$ = hx1$ & hx$ & " " 'watch display with
              '    
                  Dialog Set Text hdlg, Using$("# Color = "  & Right$(Hx1$, 60), ctr) 'just to watch working
                  Control Set Color hdlg, Id,  clor, g_Start_bg_Color
                    Control ReDraw hdlg, Id
                  Sleep slp
                Next ctr 
              '
                Control Set Text hdlg, %Msg_Btn_Id, " Next Inspirational Message"
              End Function
              '
              CallBack Function Dialog_Processor
                aa_common_Locals
                Select Case CbMsg     'This is TO determine the message TYPE 
                   '       
                   Case %WM_INITDIALOG'<- Initialiaton when the program loads 
                   '
                   Case %WM_SYSCOMMAND 'Traps Any Alt key but only F4 closes              
                   '
                   Case %WM_COMMAND  'This processes command messages
                     Select Case CbCtl
                       Case %Msg_Btn_Id
                         Select Case CbCtlMsg
                           Case %BN_CLICKED
                             Show_Msg(s$)
                         End Select
                     End Select
                End Select
              End Function
              '
              Function PBMain
                aa_common_locals
               g_Start_fg_Color =  %Black '&hff0046'&hFFD7D7
               g_Start_bg_Color = %Black 'g_Start_fg_Color '&hFFD7D7
              '
                ht = 540: ht1 = ht
                wd = 700: wd1 = wd
                Dialog New Pixels, hdlg, Space$(60) & "Lincoln's Second Inagural Address", , , wd, ht To hdlg
                    Dialog Set Color hdlg,  g_Start_fg_Color, g_Start_bg_Color
              '
               wd = Wd - 20
               ht = ht - 45
               Row = 40
               Col = 10
               Id = %Id_Label  
               Stile = %SS_Center
                Control Add Label, hdlg, Id, "Inspirations", col, row, wd, ht, stile
                Control Set Font hdlg, Id, hfont20
                Control Set Color hdlg, Id,  %White, g_Start_bg_Color
               '
               Id = %Msg_Btn_Id
               Row = ht1 - 40 'Just off bottom 
               ht = 30
                                               '
                Control Add Button, hdlg, Id, "Inspirational Message", Col, row, wd, ht, stile
                Control Set Font hdlg, Id, hfont20
                'rem next two if no Button Plus included
                Btn_Set_Text_Color(hdlg, Id, &h000000) 
                Btn_Set_Face_Color(hdlg, Id, &hFFF546): 
              '
                Dialog Show Modal hDlg   Call Dialog_Processor      
              '     
              End Function 'Abblikation beenden
              '
              Now to reduce the flicker. I'll probably have to learn Asm to do that (like that'll ever happen. {Hmmph.})

              Note: If you use Button Plus (see calls in code) here's the mods I made to it so only one Include is needed. Just add them to the top of your copy of ButtonPlus.bas (with appropriate folder settings):

              Code:
              '  At top of ButtonPlus.bas add:
              ' *******************************************************
              '
              #Include "C:\Only_My_Programs\Include Files\ButtonPlus.inc"      
              '  
              Function  Btn_Set_Face_Color(ddlg As Dword, Id As Long, Btn_Color As Long) As Long
                ButtonPlus  ddlg, Id, %BP_FACE_BLEND, 255 'true color
                 ButtonPlus dDlg, Id, %BP_FACE_COLOR, Btn_Color ' &H008FDF8F 
              End Function 
              '
              Function Btn_Set_Text_Color(ddlg As Dword, Id As Long, Btn_Color As Long) As Long
                 ButtonPlus dDlg, Id, %BP_Text_COLOR, Btn_Color ' &H008FDF8F 
              End Function 
              '
              ' *******************************************************
              '
              ===================================================
              "A bird that you set free may be caught again,
              but a word that escapes your lips will not return."
              Jewish Proverb
              ===================================================
              Last edited by Gösta H. Lovgren-2; 24 Jun 2009, 11:44 PM.
              It's a pretty day. I hope you enjoy it.

              Gösta

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

              Comment


              • #8
                Originally posted by Rodney Hicks View Post
                Gösta
                When I run this, the first thing that shows up is the "Done" MSGBOX and when that is closed the dialog appears in its final form, that is, I get to see only magenta text on a black background.
                Yup, that was my problem, Rodney. Paul's suggestion put me on the right track (see listing above).
                It's a pretty day. I hope you enjoy it.

                Gösta

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

                Comment


                • #9
                  Well, when I run your latest (three times so far) I get at 52 color, 53 color, 49 color (not responding) and the program hangs there until I close it with task manager(I didn't try F4) I have commented out the two lines near the bottom and the
                  Code:
                  #Include "C:\Only_My_Programs\Include Files\ButtonPlus.bas"
                  However, while you were fiddling in your neck of the woods, I was working real hard and I did the following stealing some from your code, quite a bit that I subsequently removed to get it to work. I see that you've change the color development, which I did too.
                  I have used a %WM_TIMER instead of a FOR/NEXT loop, and the counter resets every 256 trips. By the way, there are better ways of doing this with the timer. This way did not get rid of the flicker.
                  You can change the speed by changing the '75' in the %WM_INITDIALOG.
                  Code:
                  #PBFORMS CREATED V1.51
                  '--------------------------------------------------------------------------------------------------
                  ' The first line in this file is a PB/Forms metastatement.
                  ' It should ALWAYS be the first line of the file. Other
                  ' PB/Forms metastatements are placed at the beginning and
                  ' end of "Named Blocks" of code that should be edited
                  ' with PBForms only. Do not manually edit or delete these
                  ' metastatements or PB/Forms will not be able to reread
                  ' the file correctly.  See the PB/Forms documentation for
                  ' more information.
                  ' Named blocks begin like this:    #PBFORMS BEGIN ...
                  ' Named blocks end like this:      #PBFORMS END ...
                  ' Other PB/Forms metastatements such as:
                  '     #PBFORMS DECLARATIONS
                  ' are used by PB/Forms to insert additional code.
                  ' Feel free to make changes anywhere else in the file.
                  '--------------------------------------------------------------------------------------------------
                  
                  #COMPILE EXE
                  #DIM ALL
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** Includes **
                  '--------------------------------------------------------------------------------------------------
                  #PBFORMS BEGIN INCLUDES
                  #IF NOT %DEF(%WINAPI)
                    #INCLUDE "WIN32API.INC"
                  #ENDIF
                  #PBFORMS END INCLUDES
                  '--------------------------------------------------------------------------------------------------
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** Constants **
                  '--------------------------------------------------------------------------------------------------
                  #PBFORMS BEGIN CONSTANTS
                  %IDCANCEL    =   2
                  %IDC_LABEL1  =   3
                  %IDD_DIALOG1 = 101
                  #PBFORMS END CONSTANTS
                  '--------------------------------------------------------------------------------------------------
                  %ID_TIMER1=100
                  '--------------------------------------------------------------------------------------------------
                  '   ** Declarations **
                  '--------------------------------------------------------------------------------------------------
                  DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
                  DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                  #PBFORMS DECLARATIONS
                  '--------------------------------------------------------------------------------------------------
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** Main Application Entry Point **
                  '--------------------------------------------------------------------------------------------------
                  FUNCTION PBMAIN()
                    ShowDIALOG1 %HWND_DESKTOP
                  END FUNCTION
                  '--------------------------------------------------------------------------------------------------
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** CallBacks **
                  '--------------------------------------------------------------------------------------------------
                  CALLBACK FUNCTION ShowDIALOG1Proc()
                    STATIC hx,gosh,golly AS STRING
                    STATIC r, g, b AS BYTE
                    STATIC clor, ctr AS LONG
                    STATIC g_Start_bg_Color, g_Start_fg_Color AS LONG
                    hx = HEX$(g_Start_fg_Color, 6)
                    r = VAL(LEFT$(hx, 2))
                    g = VAL(MID$(hx, 3, 2))
                    b = VAL(RIGHT$(hx, 2))
                    gosh="With malice toward None, " + $CRLF + _
                         "With charity For All,  " + $CRLF + _
                         "With firmness in the Right  " + $CRLF + _
                         "As God gives us to see the Right,  " + $CRLF + _
                         "Let us strive on to finish the work we are in,  " + $CRLF + _
                         "To bind up the nation's wounds,  " + $CRLF + _
                         "To care for him who shall have borne the battle  " + $CRLF + _
                         "And for his widow and his orphan,  " + $CRLF + _
                         "To do all which may achieve and cherish  " + $CRLF + _
                         "A just and lasting peace among ourselves  " + $CRLF + _
                         "And with all nations."
                     golly=SPACE$(50)+$CRLF + _
                           SPACE$(50)+$CRLF + _
                           SPACE$(50)+$CRLF + _
                           SPACE$(50)+$CRLF + _
                           SPACE$(50)+$CRLF + _
                           SPACE$(50)+$CRLF + _
                           SPACE$(50)+$CRLF + _
                           SPACE$(50)+$CRLF + _
                           SPACE$(50)+$CRLF + _
                           SPACE$(50)+$CRLF + _
                           SPACE$(50)+$CRLF
                    SELECT CASE AS LONG CBMSG
                      CASE %WM_INITDIALOG
                        ' Initialization handler
                  '      g_Start_fg_Color = &hffffff '&hFFD7D7   used your variable names but as STATIC
                  '      g_Start_bg_Color = g_Start_fg_Color '&hFFD7D7  in these two cases
                        STATIC idEvent AS LONG
                        idEvent=SetTimer(CBHNDL,%ID_TIMER1,75,BYVAL %NULL) 'Increase 75 to slow it down.
                        CONTROL POST CBHNDL,%ID_TIMER1,%WM_TIMER, 0,0
                      CASE %WM_NCACTIVATE
                        STATIC hWndSaveFocus AS DWORD
                        IF ISFALSE CBWPARAM THEN
                          ' Save control focus
                          hWndSaveFocus = GetFocus()
                        ELSEIF hWndSaveFocus THEN
                          ' Restore control focus
                          SetFocus(hWndSaveFocus)
                          hWndSaveFocus = 0
                        END IF
                      CASE %WM_TIMER
                        IF CBWPARAM=%ID_TIMER1 THEN
                  '        r = r + ctr
                  '        b = b + ctr
                          clor = RGB(ctr, ctr, 0)
                          'CONTROL SET TEXT CB.HNDL, %IDC_LABEL1, golly 'I do this to make sure it just doesn't overwrite.
                          'control redraw cb.hndl, %IDC_LABEL1
                          CONTROL SET COLOR CB.HNDL, %IDC_LABEL1,  clor, %BLACK
                          CONTROL SET TEXT CB.HNDL, %IDC_LABEL1, gosh
                          INCR ctr
                        'msgbox "counter="+format$(ctr)+" color="+format$(clor) +" bcolor="+format$(g_Start_bg_Color)
                          IF ctr=256 THEN ctr=0
                            
                  '        sTime=TIME$
                  '        CONTROL SET TEXT CBHNDL, %IDC_TIME,nada
                  '        CONTROL REDRAW CBHNDL, %IDC_TIME
                  '        CONTROL SET TEXT CBHNDL, %IDC_TIME,sTime
                        END IF
                      CASE %WM_COMMAND
                        ' Process control notifications
                        SELECT CASE AS LONG CBCTL
                          CASE %IDCANCEL
                            IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                              DIALOG END CBHNDL, 0
                            END IF
                  
                          CASE %IDC_LABEL1
                  
                        END SELECT
                      CASE %WM_DESTROY
                           IF idEvent THEN
                             KillTimer CBHNDL, idEvent
                           END IF
                  
                    END SELECT
                  END FUNCTION
                  '--------------------------------------------------------------------------------------------------
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** Dialogs **
                  '--------------------------------------------------------------------------------------------------
                  FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                    LOCAL lRslt,hfont20 AS LONG
                    LOCAL gee AS STRING
                    'Static g_Start_bg_Color, g_Start_fg_Color AS LONG
                    'g_Start_fg_Color = &hffffff '&hFFD7D7   used your variable names but as STATIC
                    'g_Start_bg_Color = g_Start_fg_Color '&hFFD7D7
                    gee= "With malice toward None, " + $CRLF + _
                         "With charity For All,  " + $CRLF + _
                         "With firmness in the Right  " + $CRLF + _
                         "As God gives us to see the Right,  " + $CRLF + _
                         "Let us strive on to finish the work we are in,  " + $CRLF + _
                         "To bind up the nation's wounds,  " + $CRLF + _
                         "To care for him who shall have borne the battle  " + $CRLF + _
                         "And for his widow and his orphan,  " + $CRLF + _
                         "To do all which may achieve and cherish  " + $CRLF + _
                         "A just and lasting peace among ourselves  " + $CRLF + _
                         "And with all nations."
                                                            
                  #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
                    LOCAL hDlg  AS DWORD
                  
                    DIALOG NEW PIXELS, hParent, "                                                                   " + _
                      "   Lincoln's Second Inagural Address", 70, 406, 698, 560, TO hDlg
                    CONTROL ADD BUTTON, hDlg, %IDCANCEL, "DONE", 315, 535, 75, 25
                    CONTROL ADD LABEL,  hDlg, %IDC_LABEL1, gee , 0, 0, 698, 536, _
                      %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER, %WS_EX_LEFT OR %WS_EX_LTRREADING
                  #PBFORMS END DIALOG
                    
                    FONT NEW "Comic Sans MS", 20 TO hfont20
                    CONTROL SET FONT hdlg, %IDC_LABEL1, hfont20
                    CONTROL SET COLOR hdlg, %IDC_LABEL1,  %BLACK, %BLACK
                    DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                  
                  #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
                  #PBFORMS END CLEANUP
                  
                    FUNCTION = lRslt
                  END FUNCTION
                  '--------------------------------------------------------------------------------------------------
                  Last edited by Rodney Hicks; 25 Jun 2009, 12:53 AM.
                  Rod
                  I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                  Comment


                  • #10
                    then constantly change the text color. Sort of like it gradually appears (then gradually disappears)
                    Worth a look ???

                    AnimateWindow Function

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

                    The AnimateWindow function enables you to produce special effects when showing or hiding windows. There are four types of animation: roll, slide, collapse or expand, and alpha-blended fade.
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Originally posted by Michael Mattias View Post
                      Worth a look ???
                      It certainly is. Thanks M. Probably have to give up a bit of my DDT soul and use some API {shudder} but if it's in the line of duty....

                      ===========================
                      "A dog's admiration
                      is not conclusive evidence
                      you are wonderful."
                      Ann Landers
                      ===========================
                      It's a pretty day. I hope you enjoy it.

                      Gösta

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

                      Comment


                      • #12
                        >Probably have to give up a bit of my DDT soul and use some API {shudder)

                        In Michael's Ideal World that would be worded somewhat differently:

                        "I've done it using SDK style; now I'll see how much tedious coding work the use of DDT can save me, and at what cost to flexibility and/or features."


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

                        Comment


                        • #13
                          Of course, PowerBASIC Inc worded it differently still:

                          "Let's make something so easy to use we can capture the VB Refugee market."
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            I noticed that you're creating a Timer but then using CONTROL POST. Why? Once you create the Timer then the WM_TIMER messages should start to flow. No need to post the WM_TIMER message.

                            I would think that your flicker is caused by doing a CONTROL SET TEXT on each iteration of your loop. I would think that should be done once before the For/Next starts. Also, I would assume that the CONTROL SET COLOR will do a repaint of the text so any redraw/invalidaterect code after that should be unnecessary. If you stick with the WM_TIMER method then simply set the Text once when the dialog is created (ie. move it out of the WM_TIMER handler altogether).
                            Paul Squires
                            FireFly Visual Designer (for PowerBASIC Windows 10+)
                            Version 3 now available.
                            http://www.planetsquires.com

                            Comment


                            • #15
                              I noticed that you're creating a Timer but then using CONTROL POST. Why?
                              Because I copied those steps out of a program in the Samples directory of PBWin 8.xx and have been using them in different programs ever since, expecting that whoever wrote it in the first place knew more than I did. Because you asked this question I commented out the line and you are right, there seems to be no good reason for it.(There may have been where I copied it from.)

                              Also, I would assume that the CONTROL SET COLOR will do a repaint of the text so any redraw/invalidaterect code after that should be unnecessary
                              I had tried that in mine, assuming as you do, but the screen just stays black without the CONTROL SET TEXT statement in there. I now think that the CONTROL SET COLOR statement merely prepares the control for the next statement. Sort of analogous the DOS COLOR 8,0:LOCATE 10,20: PRINT "What the ...?" where a subsequent COLOR 0,8: LOCATE 10,20 wouldn't make any changes until another PRINT statement.

                              Gösta, have you considered trying this in a GRAPHIC WINDOW to get rid of the flicker?

                              Michael, I really always thought that it was "Let's make something so easy even Rod can do it!"
                              Rod
                              I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                              Comment


                              • #16
                                Microsoft Visual Basic is - or at least was - a pretty good product... at least if you let the sales figures speak for it.

                                Unfortunately, products like VB and DDT allow people to "program" [quotes intentional, albeit likely insulting to some] without ever learning the fundamentals of Windows applications programming.

                                I am a big believer in fundamentals. YMMV.

                                I am a big believer that tools can only be used effectively when the user understands exactly what labor-savings the tool provides. YMMV.

                                I am a big believer that true programmers can program even when their tools are taken away... by falling back on their fundamentals. YMMV.

                                OTOH, DDT is a brilliant marketing ploy. A PB license purchase is a lot easier for the prospect when he/she can honestly say, "Hey, I can do that!"

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

                                Comment


                                • #17
                                  One way to get pulsating text:
                                  Code:
                                  'PBCC5.01 program
                                  $INCLUDE "WIN32API.INC"
                                  
                                  %stop=0
                                  %draw=1
                                  FUNCTION Throb ( BYVAL xPos AS LONG, BYVAL yPos AS LONG, _
                                                          BYVAL DoWhat AS LONG, BYVAL wide AS LONG, BYVAL dw2 AS LONG) AS LONG
                                  STATIC cnt&,col&() ,hWin???,TimerHandle&,wscale!,high&, hFont&
                                  
                                  SELECT CASE DoWhat
                                      CASE %stop
                                          timeKillEvent TimerHandle&
                                          FONT END hFont&
                                          GRAPHIC WINDOW END
                                  
                                      CASE %draw
                                         ' exit function
                                          IF cnt&=0 THEN
                                              GRAPHIC ATTACH hWin???, 0  ,REDRAW
                                              GRAPHIC CLEAR %BLACK
                                          ELSE
                                   
                                          GRAPHIC SET FONT hFont&
                                          GRAPHIC SET POS (1,1)
                                          IF (cnt& AND &h100) THEN
                                              GRAPHIC COLOR col&(255-(cnt& AND &hff)),%BLACK
                                          ELSE
                                              GRAPHIC COLOR col&((cnt& AND &hff)),%BLACK
                                          END IF
                                          
                                          GRAPHIC PRINT  "And now is the time"
                                          GRAPHIC PRINT  " for all good men"
                                          GRAPHIC PRINT  "to come to the aid"
                                          GRAPHIC PRINT  "  of the party."
                                     
                                          GRAPHIC REDRAW
                                          END IF
                                  
                                          INCR cnt&
                                  
                                      CASE ELSE
                                          'it's not stop or draw so it must be start. doWhat is now the colour to use
                                          'colour should be saturated so R,G and B are either 00 or FF (e.g.&hFFFFFF or &hFF00FF..)
                                          'create a window to draw the busy indicator in
                                          GRAPHIC WINDOW "", xPos, yPos, wide&, dw2  TO hWin???
                                          
                                          wscale!=wide/256
                                          high&=dw2
                                          'set the colours
                                          BaseColour&=doWhat
                                          DIM col&(255)
                                          temp&=BaseColour&
                                  
                                          FOR r&=255 TO 0 STEP -1
                                              col&(r&)=(r&*65536 +r&*256+r&) AND BaseColour&
                                          NEXT
                                          
                                          FONT NEW "Courier New",30,1,0,0,0 TO hFont
                                          
                                          'start the timer
                                          '1=milliseconds between triggers, 0=maximum timer resolution
                                          TimerHandle& = timeSetEvent ( BYVAL 1, BYVAL 0, CODEPTR(Throb), BYVAL %draw, BYVAL %TIME_PERIODIC)
                                  
                                      END SELECT
                                  
                                  END FUNCTION
                                  
                                  
                                  FUNCTION PBMAIN () AS LONG
                                  
                                  CONSOLE SET LOC 1,1
                                  CONSOLE SET SCREEN 10,40
                                  
                                  Throb(200,200,%YELLOW,500,250) 'at position 200,200 and 500 wide x 250 high
                                  PRINT "Press a key to exit"
                                  CONSOLE SET FOCUS
                                  
                                  DO
                                      SLEEP 10 'this is where you do the main job while the pulsating text is displayed
                                  LOOP UNTIL INSTAT
                                  
                                  'end display
                                  Throb (0,0,%stop,0,0)
                                  
                                  END FUNCTION

                                  Comment


                                  • #18
                                    Rod, I like your idea of using Wm_Timer instead of a F/N loop like I do. I'm going to try to incorporate it. Also I like the idea of being able to end it at any point (your "DONE" button) where mine require Alt F4 (outside the loop) or ACD (inside it).

                                    Tip: When testing, prefix the name with "z_", then after ACD'ing, press "z" and the prog is immediately highlighted ready to be Ended. As you may infer I have to ACD a LOT when I program {sigh}.

                                    Paul, the Control Set Text is set before the F/N loop. There is a Dialog Set inside just to watch the variables.

                                    I've fooled with the Timer but it seems instant. Watching the Dialog header shows that. Obviously I'm doing something wrong but dunno what.

                                    '
                                    Code:
                                    'PBWIN 9.01 - WinApi 05/2008 - XP Pro SP3
                                    #Dim All 
                                    #Compile Exe  
                                    #Optimize SPEED
                                    #Debug Display On '<<<<<<<<<<<<<<< Remember to turn off for production code
                                    '
                                    #Include "WIN32API.INC"
                                    #Include "COMDLG32.INC"
                                    #Include "InitCtrl.inc"
                                    '
                                    '
                                    ' *******************************************************
                                    '
                                    '
                                     'this next included file needed for button colors can be found here: 
                                     'http://www.powerbasic.com/support/pbforums/showthread.php?t=38904
                                    #Include "C:\Only_My_Programs\Include Files\ButtonPlus.bas"
                                    '
                                    ' *******************************************************
                                    '
                                      Global g_Tmr, hdlg As Dword                
                                      Global g_Quit_Flag, g_Start_bg_Color, g_Start_fg_Color As Long
                                      Global ms, g_Timer_Event As Long
                                      Global g_Now_Displaying As String
                                    '
                                    %ID_TIMER1=100
                                    %Display_Msg_Id   = 1000
                                    %Msg_Btn_Id = 2000
                                    '
                                    Macro aa_Common_Locals
                                      Local hfont12, hfont16, hfont20, hfont24 As Long 
                                      Local slp, wd1, ht1, ctr1, ctr, clor, Id, Row, col, stile, ht, wd As Long
                                      Local s1, hx, s As String
                                      Local r, g, b As Byte
                                      Local Title As String * 150
                                      
                                     Font New "Comic Sans MS", 12 To hfont12
                                     Font New "Comic Sans MS", 16 To hfont16
                                     Font New "Comic Sans MS", 20 To hfont20
                                     Font New "Comic Sans MS", 24 To hfont24        
                                    End Macro
                                    '
                                    Function show_Msg_New As Long
                                      aa_common_Locals
                                      Control Set Text hdlg, %Msg_Btn_Id, " Enough, Already!"
                                         g_Quit_Flag = 1
                                         g_Tmr = Timer
                                    '
                                       g_Now_Displaying = "With malice toward None, " & $CrLf & _ 
                                           "With charity For All,  " & $CrLf & _ 
                                           "With firmness in the Right  " & $CrLf & _ 
                                           "As God gives us to see the Right,  " & $CrLf & _ 
                                           "Let us strive on to finish the work we are in,  " & $CrLf & _ 
                                           "To bind up the nation's wounds,  " & $CrLf & _ 
                                           "To care for him who shall have borne the battle  " & $CrLf & _ 
                                           "And for his widow and his orphan,  " & $CrLf & _ 
                                           "To do all which may achieve and cherish  " & $CrLf & _ 
                                           "A just and lasting peace among ourselves  " & $CrLf & _ 
                                           "And with all nations." 
                                    '       
                                      Id = %Display_Msg_Id  
                                        Control Set Text hdlg, Id, g_Now_Displaying 
                                        Control Set Color hdlg, Id, %White, %Black 'g_Start_bg_Color, g_Start_bg_Color
                                        Control ReDraw hdlg, Id 
                                        
                                        
                                    End Function
                                    '
                                    '
                                    '
                                    ' *******************************************************
                                    '
                                    CallBack Function Button_Subclass_Processor() As Long
                                      aa_common_Locals
                                      Select Case cb.Msg
                                         '
                                         Case %WM_COMMAND  'Wm_Notify doesn't do it
                                           Select Case cb.Ctl
                                             Case %Msg_Btn_Id
                                               Select Case cb.CtlMsg
                                                 Case %BN_CLICKED  
                                                  '? "here"
                                                   If g_Quit_Flag = 1 Then 
                                                      'Dialog End hdlg
                                                      Reset g_Quit_Flag 'while testing
                                                      Control Set Text hdlg, %Msg_Btn_Id, " Next Inspirational Message"
                                                      CSet Title$ = "Ain't Life just Grand!"
                                                      Dialog Set Text hdlg, Title$ 'just to watch working
                                                      KillTimer hdlg, g_Timer_Event
                                                     Else
                                                      ms = 75 'ms = milliseconds between beats '75 orig 
                                                      g_Timer_Event = SetTimer(hdlg, %ID_TIMER1, ms, 0) 'ms = milliseconds between beats '75 orig 
                                                      Control Post hdlg, %ID_TIMER1, %WM_TIMER, 0,0
                                                      g_tmr = Timer
                                                      Show_Msg_New
                                                   End If   
                                               End Select
                                           End Select
                                      End Select
                                    End Function
                                    '
                                    ' *******************************************************
                                    '
                                    Macro Timer_Draw
                                       clor = RGB(ctr, ctr, 0)       
                                       Id = %Display_Msg_Id
                                        Control Set Color cb..Hndl, Id,  clor, %Black
                                             Control ReDraw cb..Hndl, Id 
                                            Incr ctr
                                            If ctr=256 Then ctr=0
                                    End Macro
                                    '
                                    CallBack Function Dialog_Processor
                                      aa_common_Locals
                                      Static hx1 As String
                                      Select Case cb.Msg     'This is TO determine the message TYPE 
                                         '       
                                         Case %WM_INITDIALOG'<- Initialiaton when the program loads 
                                         ' 
                                         Case %WM_TIMER
                                         
                                            If cb.WParam=%ID_TIMER1 Then
                                    '          Timer_Draw
                                       Id = %Display_Msg_Id
                                        r = ctr
                                        b = ctr
                                        g = ctr
                                        clor = Bgr(r, g, b)       
                                        hx$ = Hex$(clor, 6)       
                                        hx1$ = hx1$ & hx$ & " " 
                                        CSet Title$  = Using$("# Color = "  & Right$(Hx1$, 30) & "  # Seconds at #ms per ctr", ctr, Timer - g_Tmr, ms)
                                        Dialog Set Text hdlg, Title$ 'just to watch working
                                        Control Set Color hdlg, Id,  clor, g_Start_bg_Color
                                        'Control Set Text hdlg, Id, g_Now_Displaying$
                                          Control ReDraw hdlg, Id
                                             Incr ctr
                                             If ctr = 256 Then ctr = 0
                                            End If
                                         '
                                         Case %WM_SYSCOMMAND 'Traps Any Alt key but only F4 closes              
                                         '
                                         Case %WM_COMMAND  'This processes command messages
                                      End Select
                                    End Function
                                    '
                                    Function PBMain
                                      aa_common_locals
                                     g_Start_fg_Color =  %Black '&hff0046'&hFFD7D7
                                     g_Start_bg_Color = %Black 'g_Start_fg_Color '&hFFD7D7
                                    '
                                      ht = 540: ht1 = ht
                                      wd = 700: wd1 = wd         
                                      CSet Title$ = "Lincoln's Second Inagural Address"
                                      Dialog New Pixels, hdlg, Title$, , , wd, ht To hdlg
                                          Dialog Set Color hdlg,  g_Start_fg_Color, g_Start_bg_Color
                                    '
                                     wd = Wd - 20
                                     ht = ht - (3 * 40)
                                     Row = 40
                                     Col = 10
                                     Id = %Display_Msg_Id  
                                     Stile = %SS_Center
                                      Control Add Label, hdlg, Id, "Inspirations", col, row, wd, ht, stile
                                      Control Set Font hdlg, Id, hfont20
                                      Control Set Color hdlg, Id,  %White, g_Start_bg_Color
                                     '
                                     Id = %Msg_Btn_Id
                                     Row = ht1 - 40 'Just off bottom 
                                     ht = 30
                                                                     '
                                      stile = stile Or %Bs_Notify ' send notification msg when clicked
                                      Control Add Button, hdlg, Id, "Inspirational Message", Col, row, wd, ht, stile, Call Button_Subclass_Processor
                                      Control Set Font hdlg, Id, hfont20
                                      'rem next two if no Button Plus included
                                      Btn_Set_Text_Color(hdlg, Id, &h000000) 
                                      Btn_Set_Face_Color(hdlg, Id, &hFFF546): 
                                    '
                                      Dialog Show Modal hDlg   Call Dialog_Processor      
                                    '     
                                    End Function 'Abblikation beenden
                                    '
                                    =============================
                                    He that is secure is not safe.
                                    Ben Franklin
                                    =============================
                                    It's a pretty day. I hope you enjoy it.

                                    Gösta

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

                                    Comment


                                    • #19
                                      Originally posted by Rodney Hicks View Post
                                      Gösta, have you considered trying this in a GRAPHIC WINDOW to get rid of the flicker?
                                      No, not yet. That's on the list, though {grin}.

                                      Michael, I really always thought that it was "Let's make something so easy even Rod can do it!"
                                      And here all this time I was thinking it was "Let's make something so easy a real man can snicker at it."

                                      ==============================
                                      "Heav'n hath no rage
                                      like love to hatred turn'd,
                                      Nor Hell a fury,
                                      like a woman scorn'd."
                                      William Congreve (1670-1729)
                                      ==============================
                                      It's a pretty day. I hope you enjoy it.

                                      Gösta

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

                                      Comment


                                      • #20
                                        Originally posted by Michael Mattias View Post
                                        I am a big believer in fundamentals. YMMV.
                                        It does.


                                        I am a big believer that tools can only be used effectively when the user understands exactly what labor-savings the tool provides. YMMV.
                                        It does.


                                        I am a big believer that true programmers can program even when their tools are taken away... by falling back on their fundamentals. YMMV.
                                        It does/


                                        OTOH, DDT is a brilliant marketing ploy. A PB license purchase is a lot easier for the prospect when he/she can honestly say, "Hey, I can do that!"
                                        Before DDT, I ouldn;'t even spell "Prgramer". Now I are one.

                                        ==================================
                                        "Where are we going,
                                        and why am I in this handbasket?"
                                        Bumper Sticker
                                        ==================================
                                        It's a pretty day. I hope you enjoy it.

                                        Gösta

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

                                        Comment

                                        Working...
                                        X