Fullscreen - AutoAdjust

HMG Samples and Enhancements

Moderator: Rathinagiri

Post Reply
emzampi
Posts: 106
Joined: Sun Aug 11, 2013 9:00 am

Fullscreen - AutoAdjust

Post by emzampi »

hello to everyone
I have to submit a problem with the resolution Fullscreen (my 1360 x 768) on which I built the program
using all available pixels.
I realized that using a resolution of 800x600 Fullscreen type part of the program was not
visible, and I have searched the forum for a solution that I found with partially AutoAdjust.prg 'nice program'
that does not solve my problem that I solved with this code, you can integrate it in AutoAdjust.prg
thus automating the use of H1 = ggh / nMainh W1 = ggw / nMainW


Private nMainW:=1360, nMainH:=768
ggw=GetDesktopWidth()

ggh=GetDesktopHeight()

W1=ggw/nMainW

H1=ggh/nMainh


DEFINE WINDOW condo ;
AT 0 , 0 WIDTH nMainW*w1 HEIGHT nMainH*h1 ;

TITLE 'CONDOMINIO' ;

MAIN ;

BACKCOLOR {213,235,244 } ;
CURSOR "bmp/salamandra.ani";

ON INIT AutoAdjust( ThisWindow.Name );

ON MAXIMIZE AutoAdjust( ThisWindow.Name );

ON SIZE AutoAdjust( ThisWindow.Name );

FONT "Tahoma" SIZE 9



DEFINE IMAGE Image_2

ROW 10 *h1
COL 1290*w1
WIDTH 22

HEIGHT 22

PICTURE 'bmp/quit.bmp'

HELPID Nil

VISIBLE .T.

STRETCH .F.

ACTION {||CloseTables1()} //(CIG1_Change()),,(condo2.Release)

END IMAGE
User avatar
serge_girard
Posts: 3164
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Fullscreen - AutoAdjust

Post by serge_girard »

Thanks for sharing !


Serge
There's nothing you can do that can't be done...
emzampi
Posts: 106
Joined: Sun Aug 11, 2013 9:00 am

Re: Fullscreen - AutoAdjust

Post by emzampi »

hello to everyone
I tried and tried to profane retouching program AutoAdjust to expose data also changing desktop settings were able to achieve a small result which you can test yourself and surely as the genes which I hope you are able to develop optimally
Thank you for existing

P.S. sorry but I have not found another way to insert the source file !!???



/*
* HMG - Harbour Win32 GUI library
* Copyright 2002-2008 Roberto Lopez <mail.box.hmg@gmail.com>
* /
*
* Revision: October 31, 2014
* Revised by: Danny Del Pilar
* HMG Sample: Managing Dynamic Windows Sample
*
*
*/

#include "hmg.ch"


***************


Function Main()
*ALTD()

*ggw - ggh cordinate del destop di costruzione

ggw= 1200
ggh= 600

PRIVATE hWndName := ""

DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH ggw;
HEIGHT ggh ;
MAIN;
ON INIT AutoAdjust( ThisWindow.Name );
ON MAXIMIZE AutoAdjust( ThisWindow.Name );
ON SIZE AutoAdjust( ThisWindow.Name );
TITLE 'Button Test'

DEFINE MAIN MENU
POPUP 'Test'
ITEM 'Disable button' ACTION Form_1.Button_1.Enabled := .f.
ITEM 'Enable button' ACTION Form_1.Button_1.Enabled := .t.
SEPARATOR
* ITEM "Window 1" ACTION WIND( "window1" )
* ITEM "Window 2" ACTION WIND( "window2" )
* ITEM "Window 3" ACTION WIND( "window3" )
END POPUP
END MENU

