Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Interface and Graphics (http://www.xtremevbtalk.com/-net-interface-and-graphics/)
-   -   Save Image in AxWindowsMediaPlayer Control (http://www.xtremevbtalk.com/-net-interface-and-graphics/327713-save-image-axwindowsmediaplayer-control.html)

VB_Alien 07-28-2015 06:49 PM

Save Image in AxWindowsMediaPlayer Control
I'm trying to save an image from the
AxWindowsMediaPlayer control but
i'm saving the desktop image instead.

I know where i'm going wrong but i
don't know what else to try.

In my code, i'm using Graphics.CopyFromScreen
and i know it's grabbing the desktop instead
of the wmp control surface.

Is there a way to reference the wmp control
when grabbing an image?

VB_Alien 07-29-2015 10:48 AM

I've made a little headway om this but it
still isn't what i'm looking for.


Private Function TakeImage(ByVal Width As Integer, ByVal Height As Integer) As Bitmap
        Dim Img As New Bitmap(Width, Height)
        Dim g As Graphics = Graphics.FromImage(Img)

        g.CopyFromScreen(Mp1.PointToScreen(Mp1.ClientRectangle.Location), Point.Empty, Mp1.ClientSize)

        Return Img
    End Function

I'm still using CopyFromScreen but i'm also using the points
and location of the media player to get my image from.

Now i get an image of the whole media player control, complete
with button controls but i also get the image in the player.

Also, i have a save file dialog box coming up when i attempt to save
an image, so that i can save it where i want it. After i click the save,
my code saves the image of the save dialog box, instead of the media
player image, unless i first move the save dialog box off to the side

So it looks like my code is not the way to go to get an image
from the media player. Does anyone know of a better way to
capture and save and image from the media player control or
is it even possible?

VB_Alien 07-29-2015 12:12 PM

I just found out that windows media player stopped
doing screen captures since version 11, so there
definitely isn't any functions in that player that will
capture and save screen shots.

On that note, i'm giving up. No sense beating a
dead horse.

I'll check into possibly using a different media player
that supports screen captures.

alp0001 07-30-2015 10:04 AM

Howdy VB_Alien,

Not familiar with .net capabilities nor what the intent is for, but I will suggest an approach on capturing screen shots on whatever window you want to use:
1) Make sure you have focus on the window/program you want to capture.
2) Simulate the Alt + Print Screen key presses. This should capture just the contents of the entire program/window you are interested in and not the entire desktop.
3) Now that the image is in memory, save it to disk to do further manipulation as needed.

VB_Alien 07-31-2015 10:07 AM

Thanks for replying alp0001. This way captures the whole
window and i was hoping to just capture the image in the

I was wanting to capture the image and then save it in jpeg
format to my hd.

I have a player that i created a while back that uses mciSendString
to play video files and i think i was able to save the image in the
player window (a picturebox) to the hd using bitblt. Maybe i'll try
using that to see what happens.

Anyway, thanks for replying. I appreciate it.

boops boops 08-14-2015 01:37 PM

Graphics.CopyFromScreen has always been unable to capture DirectX and other "non standard" screen renders. BitBlt is more capable. Maybe this code is worth trying:

        'based on code posted by NoBugz MVP at:

        Public Shared Function CopyFromScreen(ByVal screenRect As Rectangle) As Bitmap
                Dim hDesk As IntPtr = GetDesktopWindow()
                Dim hSrce As IntPtr = GetWindowDC(hDesk)
                Dim hDest As IntPtr = CreateCompatibleDC(hSrce)
                Dim hBmp As IntPtr = CreateCompatibleBitmap(hSrce, screenRect.Width, screenRect.Height)
                Dim hOldBmp As IntPtr = SelectObject(hDest, hBmp)
                BitBlt(hDest, 0, 0, screenRect.Width, screenRect.Height, hSrce, screenRect.Left, screenRect.Top, _
                  CopyPixelOperation.SourceCopy Or CopyPixelOperation.CaptureBlt)
                Dim bmp As Bitmap = Bitmap.FromHbitmap(hBmp)
                SelectObject(hDest, hOldBmp)
                ReleaseDC(hDesk, hSrce)
                Return bmp
        End Function

Can I assume that you know how to declare all those Win32 APIs (GetDesktopWindow, GetWindowDC etc.)? If not, I have a Win32 class somewhere: I'll see if I can dig it out for you tomorrow.


All times are GMT -6. The time now is 11:38 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.