Accueil > > > PROGRAMME PERMETTANT DE GARDER UNE FORME AU PREMIER PLAN
PROGRAMME PERMETTANT DE GARDER UNE FORME AU PREMIER PLAN
Information sur la source
Description
C'est un petit programme qui permet de charger une image et de l'afficher en la laissant toujours au premier plan. Ce programme permet par exemple d'avoir pendant une présentation votre logo au premier plan avec une autre application qui fonctionne derrière. Click droit de la souris sur l'image = déplacement de la forme sur l'écran Click avec autre bouton fermeture de l'application.
Source
- ' Ce projet a besoin d'un controle PictureBox
- Option Explicit
-
- 'The SetWindowPos function changes the size, position, and Z order of a child, pop-up, or top-level window. Child, pop-up, and top-level windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.
- Private Declare Sub SetWindowPos Lib "USER32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
-
- 'Fonctions pour déplacer la fenetre
- 'The ReleaseCapture function releases the mouse capture from a window in the current thread and restores normal mouse input processing.
- Private Declare Function ReleaseCapture Lib "USER32" () As Long
- 'The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately.
- Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
-
- 'declaration des constantes
- Const WM_NCLBUTTONDOWN = &HA1
- Const HTCAPTION = 2
- Const RGN_OR = 2
-
- Const HWND_TOPMOST = -1
- Const HWND_NOTOPMOST = -2
- Const SWP_NOSIZE = &H1
- Const SWP_NOMOVE = &H2
- Const SWP_NOACTIVATE = &H10
- Const SWP_SHOWWINDOW = &H40
-
- Private Sub Form_Load()
-
- ' si erreur continue ( par exemple si pas de fichier logo.bmp alors on a l'image déjà présente dans le controle
- ' picture box
- On Error Resume Next
-
- 'Repositionnne l'image
- Picture1.Left = 0
- Picture1.Top = 0
- Picture1.Appearance = 0 ' apparence=Flat
- Picture1.AutoSize = True ' Redimensionne le controle picture box à la taille de l'image
-
-
- 'Charge L'image avec le fichier image.bmp présent dans le répertoire de l'apli
- Picture1 = LoadPicture(App.Path + "\Logo.bmp")
-
- 'Redimensione la forme selon la taille de l'image
- Me.Height = Picture1.Height
- Me.Width = Picture1.Width
-
- ' la fenetre est mise toujours au premier plan
- SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
-
- End Sub
-
-
- ' click bouton droit = deplacement de la forme
- ' click autre bouton = fin application
- Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
- 'Pour déplacer la form
- If Button = 1 Then
- ReleaseCapture
- SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
- Else
- ' un autre bouton ferme l'application
- Unload Me
- End If
- End Sub
' Ce projet a besoin d'un controle PictureBox
Option Explicit
'The SetWindowPos function changes the size, position, and Z order of a child, pop-up, or top-level window. Child, pop-up, and top-level windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.
Private Declare Sub SetWindowPos Lib "USER32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
'Fonctions pour déplacer la fenetre
'The ReleaseCapture function releases the mouse capture from a window in the current thread and restores normal mouse input processing.
Private Declare Function ReleaseCapture Lib "USER32" () As Long
'The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately.
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'declaration des constantes
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Const RGN_OR = 2
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Sub Form_Load()
' si erreur continue ( par exemple si pas de fichier logo.bmp alors on a l'image déjà présente dans le controle
' picture box
On Error Resume Next
'Repositionnne l'image
Picture1.Left = 0
Picture1.Top = 0
Picture1.Appearance = 0 ' apparence=Flat
Picture1.AutoSize = True ' Redimensionne le controle picture box à la taille de l'image
'Charge L'image avec le fichier image.bmp présent dans le répertoire de l'apli
Picture1 = LoadPicture(App.Path + "\Logo.bmp")
'Redimensione la forme selon la taille de l'image
Me.Height = Picture1.Height
Me.Width = Picture1.Width
' la fenetre est mise toujours au premier plan
SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
' click bouton droit = deplacement de la forme
' click autre bouton = fin application
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Pour déplacer la form
If Button = 1 Then
ReleaseCapture
SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
Else
' un autre bouton ferme l'application
Unload Me
End If
End Sub
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
GESTION D'EXCEPTION AVEC LES TASKSGESTION D'EXCEPTION AVEC LES TASKS par richardc
Nous avons vu dans un précédent article comment utiliser Task pour effectuer des opérations dans un autre thread.
Malheureusement, comme tout le monde n'est pas parfait, il se peut que cette exécution se passe mal et qu'une exception se produise.
La...
Cliquez pour lire la suite de l'article par richardc DéMARRONS AVEC LES TASKSDéMARRONS AVEC LES TASKS par richardc
Que vous le vouliez ou non, le développement multi-tâche est maintenant une obligation pour toute nouvelle application. Il est donc vital d'en comprendre les mécanismes et de s'y mettre le plus tôt possible.
En attendant le .NET Framework 4.5 avec le...
Cliquez pour lire la suite de l'article par richardc SLIDE & DéMO TECHDAYS 2012 - FAST & FURIOUS XAML APPSSLIDE & DéMO TECHDAYS 2012 - FAST & FURIOUS XAML APPS par Vko
Retrouvez les slides et les démo de ma session Fast & Furious XAML Apps. A ceux qui se posent la question : "est-ce que le code de la DataGrid est disponible?", je vous répondrais "pas encore". Je vais mettre en place un projet codeplex pour part...
Cliquez pour lire la suite de l'article par Vko XNA IS DEAD!XNA IS DEAD! par richardc
Depuis la semaine dernière (et grâce aux TechDays 2012), je me penche activement sur la nouvelle version de Windows, aka Windows 8. Vous me direz, il était temps puisque la première preview date de Septembre dernier.
OK. Remarquez, on n'en est qu'aux...
Cliquez pour lire la suite de l'article par richardc TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|