J'ai été un peu trop vite avec mon code car vous aurez des problèmes avec la fenêtre quand vous irez au bord supérieur de l'écran.
Voici le programme en entier avec les corrections apportées (et en plus c'est un peu plus court).
Code : Tout sélectionner
InitSprite();nécessaire pour l'exemple
Procedure WindowProc(hWnd,msg,wParam,lParam)
If msg=#WM_SIZING
GetWindowRect_(WindowID(0),old.rect)
long.w=old\right-old\left
haut.w=old\bottom-old\top
*st.rect=lParam
ecx.w=*st\right-*st\left-long
ecy.w=*st\bottom-*st\top-haut
If wParam=#WMSZ_LEFT or wParam=#WMSZ_RIGHT or wParam=#WMSZ_ BOTTOMRIGHT or wParam=#WMSZ_BOTTOMLEFT
pc.f=(ecx*100)/long
mt.f=(haut*pc)/100
*st\bottom=old\bottom+mt
Elseif wParam=#WMSZ_TOP or wParam=#WMSZ_BOTTOM
pc=(ecy*100)/haut
mt=(long*pc)/100
*st\right=old\right+mt
Elseif wParam=#WMSZ_TOPRIGHT or wParam=#WMSZ_TOPLEFT
pc=(ecx*100)/long
mt=(haut*pc)/100
If old\top-mt<0
*st\top=0
*st\bottom=old\bottom+mt
Else
*st\top=old\top-mt
Endif
Endif
Endif
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
;-------------------------------------
lgf.w=300;détermine la longueur de la fenêtre
htf.w=200;détermine la hauteur de la fenêtre
;vous pouvez changer ces valeurs à votre guise
;--------------------------------------
If OpenWindow(0,0,0,lgf,htf,"Redimensionne moi !",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
OpenWindowedScreen(WindowID(0),0,0,lgf,htf,1,0,0)
WindowBounds(0,lgf,htf,lgf*3,htf*3)
SmartWindowRefresh(0,1)
SetWindowCallback(@WindowProc())
LoadFont(1,"Arial",30,#PB_Font_Underline|#PB_Font_Bold)
StartDrawing(ScreenOutput())
DrawingFont(FontID(1))
DrawText(0,0,"TESTER",RGB(170,170,170),0)
StopDrawing
Repeat
Event=WaitWindowEvent()
Until Event=#PB_Event_CloseWindow
Endif