@ 70,70 BUTTON Button_1 PICTURE "button.bmp" WIDTH 50 HEIGHT 50
@ 40,400 LABEL M1 VALUE 'turoituioer' font '.vntime' size 10 bold BACKCOLOR {56,240,32 } FONTCOLOR RED WIDTH 200 HEIGHT 20
@ 80,400 LABEL m2 VALUE 'turoituioer' font '.vntime' size 10 bold BACKCOLOR {56,240,32 } FONTCOLOR RED WIDTH 250 HEIGHT 20
@ 120,400 LABEL m3 VALUE 'turoituioer' font '.vntime' size 10 bold BACKCOLOR {56,240,32 } FONTCOLOR RED WIDTH 300 HEIGHT 20
@ 140,960 LABEL m4 VALUE 'turoituioer' font '.vntime' size 10 bold BACKCOLOR {56,240,32 } FONTCOLOR RED WIDTH 180 HEIGHT 20
@ 180,970 LABEL m5 VALUE 'turoituioer' font '.vntime' size 10 bold BACKCOLOR {56,240,32 } FONTCOLOR RED WIDTH 180 HEIGHT 20
@ 220,980 LABEL m6 VALUE 'turoituioer' font '.vntime' size 10 bold BACKCOLOR {56,240,32 } FONTCOLOR RED WIDTH 180 HEIGHT 20
@ 250,990 LABEL m7 VALUE 'turoituioer' font '.vntime' size 10 bold BACKCOLOR {56,240,32 } FONTCOLOR RED WIDTH 180 HEIGHT 20
@ 280,1000 LABEL m8 VALUE 'aaaaaaaaaa' font '.vntime' size 10 bold BACKCOLOR {56,240,32 } FONTCOLOR RED WIDTH 180 HEIGHT 20

@ 310,400 LABEL settore VALUE 'turoituioer' font '.vntime' size 10 bold BACKCOLOR {56,240,32 } FONTCOLOR RED WIDTH 400 HEIGHT 50

@ 300,580 LABEL m9 VALUE 'turoituioer' font '.vntime' size 10 bold BACKCOLOR {156,2,132 } FONTCOLOR RED WIDTH 400 HEIGHT 20

END WINDOW

Form_1.Maximize
ACTIVATE WINDOW Form_1
Return
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Function AutoAdjust( cForm )
Local hWnd := GetFormHandle( cForm )




Local i,; // From no
k,; // Control no
ParentForm,;
ControlCount,;
ControlName,;
ControlType,;
nWidth,;
nHeight,;
lvisible := .T.,;
nDivw,;
nDivh


Private nMainW:=GetWindowWidth ( hWnd ), nMainH:=GetWindowHeight ( hWnd)


aa=ggw/GetWindowWidth ( hWnd )
bb=ggh/GetWindowHeight ( hWnd )

IF GetDesktopWidth() > GetWindowWidth ( hWnd )
nWidth :=GetDesktopWidth()
nWidth=(nWidth/nMainW)
ELSE
nWidth := GetWindowWidth ( hWnd )
nWidth=(nWidth/nMainW)
ENDIF

IF GetDesktopHeight() > GetWindowHeight ( hWnd )
nHeight := GetDesktopHeight()
nHeight=( nHeight/nMainH)
ELSE
nHeight := GetDesktopHeight()
nHeight=( nHeight/nMainH)
ENDIF

IF IsWindowVisible( hWnd ) .AND. ! IsAppXPThemed()
HideWindow ( hWnd )
ELSE
lvisible := .F.
ENDIF

i := aScan ( _HMG_SYSDATA[67], hWnd )

ParentForm := _HMG_SYSDATA[66]

IF _HMG_SYSDATA[ 92, i ] > 0 .AND. _HMG_SYSDATA[ 91, i ] >0
nDivw := nWidth / _HMG_SYSDATA[ 92, i]
nDivh := nHeight/ _HMG_SYSDATA[ 91, i]
ELSE
nDivw := aa //
nDivh := bb //
ENDIF

form_1.m1.value:=str(nMainW)
form_1.m2.value:=str(nMainH)
form_1.m3.value:=str(nWidth)
form_1.m4.value:=str(nHeight)
form_1.m5.value:=str(nDivw)+'ndivw'
form_1.m6.value:=str(nDivh)+'ndivh'
form_1.m7.value:=str(_HMG_SYSDATA[ 92, i ])
form_1.m8.value:=str(_HMG_SYSDATA[ 91, i ])
*form_1.settore.value:=str(nMainW)+str(nMainH)+str(nWidth)+str(nHeight)

ControlCount := LEN ( _HMG_SYSDATA[ 3 ] )

FOR k := 1 To ControlCount

ControlName := _HMG_SYSDATA[ 2, k ]

IF _IsControlDefined ( ControlName, ParentForm )
ControlType := _HMG_SYSDATA[ 1, k ]

IF !EMPTY( ControlName ) .AND. !( ControlType $ "MENU,HOTKEY,TOOLBAR,MESSAGEBAR,ITEMMESSAGE,TIMER" )

DO CASE

CASE ControlType == "LABEL"
_SetControlSizePos( ControlName, ParentForm,;
_GetControlRow( ControlName, ParentForm ) / nDivh, ; // row
_GetControlCol ( ControlName, ParentForm ) / nDivw ,; // column
_GetControlWidth( ControlName, ParentForm ) / nDivw ,; // with
_GetControlHeight ( ControlName, ParentForm)/ nDivh ) // height

