I have a queue and based on its contents I create image controls at runtime. So if I have 5 records in the queue, I use CREATE() to put 5 image controls on the window. This works.
But I want these images to become ActiveImages because I need to get mousedown events when user clicks on any of these images.
I’ve manually added INCLUDE(‘ActiveImage.inc’),once in global embeds, I’ve declared:
img1 ActiveImage in data of the window
Now here’s the problem. If I put an image control in designer onto the window and call img1.init(window,?image1,0,0) anywhere in ThisWindow.Init embed, it works.
So for some reason INIT has to be rather early in the process. But the trick is I’m not putting image controls in designer, I’m creating them at runtime. And calling img1.init after CREATE() sometime later on does not work, meaning mousedown is not reported as event. Sort of chicken-egg issue.
Any idea how can I make this work? Create image controls at runtime and catch an event when users clicks on any of them (of course I need to know on which control the user has clicked so I can act properly later on). If this can be done without using activeimage, no problem. I just need events fired when users clicks on those images.
Put FEQs of the created controls in a queue and then check for them inside the accept loop
smth like
CurrentField = FIELD()
CLEAR(CreatedControlsQ)
CRCNTQ:FEQ = CurrentField
Get(CreatedControlsQ,CRCNTQ:FEQ)
If ~ErrorCode()
CASE CurrentField
OF Image1FEQ
CASE EVENT()
OF EVENT:Accepted
…
RIght now I’ve checked the activeimage source and one thing did the trick. I called INIT after creating the control and after that I called post(event:openwindow,ImgFEQ#) and it works. Seems like source expects the “usual” OpenWindow event fired to process all needed to activate activeimage.
Now only one thing remains. I can have 50 records in my queue, so my loop creates 50 controls. All good, but for activeimage I need to declare:
img1 activeimage
img2 activeimage
.
.
img50 activeimage
in DATA section.
or perhaps ditch whole activeimage and just somehow properly use REGISTEREVENT? But that’s above my knowledge, there are some pointers and addresses involved
Perhaps you could use an ImageEx viewer control (or multiple ones if you need them separate). Not sure the result you’re trying to achieve. You could maintain a queue of ImageEx bitmaps, and load into the viewer as needed. I do that for maintaining multiple UNDO.
I’m reading jpg files from a folder, trying to display thumbnails vertically and using imageex to display a larger image of selected thumbnail. Obviously number of jpgs varies hence I make image controls on the fly. I like vertical positioning of thumbnails with scroll attribute on window so i get nice scrollbar to move down the thumbnails. I’m closw but would need to figure out how to properly register mousedown events on images at runtime - use part of activeimage class. Then it would all be done at runtime. I guess more cw developers could use this as image gallery then too…
Sounds neat. You could also use a single bitmap to contain all of the thumbnails. If you maintain a queue of coordinates, you could identify which thumbnail was clicked on. It would scroll just like a single image.
Would not take all that much work to write a function that receives a list of files and:
Renders a thumbnail with the thumbnail class within the size constraints you define.
Saves the thumbnailed bitmap object to a queue, along with the height/width, and position within the grid.
Processes the queue, and based on the total size and quantity of thumbnails, creates a host bitmap where you can draw all of the thumbnails. As you draw each thumbnail, save the position in the queue.
I think if you spent the time to get that working as desired, you would have a product that’s much easier to maintain than ### image controls.
Made it work without activeimage. What activeimage does is actually create regions around all images and deal with that. I’m quite happy with the solution
you could use Mark Goldberg’s solution with images inside an image control but we found that problems can occur with positioning images Xpos and Ypos
another solution is to display the image controls over a list with the height of the list set to the height of the images to scroll…
as the list scrolls it scrolls your images but you run into the problem of when to hide the images into and out of view.
The help used to show an OCX solution for this but of course that wont show up if you use the new Internet solution from SV and the Anyscreen development group.
I’m rather happy with what I’ve done, works great, is dynamic regarding data etc. Only annoyance is when you scroll the images up and down, for some reason window flickers sometimes, no idea why or how to eliminate that…