Page 1 of 1

Metropanel bug

Posted: Sun Aug 18, 2013 6:15 am
by Richard Chidiak
Good morning

There is a naughty bug in metropanel .

Define your buttons (with images) on the main panel and from one of the buttons call a dialog. In the dialog define some images , if the mage coordinates are similar to the ones from the main panel, once the images buttons from the dialog are fired, the images from the main panel corresponding to the main panel get fired.

I have set a sample to show the problem, please execute from the fwh samples

click on users button and then either copy or print button from the dialog

Richard

Code: Select all

#INCLUDE "FIVEWIN.CH"
#include "metropnl.ch"

STATIC OWND

FUNCTION MAIN()
   DEFINE IMAGE oImgTouch FILENAME "..\bitmaps\AlphaBmp\handnew.bmp"

   DEFINE IMAGE oImgEnd FILENAME "..\bitmaps\pngs\end.png"

   DEFINE WINDOW oWnd STYLE nOr( WS_POPUP, WS_VISIBLE ) ;
      COLOR CLR_BLACK, CLR_BLUE

   oWnd:Maximize()

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      ON CLICK If( nRow > ScreenHeight() - 100 .and. ;
                   nCol > ScreenWidth() - 100, oWnd:End(),;
                   BuildMetroPanel() ) ;
      ON PAINT ( ABPaint( hDC, 500, 250, oImgTouch:hBitmap, 255 ),; // DrawTransparent( hDC, oImgTouch:hBitmap, 250, 500 ),;
                 ABPaint( hDC, ScreenWidth() - 100, ScreenHeight() - 40,;
                 oImgEnd:hBitmap, 255 ) )

   oImgEnd:End()

RETURN NIL


function BUILDMETROPANEL()
Local oMetro, oBtn

DEFINE METROPANEL oMetro OF oWnd COLOR CLR_WHITE,CLR_BLUE

oMetro:lDesignMode  := .T.
oMetro:nMetroTop    = 150
oMetro:nMetroMargin = 10
oMetro:nBtnSize     = 110 * OWND:nHorzRes() / 1024
oMetro:nSliderTop   = 170

oWnd:bMouseWheel = { | nKey, nDelta, nXPos, nYPos | oMetro:MouseWheel( nKey, nDelta, nXPos, nYPos )  }

DEFINE METROBUTTON oBtn OF oMetro LARGE ;
      CAPTION  "USERS" ;
      ALIGN    "BOTTOMCENTER" ;
      BITMAP   "..\bitmaps\metro\users.bmp" ;
      BMPALIGN "MIDDLECENTER" ;
      ACTION GETUSERS()

DEFINE METROBUTTON oBtn OF oMetro LARGE ;
      CAPTION "INTERNET" ;
      ALIGN    "BOTTOMCENTER" ;
      BITMAP   "..\bitmaps\metro\internet.bmp" ;
      BMPALIGN "MIDDLECENTER" ;
      ACTION MSGINFO("INTERNET")

DEFINE METROBUTTON oBtn OF oMetro ;
      COLOR   CLR_BLUE, RGB( 123, 140, 223 ) ;
      BITMAP  "..\bitmaps\metro\Metro-Calendar-Black-48.png" ;
      BMPALIGN   "MIDDLECENTER" ;
      CAPTION "Date" ;
      ALIGN "BOTTOMCENTER" ;
      ACTION MSGINFO("DATE...")

DEFINE METROBUTTON oBtn OF oMetro ;
      GROUP    4 ;
      CAPTION  "EXIT" ;
      ALIGN    "BOTTOMCENTER" ;
      BITMAP   "..\bitmaps\metro\exit.bmp" ;
      BMPALIGN "MIDDLECENTER" ;
      ACTION   oMetro:End()

oMetro:Show()
RETURN NIL

STATIC FUNCTION GETUSERS()
LOCAL ODLG,OBTN,OBTN2,obtn3

DEFINE DIALOG oDlg SIZE ScreenWidth(), ScreenHeight() + 50 ;
      STYLE nOr( WS_CHILD, WS_POPUP ) ;
      COLOR CLR_BLACK,CLR_WHITE  PIXEL  TRANSPARENT

@ 10, 10 IMAGE OBTN FILENAME "..\bitmaps\metro\back-black-48.png" OF oDlg PIXEL NOBORDER
OBTN:bLClicked := { || oDlg:End() }

@ 100,10 IMAGE OBTN2 FILENAME "..\bitmaps\metro\copy_50.png" OF oDlg PIXEL NOBORDER
OBTN2:bLClicked := { || oDlg:End() }
obtn2:CTOOLTIP := "please fire me"

@ 150, 10 IMAGE obtn3 FILENAME "..\bitmaps\metro\printer1_50.png" OF oDlg sIZE 40, 40 PIXEL NOBORDER
OBTN3:bLClicked := { || oDlg:End() }
obtn3:CTOOLTIP := "please fire me"


@ 200,140 SAY "Click on copy or print button "  COLOR CLR_BLACK, CLR_WHITE OF oDlg TRANSPARENT PIXEL SIZE 150,35

ACTIVATE DIALOG ODLG CENTERED
RETURN NIL

 

Re: Metropanel bug

Posted: Mon Aug 19, 2013 9:47 am
by Antonio Linares
Richard,

Please replace these lines:

OBTN2:bLClicked := { || oDlg:End() }

with:

OBTN2:bLButtonUp := { || oDlg:End() }

The problem was that the mouse up event was routed to the main screen so the metro button action was fired again

Re: Metropanel bug

Posted: Mon Aug 19, 2013 11:22 am
by Richard Chidiak
Antonio

it works ok now

Thank you

Richard

PS : it will be a good idea to change touch.prg , i will send you an updated copy

Re: Metropanel bug

Posted: Mon Aug 19, 2013 12:02 pm
by Antonio Linares
Richard,

thanks :-)