Announcement

Collapse
No announcement yet.

help - DDT code doing the unexpected

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

  • help - DDT code doing the unexpected

    this is code from a callback funtion to respond to a button click. the code grabs string DMS from textbox1 just fine. Next function DMStoD(DMS) returns a modifed (different) string which now should be written to textbox2. That works fine too the first time through. The problem is that each time I press this button, textbox2 does not refresh/erase ... it just piles the new text on top of the old. The help file says it will "replace" the text when you use set text. In fact, it seems to just write over it ... makes a mess on the screen... help please! ???? I want textbox2 to clear and take a new value each time the button is pressed.



    CASE %IDC_BUTTON1
    IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
    CONTROL GET TEXT CBHNDL, %IDC_TEXTBOX1 TO DMS
    CONTROL SET TEXT CBHNDL, %IDC_TEXTBOX2, DMStoD(DMS)
    END IF

  • #2
    Originally posted by Mark Farrar View Post
    Next function DMStoD(DMS) returns a modifed (different) string
    are you sure it is returning the right value?

    Comment


    • #3
      Sounds as though you are intercepting the %WM_ERASEBKGND message for Textbox2 and stopping its normal action. Or possibly you have set the font to %Transparent

      Comment


      • #4
        I usually do the following:

        CASE %IDC_BUTTON1
        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
        CONTROL GET TEXT CBHNDL, %IDC_TEXTBOX1 TO DMS
        CONTROL SET TEXT CBHNDL, %IDC_TEXTBOX2, "" 'or " "
        CONTROL REDRAW CBHNDL, %IDC_TEXTBOX2
        CONTROL SET TEXT CBHNDL, %IDC_TEXTBOX2, DMStoD(DMS)
        END IF

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

        Comment


        • #5
          How can DMS be both a string variable and a subscript?
          Please post code within brackets (code) (/code).
          Code:
           SELECT CASE AS LONG CBCTL
                          CASE %IDC_BUTTON1
                              LOCAL DMS AS STRING
                              LOCAL DMS AS LONG
                              DIM DMStoD(0 TO 0) AS STRING
                              IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                CONTROL GET TEXT CBHNDL, %IDC_TEXTBOX1 TO DMS
                                CONTROL SET TEXT CBHNDL, %IDC_TEXTBOX2, DMStoD(DMS)
                              END IF
          The world is full of apathy, but who cares?

          Comment


          • #6
            Originally posted by Mark Farrar View Post
            this is code from a callback funtion to respond to a button click. the code grabs string DMS from textbox1 just fine. Next function DMStoD(DMS) returns a modifed (different) string which now should be written to textbox2. That works fine too the first time through. The problem is that each time I press this button, textbox2 does not refresh/erase ... it just piles the new text on top of the old. The help file says it will "replace" the text when you use set text. In fact, it seems to just write over it ... makes a mess on the screen... help please! ???? I want textbox2 to clear and take a new value each time the button is pressed.



            CASE %IDC_BUTTON1
            IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
            CONTROL GET TEXT CBHNDL, %IDC_TEXTBOX1 TO DMS
            CONTROL SET TEXT CBHNDL, %IDC_TEXTBOX2, DMStoD(DMS)
            END IF
            My best guess is that your function is not parsing the string properly. Please post DMStoD() code.

            Stan
            Do not go quiet into that good night,
            ... Rage, rage against the dark.

            Comment


            • #7
              To be a little more specific than my previous post.

              Whenever I have set the background color to transparent rather than the default or a specific color, so Simon's on the right track, I think.

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

              Comment


              • #8
                Originally posted by Mike Doty View Post
                How can DMS be both a string variable and a subscript?
                No, it was an argument to a function.

                All the code would be nice.

                Comment


                • #9
                  If you are using a transparent background the problem may occur.

                  Some window classes (controls) don't handle a transparent background well.

                  Static (Label) controls do allright with the WS_EX_TRANSPARENT style, but you have to invalidate the client area when you change the text, so it redraws properly.

                  The Edit control (especially when it is not readonly) may not work well with a transparent background.

                  I have found only the following controls work well with a transparent background:

                  CheckBox (button class)
                  Radio or Option Button (button class)
                  Frame (button class)
                  Label (static class)
                  Chris Boss
                  Computer Workshop
                  Developer of "EZGUI"
                  http://cwsof.com
                  http://twitter.com/EZGUIProGuy

                  Comment


                  • #10
                    No, it was an argument to a function.
                    OIC, he is passing DMS as a string and we have no idea what it is being modified to in the DMS sub or function.
                    Last edited by Mike Doty; 27 Jun 2008, 08:54 AM.
                    The world is full of apathy, but who cares?

                    Comment


                    • #11
                      'This is a test program
                      Code:
                      #PBFORMS CREATED V1.52
                      '------------------------------------------------------------------------------
                      #COMPILE EXE
                      #DIM ALL
                      '------------------------------------------------------------------------------
                      '   ** Includes **
                      '------------------------------------------------------------------------------
                      #PBFORMS BEGIN INCLUDES
                      #IF NOT %DEF(%WINAPI)
                          #INCLUDE "WIN32API.INC"
                      #ENDIF
                      #PBFORMS END INCLUDES
                      '------------------------------------------------------------------------------
                      '------------------------------------------------------------------------------
                      '   ** Constants **
                      '------------------------------------------------------------------------------
                      #PBFORMS BEGIN CONSTANTS
                      %IDD_DIALOG1  =  101
                      %IDC_BUTTON1  = 1001
                      %IDC_TEXTBOX1 = 1002
                      %IDC_TEXTBOX2 = 1003
                      #PBFORMS END CONSTANTS
                      '------------------------------------------------------------------------------
                      '------------------------------------------------------------------------------
                      '   ** Declarations **
                      '------------------------------------------------------------------------------
                      DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
                      DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                      #PBFORMS DECLARATIONS
                      '------------------------------------------------------------------------------
                      DECLARE FUNCTION DMStoD(s AS STRING) AS STRING
                      '------------------------------------------------------------------------------
                      '   ** Main Application Entry Point **
                      '------------------------------------------------------------------------------
                      FUNCTION PBMAIN()
                          ShowDIALOG1 %HWND_DESKTOP
                      END FUNCTION
                      '------------------------------------------------------------------------------
                      '------------------------------------------------------------------------------
                      '   ** CallBacks **
                      '------------------------------------------------------------------------------
                      CALLBACK FUNCTION ShowDIALOG1Proc()
                          SELECT CASE AS LONG CBMSG
                              CASE %WM_INITDIALOG
                                  ' Initialization handler
                              CASE %WM_NCACTIVATE
                                  STATIC hWndSaveFocus AS DWORD
                                  IF ISFALSE CBWPARAM THEN
                                      ' Save control focus
                                      hWndSaveFocus = GetFocus()
                                  ELSEIF hWndSaveFocus THEN
                                      ' Restore control focus
                                      SetFocus(hWndSaveFocus)
                                      hWndSaveFocus = 0
                                  END IF
                              CASE %WM_COMMAND
                                  ' Process control notifications
                                  SELECT CASE AS LONG CBCTL
                                      CASE %IDC_BUTTON1
                                          LOCAL DMS AS STRING
                                          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                            CONTROL GET TEXT CBHNDL, %IDC_TEXTBOX1 TO DMS
                                            CONTROL SET TEXT CBHNDL, %IDC_TEXTBOX2, DMStoD(DMS)
                                          END IF
                                      CASE %IDC_TEXTBOX1
                                      CASE %IDC_TEXTBOX2
                                  END SELECT
                          END SELECT
                      END FUNCTION
                      '------------------------------------------------------------------------------
                      '------------------------------------------------------------------------------
                      '   ** Dialogs **
                      '------------------------------------------------------------------------------
                      FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                          LOCAL lRslt AS LONG
                      #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
                          LOCAL hDlg  AS DWORD
                          DIALOG NEW hParent, "Dialog1", 131, 183, 527, 305, %WS_POPUP OR _
                              %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR _
                              %WS_MAXIMIZEBOX 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 BUTTON,  hDlg, %IDC_BUTTON1, "Button1", 5, 5, 50, 15
                          CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX1, "TextBox1", 5, 20, 100, 13
                          CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX2, "TextBox2", 5, 35, 100, 13
                      #PBFORMS END DIALOG
                          DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                      #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
                      #PBFORMS END CLEANUP
                          FUNCTION = lRslt
                      END FUNCTION
                      '------------------------------------------------------------------------------
                      FUNCTION DMStoD(s AS STRING) AS STRING
                        'What happens here?
                        FUNCTION = s
                      END FUNCTION
                      The world is full of apathy, but who cares?

                      Comment


                      • #12
                        Mike,

                        If you change the background color of the target textbox to transparent you'll see the problem he was having.

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

                        Comment


                        • #13
                          Originally posted by Rodney Hicks View Post
                          Mike,

                          If you change the background color of the target textbox to transparent you'll see the problem he was having.

                          Rod
                          Rod,
                          Okay, I see the error now. Will setting the styles of TextBox2 like this instead of using the SET COLOR statement solve the problem? It seems to work on my system.

                          Code:
                          CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX2, "TextBox2", 5, 35, 100, 13,%ES_AUTOHSCROLL _
                              OR %ES_LEFT OR %WS_BORDER OR %WS_TABSTOP OR %ES_READONLY, %WS_EX_CLIENTEDGE OR _
                              %WS_EX_LEFT OR %WS_EX_TRANSPARENT
                          or am I still missing the point?

                          Stan
                          Do not go quiet into that good night,
                          ... Rage, rage against the dark.

                          Comment


                          • #14
                            You're right Stan. You don't even need the %WS_EX_TRANSPARENT if you don't set the color. At least on mine.

                            Code:
                            FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                                LOCAL lRslt AS LONG
                            #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
                              LOCAL hDlg  AS DWORD
                            
                              DIALOG NEW hParent, "Dialog1", 131, 183, 527, 305, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR _
                                %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX 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 BUTTON,  hDlg, %IDC_BUTTON1, "Button1", 5, 5, 50, 15
                              CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX1, "TextBox1", 5, 20, 100, 13
                              CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX2, "TextBox2", 5, 35, 100, 13, %WS_CHILD OR %WS_VISIBLE _
                                OR %WS_TABSTOP OR %ES_LEFT OR %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE OR _
                                %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
                              'CONTROL SET COLOR    hDlg, %IDC_TEXTBOX2, -1, -2
                            #PBFORMS END DIALOG
                                DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                            #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
                            #PBFORMS END CLEANUP
                                FUNCTION = lRslt
                            END FUNCTION
                            Rod
                            Rod
                            In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                            Comment


                            • #15
                              thank you all - got it working

                              Thank you everyone.

                              The problem was simply that the background color in textbox2 was set to transparent ... I didn't even realize I had done it ... leftover from previous debug work.

                              Just to answer the one question that was asked.

                              DMS is a string
                              DMStoD() is a functin that modifies a string and returns another string

                              The problem was independant of the function DMStoD ... I get the same behavior no matter what string I put in the box i.e. "dummy_string" etc etc...

                              yes...it was just the transparent background...once changed to system default the code works fine .... thank you again for helping me find the bug.

                              M

                              Comment

                              Working...
                              X