CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #3
    Join Date
    May 2019
    Posts
    53

    Re: Reading contents of file into SetWindowTextA for output into an Edit field of win

    Quote Originally Posted by VictorN View Post
    Use CreateFile / ReadFile Win32 API functions
    Oh... seems I found the solution using your help... though there are still problems...:

    Code:
    HANDLE file = CreateFile(ofn.lpstrFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    DWORD fileSize = GetFileSize(file, NULL);
    LPSTR buffer = (LPSTR)GlobalAlloc(GPTR, fileSize + 1);
    DWORD read;
    
    ReadFile(file, buffer, fileSize, &read, NULL);
    
    SetWindowTextA(hEdit, buffer);
    Can you see any problems with the above code?

    I also still have the problem that the text is invisible inside the text box until the user HIGHLIGHTS (click-drags mouse over it) it.
    Any idea how to cause the text box (hEdit) to refresh after the SetWindowTextA operation?
    Last edited by Arianax; May 26th, 2019 at 10:33 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured