HTML in a Listbox cell

I want to be able to render some HTML in a listbox cell. Any ideas on how to achieve that?

Ideas I’ve had:

  • Somehow embed an HTMLViewer into each cell (doesn’t sound very efficient).
  • Render the HTML in an “hidden” HTMLViewer and somehow get a Picture of the result (doubt that’s possible).
  • Write my own HTML renderer (not going to happen).

You would basically need to write your own renderer. You could add an HTMLViewer and size it to the fit the cell then shift its position as needed, but it’d be clunky and prone to breakage. I don’t think DrawInto works for the HTMLViewer, so that’s out as well, and you’d have to wait for the page to load, then grab the picture, then draw it to the cell for each row…which would likely be far too slow.

If you plain to only do simple HTML, you could use something like the HTML rendering from GraffitiHTMLLabel to spit out a picture of the HTML, but you’ll be incredibly limited.

In your shoes, I would generate a picture for what you want to display and draw it using the ListBox’s events rather than muck about with HTML rendering in a cell.

You can get a picture of the HTMLViewer (search the forums for HTMLViewer EmbedWithin or check out MBS)

It’s still going to be slow if he goes with a similar method. Initiate the page load, wait for the page to fully load, grab the image, draw the image to the cell, multiply by number of rows. Additionally, there’s no way to interact with individual elements within the picture such as links. If interaction is key, and he’s not writing a webpage screenshot app, it’s best to develop a method of drawing the desired result as a Picture directly and handle the mouse positioning based on link location and the like determined within the drawing routine.

[quote=380030:@Paul Rodman]I want to be able to render some HTML in a listbox cell. Any ideas on how to achieve that?

Ideas I’ve had:

  • Somehow embed an HTMLViewer into each cell (doesn’t sound very efficient).
  • Render the HTML in an “hidden” HTMLViewer and somehow get a Picture of the result (doubt that’s possible).
  • Write my own HTML renderer (not going to happen).[/quote]
    Could you describe what it is that you’re trying to accomplish with this?

I have an application that allows editing of HTML text (using the HTML Editor add on). The editor allows one to create “styled” text. I want be able to display that styled text in a list box cell.

Seems daunting to come up with an HTML interpreter that addresses CSS.

The HTMLViewer indeed cannot drawinto.

However, on Mac, you can drawinto a window that bears an HTMLViewer and get the picture from that HTMLViewer.

It should not be too difficult to size the resulting image.

On Windows, you should be able to briefly show a window and capture a screen shot with BitBlt before hiding it again.

New : I just tried 's own DrawInto, and it fixes the issue with HTMLViewer, which now can be drawinto.

Paul, you now have a solution both on Mac and Windows.

https://www.dropbox.com/s/im8d4ds68e74u61/DrawInto2.xojo_binary_project?dl=1

Unfortunately that is for Windows-only, and my app is Mac-only, but it does give me an avenue to explore. Thanks.

Paul, PLEASE READ the previous post. I posted a solution for Mac.

[quote=380115:@Michel Bujardet]However, on Mac, you can drawinto a window that bears an HTMLViewer and get the picture from that HTMLViewer.

It should not be too difficult to size the resulting image.[/quote]

Sigh :confused:

Ah, but you posted that yesterday. My aging brain can’t remember that far back