Announcement

Collapse
No announcement yet.

Append Text to Edit control

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

    Append Text to Edit control

    I've gotan edit control set and created in read_only mode...
    I use it to do an on-screen display of IP addresses that have connected.
    Now if I do a Control Get Text to sTmp and append new data to sTmp and control set text BACK all is well.

    I searched but could not find what I was looking for, either there was a SendMessage api that could append text or I need to GET the text and append it.

    However, this is inside of a thread, not a callback - so Control Get Text is out.

    This is not working...Buff isreturned Zero but GETTEXTLENGTH returns 62 bytes on first run (and it is 62 bytes) - so it sees it, what am I missing here?
    I've tried it using a STRINg as well and a StrPtr - no go.

    Code:
    Function AppendTextToWindow(ByVal sPacket As String) As Long
    Local Buff As Asciiz * 4096
    Local BuffSize As Long
    
    BuffSize = SendMessage(BBSDown.txtHandle, %WM_GETTEXTLENGTH,0,0) '62 bytes on average
    
    If Not IsFalse BuffSize Then 'We have text there, grab it and add a $CrLf
        SendMessage BBSDown.txtHandle, %WM_GETTEXT, 0, ByVal VarPtr(Buff)
        Buff = Buff & $CrLf & sPacket
    Else
        Buff = sPacket
    End If
    SendMessage BBSDown.txtHandle, %WM_SETTEXT, 0, VarPtr(Buff)
    End Function
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    #2
    Maybe change to use a combobox or listbox one row per IP address isntead of a multi-line edit control? (you can make combobox read only if you want)

    You are doing a 'new line' for each address anyway.

    ???


    Failing that, what are the error codes from WM_GETTEXT and WM_SETTEXT? (yes they do return success/fail values)


    MCM
    Last edited by Michael Mattias; 16 Oct 2008, 01:28 PM.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


      #3
      See:

      EM_SETSEL
      EM_REPLACESEL
      kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

      Comment


        #4
        Ya forgot about that setsel - the combo box idea is good, it's only getting written TO it, never recovered from it....may go that route, it's just a display to showwho connected...

        But still, one would think this would work.
        '
        THe error code is zero......that's the weird part...

        no prob, combobox it is....
        Scott Turchin
        MCSE, MCP+I
        http://www.tngbbs.com
        ----------------------
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

        Comment


          #5
          >The error code is zero......that's the weird part...

          The RETURN from WM_GETTEXT = 0? That means "no characters retrieved."

          Kinda means it's working as designed, huh?
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


            #6
            I don't like it, strange, it's supposed to bring back some text..
            IT is inside of a thread though, not sure if that matters...

            Listbox will work but it's a PITA, gotta create a friggin array just to create the listbox....otherwise it works...
            Scott Turchin
            MCSE, MCP+I
            http://www.tngbbs.com
            ----------------------
            True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

            Comment


              #7
              Originally posted by Scott Turchin View Post
              ... gotta create a friggin array just to create the listbox...
              surely that kind of friggin is not necessary? Just create the ListBox without supplying the array parameter to CONTROL ADD LISTBOX then add items with LISTBOX ADD?

              Comment


                #8
                ok, I am lost
                <code not shown>

                Can you provide an example so we can see how the error is 0? or something else we can see but you can't see?

                Often when its "2+2=5", its really "2+2+<oops>=5"
                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


                  #9
                  Originally posted by Scott Turchin View Post
                  I've gotan edit control set and created in read_only mode... what am I missing here?
                  maybe setting RO (EM_SETREADONLY?) prevents data from being added to the control, there would be a certain logic in that?

                  Why not post some compileable code?

                  Comment


                    #10
                    maybe setting RO (EM_SETREADONLY?) prevents data from being added to the control, there would be a certain logic in that?
                    No, the flags such as WS_DISABLED and ES_READONLY only affect the user's ability to change the content of the control.
                    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                    Comment


                      #11
                      A few little changes and I think this might work for you perfectly:
                      Use Listview control as a console. September 13 2003.
                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                        #12
                        Thanks Michael- just created a 2 element LONG array to get it created, and then just keep piling the status on...

                        I'm not certain why it kept the top element highlighted so this code was an attempt to put focus on the last element, while it doesn't highlight the last element it does keep it scrolled to the bottom so you can see the last info posted.

                        lHost = RemoteIp(ByVal hTcp)
                        sTmp = TimeStamp() & " Connection established from: " & lHost
                        lResult = SendMessage(BBSDown.txtHandle, %LB_ADDSTRING, 0, StrPtr(sTmp))
                        lResult = SendMessage(BBSDown.txtHandle, %LVM_GETITEMCOUNT, 0, 0)
                        lResult = SendMessage(BBSDown.txtHandle, %LVM_SETITEM, 0, lResult)
                        Scott Turchin
                        MCSE, MCP+I
                        http://www.tngbbs.com
                        ----------------------
                        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                        Comment


                          #13
                          To highlight a listview row .. you select it.

                          Code:
                          FUNCTION ListView_SetSelection (BYVAL hWnd AS LONG, BYVAL Rowno AS LONG) AS LONG
                            ListView_SetItemState hWnd, RowNo, &hFFFFFFFF, (%LVIS_SELECTED OR %LVIS_FOCUSED)
                          END FUNCTION
                          MCM
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                            #14
                            Because I wrote that before the compiler supported MACROs, that's why not.
                            Michael Mattias
                            Tal Systems (retired)
                            Port Washington WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment

                            Working...
                            X
                            😀
                            🥰
                            🤢
                            😎
                            😡
                            👍
                            👎