Summary of fat fat in worms About window (form) in Delphi

zhaozj2021-02-16  150

Can't release in the pattern form

One method of Form1 is as follows:

VAR

x: TFORM2;

Begin

x: = tform2.createparented (self.handle);

X.ShowModal;

If you use self.release release yours in an event method in Form2, Form2 disappears, but Form1 will never respond to keyboards and mouse. If it is changed to the following:

x: = tform2.createparented (Self.handle); (or x: = tform2.create (nil))

X.ShowModal;

x.release; (or x.free)

It is normal to change the second sentence to x. SHOW.

Conclusion: You can't be release yourself in the pattern form,

Principle: By the code traceability, the discovery form is implemented: Repeat the message and ModalResult attribute value in the showModal method until it is eligible to close your own series of actions. So, if you call the Release or the like in the mode form, you will trigger confusion. To close yourself in the mode form, you can call the Close method, or set the ModalResult property to a non-zero value.

After the display mode form, the schema form cannot be returned to the front of the screen.

Still the first code of the last problem,

VAR

x: TFORM2;

Begin

x: = tform2.createparented (self.handle);

X.ShowModal;

After Form2 is displayed (when FormStyle Attributes = FSNORMAL), switch to other task screens in the operating system

Only the following method can return to the program screen (that is, let Form2 back to the front of the screen):

1. Select the "Show Desktop" and click on the program task on the taskbar;

2. Click Form1, although Form1 cannot receive focus, but cause Form2 to come to the front of the screen;

3. Click on the title bar of Form2.

The following method is unable to let Form2 return to the front of the screen.

1. Click on the area outside the title bar outside of Form2. At this time, although FORM2 is activated, it cannot be returned to the forefront;

2. Click on the program task on the operating system taskbar

3. Switch to the program via the task manager

Cause: Almost certainly it is a bug in delphi.

Solution

Cover the WndProc method of FORM2, capture the WM_ACTIVATE message, get the message after setting, SETWINDOWPOS (Self.handle, HWND_TOP,

0, 0, 0, 0, SWP_NOSize SWP_NOMOVE); this statement makes Form2 back to the front.

Non-mode forms To avoid using a BSDialog border

2003.7.28

It also found that in Excel, the non-moderate border established by Delphi is also the same as the form of BSDialog, and when switching to other tasks in the operating system, Excel is difficult to display,

However, when it is displayed, the form status is normal.

Therefore, non-mode forms should try to avoid using the BSDialog border,

Message response problem

I override the WndProc method attempt to capture the Shift key in any combination key, the code is as follows:

Procedure TFORM1.WNDPROC (VAR Message: TMESSAGE);

Begin

IF message.msg = wm_keyup then

IF getKeyState (vk_shift) = 1 THEN

ShowMessage ('Shift');

inherited;

END;

The results found that each combination key (such as Shift 1), getKeyState captured once, more destined, when captured Shift once, now start only 1 Shift key, can getKeyState, each time Capture the Shift key. in conclusion:

Whether WndProc or mainwndproc method, its Message parameters are processed, that is, there is another process (this process is generated at runtime, with the 1267299 article in the Dharma) to respond to Windows news, The message is processed into the TMESSAGE structure and then passed to the mainwndproc method, which has been different from the original news of Windows.

转载请注明原文地址:https://www.9cbs.com/read-8763.html

New Post(0)