Reprise du focus
Publié : mer. 25/févr./2004 16:18
Pour savoir si une fenêtre reprend le focus
Code : Tout sélectionner
Procedure LoWord(value)
ProcedureReturn value & $FFFF
EndProcedure
Procedure HiWord(value)
ProcedureReturn value >> 16 & $FFFF
EndProcedure
Procedure WindowCallBack(Window, Message, wParam, lParam)
ReturnValue = #PB_ProcessPureBasicEvents
Select Message
; =========================================================================
; =========================================================================
Case #WM_ACTIVATE ; détecte si on a bascule d'une fenêtre vers la fenêtre principale
If ((LoWord(Wparam) = #WA_ACTIVE ) Or (LoWord(Wparam) = #WA_CLICKACTIVE)) And Window = WindowID(0)
FontText.l = LoadFont(2, "Arial", 14, #PB_Font_HighQuality)
SetGadgetText(1, "Alors le texte a changé ?")
SetGadgetFont(1, FontText)
ReturnValue = 0 ; doit retourner 0 si on répond au message
EndIf
; =========================================================================
; =========================================================================
EndSelect
ProcedureReturn ReturnValue
EndProcedure
If OpenWindow(0, 200, 200, 400, 400, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "WM_ACTIVATE")
CreateGadgetList(WindowID())
TextGadget(1, 50, 50, 220, 80, "Texte avant")
EndIf
SetWindowCallback(@WindowCallBack())
Repeat
Until WaitWindowEvent() = #PB_EventCloseWindow
End