<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Faire un splashscreen avec le canal alpha (donc avec de la translucidité)]]></title><description><![CDATA[<p dir="auto">Salut all,</p>
<p dir="auto">Je encore faire un tuto à l'arrache. <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61b.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--stuck_out_tongue" style="height:23px;width:auto;vertical-align:middle" title=":P" alt="😛" /><br />
Donc je vais vous expliquer comment faire pour faire un splashScreen, c'était l'image de présentation ou de chargement que l'on peu voir parfois avec certains programmes.</p>
<p dir="auto">je vais prendre comme exemple:<br />
![logos_red-30cdb6e.png](&lt;<em><strong>base_url</strong></em>&gt;/applications/sslimageproxy/interface/image.php?url=<a href="http://img72.xooimage.com/files/b/7/a/logos_red-30cdb6e.png" rel="nofollow ugc">http://img72.xooimage.com/files/b/7/a/logos_red-30cdb6e.png</a>)<br />
il y a un dégradé de transparence et donc si j'utilise "tranparencyColor" ça va juste me retirer la couleur pure... alors dans ce cas il faut rien mettre dans transparency et mette un code kikoolong, enfin un peu long <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61b.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--stuck_out_tongue" style="height:23px;width:auto;vertical-align:middle" title=":P" alt="😛" /></p>
<p dir="auto">/!\Les contrôles (outils) ne sont pas visible après la manipulation !/!\</p>
<p dir="auto">Le code à mettre après "Public Class [Votreforme]"</p>
<pre><code>#Region "full_decla"
    Public Structure BLENDFUNCTION
        Public BlendOp As Byte
        Public BlendFlags As Byte
        Public SourceConstantAlpha As Byte
        Public AlphaFormat As Byte
    End Structure
    Public Const ULW_COLORKEY As Integer = 1
    Public Const ULW_ALPHA As Integer = 2
    Public Const ULW_OPAQUE As Integer = 4
    Public Const AC_SRC_OVER As Byte = 0
    Public Const AC_SRC_ALPHA As Byte = 1
    Public Const GWL_EXSTYLE = (-20)
    Public Declare Function UpdateLayeredWindow Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal hdcDst As IntPtr, ByRef pptDst As Point, ByRef psize As Size, ByVal hdcSrc As IntPtr, ByRef pprSrc As Point, ByVal crKey As Integer, ByRef pblend As BLENDFUNCTION, ByVal dwFlags As Integer) As Boolean
    Private Declare Auto Function SetWindowLong Lib "User32.Dll" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
    Private Declare Auto Function GetWindowLong Lib "User32.Dll" (ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
    Public Declare Function GetDC Lib "user32.dll" (ByVal hWnd As IntPtr) As IntPtr
    Public Declare Function ReleaseDC Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As Integer
    Public Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hDC As IntPtr) As IntPtr
    Public Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As IntPtr) As Boolean
    Public Declare Function SelectObject Lib "gdi32.dll" (ByVal hDC As IntPtr, ByVal hObject As IntPtr) As IntPtr
    Public Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As IntPtr) As Boolean
    Public Sub SetBitmap(ByVal PNG As Bitmap, ByVal opacity As Byte)
        If Not (PNG.PixelFormat = Imaging.PixelFormat.Format32bppArgb) Then
            Throw New ApplicationException("The bitmap must be 32ppp with alpha-channel.")
        End If
        Dim screenDc As IntPtr = GetDC(IntPtr.Zero)
        Dim memDc As IntPtr = CreateCompatibleDC(screenDc)
        Dim hBitmap As IntPtr = IntPtr.Zero
        Dim oldBitmap As IntPtr = IntPtr.Zero
        Try
            hBitmap = PNG.GetHbitmap(Color.FromArgb(0))
            oldBitmap = SelectObject(memDc, hBitmap)
            Dim size As Size = New Size(PNG.Width, PNG.Height)
            Dim pointSource As Point = New Point(0, 0)
            Dim topPos As Point = New Point(Left, Top)
            Dim blend As BLENDFUNCTION = New BLENDFUNCTION
            blend.BlendOp = AC_SRC_OVER
            blend.BlendFlags = 0
            blend.SourceConstantAlpha = opacity
            blend.AlphaFormat = AC_SRC_ALPHA
            UpdateLayeredWindow(Handle, screenDc, topPos, size, memDc, pointSource, 0, blend, ULW_ALPHA)
        Finally
            ReleaseDC(IntPtr.Zero, screenDc)
            If Not (hBitmap.Equals(IntPtr.Zero)) Then
                SelectObject(memDc, oldBitmap)
                DeleteObject(hBitmap)
            End If
            DeleteDC(memDc)
        End Try
    End Sub
