Ross Levis" <[EMAIL PROTECTED]> wrote > I want to change the Text property of a ComboBox inside the > OnChange event. Setting it directly doesn't work presumeably > because the OnChange event occurs before the change occurs > rather than after.
According to the Delphi 6 Help file: "Write an OnChange event handler to take specific action immediately after the user edits the text in the edit region or selects an item from the list. The Text property gives the new value in the edit region. "Note: OnChange only occurs in response to user actions. Changing the Text property programmatically does not trigger an OnChange event." > The problem is not recursion. It appears the OnChange event is > occuring before the new selected value is entered into the Text > field, so changing it inside the OnChange procedure has no effect. No! The OnChange event is *not triggered* when you change anything in a combo box programmatically. > So I decided the best way to do this would be to send the > WM_SETTEXT message using PostMessage with a global variable > storing the text... Not the way I would have gone about it. 8-) I realize that your query and the answers, so far, relate to message handling but what is it that you are really after? Learning something about message handling or simply getting your app to work? If getting your app to work is your main objective then I would use a different approach. > I want to change the Text property of a ComboBox inside the > OnChange event. But, as I have pointed out above, the OnChange event does not fire when you change the contents of Combo box programmatically so the event handler is not the way to go. Look at the place in your code where you call PostMessage. Presumably at this point you know the new text that you wish to set. Do whatever you wish to do with the text *at this point*, and then set the text directly. No need for messages (WM_SETTEXT, WM_USER or otherwise), event handlers or timers.. Also there is no need to create a global variable to hold the text. In summary, if something is getting too complex and tricky, there is usually a simpler and more direct way. Henry Bartlett Delphi Links Page: ( http://www.hotkey.net.au/~hambar/habit/delflink.htm ) _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

