Archived

This topic is now archived and is closed to further replies.

Wanting to change windows control data

This topic is 5530 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a standard edit control, used for a floating point value. I can read it ok by capturing the message to the control''s parent dialog, but not all values are acceptable. So if a bad value is input I want to change the text to an acceptable value. However because all this is done in response to a message for the control, using SetDlgItemText() or SetWindowText() both cause another message to be sent to the control - hence an infinite loop occurs (well a stack overflow really) How can I fix this? I thought maybe send a message directly to change the text?
Read about my game, project #1 NEW (9th September)diaries for week #5 Also I''m selling a few programming books very useful to games coders. Titles on my site.
John 3:16

Share this post


Link to post
Share on other sites
SendMessage( (hwnd of edit), WM_SETTEXT, 0, (WPARAM)"0.1" );

But if the other two are giving you recursion why won''t this? I believe that it boils down to what message you are trapping, and the logic you are using... Good luck

Share this post


Link to post
Share on other sites
You may want to handle the EN_CHANGE or EN_UPDATE notification from the edit control. I don''t think SetWindowText will result in another update notification, but if it does, you can always set a global value specifying if you''re currently handling a text change message and, if so, cancel out of the infinite recursion.

Share this post


Link to post
Share on other sites
More accurately what I do is:

respond to any WM_COMMAND message targeted for the edit box:
I check what the value is by calling GetDlgItemText() and atof() to get a float. Then I check if this value is OK - if not I want to change the value in the window.
I tried changing a different edit box to the one receiving the message and that works fine, so it diffinately is that changing the text sends another message. I''ll look into detecting what kind of message is being received.



Read about my game, project #1
NEW (9th September)diaries for week #5

Also I''m selling a few programming books very useful to games coders. Titles on my site.


John 3:16

Share this post


Link to post
Share on other sites
How do I tell, when a control sends me a WM_COMMAND message, what it wants to tell me?

I guess its somewhere in LPARAM or WPARAM, but which bit of what - the id and handle to the control, and the actual message are also stored but I want the bit that says "Hi, I just updated the control" or whatever. And what values can it send me exactly?

Share this post


Link to post
Share on other sites