Announcement

Collapse
No announcement yet.

Edit control blues

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

  • Edit control blues

    Hey all,
    I am singing some edit control blues, I am using Ed Turner's
    visual designer to create this notepad app. This is my
    open procedure to open a and load a file:

    [code]
    Sub Notepad_Openitem_CLICK(formNo As Long)
    Local Path As String
    Local buffer As String
    Local f As String
    Local Style As Long
    Local hFile As Long

    Path = CurDir$
    f = "*.txt"
    Style = %OFN_FILEMUSTEXIST Or %OFN_HIDEREADONLY Or %OFN_LONGNAMES
    If OpenFileDialog(wForm(formNo).hwnd, "Open File", f, Path, _
    "Text Files|*.txt|All Files|*.*", "txt", Style) Then
    hFile = FreeFile
    Open f For Binary As hFile
    Get$ hFile,Lof(hFile),buffer
    Close hFile
    f = filenam(f)
    f = Extract$(f,".") + " - Notepad"
    SetWindowtext wForm(FormNo).hwnd,ByVal StrPtr(f)
    SetWindowtext wControl(1).hwnd,ByVal StrPtr(buffer)
    Sendmessage wControl(1).hwnd,%EM_SETMODIFY,%FALSE,0
    End If
    End Sub
    [\code]

    ...and here is my save\save as procedure:
    [code]
    Sub SaveFile(ByVal Ask As Long)
    Local Path As String
    Local f As String
    Local Style As Long
    Local hFile As Long
    Local Buffer As String
    Local zText As Asciiz * 255

    GetWindowText wForm(0).hwnd, zText, SizeOf(zText)
    If zText = "Untitled - Notepad" Then
    Path = CurDir$
    f = ""
    Ask = %TRUE
    Else
    Path = FilePath(zText)
    f = FileNam(zText)
    End If
    Style = %OFN_HIDEREADONLY Or %OFN_LONGNAMES

    If IsTrue(Ask) Then
    If IsFalse(SaveFileDialog(wForm(0).hwnd, "Save File As", f, Path, _
    "Text Files|*.txt|All Files|*.*", "txt", Style)) Then
    Exit Sub
    End If
    End If

    hFile = FreeFile
    Open f For Binary As hFile
    Buffer = Space$(GetWindowTextLength(wControl(1).hwnd) + 1)
    GetWindowText wControl(1).hwnd, ByVal StrPtr(Buffer), Len(Buffer)
    Put$ hFile, Left$(Buffer, Len(Buffer)-1)
    SetEof hFile
    Close hFile
    f = filenam(f)
    f = Extract$(f,".") '+ " - Notepad"
    SetWindowText wForm(0).hwnd, ByVal StrPtr(f)
    SendMessage wControl(1).hwnd, %EM_SETMODIFY, 0, 0
    End Sub
    [\code]
    I borrowed the code from the pbnote sample and modified it for
    my app. Now here is why I am singing the blues. When I create
    a new file with some text the file gets created and data
    written to file just fine, but when I reload that file and
    try to make changes to it, it does not write the changes to
    the file. A msgbox statement does tell me that the buffer is
    getting loaded with the modified text but it is not writing
    the changes to the file.

    ------------------
    Well obviously I couldn't remember what the syntax for the code
    tags are, please excuse my memory.



    [This message has been edited by Adam Ritchie (edited September 23, 2000).]

  • #2
    Never mind folks, I have discovered the problem and have solved
    it.

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

    Comment


    • #3
      Adam,

      Well obviously I couldn't remember what the syntax for the code tags are, please excuse my memory.
      You almost got it. It's [/ code] (remove the space between the slash and the word code.)

      Knuth


      ------------------
      http://www.softAware.de

      Comment

      Working...
      X