Maximizar y minimizar

HMG Samples and Enhancements

Moderator: Rathinagiri

Post Reply
User avatar
jrendon
Posts: 92
Joined: Thu Aug 14, 2008 9:21 pm

Maximizar y minimizar

Post by jrendon » Tue Sep 09, 2008 8:19 pm

Español

Hola a todos, alguien sabe como hacer que desde minigui se pueda Maximizar o Minimizar cualqquier otra aplicación que se encuentra abierta

Saludos

English (Powered By Google)

Hello everyone, someone knows how to do that since minigui can maximize or minimize any application that is open

Greetings

Juan Rendon

User avatar
Rathinagiri
Posts: 5023
Joined: Tue Jul 29, 2008 6:30 pm
Location: Sivakasi, India
Has thanked: 73 times
Been thanked: 83 times
Contact:

Re: Maximizar y minimizar

Post by Rathinagiri » Wed Sep 10, 2008 3:10 am

Any application? Meaning, only MiniGUI applications or other applications also?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
gfilatov
Posts: 495
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 5 times
Been thanked: 23 times
Contact:

Re: Maximizar y minimizar

Post by gfilatov » Wed Sep 10, 2008 8:57 am

jrendon wrote:...
Hello everyone, someone knows how to do that since minigui can maximize or minimize any application that is open
Hello Juan Rendon,

Try the following samples for standard Calculator and Notepad applications:

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library Demo
 *
 * Copyright 2002-2008 Roberto Lopez <harbourminigui@gmail.com>
 * http://harbourminigui.googlepages.com/
 *
 * Copyright 2006-2008 Grigory Filatov <gfilatov@freemail.ru>
*/

#include "minigui.ch"

#define GW_HWNDFIRST		0
#define GW_HWNDLAST		1
#define GW_HWNDNEXT		2
#define GW_HWNDPREV		3
#define GW_OWNER		4
#define GW_CHILD		5

#define APP_TITLE 'Calculator'

FUNCTION Main()

	DEFINE WINDOW Form_Main ;
		AT 0,0 ;
		WIDTH 400 HEIGHT 200 ;
		TITLE "Minimize/Restore Calc Demo" ;
		MAIN ;
		ON INIT StartIt()

		DEFINE BUTTON Button_1
			ROW	10
			COL	10
			WIDTH	200
			CAPTION 'Minimize/Restore Calc' 
			ACTION MinimizeIt()
			DEFAULT .T.
		END BUTTON

		DEFINE BUTTON Button_2
			ROW	40
			COL	10
			WIDTH	200
			CAPTION 'Cancel'
			ACTION ThisWindow.Release
		END BUTTON

	END WINDOW

	CENTER WINDOW Form_Main

	ACTIVATE WINDOW Form_Main

RETURN Nil

FUNCTION StartIt()
Local aTitles := GetTitles( GetFormHandle("Form_Main") )
Local n

	n := aScan( aTitles, {|e| APP_TITLE $ e[1] } )

	IF EMPTY( n )

		_Execute ( 0, , "Calc", , , 5 )

	ENDIF

RETURN Nil

FUNCTION MinimizeIt()
Local aTitles := GetTitles( GetFormHandle("Form_Main") )
Local hWnd

	n := aScan( aTitles, {|e| APP_TITLE $ e[1] } )

	IF n > 0

		hWnd := aTitles[ n ][ 2 ]

		IF IsIconic( hWnd )

			Restore( hWnd )

		ELSE

			Minimize( hWnd )

		ENDIF

	ELSE

		MsgStop( "Cannot find application window!", "Error" )

	ENDIF

RETURN Nil

*--------------------------------------------------------*
Function GetTitles( hOwnWnd )
*--------------------------------------------------------*
Local aTasks := {}, cTitle := "", ;
	hWnd := GetWindow( hOwnWnd, GW_HWNDFIRST )        // Get the first window

	WHILE hWnd != 0                                   // Loop through all the windows

		cTitle := GetWindowText( hWnd )

		IF GetWindow( hWnd, GW_OWNER ) = 0 .AND.;  // If it is an owner window
			IsWindowVisible( hWnd ) .AND.;      // If it is a visible window
			hWnd != hOwnWnd .AND.;              // If it is not this app
			!EMPTY( cTitle ) .AND.;             // If the window has a title
			!( "DOS Session" $ cTitle ) .AND.;  // If it is not DOS session
			!( cTitle == "Program Manager" )    // If it is not the Program Manager

			aAdd( aTasks, { cTitle, hWnd } )
		ENDIF

		hWnd := GetWindow( hWnd, GW_HWNDNEXT )     // Get the next window
	ENDDO

