Minimum and Maximum window size

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Minimum and Maximum window size

Post by BackupUser »

Code updated for 5.20+ (same as WindowBounds())

Restored from previous forum. Originally posted by fred.

Ok, here is the trick to have min/max dimensions on a resiseable window.

Code: Select all

;
; Max/Min Window size tracking..
;

Procedure SizeCallback(WindowID, Message, wParam, lParam)
 
  ; Here is the trick. The GETMINMAXINFO must be processed
  ; and filled with min/max values...
  ;
  If Message = #WM_GETMINMAXINFO
    *SizeTracking.MINMAXINFO = lParam
    *SizeTracking\ptMinTrackSize\x = 100
    *SizeTracking\ptMinTrackSize\y = 100
    *SizeTracking\ptMaxTrackSize\x = 600
    *SizeTracking\ptMaxTrackSize\y = 300
  EndIf
  
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

If OpenWindow(0,10,10,200,200, "Resize me !",#PB_Window_SystemMenu | #PB_Window_SizeGadget)
  SetWindowCallback(@SizeCallback())
       
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Sorry Fred, it crashes on my computer.

If I mark 'SetWindowCallback(@SizeCallback())' as text it don't crash, but I suppose this is not really useful for this function.

Windows 98SE is used.



Have a nice day...
Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Sorry Fred... your code crash always on Win98 1st Edition too..

MrVainSCL!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Have to check this. Works fine on WinXP.

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by wavemaker.

This works in Win 98, but Fred's code should work, too:

Code: Select all

;
; Max/Min Window size tracking..
;
Procedure SizeCallback(WindowID, Message, wParam, lParam)
  ; Here is the trick. The GETMINMAXINFO must be processed
  ; and filled with min/max values...
  ;
  If Message = #WM_GETMINMAXINFO
    PokeL(lParam+24, 100)
    PokeL(lParam+28, 100)
    PokeL(lParam+32, 600)
    PokeL(lParam+36, 300)
  EndIf
EndProcedure
If OpenWindow(0,10,10,200,200,#PB_Window_SystemMenu | #PB_Window_SizeGadget, "Resize me !")
  SetWindowCallback(@SizeCallback())
  Repeat
  Until WaitWindowEvent() = #PB_EventCloseWindow
EndIf
Bye,

Juan Calderón Alonso
Registered user
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tranquil.

Hm, Wavemakers code works fine on my system but I cant find any false in Freds code!? Is it a compiler bug or something internal goes wrong!?!?

Crazy...


Bye

Mike

Tranquilizer/ Secretly!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Wavemakers modification works fine on my machine.

BTW: Fred you work with WinXP, do you know how to use the zip dll's that comes with it?
Now I have also WinXP at home and I'm testing my templates on this OS (hi Fangles didn't forget you ). Found out that the win internal AboutBox handles the user images on it quite different. In the older Win OS you can work with images of the size 50x240 without problems. Now every image is resized to a square to approximately 32x32.
Have you also found some discrepancies on WinXP?


Have a nice day...
Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.
Have you also found some discrepancies on WinXP?
Nop...

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.
Have you also found some discrepancies on WinXP?
Nop...

Fred - AlphaSND
I have found some... i will post it, then Fred can fix it

Regards

Ricardo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.
Hm, Wavemakers code works fine on my system but I cant find any false in Freds code!? Is it a compiler bug or something internal goes wrong!?!?
This was a compiler (or better a windows lacks) bug. Worked fine on NT range Windows but failed on Win9x one.. Fixed now.

Fred - AlphaSND
Post Reply