| |

VerySource

 Forgot password?
 Register
Search
View: 861|Reply: 4

What is the difference between the form's activate event and the create event

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-20 20:00:01
| Show all posts |Read mode
Hello teachers.
    I am a rookie in delphi and ask a few questions from teachers.
    1. What is the difference between the form's onactivate and oncreate?
    2. What is the difference between the onclose, onclosequery, ondeactivate, and ondestroy window closing events?
Reply

Use magic Report

0

Threads

40

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-4-29 13:00:01
| Show all posts
On the surface, the execution order is different.
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-30 14:00:01
| Show all posts
1. What is the difference between onactivate and oncreate forms activation events?

    There is a difference, onactivate, executed when the form is activated (may be executed multiple times)
    oncreate is executed when the form class is instantiated (can only be executed once)
    oncreate executes before onactivate

 2. The onclose of the form,
         onclosequery,
        What is the difference between the ondeactivate and ondestroy window closure events?

     onclose is executed when the form is closed (may be multiple times)
     onclosequery is before executing onclose () before the form is closed
     ondeactivate is executed when the form is not activated
     ondestroy Executed when the form object is destroyed
Reply

Use magic Report

0

Threads

53

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-5-1 13:45:01
| Show all posts
1. onactivate is an activation event, which is triggered when the window gets the focus (that is, the title bar becomes blue) and becomes the current state. This event mainly executes DoNestedActivation
procedure DoNestedActivation (Msg: Cardinal; Control: TWinControl; Form: TCustomForm);
begin
  if Control = nil then Exit;
  {Find the closest parent which is a form}
  while (Control.Parent <> nil) and not (Control is TCustomForm) do
    Control: = Control.Parent;
  if Assigned (Control) and (Control <> Form) then
    SendMessage (Control.Handle, Msg, 0, 0)
end;
On the contrary, it is the ondeactivate event, which is the loss of focus and the transition from the current state to the inactive state

When executing these events, the OnCreate event has already been executed. The onCreate event is an initialization event, also called a create event. Is the constructor
2. The onclose event is an event to be executed before the window is closed. The hide form will not execute this event.
The FormCloseQuery event is more interesting. It is also an event to be executed before closing the window. It is executed before the onclose event. There is a parameter Canclose in this event to restrict you from closing the window. CanClose: = False; indicates that it cannot be closed, on the contrary CanClose: = true allows closing
Corresponding to the oncreate constructor event is the ondestroy destroy function event, which is only the event executed before releasing all window resources at the end of the window
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-5-10 22:15:01
| Show all posts
The above landlord's answer is more complete.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list