- ' 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