Scott Clark mentioned this to All:
SC> This is not a problem, but when I create a form and use the Show method
SC> for displaying it it appears to be acting strangely. Firstly, I cannot
SC> get any labels on the form to display, and the abort button I put on
SC> the form is just shown as a white square where the button was placed.
Also
SC> the form cannot be dragged around while it is shown.
If you put your processing in the OnShow event, the form is showing is it
not? But all the controls have not finished drawing. And they can't
until your code in the OnShow event is done.
To handle this situation, create your own Windows message and post it to the
form in the OnShow event. When your form receives the message, all paint
messages should have been handled and you can then begin your code.
interface
uses
Forms, Messages, Windows;
const
WM_ACTIONMESSAGE = WM_USER;
type
TMyForm = class(TForm)
...
protected
procedure DoAction(var Msg : TMessage); message WM_ACTIONMESSAGE;
...
implementation
procedure TMyForm.OnShow(Sender : TObject);
begin
PostMessage(Handle, WM_ACTIONMESSAGE, 0, 0);
end;
procedure TMyForm.DoAction(var Msg : TMessage);
begin
{ Do your stuff here }
end;
SC> If I use ShowModal to display the form then it acts as I would expect it
SC> to act, but none of the code I put in the OnShow event gets executed.
I find that odd, since the OnShow event gets executed when either Show or
ShowModal is used. Using Show, however, makes the form modeless, so if the
user clicks on another visible form, your current form will disappear behind
it.
SC> its just the frilly bits I am trying to add that do not, and I
SC> was led to believe that Delphi was good at all that stuff. :(
It is, but you still have to understand how Windows works.
...Gary
--- GoldED 2.41
---------------
* Origin: The Flying Circus BBS. (1:2410/905)
|