🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
1 messages
1 total messages Started by Bill Carson Mon, 12 May 2003 19:40
Child Window Edit Control Problem
#16529
Author: Bill Carson
Date: Mon, 12 May 2003 19:40
52 lines
3100 bytes
I can't get the text to display in a child window
edit control, unless I click on either the vertical
scroll bar or a parent window menu item first.

I'm currently learning to program with Win32 API,
and have been trying to get a small program to
open a file and display it's contents in a child
window edit control. I've basically taken Petzold's
Poppad example and altered it for my purposes. The
main change I have made to his example is that I create
the child window edit control as invisible, then by menu
command I open and read in text from a file, use ShowWindow
to make the child control visible, then either SetWindowText,
or send a WM_SETTEXT message to the control to display the
text. The guts of the code follows:

case WM_COMMAND:
  switch(LOWORD(wParam))
  {
  case FILE_OPEN:
    OfnInit(hwnd); // initialize OPENFILENAME structure, display open
dialog
    hDemFile = CreateFile(ofn.lpstrFile, GENERIC_READ, 0, NULL,
OPEN_EXISTING,  FILE_ATTRIBUTE_NORMAL, NULL);
    iFileSize = GetFileSize(hDemFile, NULL);
    pFileBuffer = malloc(iFileSize + 2);
    ReadFile(hDemFile, pFileBuffer, iFileSize, &dwBytesRead, NULL);
    CloseHandle(hDemFile);
    pFileBuffer[iFileSize] = '\0';
    pFileBuffer[iFileSize + 1] = '\0';
    pText = pFileBuffer;
    pConv = malloc(2 * iFileSize + 2);
    lstrcpy((PTSTR) pConv, (PTSTR) pText); // copy file buffer into
text buffer
    ShowWindow(hwndView, SW_SHOW); // show child window edit control
//      SendMessage(hwndView, WM_SETTEXT, 0, (LPARAM) pConv);
    SetWindowText(hwndView, (PTSTR) pConv);
  break;

All the examples I've been able to find usually make the child window
visible first before putting text in the control, so I assume that
the problem is because I have made the control invisible to begin
with.
The problem, as stated above, is the same whether I send a message or
use SetWindowText. I suspect that the act of putting text in a control
does not automatically change the focus to that control.  But I have a
lot yet to learn about the Win32 API, so any suggestions would be most
appreciated.

Thanks,

Bill
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads