Re: LoadImage API



Mike,

The refresh line did the trick, and now the project is working as I intended
it.

Thanks for your help,
Jim

"Mike Williams" <Mike@xxxxxxxxxxxxxxxxx> wrote in message
news:dq68n0$tp1$1@xxxxxxxxxxxxxxxxxxxxxx
> "Fella" <Nospam@xxxxxxxxxx> wrote in message
> news:r6xxf.460383$zb5.373967@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>> The .bmp never shows in the picture box. I appears that LoadBitmap
>> is supposed to create an object must associate a device context to,
>> and the object isn't being created in the first place.
>
> I presume you're talking about the LoadImage API. If so then that API
> loads a bitmap (from disk in your specific case) and resizes it according
> to the parameters you give it and assigns the result to a bmp object,
> returning the handle of the bmp object for you. The rest of the code you
> posted then creates a device context and selects that bitmap into the
> device context and then "blits" it into a picture box. I've just copied
> and pasted the code you posted into a new VB project and it works fine.
> Obviously I had to change to filename to a bmp that actually exists on my
> own machine, but when I did so it worked fine, displaying the bitmap in
> the picture box. No problems at all. Have you tried getting riud of the
> "Appt.Path" stuff and instead hard coding the filename of a bitmap in your
> main drive (for example, "c:\mypic.bmp"). Try creating such a bitmap and
> putting it in your main drive root folder and doing just that. It
> certainly works for me. By the way, does your picture box have its
> Autoredraw property set to True? If it does (and if it is not currently
> visible on the display at the time the picture is loaded) then you won't
> see the result, because it will not be persistent. So, check if your
> picture box has its Autoredraw proiperty set to True and if it does then
> add the line "Picture1.Refresh" just after the blit line of code.
>
> Basically, I can't fault the code you have posted. It works fine for me.
> When you say you have "loaded the bitmap into the picture box as I
> suggested and there is still no change", what exactly do you mean. Exactly
> how did you load the bitmap into the picture box? And what happened when
> you did so? Are you *absolutely sure* that the bitmap exists and thas has
> exactlky the name you have coded into your code and that it actually
> "lives" in your app's "App.Path" folder? Don't forget that the App.Path
> reeturns a different path whe nyour code is run in the VB IDE than it does
> when it is run as a compiled exe. Have you checked that? Ditch the
> "App.Path" stuff for a minute and enter a full "hard coded" path and
> filename into your code of a valid bitmap and see what happens.
>
> Mike
>
>
>


.



Relevant Pages

  • Re: Cannot Save to my desktop
    ... click on a picture I want to save and choose .bmp ... unreadable format. ... could do this and get a bitmap file that I could open ... Internet Explorer Save As BMP Problem ...
    (microsoft.public.windowsxp.photos)
  • Specified Cast not Valid: Object to Bitmap
    ... The bitmaps/images come from a DLL. ... A picture is requested from the DLL as follows: ... Dim BMP As Bitmap ... BMP = CType(OBJ, Bitmap) ...
    (microsoft.public.dotnet.framework)
  • untitled BMP
    ... When I Rt Click and save a picture from an email or on the web it is always ... saved as a "untitled" bitmap, ... JPGs and I Rt. ... KNOW it's a JPEG and not a BMP. ...
    (microsoft.public.windowsxp.general)
  • Re: Did anyone see this tv prog?
    ... On 05/01/2006 Aries wrote: ... > No it has to be a suitable:') bitmap (bmp) black and white picture ...
    (uk.people.silversurfers)
  • Re: Zoom in/ Zoom out images
    ... Picture control in the same dialog. ... As soon as you leave this function the destructor is called and the bitmap object is ... The drawing must be done in the OnPaint handler. ...
    (microsoft.public.vc.mfc)

Loading