Page 1 of 2
Rezise window limit, how i do ?
Posted: Fri Mar 18, 2022 11:48 pm
by Claudio Ricardo
Hola
Se puede setear un tamaño minimo limite al redimensionamiento de una ventana ?
Que no la puedan achicar mas de lo especificado por mi ? Es para evitar que se solapen los controles.
Algo asi como en el administrador de tareas de W7.
Desde yá muchas gracias !
Hello
Is it possible to set a minimum size limit to the resizing of a window?
That they cannot shrink it more than what is specified by me? This is to prevent controls from overlapping.
Something like in the task manager of W7.
Thanks in advance !
Re: Rezise window limit, how i do ?
Posted: Sat Mar 19, 2022 12:48 am
by andyglezl
Maybe...
DEFINE WINDOW <WindowName> AT <nRow> ,<nCol> WIDTH <nWindth> HEIGHT <nHeight>
.
. ON SIZE PonerLimites()
Re: Rezise window limit, how i do ?
Posted: Sat Mar 19, 2022 2:01 am
by Claudio Ricardo
Gracias por contestar Andy
En ON SIZE llamo a la función que redimensiona los controles, lo que no sé es cómo fijar por ejemplo
Form Min Width = 1000 Form Min Height = 700 y que al llegar a alguno de esos valores, el usuario no pueda seguir
achicando la ventana, tal como sucede en la ventana del administrador de tareas de W7.
Thanks for answering Andy.
In ON SIZE I call the function that resizes the controls, what I don't know is how to set for example
Form Min Width = 1000 Form Min Height = 700 and that when reaching any of those values, the user cannot continue
shrinking the window, just like in the W7 task manager window.
Re: Rezise window limit, how i do ?
Posted: Sat Mar 19, 2022 10:05 am
by trmpluym
Claudio,
In the ON RESIZE function you use, u can limit the size by defining a minimum width en height. For example:
Code: Select all
ON RESIZE AutoAdjust( cForm ,nMinWidth ,nMinHeight, nMaxWidth ,nMaxHeight )
Code: Select all
nMinWidth := iif(nMinWidth =NIL,0,nMinWidth )
nMinHeight := iif(nMinHeight=NIL,0,nMinHeight)
nMaxWidth := iif(nMaxWidth =NIL,GetDesktopWidth() ,nMaxWidth )
nMaxHeight := iif(nMaxHeight=NIL,GetDesktopHeight(),nMaxHeight)
IF GetDesktopWidth() < GetWindowWidth ( hWnd )
nWidth := GetDesktopWidth()
ELSEIF GetWindowWidth(hWnd) < nMinWidth
SetProperty ( cForm , "Width" , nMinWidth )
nWidth := nMinWidth
ELSEIF GetWindowWidth(hWnd) > nMaxWidth
SetProperty ( cForm , "Width" , nMaxWidth )
nWidth := nMaxWidth
ELSE
nWidth := GetWindowWidth ( hWnd )
ENDIF
IF GetDesktopHeight() < GetWindowHeight ( hWnd )
nHeight := GetDesktopHeight()
ELSEIF GetWindowHeight ( hWnd ) < nMinHeight
SetProperty ( cForm , "Height" , nMinHeight )
nHeight := nMinHeight
ELSEIF GetWindowHeight ( hWnd ) > nMaxHeight
SetProperty ( cForm , "Height" , nMaxHeight )
nHeight := nMaxHeight
ELSE
nHeight := GetWindowHeight( hWnd )
ENDIF
Theo
Re: Rezise window limit, how i do ?
Posted: Sat Mar 19, 2022 11:06 am
by Claudio Ricardo
Thank you very much Theo and Andy, problem solved thanks to your help !
Re: Rezise window limit, how i do ?
Posted: Sat Mar 19, 2022 11:49 am
by edk
Other solution:
Code: Select all
#include "hmg.ch"
FUNCTION Main()
Local nEvent, nMinHeight := 350, nMinWidth := 550, nMaxHeight := 400, nMaxWidth := 650
DEFINE WINDOW Test AT 157 , 162 WIDTH nMinWidth HEIGHT nMinHeight TITLE "Hello World!!!!!" MAIN ON PAINT PaintSizeGrip( ThisWindow.Handle ) ON RELEASE EventRemove ( nEvent )
DEFINE MAIN MENU
DEFINE POPUP "File"
MENUITEM "Some item" ACTION MsgInfo ( "Some item" )
SEPARATOR
MENUITEM "Exit" ACTION ThisWIndow.Release
END POPUP
END MENU
nEvent := EventCreate( { || SetMinMaxTrackSize( EventLPARAM(), nMinWidth, nMinHeight, nMaxWidth, nMaxHeight ) }, test.HANDLE, 36 /*WM_GETMINMAXINFO*/ )
// only min size defined
// nEvent := EventCreate( { || SetMinMaxTrackSize( EventLPARAM(), nMinWidth, nMinHeight ) }, test.HANDLE, 36 /*WM_GETMINMAXINFO*/ )
END WINDOW
Center Window Test
Activate Window Test
RETURN NIL
***********************************************************************************
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"
#include <windowsx.h>
#include <commctrl.h>
#include <shlobj.h>
//PaintSizeGrip(nHWnd)
HB_FUNC( PAINTSIZEGRIP )
{
HWND hWnd;
PAINTSTRUCT ps;
RECT rc;
HDC hdc;
hWnd = (HWND) HMG_parnl(1);
hdc = BeginPaint(hWnd, &ps);
if (hdc)
{
GetClientRect(hWnd, &rc);
rc.left = rc.right - GetSystemMetrics(SM_CXVSCROLL);
rc.top = rc.bottom - GetSystemMetrics(SM_CYVSCROLL);
DrawFrameControl(hdc, &rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
EndPaint(hWnd, &ps);
}
}
//SetMinMaxTrackSize(lParam, nMinX, nMinY, nMaxX, nMaxY)
HB_FUNC( SETMINMAXTRACKSIZE )
{
MINMAXINFO *MinMax = (MINMAXINFO *) HMG_parnl(1);
if (hb_parni(2) > 0)
MinMax->ptMinTrackSize.x = hb_parni(2);
if (hb_parni(3) > 0)
MinMax->ptMinTrackSize.y = hb_parni(3);
if (hb_parni(4) > 0)
MinMax->ptMaxTrackSize.x = hb_parni(4);
if (hb_parni(5) > 0)
MinMax->ptMaxTrackSize.y = hb_parni(5);
}
#pragma ENDDUMP
********************************
Re: Rezise window limit, how i do ?
Posted: Sat Mar 19, 2022 11:19 pm
by Claudio Ricardo
Hi Edward, you code WORK PERFECT !!!!
I had done:
Code: Select all
Function Main_Form_OnSize // called from Main OnSize
LOCAL nMainHeight := GetProperty ("Main" , "Height")
LOCAL nMainWidth := GetProperty ("Main" , "Width")
If nMainWidth < 1000
SetProperty ("Main" , "Width" , 1000)
Return Nil
EndIf
If nMainHeight < 700
SetProperty ("Main" , "Height" , 700)
Return Nil
EndIf
// here another control's resize and positioning
But when reaching the minimum limit established both in width and height, it produced flashes in the window that were very annoying to the eye.
Your code doesn't do them and it's like it disables the mouse drag when it reaches the limit, exactly what I wanted !!!
Extremely grateful for your help !!!
Re: Rezise window limit, how i do ?
Posted: Mon Mar 21, 2022 10:56 pm
by Red2
Hi Edward,
Thank you for your very helpful post. The part that I needed (and
really appreciate your sharing) was your
//PaintSizeGrip(nHWnd)
HB_FUNC( PAINTSIZEGRIP )
code. I did not know how to do this in HMG.
I added your code to my form which has a BACKCOLOR.
Unfortunately the PAINTSIZEGRIP image displays opaquely.
Its background
Gray overwrites my form's
{255,250,240} BACKCOLOR.
My Question:
Is there any way to display this kind of a "resize" corner
transparently to show my forms BACKCOLOR?
============================
Google Spanish
¿Hay alguna forma de mostrar este tipo de esquina de "cambio de tamaño" de forma
transparente para mostrar mis formularios BACKCOLOR?
============================
Thank you,
Red2

Re: Rezise window limit, how i do ?
Posted: Tue Mar 22, 2022 1:44 am
by Claudio Ricardo
Hi Red2... the same thing happened to me so I didn't use PaintSizeGrip () function in OnPaint.
Re: Rezise window limit, how i do ?
Posted: Tue Mar 22, 2022 9:27 am
by edk
Red2 wrote: ↑Mon Mar 21, 2022 10:56 pm
Is there any way to display this kind of a "resize" corner
transparently to show my forms BACKCOLOR?
============================
¿Hay alguna forma de mostrar este tipo de esquina de "cambio de tamaño" de forma
transparente para mostrar mis formularios BACKCOLOR?
Hi Red2.
Unfortunately, the description on the page
https://docs.microsoft.com/en-us/window ... amecontrol shows that the transparency attribute (DFCS_TRANSPARENT) can only be used with DFCS_MENUARROWUP or DFCS_MENUARROWDOWN. My knowledge of C is very limited to the basics. I am not able to help with this problem, but as Claudio wrote, you can skip the grip drawing.