VB.net Octopus Brother Production--use API function AnimateWindow create popup Prompt window

Source: Internet
Author: User

When we open the computer to the Internet, is not often seen in the bottom right corner of the desktop pop up a small news hotspot form, we can achieve it? Of course, this article will give you a cover-up how to use code implementation. Look, it's writing. A pop-up.

The main function used is the API function AnimateWindow. The following is a brief introduction to the use of this function.
1 function declarations

  ' Declare API function AnimateWindow. The function can dynamically manipulate the form    Declare function AnimateWindow Lib "user32" Alias "AnimateWindow" (ByVal hwnd as INTPTR, ByVal Dwtime as Int32, ByVal DwFlags as Int32) as Boolean
2, parameter setting

HWnd: Specifies the handle of the window that produces the animation. Dwtime: Indicates the duration of the animation (in microseconds), and the standard time to complete an animation is 200 microseconds. Dwfags: Specifies the type of animation. This parameter can be a combination of one or more of the following flags. Flag Description: Aw_slide: Use sliding type. The default is the scrolling animation type. This flag is ignored when the Aw_center flag is used. Aw_activate: Activates the window. Do not use this flag after you have used the AW_HIDE flag. Aw_blend: Use fade out effect. This flag can only be used when the HWND is the top-level window. Aw_hide: Hides the window and displays the window by default. Aw_center: If the aw_hide flag is used, the window is overlapped, and if the AW_HIDE flag is not used, the window expands outward. Aw_hor_positive: Displays the window from left to right. This flag can be used in scrolling animations and slide animations. When the Aw_center flag is used, the flag is ignored. Aw_ver_positive: Displays the window from top to bottom. This flag can be used in scrolling animations and slide animations. When the Aw_center flag is used, the flag is ignored. Aw_ver_negative: Displays the window from the bottom up. This flag can be used in scrolling animations and slide animations. When the Aw_center flag is used, the flag is ignored. Aw_hor_negative: Displays the window from right to left. This flag can be used in scrolling animations and slide animations. When the Aw_center flag is used, the flag is ignored
3, return value
If the function succeeds, the return value is not 0, and if the function fails, the return value is zero. The function will fail under the following conditions
Second, the form design:
The form is simple, a form window, a PictureBox control, a button, a Timer control

Implementation function: Every three seconds, the prompt window shows hidden alternation in the lower right corner of the desktop. There are many ways to display and hide. It is reflected in the code and can be tested by the reader itself.
Third, the code implementation
Define some global variables in the Moudul module first
Module Module1    ' from left to right shows public    const aw_hor_positive as Int32 = &h1    ' right-to-left display public    const AW_HOR_ Negative as Int32 = &h2    ' from top to bottom show public    const aw_ver_positive as Int32 = &h4    ' from bottom to top show public    const A W_ver_negative as Int32 = &h8    ' If the aw_hide flag is used, the window is overlapped, that is, the window is shrunk, otherwise the window is expanded outward, that is, the window public    Const Aw_center as Int32 = &h10 public    Const aw_hide as Int32 = &h10000 ' Hide window, by default the window    ' activation window is displayed. This flag cannot be used after using the AW_HIDE flag public    Const aw_activate as Int32 = &h20000    ' use sliding type. The default is the scrolling animation type. When using the Aw_center flag, this flag is ignored public    const aw_slide as Int32 = &h40000    ' Transparency from high to low public    const Aw_blend AS Int32 = &h80000    ' Determines whether the form hides public    ishide as Booleanend Module

Code implemented in the prompt form's class:
' *************************************************************************** ' octopus brother, qq:3107073263 Group: 309816713 ' If you want to source or good advice please contact me, we progress together ' group is building, welcome to participate in the discussion ' ****************************************************public Class form_main ' Display in the bottom right corner of the screen, Dim Rect As Rectangle = Screen.PrimaryScreen.WorkingArea ' Get PC Desktop screen Dim X As Integer ' hint window left value Dim Y A The top value of the S Integer ' hint window ' declares the API function AnimateWindow. The function can dynamically manipulate the form Declare function AnimateWindow Lib "user32" Alias "AnimateWindow" (ByVal hwnd as INTPTR, ByVal Dwtime as I Nt32, ByVal DwFlags as Int32) as Boolean ' form initializes Private Sub form_main_load (ByVal sender as System.Object, ByVal E As System.EventArgs) Handles mybase.load X = rect.width-me.width Y = rect.height-me.height Me.set Bounds (X, Y, Me.Width, me.height) ' Define form position timer1.enabled = True ' Turn on Timer control ' to set the form to borderless format. That makes sense, don't believe you. This code comment off try Me.formborderstyle = Windows.Forms.FormBorderStyle.None End Sub ' show Private Sub Show      Form ()  ' Three ways can be used, you want to use the annotation of the other two ' AnimateWindow (Me.handle, A, aw_ver_negative or aw_hor_negative) ' Right on the fly out Animatewin Dow (Me.handle, aw_center) ' Middle diffusion ' AnimateWindow (Me.handle, S, aw_blend) ' from shallow to deep ishide = False End S UB ' Hidden Private Sub hideform () ' AnimateWindow (Me.handle, A, aw_hide Or aw_ver_positive) ' from top to bottom ' Anim  Aw_hide or aw_blend) ' form slowly fades out ishide = True End Sub ' timer, alternating 3 seconds to show or hide Private Sub timer1_tick (ByVal sender As System.Object, ByVal e as System.EventArgs) Handles Timer1.tick If ishide then ShowForm () Els e hideform () End If End SubEnd Class
Well, try the effect! Good luck, octopus brother.



VB.net Octopus Brother Production--use API function AnimateWindow create popup Prompt window

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.