Here I am with the some tests result.
I tried to write an event handler for creating the images, in order not to burden the FormShow() procedure: I've put in the FormShow a PostMessage(... LM_USER+1 ...), and wrote a handler to create the images. The result is the same. Indeed, the program was working under Delphi (yes, I have converted it).
Then I played a little with PostMessage() and CallDefaultHandler, trying to fake the LCL into thinking that a mouse click were done by the user, but it didn.t work. The result is always the same: I must click with the mouse anywhere in the form, on any active area; after that, the image receives the onclick. Clicking on a disabled button, on a scrollbat, using the keyboard, minimize and restore the window... nothing works: I have to click.
I attach the whole project... basically it is a kind of file browser, able to build a database of thumbnails from movies/clips. Using this database, the program can try to find duplicate or similar clips.
To use the program, the user needs at least a video clip (mpeg, avi, mp4 or whatever), mplayer installed, and a directory to store thumbs. When the program runs, use the menu Options/Preferences to tell the program where to find things.
Then, use the upper left controls: "Go root", browse to find a video clip, with the right button call its popupmenu and choose "Create thumbnails for single file". After creation, invoke from the same menu "View cached frames". A window opens where a few thumbnails are visible. The first click on any image is ignored. I added a useless OnMouseDown() to the upper scrollbox, for testing; it exhibits the same behavior, the first click does not fire.
I suppose the LCL, at least in my context, has some variable stuck somewhere which does not reset at the right time. The first click does the job, but I can not simulate it.
Let's see what is happening, if someone has time to do this not-so-simple-test.
Thank you...