form_1.settore.value:=str(_GetControlRow( ControlName, ParentForm ) )+str(ndivh)

CASE ControlType $ "RADIOGROUP,TEXT,BUTTON"
_SetControlSizePos( ControlName, ParentForm,;
_GetControlRow( ControlName, ParentForm ) / nDivh, ; // row
_GetControlCol ( ControlName, ParentForm ) / nDivw ,; // column
_GetControlWidth( ControlName, ParentForm ) / nDivw,; // with
_GetControlHeight ( ControlName, ParentForm ) / nDivh) // height

CASE ControlType == "SLIDER"
_SetControlSizePos ( ControlName, ParentForm,;
_GetControlRow ( ControlName, ParentForm ) * nDivh, _GetControlCol ( ControlName, ParentForm ) * nDivw,;
_GetControlWidth ( ControlName, ParentForm ) * nDivw, _GetControlHeight ( ControlName, ParentForm ) * nDivh )

CASE ControlType == "STATUSBAR"
// do nothing

CASE !ControlType $ "TOOLBUTTON"
_SetControlSizePos ( ControlName, ParentForm,;
_GetControlRow ( ControlName, ParentForm ) * nDivh, _GetControlCol ( ControlName, ParentForm ) * nDivw,;
_GetControlWidth ( ControlName, ParentForm )* nDivw, _GetControlHeight ( ControlName, ParentForm ) * nDivh )
OTHERWISE

IF EMPTY( _HMG_SYSDATA[ 28, k ] )

_SetFontSize ( ControlName, ParentForm , 8 * nDivh )
ELSE
_SetFontSize ( ControlName, ParentForm , _HMG_SYSDATA[28] [k] * nDivh )
ENDIF


ENDCASE
ENDIF
ENDIF



NEXT k

_HMG_SYSDATA[92] :=nWidth
_HMG_SYSDATA[91] :=nHeight

IF lvisible
ShowWindow ( hWnd )
ENDIF
Return Nil

FUNCTION ISAPPXPTHEMED()
RETURN ( OS_ISWINXP_OR_LATER() ; // <= hrb\contrib/hbwin/legacycv.c
.AND. IsAppThemed() ) // <= HMG\h_window.prg
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Fullscreen - AutoAdjust

Post by esgici »

emzampi wrote: ...
P.S. sorry but I have not found another way to insert the source file !!???
...
Embed your code lines between "code" and "/code" tags. "Tags" should be enclosed by brackets.

You can use "Code" button of post editor:
CodeButton.PNG
CodeButton.PNG (21.98 KiB) Viewed 5404 times
There isn't a "file insert" option; you need copy and past. You can use "attachment" option for long files.

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
emzampi
Posts: 106
Joined: Sun Aug 11, 2013 9:00 am

Re: Fullscreen - AutoAdjust

Post by emzampi »

thanks esgici

Code: Select all

/*
 * HMG - Harbour Win32 GUI library
 * Copyright 2002-2008 Roberto Lopez <mail.box.hmg@gmail.com>
 * http://www.hmgforum.com//
 *
 * Revision: October 31, 2014
 * Revised by: Danny Del Pilar
 * HMG Sample: Managing Dynamic Windows Sample
 *
 *
*/

#include "hmg.ch"


***************


Function Main()
*ALTD()

*ggw - ggh cordinate del destop di costruzione

