[All]
Pop Up menu on DBGrid does not correctly work with Showmodal command
Abstract: Pop Up menu on DBGrid does not correctly work with Showmodal command
Product: Borland Developer Studio.
Version: 2006
Question:
Using popup menu with a db or string grid - showmodal of another form does not give focus to required controls
Answer:
The issue is that the grid is not getting the focus messages in the right sequence, because a grid is a composite component it is important that the messages arrive in the correct sequence.
So to rectify the following needs to be done:
1) forcing control to the form that you are going to popup.
2) making sure the messages are sent to the grid.
Adding the code
Windows.SetFocus(DetailForm.handle);� and
Application.ProcessMessages;
before the showmodal command will rectify this issue.