Page 2 of 2

Re: Rezise window limit, how i do ?

Posted: Tue Mar 22, 2022 3:03 pm
by Red2
Hi Edward,

Thank you for your kind and quick response!
(My knowledge of C is, unfortunately, less than yours).
Perhaps this "corner" is not normally implemented in HMG.

My own Resize code accurately resizes the columns in GRIDs and BROWSEs.
To these windows I just want some way to include the "Resize Corner" graphic.

Is there is any other way this can be done in HMG?
=======================
¿Hay alguna otra forma en que esto se pueda hacer en HMG?
=======================

I would greatly appreciate anyone's suggestions or guidance here.

Thanks again,
Red2

Re: Rezise window limit, how i do ?

Posted: Wed Mar 23, 2022 6:47 am
by Claudio Ricardo
Hi Red2, Maybe this...
At the end of the form

Code: Select all

	DEFINE IMAGE Image_Resize
		ROW Main.ClientAreaHeight - 20
		COL Main.ClientAreaWidth - 20
		WIDTH 20
		HEIGHT 20
		ONCLICK Nil
		PICTURE "Your_Transparent_.png_Icon"
		STRETCH .T.
		HELPID Nil
		VISIBLE .T.
		TRANSPARENT .T.
		BACKGROUNDCOLOR {255,255,255}	// <- Your back color
		ADJUSTIMAGE .F.
		TRANSPARENTCOLOR Nil
		TOOLTIP "Resize"
	END IMAGE
Add this control in the reposition function when resizing.
It won't actually do anything but warn the user that the window can be resized.
I didn't find .png icon but you can search the internet.

Re: Rezise window limit, how i do ?

Posted: Wed Mar 23, 2022 8:15 am
by Claudio Ricardo
Hi, I do this icon in transparent .png with Gimp white and black color 20x20 px.
Screenshot_20220323_050207.png
Screenshot_20220323_050207.png (4.85 KiB) Viewed 1323 times

Re: Rezise window limit, how i do ?

Posted: Wed Mar 23, 2022 3:19 pm
by edk
Or following Claudio's idea to use Label instead of Image:

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 BACKCOLOR {120,150,255} ON PAINT PaintSizeGrip( ThisWindow.Name ) 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>

//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
********************************
FUNCTION PaintSizeGrip( cWName )
Local nRow, nCol
IF !Empty ( cWName )
	nRow := GetProperty ( cWName, "ClientAreaHeight" ) - 10
	nCol := GetProperty ( cWName, "ClientAreaWidth" )  - 10

	IF .Not. _IsControlDefined ( "SizeGrip", cWName )
		@ nRow, nCol Label SizeGrip OF &cWName VALUE Chr ( 0x79 ) AUTOSIZE FONT "Wingdings 3" SIZE 10 TRANSPARENT
	ELSE
		SetProperty ( cWName, "SizeGrip", "Row", nRow )
		SetProperty ( cWName, "SizeGrip", "Col", nCol )
	ENDIF
ENDIF
RETURN
Claudio Ricardo wrote: Wed Mar 23, 2022 6:47 am Add this control in the reposition function when resizing.
A small hint: ON PAINT can also be used instead of the ON SIZE event

Re: Rezise window limit, how i do ?

Posted: Wed Mar 23, 2022 9:57 pm
by Red2
Thank you Claudio and Edward,
Your kind guidance looks promising.

However, I have not been able to get Claudio's actual .PNG image, "SizeGrip",
to appear in the bottom right corner. Instead, just a black square displays.
Despite my attempts, the .PNG image is not being displayed.

My Question:
What am I doing wrong or missing?
I would appreciate any and all suggestions.
----------------------------------------------
¿Qué estoy haciendo mal o omitiendo?
Agradecería cualquier y todas las sugerencias.
----------------------------------------------
From the .RC:

Code: Select all

SizeGrip PNG  Grip_Resize.PNG
The IMAGE definition in the .FMG file:

Code: Select all

    DEFINE IMAGE imgResizeGrip
        ROW    325
        COL    363
        WIDTH  20
        HEIGHT 20
        PICTURE "SizeGrip"
        HELPID Nil
        VISIBLE .T.
        STRETCH .T.
        ACTION Nil
    END IMAGE

Re: Rezise window limit, how i do ?

Posted: Wed Mar 23, 2022 10:52 pm
by Claudio Ricardo
Hi... TRANSPARENT .T. and posibly also need set backcolor, when define image control (see my code)
Attention ! HMG Ide delete this line when open .fmg for edit...
you need put it editing manually the .fmg file.

Edward code using LABEL instead IMAGE is best option.