- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everybody,
I am presently working on a simple Win32 application in Visual Fortran which launches an external program, takes the results of calculations and then displays the data on the child window. I am trying to use a "readonly" edit control box and set the corresponding data to it in a text form.
Which function can I use for that? There is no specific parameter of the SendMessage() function for the edit control for this purpose.
Should I use the the WM_SETTEXT message? Then I have the question how can one set the text itself. I found that one can use some integer pointer represented by the 'lparam' parameter of the SendMessage() function, but as I understand the pointer can be specified only for data of the same data type? Then how I get to my text message?
Or are there any other possibilities to set text to the edit control box?
P.S. In former times, I could easily set text to edit boxes in dialog applications, but here I have a Win32 application.
Oleksii G
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use IFWIN, only: dword, SetDlgItemText, handle integer(handle) :: hDlg integer :: ID integer(DWORD) :: ret character(80) :: gchar gchar='my text'//achar(0) ! null terminated string ret = SetDlgItemText (hDlg, ID , gchar ) !dialog handle and control ID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, app4619.
But as I can see this example is used for a dialog window. In my Win32 application, the edit control box is created via the CreateWindowsEx() function, so it is not a part of a dialog window? Or maybe I understand it wrong? I am quite new in Win32 programming...
Oleksii
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An edit control is a window.
So you can use the SetWindowText function.
Using C++ should be:
BOOL WINAPI SetWindowText(
_In_ HWND hWnd,
_In_opt_ LPCTSTR lpString
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Luigi,
Just tried it, it works perfectly for the title of the parent window. But the edit control box is created as a child window, and the function returns .false. for it. Probably different parameters(styles) in CreateWindowEx() function could be used to solve the issue, but so far I did not find anything yet. By the way, the same result gives also the SendMessage() function with WM_SETTEXT message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a piece of my code where edit control is created in a window. The only difference is that I am using MFC so the edit control is attached to a MFC object. Make sure that the window handle is correct and the edit control window has been created and exists.
if(itype EQ 1)
{
pedit = (CEdit*) xvalCtr[i-1] ;
pedit->SetWindowText(cValue) ;
};
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Now it works fine.
I can use either the SetWindowText() or SendMessage() in the following way:
iret = SendMessage(edit_handle, WM_SETTEXT, NULL, LOC(CharVar))
Thanks a lot again!
Regards, Oleksii

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page