Method Perform inside ListBox class - listbox

could someone please tell me (or give me a proper link) what is method Perform inside of ListBox class used for?
Thanks in advance.

The Perform() method sends a window message directly to the control's WindowProc without going through the calling thread's message queue. It is similar to the Win32 API SendMessage() function, but without going through the API to deliver the message.

Related

How do I intercept form creation outside of the form in Delphi?

I'm trying to find a generic way to know when any form has been created with windows events or something of the sort. Currently I'm listening for WM_PAINT events within TApplicationEvents.OnMessage and then when I detect a Msg.hwnd I use FindControl() and see if the control is TForm. Then I know this form is being opened and I can then do some styling that is uniform across the hundreds of forms in the application.
When I listen for WM_CREATE events instead I get nothing. I'm not sure why. I was thinking this would tell me the form has been created, but evidently it doesn't. At the moment, there are a couple of timing issues that cause only a few forms to render, and then a split second later my styling kicks in. I only find this in some cases, and the majority of the cases it works just fine. So you have the form opening up on its original styling only to have it change a split second later - in a few cases.
The moment I detect a form like this, I also reassign its OnClose event so that I can perform some operation when the form closes, and then I redirect it to its original OnClose event handler. I've tried doing the same thing with its OnCreate and OnShow events, but that doesn't fire at all this way. The OnClose have been working perfectly, though.
I need my styling to kick in first before the form is shown. Any ideas?
I'm trying to find a generic way to know when any form has been created with windows events or something of the sort.
At the Win32 level, there are events related to window creation, such as:
SetWindowsHookEx() hooks, such as the HCBT_CREATEWND notification of a WH_CBT hook.
SetWinEventHook() events, such as EVENT_OBJECT_CREATE.
The problem with this approach is that the events are triggered after the underlying HWND struct has been allocated, but before it has been sent WM_(NC)CREATE messages. So, for instance, calling FindControl() inside a handler for these events won't work, because the VCL has not yet established the link between the HWND and the TForm object.
At the VCL level, there are no global events for Form creation. There is only the TForm.OnCreate event. If you need to handle that globally for all of your Forms (or even just some of them), you should create a base TForm class that overrides the virtual DoCreate() method (and/or other virtual methods, like CreateWnd(), PaintHandler(), WndProc(), etc), and then derive your desired TForm classes from this base class.
When I listen for WM_CREATE events instead I get nothing. I'm not sure why.
WM_CREATE is not a posted message. The Win32 CreateWindow/Ex() API sends this message directly to the window's message procedure while creating the window. The message does not go through the creating thread's message queue, and thus will never appear in the TApplication(Events).OnMessage event.
At the moment, there are a couple of timing issues that cause only a few forms to render, and then a split second later my styling kicks in. I only find this in some cases, and the majority of the cases it works just fine. So you have the form opening up on its original styling only to have it change a split second later - in a few cases.
If you are doing custom styling inside of a WM_PAINT handler, there should be no timing issues.
On the other hand, why are you not utilizing the VCL's built-in styling system? For instance, you can use TCustomStyleEngine.RegisterStyleHook() to register your own styling hook derived from TStyleHook for your desired classes.
Or, you could simply define your own custom Style for the VCL to use natively, no need to write any code for this.
The moment I detect a form like this, I also reassign its OnClose event so that I can perform some operation when the form closes, and then I redirect it to its original OnClose event handler. I've tried doing the same thing with its OnCreate and OnShow events, but that doesn't fire at all this way.
Correct, because the TForm object has already been created and its window is visible onscreen before it receives WM_PAINT messages from the OS.

How to check if a method is available in an OCX interface

Currently I have an OCX embedded in our product using standard boilerplate Delphi importing of the OCX. The vendor has issued a new version of the OCX that uses the exact same GUIDs for everything (object and interfaces) but there are changes to the API. These changes are quite limited but I'm having some difficulty coming up with a reliable way to identify if the installed OCX is using the old or new version. The obvious way is to drill into the interface and check if a specific method is available from the object once it has been instantiated. I would like to do this by actually asking the object what the dispatch ID is for a particular method to see if it is present.
I don't want to use the approach of calling a new method and getting an exception as the object won't work until it has been initialised and the initialisation API is one of the things that has changed. This means that any call of a new method before initialisation will fail anyway.
Does anyone know what would be the proper way to poke through the Delphi wrapper and find out if a particular method can be resolved?
The answer is actually in your question:
I would like to do this by actually asking the object what the dispatch ID is for a particular method to see if it is present.
An OCX object implements the IDispatch interface, and IDispatch has a GetIDsOfNames() method for the very purpose of returning the dispatch ID of the object's methods and properties (for use with IDispatch.Invoke()). If a requested name is not known to the object, GetIDsOfNames() returns DISP_E_UNKNOWNNAME.

Override Eventbrite Register Button

Have anyone tried overriding the Eventbrite "Register" button? Essentially,I am looking to make an api call whenever person registers/RSVPs to the Eventbrite event.
So far my exploration has not yield any outcome. Let me know if anyone have any pointers to help me explore further.
Thank you in advance!
Sourabh
Although this is not directly overriding the register button, you can trigger a webhook on a new registration, which would allow your application to process some logic. The webhook will not send the attendee information, but allows it to be looked up by an API call back to Eventbrite. For more information see https://www.eventbrite.com/developer/v3/api_overview/webhooks/

Passing message to another window

I would like to write an application which passes every message it receives to another window. For example, I have an application where user can press some keys, move mouse over it, etc. and I want all these messages passed to, for example, MS Paint.
How do I do this? Any ideas? As far as I know, there may be a problem with sending key strokes to another window, so please advice as well.
EDIT
Okay, maybe I will give you more description of what I'm looking for.
My applications displays a window of another application on the form. Now I would like to control the other window using messages sent to my application's form (like key downs, mouse moves, etc.).
I have been thinking of passing all the messages my form receives to the window of the application I'm kind of 'embedding' into my own. By 'embedding' I mean making the application window display on my form.
Maybe there's another solution to my problem. Please advice.
Thank you for your time.
Some messages (i.e. input messages) arrive through the message queue and the rest are delivered straight to the recipient windows. What you are asking to do therefore requires you to do all of the following:
Implement a top level message loop that retrieves messages from the queue and sends them to the other app.
Reimplement all modal window loops to pass all messages on.
Replace the window procedure for all windows in your process with one that passes all messages on to the other app.
Look for other opportunities for messages to arrive that I have not covered.
I can't imagine that this is really going to be the solution to your problem, whatever that problem is.
Forwarding the messages is definitely possible and easy, but it likely won't do what you are expecting. Take a look here.
Override the form's DefaultHandler() and post every message it gets to the other form. If there are any explicit message handlers in the form or even some controls then you may not see those messages in DefaultHandler().

Hourglass in grails

I have a Grails app that downloads a file that's generated from a database query that takes about a minute. How can I implement a sort of hourglass (or something prettier) so the user knows the request is being processed ?
The corresponding link calls a controller method that does the processing and uses the response object.
I think you want to do something like a spinner notification while an operation is being processed.
you can check this out

Resources