How to shield the flash control in Delphi pop-up menu

xiaoxiao2021-03-06  19

There are many people who have asked how to shield the flash control, there are many people who answer, basically all about intercepting the Application message, or inheriting a new control, overloading the MouseDown message, the first solution, as if It is simple, but there is a problem is that if the message of the column app, it will inevitably cause all the messages of the application to execute this intercept process, although the other news can be filtered, but the execution judgment itself is required. Time (although every time there is not much time, there is a lot of time, there is a lot of time), and another method is to inherit the control, you can write and trouble, if you need to use it in the design period, Re-register. Is there a simpler way? Don't filter all application messages, don't you need to override controls? There is also a third method, which is a method of deLPHI to reserve messages for processing a single control in the case of no overwriting controls, but this method is rarely used because the control control message is rarely used because It is an event of the TControl class, but it defines in the public domain, so it is not visible when design: this is TControl.WindowProc, it is the TWndMethode process type, the type is defined in the classs unit: twior = procedure (Var Message: tMessage , but we can't just write this event handle because the instance of the TControl class has assigned this event at the beginning of the creation, its value is the WndProc method of the TControl class. And TControl is relying on the WndProc method. Distribute messages to each message to handle handle, if we simply rewrite the WindowProc event, turn off message distribution, it will cause all messages to be handled, but must be programmed to process messages in WindowProc events, the result may be This control can only draw a framework. In order to rewrite this WindowProc event, do not have to re-process the message distribution, so we have to want to save the original event handle before rewriting this event, and then call the message processing function. the original event handler processes the message distribution specific source, see: type TFormProg = class (TForm) private  FFlash:. TShockwaveFlash; // need to dynamically create  FFlashMes: TWndMethod; // save the original Flash control WindowProc event handler protected  procedure. FlashMes (var Message: TMessage);  {Private declarations} public end; var FormProg: TFormProg; implementation procedure TFormProg.FlashMes (var Message: TMessage); begin if (Message.Msg = WM_RBUTTONDOWN) then // if the right button : Flash control is popped up in the message pressed in the mouse. Begin   fflash.Perform (WM_RButtonup, Messag E.WPARAM, Message.lParam;                                                  e                                                                          Press the message,                                                                                                                                                This will not pop up the right-click menu.

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

New Post(0)