#End Region
</code></pre>
<p dir="auto">Puis dans Form.load:</p>
<pre><code>Dim Param As Long
        Param = GetWindowLong(Me.Handle, GWL_EXSTYLE)
        Call SetWindowLong(Me.Handle, GWL_EXSTYLE, Param Or (524288))
        Call SetBitmap(Me.BackgroundImage, 255)
</code></pre>
<p dir="auto">___________<br />
Tuto part2, un petit bonus <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61b.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--stuck_out_tongue" style="height:23px;width:auto;vertical-align:middle" title=":P" alt="😛" /></p>
<p dir="auto">Comment faire une animation et faire en sorte que le splash se ferme un jour xD</p>
<p dir="auto">Il suffit de mettre un timer avec un interval de 1000ms (1sec.)<br />
et d'ajouter 2variales de type byte que on va appeler "Anim" et "Loader" (pense bête: faire un tuto sur les variables)<br />
Donc vous mettez le code suivant entre de sub (si on le met dedans la variable va toujours se redéclarer et remettre la valeur de base.</p>
<pre><code>Dim anim As Byte = 0
Dim loader As Byte = 0
</code></pre>
<p dir="auto">Puis dans le Timer.tick (double clique sur le timer pour le voir) et dedans on va mettre:</p>
<pre><code>anim += 1
        If anim = 1 Then
            Me.BackgroundImage = My.Resources.trame1 'la première image de l'animation 
        ElseIf anim = 10 Then
            Me.BackgroundImage = My.Resources.trame2 ' la seconde
        ElseIf anim = 11 Then
            Me.BackgroundImage = My.Resources.trame2 ' la quatrième ou troisième je sais pu
            loading += 1
            anim = 0
        End If
        Dim Param As Long
        Param = GetWindowLong(Me.Handle, GWL_EXSTYLE)
        Call SetWindowLong(Me.Handle, GWL_EXSTYLE, Param Or (524288))
        Call SetBitmap(Me.BackgroundImage, 255)
        If loader = 3 Then
            ' Pensez à mettre la forme suivante à ouvrir et aller dans les préférences de votre projet et changer le style de fermeture par fermeture du dernier formulaire
            Me.Close()
        End If
</code></pre>
<p dir="auto">Voilà maintenant vous savez faire des SplashScreen stylé <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f604.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--smile" style="height:23px;width:auto;vertical-align:middle" title=":D" alt="😄" /><br />
le code de base et pas de moi j'ai oublié la source mais je l'ai bcp édité de toute façon <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61b.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--stuck_out_tongue" style="height:23px;width:auto;vertical-align:middle" title=":P" alt="😛" /></p>
<p dir="auto">Bonne programmation à tous!<br />
Cordialement,<br />
Mars073</p>
]]></description><link>http://new.melinyel.net/topic/122/faire-un-splashscreen-avec-le-canal-alpha-donc-avec-de-la-translucidité</link><generator>RSS for Node</generator><lastBuildDate>Thu, 21 May 2026 21:16:34 GMT</lastBuildDate><atom:link href="http://new.melinyel.net/topic/122.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 13 Mar 2014 21:10:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Faire un splashscreen avec le canal alpha (donc avec de la translucidité) on Thu, 13 Mar 2014 22:23:47 GMT]]></title><description><![CDATA[<p dir="auto">Merci du tutoriel.</p>
<p dir="auto">Si quelqu'un retrouve les sources, postez-les.</p>
<p dir="auto">+1 Rep. <img src="http://new.melinyel.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=aa95655114f" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>http://new.melinyel.net/post/1322</link><guid isPermaLink="true">http://new.melinyel.net/post/1322</guid><dc:creator><![CDATA[Azad]]></dc:creator><pubDate>Thu, 13 Mar 2014 22:23:47 GMT</pubDate></item></channel></rss>