VB.NET-QQ News pop-up window style picture making tool

Source: Internet
Author: User

0.

This program (Baidu Network disk): Http://pan.baidu.com/s/1qWBGGGG

I. About this procedure

Gnaea is a QQ news pop-up tool, you can enter the news headlines and news content after the creation of a similar QQ news pop-up pictures. The resulting images can be saved as BMP and PNG two formats, or copied directly to the Clipboard.

Effects such as (note: content is purely fictitious)

Second, the program control


Third, the program resources

Resources used as footage: My.Resources.PopUp, drawing from a PNG-formatted picture


Iv. Code of the program

imports system.textpublic class formgnaea#region  "Initialize form"      "load Form"     private sub formgnaea_load (sender as object, e as  EventArgs)  _        Handles MyBase.Load         Me.pnlMiddle.BorderStyle = BorderStyle.FixedSingle         Me.pnlButtom.BorderStyle = BorderStyle.FixedSingle         me.picpreview.image = my.resources.popup    end  Sub#End Region#Region  "Update picture related"      "update picture information by News title and content      Private sub previewonpic ()         Dim bmp As  bitmap = my.resources.popup        dim g =  Graphics.fromimage (BMP)          ' Draw news headlines         Dim  Lenoftitle = encoding.default.getbytecount (TxtTitle.Text.Trim)          g.drawstring (              Txttitle.text,             new font ("The song Body" ,  10, fontstyle.bold),              New solidbrush (Color.FromArgb (255, 47, 75, 87)),              new point (125 - lenoftitle * 3.5, 30))           ' Drawing news content         dim s  As String =  ""  + txtContent.Text         dim s1 =  new stringbuilder        dim s2 = new  Stringbuilder        dim s3 = new stringbuilder         Dim s4 = New StringBuilder         for i as integer = 0 to s.length -  1             ' Skip all carriage returns and line feeds              if s (i)  = vbcrlf or s (i)  =  vbcr or s (i)  = vbLf Then                 Continue For             End If             ' Assign valid characters to each line    &Nbsp;        if encoding.default.getbytecount (s.Substring (0,  i + 1))  < 33 Then                 s1. Append (S (i))   ' first line             ElseIf  Encoding.Default.GetByteCount (s.substring (0, i + 1))  < 65 Then                 s2. Append (S (i))   ' second line             ElseIf  Encoding.Default.GetByteCount (s.substring (0, i + 1))  < 97 Then                 s3. Append (S (i))   ' third line             ElseIf  Encoding.Default.GetByteCount (S.substriNg (0, i + 1))  < 129 Then                 s4. Append (S (i))   ' fourth line             end if         Next         ' first line          g.drawstring (              s1. Tostring,             new font ("The song Body",  10, fontstyle.regular),              new solidbrush (Color.FromArgb (255, 47, 75, 87)),              new point (20, 53))          g.drawstring (      &nbsP;      s2. Tostring,             new font ("The song Body",  10, fontstyle.regular),              new solidbrush (Color.FromArgb (255, 47, 75, 87)),              new point (20, 73))          g.drawstring (&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;S3. Tostring,             new font ("The song Body",  10, fontstyle.regular),              new solidbrush (Color.FromArgb (255, 47, 75, 87)),              new point (20, 93)) &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSp;  g.drawstring (&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;S4. Tostring,             new font ("The song Body",  10, fontstyle.regular),              new solidbrush (Color.FromArgb (255, 47, 75, 87)),              new point (20, 113))          picPreview.Image = bmp    End Sub     ' Automatically update picture     private sub txttitle_textchanged when you modify a news title (Sender as object,  e as eventargs)  _        Handles  txttitle.textchanged        try             previewoNPic ()         Catch ex As Exception             messagebox.show (ex. Message)         End Try    End Sub      ' Automatically update picture     private sub txtcontent_textchanged when changing news content (sender  as object, e as eventargs)  _         handles txtcontent.textchanged        try             previewonpic ()          catch ex as exception             MessageBox.Show (ex. Message)         end try    end sub#end  Region#Region  "button Event correlation"      ' button: Copies the picture to the Clipboard     private sub btncopy_click (sender As  Object, e as eventargs)  _        Handles  Btncopy.click        clipboard.setimage (picPreview.Image)      End Sub     ' button: Save picture     private sub btnsave_ Click (Sender as object, e as eventargs)  _         Handles btnSave.Click        Try              ' Save picture form              Dim sfd As SaveFileDialog = New SaveFileDialog             With sfd                 . overwriteprompt = true                 . filter =  "Windows Bitmap (BMP) |*.bmp| Portable Network Graphics |*.png"                  . filename =  "News _"  & datetime.now.tostring ("Yyyymmdd_hhmmss")                  . title =  "Save Picture"             end with              ' Save pictures       &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;IF&NBSP;SFD. showdialog = windows.forms.dialogresult.ok then         &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;IF&NBSP;SFD. filterindex = 1 then                     PicPreview.Image.Save (SFD). Filename, imaging.imageformat.bmp)             &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;ELSEIF&NBSP;SFD. filterindex = 2 then                     picpreview.image.save (SFD). Filename, imaging.imageformat.png)                  End If             End If        Catch ex As Exception             messagebox.show (ex. Message)         End Try    End Sub      ' button: Exit program     private sub btnclose_click (sender as object, e as  EventArgs)  _        Handles btnClose.Click         application.exit ()     End Sub#End RegionEnd  Class

END

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.