Return ( aTasks )


#pragma BEGINDUMP

#define HB_OS_WIN_32_USED
#define _WIN32_WINNT 0x0400

#include <windows.h>
#include "hbapi.h"
#include "hbapiitm.h"

HB_FUNC( ISICONIC )
{
   hb_retl( IsIconic( ( HWND ) hb_parnl( 1 ) ) );
}

#pragma ENDDUMP
and

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library Demo
 *
 * Copyright 2002-2008 Roberto Lopez <harbourminigui@gmail.com>
 * http://harbourminigui.googlepages.com/
 *
 * Copyright 2006-2008 Grigory Filatov <gfilatov@freemail.ru>
*/

#include "minigui.ch"

#define GW_HWNDFIRST		0
#define GW_HWNDLAST		1
#define GW_HWNDNEXT		2
#define GW_HWNDPREV		3
#define GW_OWNER		4
#define GW_CHILD		5

#define APP_TITLE 'Notepad'

FUNCTION Main()

	DEFINE WINDOW Form_Main ;
		AT 0,0 ;
		WIDTH 400 HEIGHT 200 ;
		TITLE "Minimize/Maximize Notepad Demo" ;
		MAIN ;
		TOPMOST ;
		ON INIT StartIt()

		DEFINE BUTTON Button_1
			ROW	10
			COL	10
			WIDTH	200
			CAPTION 'Minimize/Maximize Notepad'
			ACTION MinimizeIt()
			DEFAULT .T.
		END BUTTON

		DEFINE BUTTON Button_2
			ROW	40
			COL	10
			WIDTH	200
			CAPTION 'Cancel'
			ACTION ThisWindow.Release
		END BUTTON

	END WINDOW

	CENTER WINDOW Form_Main

	ACTIVATE WINDOW Form_Main

RETURN Nil

FUNCTION StartIt()
Local aTitles := GetTitles( GetFormHandle("Form_Main") )
Local n

	n := aScan( aTitles, {|e| APP_TITLE $ e[1] } )

	IF EMPTY( n )

		_Execute ( 0, , "Notepad", , , 5 )

	ENDIF

RETURN Nil

FUNCTION MinimizeIt()
Local aTitles := GetTitles( GetFormHandle("Form_Main") )
Local hWnd

	n := aScan( aTitles, {|e| APP_TITLE $ e[1] } )

	IF n > 0

		hWnd := aTitles[ n ][ 2 ]

		IF IsIconic( hWnd )

			Maximize( hWnd )

		ELSE

			Minimize( hWnd )

		ENDIF

	ELSE

		MsgStop( "Cannot find application window!", "Error" )

	ENDIF

RETURN Nil

*--------------------------------------------------------*
Function GetTitles( hOwnWnd )
*--------------------------------------------------------*
Local aTasks := {}, cTitle := "", ;
	hWnd := GetWindow( hOwnWnd, GW_HWNDFIRST )        // Get the first window

	WHILE hWnd != 0                                   // Loop through all the windows

		cTitle := GetWindowText( hWnd )

		IF GetWindow( hWnd, GW_OWNER ) = 0 .AND.;  // If it is an owner window
			IsWindowVisible( hWnd ) .AND.;      // If it is a visible window
			hWnd != hOwnWnd .AND.;              // If it is not this app
			!EMPTY( cTitle ) .AND.;             // If the window has a title
			!( "DOS Session" $ cTitle ) .AND.;  // If it is not DOS session
			!( cTitle == "Program Manager" )    // If it is not the Program Manager

			aAdd( aTasks, { cTitle, hWnd } )
		ENDIF

		hWnd := GetWindow( hWnd, GW_HWNDNEXT )     // Get the next window
	ENDDO

Return ( aTasks )


#pragma BEGINDUMP

#define HB_OS_WIN_32_USED
#define _WIN32_WINNT 0x0400

#include <windows.h>
#include "hbapi.h"
#include "hbapiitm.h"

HB_FUNC( ISICONIC )
{
   hb_retl( IsIconic( ( HWND ) hb_parnl( 1 ) ) );
}

#pragma ENDDUMP
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest