Re: How to bypass dialog box and window and create bitmap frames for animations of scrolling an listbox

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



See below...
On Wed, 17 Sep 2008 20:14:12 -0700, "Siegfried Heintze" <siegfried@xxxxxxxxxxx> wrote:

I have a custom LCD display connected to a embedded processor with which I
communicate via USB.

Can someone point me to an example of drawing to a GDI+ bitmap without
drawing to a window first?
*****
Create a DIB section, select it into a memory DC, draw to the memory DC
*****
I want to create a list box in a GDI+ bitmap
instead of a window and then scroll the contents of the listbox by
simulating mouse clicks while periodicatlly piping a copy of the bitmap
display (via IMediaSample) down thru the USB to create an animation on the
embedded device.
*****
Seems to be a complex solution to a simple problem, but essentially, once you've drawn the
bitmap into a memory DC, you can BitBlt any arbitrary rectangle into another window's DC
during the OnPaint handler, so you can simulate scrolling by doing a different BitBlt, or
perhaps by changing the window origin of the target window. Note that you will probably
need to create a clipping region equal to the client area you want to display and select
that clipping region in, because most controls have a clipping region which is the parent
(they seem to have fixed this fundamental design error in Vista)
*****

I don't know how to create a listbox outside of the context of a dialog
box -- so I need help there. I don't know how to create any window (let
alone a listbox) on a GDI+ bitmap so I need help there too. I guess I would
set up a winproc and use SendMessage(WM_LBUTTONDOWN ...) to the handle of
the bitmap?
****
You would not create a list box. You would create a bitmap, and simulate the drawing of
the list box contents. I don't see why you want to go through all this work instead of
just creating a list box, but no, you can't really get a list box to paint itself onto a
bitmap.
****

Also, I want to populate each element of the list box with images. I've seen
the code for that in MFC books. I'll need a pointer for that too.
*****
It depends on what you mean by "images". For example, you can do an owner-draw-variable
listbox, but your maximum height is limited to 255 pixels. Some years ago I had to do a
control for a client that needed unlimited image size (1024 was common) in a listbox, as
well as scroll-by-image and scroll-image capabilities (up/down, left/right). This
required a completely custom control. They also ended up adding "iconize" so the images
could be collapsed, and double-clicking an image expanded it to full size.

To do this, you typically do an owner-draw-no-strings style listbox, and sinceyou are not
using MFC, you would use the ListBox_AddString (if you are not using MFC, you should be
using windowsx.h!) but cast a structure of your devising to the ItemData value (I think it
is the LPARAM). Then, in your WM_DRAWITEM handler for the listbox, or in my case, a
WM_PAINT for the custom control; you examine the contents of the itemdata structure, which
in my case included such things as the BITMAP structure, the HBITMAP, flags about the
iconized state, the current horizontal and vertical scroll position of the image, etc.,
and derived the necessary BitBlt information from that. Note that I could have as few as
one item, partially displayed, or a whole lot of iconized items (StretchBlt rendered them
largely unintelligible, but apparently the users could recognize what they needed), so you
would get many WM_DRAWITEM messages. It helps to set a clipping region equal to the
drawitemstruct.rcItem to avoid spillover.
joe
*****

Thanks!
Siegfried

.



Relevant Pages

  • Re: Copying Bitmap
    ... Remember I said that my code does not work when the window is obscured by another window. ... CDC dc_bitmap; ... // Copy output bitmap onto display target ... Add your control notification handler code here ...
    (microsoft.public.vc.mfc)
  • Re: how to get a bitmap from the screen and then inside lisp?
    ... Getting pixels off the screen quickly is a bit complicated and you ... have to do some decoding of Windows bitmap data structures. ... int x, int y, int w, int h, ... // get the window handle ...
    (comp.lang.lisp)
  • Re: How to use DrawDibDraw
    ... You may choose the entire bitmap or part of the bitmap to render(e.g., ... you may choose to render to the entire window or some part of the ... seem to be missing from "bitmapinfoheader" that I see in the hex edittor. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Scaling of data into dc
    ... you end up scaling the bitmap which gets really lousy representation for the ... Well, I understand the sizing of the viewport, but sizing of the window ... I do apply these commands to the dc of MemDC (so it is inside the MemDC ... Scaling will then be automatic. ...
    (microsoft.public.vc.mfc)
  • Re: Problem drawing in the window
    ... client area is covered with a bitmap. ... sluggish and the drawing blinks occasionally. ... Are you drawing the bitmap onto the window, and then drawing on top of that, ... Then, each time the window is repainted, simply draw the in-memory bitmap ...
    (microsoft.public.win32.programmer.gdi)