Page 1 of 1

error in btnbmp

Posted: Wed Mar 19, 2008 6:53 pm
by Silvio
if i make this test :

Code: Select all

#include "FiveWin.ch"

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

function Main()

   local oDlg , omenutry

   SET _3DLOOK ON

   MENU omenutry POPUP  2007

      MENUITEM "first menu"
      MENUITEM "second menu"
      ENDMENU

   DEFINE DIALOG oDlg RESOURCE "Main" COLOR "N/B"

   REDEFINE BTNBMP ID 110 OF oDlg ;
      RESOURCE "Yes" NOBORDER ACTION oDlg:End()
      
    oDlg:aControls[ 1 ]:lTransparent = .t.

   REDEFINE BTNBMP ID 120 OF oDlg ;
      RESOURCE "No"
      oDlg:aControls[ 2 ]:oPopup := omenutry

   REDEFINE BTNBMP ID 130 OF oDlg ;
      RESOURCE "Cancel"

   ACTIVATE DIALOG oDlg CENTERED

return nil
THE RESOURCES FILE IS TESTBTNB.RC ( ON SAMPLES FOLDER OF FWH)

it make error on the secondo button when I click to open the menu popup

NCMOUSEMOVE

at TBTNBMP:LBUTTONUP(0)

How I can resolve it ?

Posted: Wed Mar 19, 2008 8:29 pm
by Antonio Linares
Silvio,

Please modify Class TBtnBmp Method LButtonUp() this way:

Code: Select all

METHOD LButtonUp( nRow, nCol )  CLASS TBtnBmp

   local oWnd
   local lClick := IsOverWnd( ::hWnd, nRow, nCol )

   if ::lDrag .or. ! Empty( ::oDragCursor )
      return Super:LButtonUp( nRow, nCol )
   endif

   if ::bLButtonUp != nil
      Eval( ::bLButtonUp, nRow, nCol)
   endif

   ::lBtnUp  = .t.

   if ! ::lWorking
      if ::lCaptured
         ::lCaptured = .f.
         ReleaseCapture()
         if ! ::lPressed
            if ::lBtnDown
               ::lPressed = .t.
               ::Refresh()
            endif
         else
            if ! ::lBtnDown
               ::lPressed = .f.
               ::Refresh()
            endif
         endif
         if lClick
            if ::oPopup != nil
               if nCol >= ::nWidth() - 13
                  if ::oWnd:oWnd != nil .and. Upper( ::oWnd:oWnd:Classname() ) == "TBAR"
                     oWnd := ::oWnd:oWnd
                  else
                     oWnd := ::oWnd
                  endif
                  oWnd:NcMouseMove() // close the tooltip
                  oWnd:oPopup = ::oPopup
                  ::oPopup:Activate( ::nTop + ::nHeight(), ::nLeft, oWnd, .f. )
                  oWnd:oPopup = nil
                  ::Refresh()
               else
                  ::Click()
               endif
            else
               ::Click()
            endif
         endif
      endif
   endif

return 0
Now your sample works fine :-)

Posted: Wed Mar 19, 2008 11:18 pm
by Antonio Linares
Silvio,

We have also improved PALBTNPAINT() so the bitmap looks in the proper position when the popup menu is used:
Image