[ sulja @ 20.02.2006. 16:04 ] @
Da li je moguce nekako preko .Net koda uhvatiti samo screen shot kontrole na formi aplikacije, i ako jeste gde mogu da pogledam kod ? Unapred hvala |
[ sulja @ 20.02.2006. 16:04 ] @
[ Oliver Klaćik @ 20.02.2006. 22:47 ] @
To možeš jedino učiniti pozivanjem neke Win32 GDI funkcije...
[ sulja @ 21.02.2006. 08:08 ] @
Ok, ali kako, koju GDI funkciju, jel ima negde da se pogleda kod ili primer ?
[Ovu poruku je menjao sulja dana 21.02.2006. u 09:51 GMT+1] [ Oliver Klaćik @ 21.02.2006. 08:50 ] @
Pogledaj ovde:
http://www.c-sharpcorner.com/U...005234547PM/ScreenCapture.aspx A pade mi na pamet i ova varijanta, ako si u mogućnosti da koristiš Print Screen na tastaturi: Code: If Clipboard.ContainsImage Then Dim b As Bitmap = CType(Clipboard.GetImage, Bitmap) b.Save("C:\1.bmp") End If Btw, ne služi forum da dobiješ gotova rešenja, već da te neko uputi u pravom smeru. Ako ja treba da listam MSDN zbog tebe, koja je poenta? [ mmix @ 21.02.2006. 15:27 ] @
Decku treba screenshot kontrole, ne celog ekrana...
Primer koji je dat je ok, treba ga samo modifikovati da koristi HDC kontrole umesto HDC-a ekrana: Code: using System; using System.Runtime.InteropServices; using System.Drawing; using System.Drawing.Imaging; using System.Windows.Forms; class GDI32 { [DllImport("GDI32.dll")] public static extern bool BitBlt(System.IntPtr hdcDest,int nXDest,int nYDest,int nWidth,int nHeight,System.IntPtr hdcSrc,int nXSrc,int nYSrc,int dwRop); [DllImport("GDI32.dll")] public static extern System.IntPtr CreateCompatibleBitmap(System.IntPtr hdc,int nWidth, int nHeight);[DllImport("GDI32.dll")] public static extern System.IntPtr CreateCompatibleDC(System.IntPtr hdc); [DllImport("GDI32.dll")] public static extern bool DeleteDC(System.IntPtr hdc); [DllImport("GDI32.dll")] public static extern bool DeleteObject(System.IntPtr hObject); [DllImport("GDI32.dll")] public static extern int SelectObject(System.IntPtr hdc, System.IntPtr hgdiobj); } class Export { public static void SaveControlImage(Control ctrl, string path) { Graphics graph = Graphics.FromHwnd(ctrl.Handle); System.IntPtr ctrlHdc = graph.GetHdc(); System.IntPtr hdcDest = GDI32.CreateCompatibleDC(ctrlHdc); System.IntPtr hBitmap = GDI32.CreateCompatibleBitmap(ctrlHdc, ctrl.Width, ctrl.Height); GDI32.SelectObject(hdcDest, hBitmap); GDI32.BitBlt(hdcDest, 0, 0, ctrl.Width, ctrl.Height, ctrlHdc, 0, 0, 0x00CC0020); Bitmap bmp = new Bitmap(Image.FromHbitmap(hBitmap), ctrl.Width, ctrl.Height); bmp.Save(path, System.Drawing.Imaging.ImageFormat.Bmp); graph.ReleaseHdc(ctrlHdc); GDI32.DeleteDC(hdcDest); GDI32.DeleteObject(hBitmap); } } pozivom Export.SaveControlImage prebacice se area koji kontrola zauzima u BMP fajl. Postoji samo jedan problem sa ovim, diaply HDC nije multi-layer, sto ce reci uradice snapshot onoga sto se trenutno nalazi na erkanu na tim pozicijama (ako je tvoja aplikacija pokrivena nekom drugom dobices sliku iz te druge aplikacije ![]() Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.
|