Very Exclusive Tutorial!

Use this board to post your code snippets - tips and tricks
8 posts Page 1 of 1
Contributors
User avatar
Danny
VIP - Donator
VIP - Donator
Posts: 621
Joined: Sat Oct 30, 2010 8:21 pm

Very Exclusive Tutorial!
Danny
it saves a panel with all of his controls as a picture!
(all controls supported)
Tutorial ;D
First!
add a panel with some labels or other controls,
Then!
add a other panel or a picture to display the picture of the panel with his controls.
You also need a button to let the code work ;)
if you want to save the picture direct use this code:
Code: Select all
myBmp.Save("C:\mybmp.jpg")
Then you need the add the codes, they will be at the link below.
link to the code:
http://nomesoft.usersboard.com/t11-excl ... to-picture
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Very Exclusive Tutorial!
MrAksel
Is this like Panel1.DrawToBitmap?
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Danny
VIP - Donator
VIP - Donator
Posts: 621
Joined: Sat Oct 30, 2010 8:21 pm

Re: Very Exclusive Tutorial!
Danny
not exact just try the code
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Very Exclusive Tutorial!
Codex
Can you tell me the difference between your code and this code:
Code: Select all
    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
        PictureBox1.Image = GetPanelImage()

    End Sub

    Private Function GetPanelImage() As Bitmap
        ' Make the bitmap.
        Dim wid As Integer = Panel1.Width
        Dim hgt As Integer = Panel1.Height
        Dim bm As New Bitmap(wid, hgt)

        ' Draw the form onto the bitmap.
        Panel1.DrawToBitmap(bm, New Rectangle(0, 0, wid, hgt))

        ' If we want the borders, return the bitmap.

        ' Make a smaller bitmap without borders.
        wid = Me.ClientSize.Width
        hgt = Me.ClientSize.Height
        Dim bm2 As New Bitmap(wid, hgt)

        ' Copy the part of the original bitmap that we want
        ' into the bitmap.
        Dim gr As Graphics = Graphics.FromImage(bm2)
        gr.DrawImage(bm, 0, 0, New Rectangle(0, 0, wid, hgt), _
            GraphicsUnit.Pixel)
        Return bm2
    End Function
I modified the code above from this article, but it does the same job, so whats so unique/exclusive ?

I have tried your code on my form, exact same effect.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
Danny
VIP - Donator
VIP - Donator
Posts: 621
Joined: Sat Oct 30, 2010 8:21 pm

Re: Very Exclusive Tutorial!
Danny
because I think it is Exclusive because i think it is .... >.<
User avatar
clanc789
Coding Guru
Coding Guru
Posts: 786
Joined: Tue Nov 02, 2010 4:45 pm

Re: Very Exclusive Tutorial!
clanc789
Danny wrote:
because I think it is Exclusive because i think it is .... >.<
I use those kind of arguments on my tests as well! Just kidding :P I think it is exclusive as well. But why would i want to save my panel as .bmp? You better make a DLL from it and then import it in multiple programs...

Just my opinion :P
Practice makes perfect!

VIP since: 6-10-2011
User avatar
Danny
VIP - Donator
VIP - Donator
Posts: 621
Joined: Sat Oct 30, 2010 8:21 pm

Re: Very Exclusive Tutorial!
Danny
first it may be handy for some reason
second,.. how to make that?!
User avatar
clanc789
Coding Guru
Coding Guru
Posts: 786
Joined: Tue Nov 02, 2010 4:45 pm

Re: Very Exclusive Tutorial!
clanc789
Danny wrote:
first it may be handy for some reason
second,.. how to make that?!
Just use a usercontrol (project>add form and choose usercontrol). Create that one and build the dll. Import using toolbox!!
Practice makes perfect!

VIP since: 6-10-2011
8 posts Page 1 of 1
Return to “Quick Snips”