ggw= 1360
ggh= 600 

   PRIVATE hWndName := ""

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH ggw;
      HEIGHT ggh ;
      MAIN;
	  ON INIT AutoAdjust( ThisWindow.Name );
       ON MAXIMIZE AutoAdjust( ThisWindow.Name );
       ON SIZE AutoAdjust( ThisWindow.Name );
      TITLE 'Button Test'

      DEFINE MAIN MENU
              POPUP 'Test'
                ITEM 'Disable button' ACTION Form_1.Button_1.Enabled := .f.
                ITEM 'Enable button'  ACTION Form_1.Button_1.Enabled := .t.
                SEPARATOR
               * ITEM "Window 1" ACTION WIND( "window1" )
               * ITEM "Window 2" ACTION WIND( "window2" )
               * ITEM "Window 3" ACTION WIND( "window3" )
              END POPUP
      END MENU

      @ 70,1200 BUTTON Button_1 PICTURE "button.bmp" WIDTH 50 HEIGHT 50
	  @ 40,400 LABEL M1 VALUE  'turoituioer'  font '.vntime' size 10 bold BACKCOLOR  {56,240,32 }  FONTCOLOR RED WIDTH 200 HEIGHT 20 
	  @ 80,400 LABEL m2 VALUE  'turoituioer'  font '.vntime' size 10 bold BACKCOLOR  {56,240,32 }  FONTCOLOR RED WIDTH 250 HEIGHT 20
	  @ 120,400 LABEL m3 VALUE  'turoituioer'  font '.vntime' size 10 bold BACKCOLOR  {56,240,32 }  FONTCOLOR RED WIDTH 300 HEIGHT 20
	  @ 140,960 LABEL m4 VALUE  'turoituioer'  font '.vntime' size 10 bold BACKCOLOR  {56,240,32 }  FONTCOLOR RED WIDTH 180 HEIGHT 20
	  @ 180,970 LABEL m5 VALUE  'turoituioer'  font '.vntime' size 10 bold BACKCOLOR  {56,240,32 }  FONTCOLOR RED WIDTH 180 HEIGHT 20
	 @ 220,980 LABEL m6 VALUE  'turoituioer'  font '.vntime' size 10 bold BACKCOLOR  {56,240,32 }  FONTCOLOR RED WIDTH 180 HEIGHT 20
	  @ 250,990 LABEL m7 VALUE  'turoituioer'  font '.vntime' size 10 bold BACKCOLOR  {56,240,32 }  FONTCOLOR RED WIDTH 180 HEIGHT 20
	 @ 280,1000 LABEL m8 VALUE  'aaaaaaaaaa'  font '.vntime' size 10 bold BACKCOLOR  {56,240,32 }  FONTCOLOR RED WIDTH 180 HEIGHT 20

	@ 310,400 LABEL settore VALUE  'turoituioer'  font '.vntime' size 10 bold BACKCOLOR  {56,240,32 }  FONTCOLOR RED WIDTH 400 HEIGHT 50
  
@ 300,580 LABEL m9 VALUE  'turoituioer'  font '.vntime' size 10 bold BACKCOLOR  {156,2,132 }  FONTCOLOR RED WIDTH 400 HEIGHT 20

  END WINDOW

  Form_1.Maximize
   ACTIVATE WINDOW Form_1
   Return
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Function AutoAdjust( cForm )
Local hWnd := GetFormHandle( cForm )




Local i,;                    // From no
      k,;                    // Control no                  
      ParentForm,;  
      ControlCount,; 
      ControlName,; 
      ControlType,; 
      nWidth,; 
      nHeight,; 
      lvisible := .T.,; 
      nDivw,; 
      nDivh
 
	
Private nMainW:=GetWindowWidth ( hWnd ), nMainH:=GetWindowHeight ( hWnd)

 
aa=ggw/GetWindowWidth ( hWnd )
bb=ggh/GetWindowHeight ( hWnd )

IF GetDesktopWidth() > GetWindowWidth ( hWnd )
   nWidth :=GetDesktopWidth() 
 nWidth=(nWidth/nMainW)
ELSE
   nWidth :=  GetWindowWidth ( hWnd )
 nWidth=(nWidth/nMainW)
ENDIF

IF GetDesktopHeight() > GetWindowHeight ( hWnd )
   nHeight := GetDesktopHeight() 
   nHeight=( nHeight/nMainH)
 ELSE
   nHeight := GetDesktopHeight() 
 nHeight=( nHeight/nMainH)
ENDIF

IF IsWindowVisible( hWnd ) .AND. ! IsAppXPThemed()
   HideWindow ( hWnd )
ELSE
   lvisible := .F.
ENDIF

i := aScan ( _HMG_SYSDATA[67], hWnd )

ParentForm := _HMG_SYSDATA[66] [i]

IF _HMG_SYSDATA[ 92, i ] > 0 .AND. _HMG_SYSDATA[ 91, i ] >0
   nDivw := nWidth / _HMG_SYSDATA[ 92, i]
   nDivh := nHeight/ _HMG_SYSDATA[ 91, i]
ELSE
    nDivw := aa //
   nDivh :=  bb //
   ENDIF
 
  form_1.m1.value:=str(nMainW)
form_1.m2.value:=str(nMainH)
form_1.m3.value:=str(nWidth)
form_1.m4.value:=str(nHeight)
form_1.m5.value:=str(nDivw)+'ndivw'
form_1.m6.value:=str(nDivh)+'ndivh'
form_1.m7.value:=str(_HMG_SYSDATA[ 92, i ])
form_1.m8.value:=str(_HMG_SYSDATA[ 91, i ])
*form_1.settore.value:=str(nMainW)+str(nMainH)+str(nWidth)+str(nHeight)

