VB2010 Screenshot von einem Panel was Autoscroll hat

  • VB.NET

Es gibt 10 Antworten in diesem Thema. Der letzte Beitrag () ist von GMT.

    VB2010 Screenshot von einem Panel was Autoscroll hat

    Hallo Leute,

    ich habe ein Panel was Autoscroll auf True hat dort drinne ist wiederrum ein Panel was dann größer ist als das Panel1
    Das ist ja kein Problem da ich ja Autoscroll auf True habe jetzt möchte ich aber gerne Einen Screenshot von dem gesamten
    Inhalt aus Panel1 machen, wie kann ich das machen?

    Grüße GMT
    Das geht so nicht, sieh Dir mal die Definition von Screenshot an.
    Möglicherweise kannst Du über eine Umleitung der Paint-Funktion was machen.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Naja wäre es vill. eine Lösung was natürlich echt S***** ist und Umständlich, Das Panel zu vergrößern und dann wieder Verkleinern? So das es auf Den Bildschirm passt, Aber dann gibt es natürlich ein Problem wenn man einen zu Kleinen Bildschirm hat :) ??!!!

    Grüße GMT
    Ok mein Code sieht jetzt so aus:

    VB.NET-Quellcode

    1. Dim bmp As New Bitmap(frm.Panel4.ClientRectangle.Width, frm.Panel4.ClientRectangle.Height)
    2. frm.Panel4.DrawToBitmap(bmp, frm.Panel4.ClientRectangle)


    Aber dann bekomme ich diese Fehlermeldung:
    Eine Ausnahme (erste Chance) des Typs "System.ArgumentException" ist in System.Drawing.dll aufgetreten.

    Wo liegt das Problem er hat bei der 2 Zeile von dem Code oben ein Problem!?

    Grüße GMT
    Spoiler anzeigen
    System.ArgumentException wurde nicht behandelt.
    Message=Ungültiger Parameter.
    Source=System.Drawing
    StackTrace:
    bei System.Drawing.Graphics.GetHdc()
    bei System.Windows.Forms.Control.DrawToBitmap(Bitmap bitmap, Rectangle targetBounds)
    bei test.hochladen.Screenshot1() in C:\Users\Admin\Documents\Visual Studio 2010\Projects\test\sicherung\test\Forms\hochladen.vb:Zeile 12.
    bei test.hochladen.Screenshot1() in C:\Users\Admin\Documents\Visual Studio 2010\Projects\test\sicherung\test\Forms\hochladen.vb:Zeile 12.
    bei test.hochladen.hochladen_Load(Object sender, EventArgs e) in C:\Users\Admin\Documents\Visual Studio 2010\Projects\test\sicherung\test\Forms\hochladen.vb:Zeile 22.
    bei System.Windows.Forms.Form.OnLoad(EventArgs e)
    bei System.Windows.Forms.Form.OnCreateControl()
    bei System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
    bei System.Windows.Forms.Control.CreateControl()
    bei System.Windows.Forms.Control.WmShowWindow(Message& m)
    bei System.Windows.Forms.Control.WndProc(Message& m)
    bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    bei System.Windows.Forms.Form.WmShowWindow(Message& m)
    bei System.Windows.Forms.Form.WndProc(Message& m)
    bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    bei System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
    bei System.Windows.Forms.Control.SetVisibleCore(Boolean value)
    bei System.Windows.Forms.Form.SetVisibleCore(Boolean value)
    bei System.Windows.Forms.Control.Show()
    bei test.frm_game.hochladen_abdungeln() in C:\Users\Admin\Documents\Visual Studio 2010\Projects\test\sicherung\test\Forms\frm_game.vb:Zeile 2277.
    bei test.frm_game.bt_beenden_Click(Object sender, EventArgs e) in C:\Users\Admin\Documents\Visual Studio 2010\Projects\test\sicherung\test\Forms\frm_game.vb:Zeile 2339.
    bei System.Windows.Forms.Control.OnClick(EventArgs e)
    bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    bei System.Windows.Forms.Control.WndProc(Message& m)
    bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
    bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    bei test.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81.
    bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    bei System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    bei System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
    bei System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
    bei System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
    bei System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
    bei System.Activator.CreateInstance(ActivationContext activationContext)
    bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
    bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
    bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    bei System.Threading.ThreadHelper.ThreadStart()
    InnerException:


    Übrigens Zeile 12 Ist die Zeile wie oben

    GMT schrieb:

    Jetzt habe ich das Komplette Panel auf dem Screenshot!

    Fein. Es wäre jedoch echt stark von Dir, wenn Du uns an Deiner Lösung teilhaben lässt, dass beim nächsten Mal Deine Lösung gefunden und nicht erst gefragt werden muss. :thumbsup:
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Das ist der Code :
    Ersteinmal habe ich das Falsche Panel genommen Aber jetzt Funktioniert es,
    man Muss das Panel nehmen was Innen drinne ist nicht was aussen ist
    einfach dann die Masse bei DrawToBitmap einfügen.
    Und dann geht es

    VB.NET-Quellcode

    1. Dim bmp As New Bitmap(1298, 831)
    2. Frm.Panel3.DrawToBitmap(bmp, New Rectangle(0, 0, 1298, 831))
    3. Me.PictureBox2.Image = bmp