Page 1 of 1

How to keep a appl. on top of the dlg on resize ? (solved)

PostPosted: Fri Jul 31, 2015 5:33 pm
by ukoenig
Hello,

I have 2 questions :

The situation : from inside the RGB-tool I call the colorpicker ( exe )

1. how to close the colorpicker as well, using the exit button from the RGB-tool ?
2. how to keep the colorpicker on top after minimize / maximize the RGB-tool ?

Added : calling the Colorpicker ( standalone exe ) from inside the RGB-tool

Image

best regards
Uwe :?:

Re: How to keep a appl. on top of the dialog on resize ?

PostPosted: Fri Jul 31, 2015 9:09 pm
by cnavarro
ukoenig wrote:Hello,

I have 2 questions :

The situation : from inside the RGB-tool I call the colorpicker ( exe )

1. how to close the colorpicker as well, using the exit button from the RGB-tool ?
2. how to keep the colorpicker on top after minimize / maximize the RGB-tool ?

Added : calling the Colorpicker ( standalone exe ) from inside the RGB-tool

best regards
Uwe :?:


Try
To close external application:
Code: Select all  Expand view

SendMessage( FindWindow( 0, "ColorPicker" ), WM_CLOSE )
 

Re: How to keep a appl. on top of the dialog on resize ?

PostPosted: Sat Aug 01, 2015 7:17 am
by ukoenig
Thank You very much for the response

the defined EXE-names
RGB.exe
Colorpick.exe

The following lines are included in RGB.prg the time I added the Colorpick-button, but doesn't work
..
DEFINE DIALOG oDlg RESOURCE "RGB" PIXEL ;
FONT oFont TITLE "RGB-colors and Gradients => Release 4.3 / 10.02.2015" OF oDlg
..

exit button in RGB.prg

REDEFINE BTNBMP oSBtn[16] OF oDlg ;
ID 580 PIXEL 2007 ;
NOBORDER ;
PROMPT "&Exit RGB-colors" ;
FILENAME c_path1 + "Exit.Bmp" ;
ACTION ( SendMessage( FindWindow( 0, "COLORPICK" ), WM_CLOSE ), oDlg:End() ) ;
FONT oFont1 ;
LEFT


the defined Line in RGB.prg, to keep the colorpicker on top using minimize / maximize of RGB.exe

oDlg:bResized := {|| ON_TOP() }

ACTIVATE DIALOG oDlg CENTERED
..
..
RETURN NIL

// ----

FUNCTION ON_TOP()
CFILENAME := "COLORPICK.exe"
IF ISEXERUNNING( CFILENAME( HB_ARGV( 0 ) ) )
SHOWWINDOW( FINDWINDOW( 0, "COLORPICK" ), 9 )
SETFOREGROUNDWINDOW( FINDWINDOW( 0, "COLORPICK" ) )
ENDIF
RETURN NIL


both are not working

The main-lines from Colorpick.prg


..
..
DEFINE WINDOW oWnd FROM 10, 10 TO 270, 290 PIXEL TITLE "COLOR-PICKER 1.1"
..
..
DEFINE TIMER oTimer OF oWnd ;
INTERVAL 70 ACTION ( nRGB := GetColor(), ;
nRed := nRGBRed( nRGB ), ;
nGreen := nRGBGreen( nRGB ), ;
nBlue := nRGBBlue( nRGB ), ;
cRGB := "nRGB( " + ALLTRIM(STR(nRed)) + ", " + ;
ALLTRIM(STR(nGreen)) + ", " + ;
ALLTRIM(STR(nBlue)) + " )", ;
oSay2:Refresh(), oSay3:Refresh() )

oTimer:Activate()
oWnd:bKeyDown := {|nKey| IF(nKey = nWKey, SAVE_COLOR(), ) }

ACTIVATE WINDOW oWnd CENTER

oTimer:DeActivate()

RETURN NIL


I tested including the Colorpick-source, but I noticed some problems ( maybe the timer )
I think a extra EXE-file is the better solution.

best regards
Uwe :?:

Re: How to keep a appl. on top of the dialog on resize ?

PostPosted: Sat Aug 01, 2015 8:08 am
by Antonio Linares
Uwe,

Great work as usual! :-)

Re: How to keep a appl. on top of the dialog on resize ?

PostPosted: Sat Aug 01, 2015 8:56 am
by ukoenig
Antonio,

thank You very much. I hope it is useful

here is a little test, what I'm trying to do from inside the RGB-tool to make it complete.
The test includes the 2 buttons of the RGB-main-dialog and the Colorpicker.

< Daniel Cuatecatl Leon > got the download-link of the colorpicker-source.
Tested and worked fine for him ( worked as well with older FWH-releases ).


Download :
http://www.pflegeplus.com/DOWNLOADS/TestPick1.zip

Image

best regards
Uwe :?:

Re: How to keep a appl. on top of the dialog on resize ?

PostPosted: Sat Aug 01, 2015 1:03 pm
by ukoenig
Both needed solutions are working fine now using FUNCTION TOP_CLOSE(nType) !!!

bring on top nType = 1
close nType = 2


Download :
http://www.pflegeplus.com/DOWNLOADS/TestPick2.zip

#define GW_CHILD 5
#define GW_HWNDNEXT 2
#define SW_RESTORE 9
,,,
,,,
FUNCTION TOP_CLOSE(nType)

hWnd := FindWnd( "COLOR-PICKER 1.1" ) // Title !!!
IF hWnd != NIL
IF ISICONIC( hWnd )
SHOWWINDOW( hWnd, SW_RESTORE )
ENDIF
IF nType = 1
SETFOREGROUNDWINDOW( hWnd )
ENDIF
IF nType = 2
SENDMESSAGE( hWnd, WM_CLOSE )
ENDIF
ELSE
MsgAlert( "COLORPICKER is not running !", "Attention" )
ENDIF

RETURN NIL

// ----------

FUNCTION FINDWND( cTitle )
local hWnd := GetWindow( GetDesktopWindow(), GW_CHILD )

WHILE hWnd != 0
IF Upper( cTitle ) $ Upper( GetWindowText( hWnd ) )
RETURN hWnd
ENDIF
hWnd = GetWindow( hWnd, GW_HWNDNEXT )
END

RETURN NIL


best regards
Uwe :D