Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Setting text to an edit control box in Win32 API (Fortran)

Oleksii_G_
Beginner
4,193 Views

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

0 Kudos
6 Replies
andrew_4619
Honored Contributor III
4,193 Views
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

 

0 Kudos
Oleksii_G_
Beginner
4,193 Views

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

0 Kudos
LRaim
New Contributor I
4,193 Views

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
);

0 Kudos
Oleksii_G_
Beginner
4,193 Views

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. 

0 Kudos
LRaim
New Contributor I
4,193 Views

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

0 Kudos
Oleksii_G_
Beginner
4,193 Views

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 

0 Kudos
Reply