ControlCount := LEN ( _HMG_SYSDATA[ 3 ] )

FOR k := 1 To ControlCount

    ControlName := _HMG_SYSDATA[ 2, k ]
    
    IF _IsControlDefined ( ControlName, ParentForm )
       ControlType := _HMG_SYSDATA[ 1, k ]
  
       IF !EMPTY( ControlName ) .AND. !( ControlType $ "MENU,HOTKEY,TOOLBAR,MESSAGEBAR,ITEMMESSAGE,TIMER" )
    
          DO CASE

		    CASE ControlType == "LABEL"
		          _SetControlSizePos( ControlName, ParentForm,;
				  _GetControlRow( ControlName, ParentForm )    / nDivh, ;   // row
                  _GetControlCol ( ControlName, ParentForm )   /  nDivw ,;  // column
                  _GetControlWidth( ControlName, ParentForm )  /  nDivw ,;  // with
                  _GetControlHeight ( ControlName, ParentForm)/ nDivh   ,;      // height
		             _SetFontSize ( ControlName, ParentForm , 10 * nDivh ))
		  form_1.settore.value:=str(_GetControlRow( ControlName, ParentForm ) )+str(ndivh)
	  
             CASE ControlType $ "RADIOGROUP,TEXT,BUTTON"
                  _SetControlSizePos( ControlName, ParentForm,;
                   _GetControlRow( ControlName, ParentForm ) / nDivh, ;   // row
                   _GetControlCol ( ControlName, ParentForm ) / nDivw ,;  // column
                   _GetControlWidth( ControlName, ParentForm ) / nDivw,;  // with
                   _GetControlHeight ( ControlName, ParentForm ) / nDivh)        // height
                
             CASE ControlType == "SLIDER"
                  _SetControlSizePos ( ControlName, ParentForm,;
                  _GetControlRow ( ControlName, ParentForm ) * nDivh, _GetControlCol ( ControlName, ParentForm ) * nDivw,;
                  _GetControlWidth ( ControlName, ParentForm ) * nDivw, _GetControlHeight ( ControlName, ParentForm ) * nDivh )
            
             CASE ControlType == "STATUSBAR"  
                  // do nothing
    
             CASE !ControlType $ "TOOLBUTTON"
                  _SetControlSizePos ( ControlName, ParentForm,;
                  _GetControlRow ( ControlName, ParentForm ) * nDivh, _GetControlCol ( ControlName, ParentForm ) * nDivw,;
                  _GetControlWidth ( ControlName, ParentForm )* nDivw, _GetControlHeight ( ControlName, ParentForm ) * nDivh )
          OTHERWISE
		
             IF EMPTY( _HMG_SYSDATA[ 28, k ] )
			
                _SetFontSize ( ControlName, ParentForm , 8 * nDivh )
             ELSE
                _SetFontSize ( ControlName, ParentForm , _HMG_SYSDATA[28] [k] * nDivh )
             ENDIF
			 
			
          ENDCASE
       ENDIF
    ENDIF


	
NEXT k

_HMG_SYSDATA[92] [i] :=nWidth
_HMG_SYSDATA[91] [i] :=nHeight

IF lvisible
   ShowWindow ( hWnd )
ENDIF
Return Nil

FUNCTION ISAPPXPTHEMED()
RETURN ( OS_ISWINXP_OR_LATER() ;     // <= hrb\contrib/hbwin/legacycv.c
         .AND. IsAppThemed() )       // <= HMG\h_window.prg

emzampi
Posts: 106
Joined: Sun Aug 11, 2013 9:00 am

Re: Fullscreen - AutoAdjust

Post by emzampi »

sorry but you do not think it will be useful this change 'course improved' which would make visible objects on a desktop other than the one with which he had planned layaut (examples of 1360 * 768 ==> 800 * 600) just by changing a few lines the program ??

ggw= 1200
ggh= 600

PRIVATE hWndName := ""

DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH ggw;
HEIGHT ggh ;
MAIN;
User avatar
serge_girard
Posts: 3164
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Fullscreen - AutoAdjust

Post by serge_girard »

I think it could be usefull, but I can't test it now while I have no time now.

Serge
There's nothing you can do that can't be done...
emzampi
Posts: 106
Joined: Sun Aug 11, 2013 9:00 am

Re: Fullscreen - AutoAdjust

Post by emzampi »

thanks Serge
for having expressed your thoughts, because I began to wonder if this is not a problem other problem users of HMG
Post Reply