BtnBmp and PopupMenu

BtnBmp and PopupMenu

Postby Silvio.Falconi » Thu Jun 21, 2018 1:34 pm

I wish Open a PopupMenu on Btnbmp I tried with

:bRClicked := { | nRow, nCol, oBtn | ShowActions( nRow, nCol,n, oBtn ) }

and

:bAction := { | nRow, nCol, oBtn | ShowActions( nRow, nCol,n, oBtn ) }

But it make error

Code: Select all  Expand view  RUN

  for n := 1 to 70
      @ nRow, nCol BTNBMP aBtn[ n ] .....
 WITH OBJECT aBtn[ n ]
         :Cargo      := n
:bRClicked := { | nRow, nCol, oBtn | ShowActions( nRow, nCol,n, oBtn ) }

 END
.....
Function ShowActions( nrow, ncol, n, oControl )
   Local oMenuPopup
   MENU POPUP oMenuPopup
  MenuItem "aaaaaaaaaaaa"
  MenuItem "bbbbbbbbbbbbb"
    ENDMENU
 ACTIVATE POPUP oMenuPopup  of oControl AT nrow, ncol
Return NIL


Any solution Please
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: BtnBmp and PopupMenu

Postby cnavarro » Thu Jun 21, 2018 2:17 pm

What error ?
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: BtnBmp and PopupMenu

Postby Silvio.Falconi » Thu Jun 21, 2018 2:27 pm

with baction I not see the menupopup
with :bRClicked I Have this error
Code: Select all  Expand view  RUN
Application
===========
   Path and name: C:\Work\Errori\image_su_btnbmp\test.Exe (32 bits)
   Size: 3,655,168 bytes
   Compiler version: Harbour 3.2.0dev (r1703231115)
   FiveWin  version: FWH 17.12
   C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
   Windows version: 6.2, Build 9200

   Time from start: 0 hours 0 mins 3 secs
   Error occurred at: 21-06-2018, 16:26:13
   Error description: Error BASE/1004  No exported method: HWND
   Args:
     [   1] = N   2

Stack Calls
===========
   Called from:  => HWND( 0 )
   Called from: .\source\classes\MENU.PRG => TMENU:ACTIVATE( 1568 )
   Called from: test.prg => SHOWACTIONS( 121 )
   Called from: test.prg => (b)SHOW_BEACH( 66 )
   Called from: .\source\classes\WINDOW.PRG => TBTNBMP:RBUTTONDOWN( 2018 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1731 )
   Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 1883 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3356 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: BtnBmp and PopupMenu

Postby Silvio.Falconi » Thu Jun 21, 2018 3:18 pm

Now I tried with

Code: Select all  Expand view  RUN
 for n := 1 to 10
      @ nRow, nCol BTNBMP aBtn[ n ]  RESOURCE OMB_LIBERO  ;
         SIZE 84,64 PIXEL OF oDlg FLAT TOP COLOR CLR_WHITE,CLR_GREEN NOBORDER

WITH OBJECT aBtn[ n ]
         :Cargo      := n
         :bRClicked    := { | nRow, nCol, oBtn | EseguiButton(nrow, ncol, n, oBtn) }
 END
 next n

FUNCTION EseguiButton( nrow, ncol, n, oControl )
RETURN { |n| Menu_popup( nrow, ncol, n, oControl )  }

FUNCTION Menu_Popup( nrow, ncol, n, oControl )
Local oMenuPop
  MENU oMenuPop POPUP 2015
   MENUITEM "Apri "
    MENUITEM "Apri "

 ACTIVATE POPUP oMenuPop OF oControl AT nrow, ncol
 oControl:Refresh()
 RETURN NIL


but not make error and not show the menu popup
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: BtnBmp and PopupMenu

Postby cnavarro » Thu Jun 21, 2018 5:42 pm

Please, search for "detached locals technicque", in forum
It is very possible that this is the problem
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: BtnBmp and PopupMenu

Postby Silvio.Falconi » Fri Jun 22, 2018 11:02 am

???????
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: BtnBmp and PopupMenu

Postby nageswaragunupudi » Fri Jun 22, 2018 1:17 pm

First please implement a small fix in btnbmp.prg.
Locate the following lines in the method ShowPopUp()
Code: Select all  Expand view  RUN
     if GetClassName( GetParent( Self:hWnd ) ) != "TBAR"
         oWnd = oWndFromhWnd( GetParent( Self:hWnd ) )
      endif
 

Comment out all the 3 lines above.

Next, please try this program:
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oDlg, oFont, aBtn[ 5 ]
   local aBmp := { "attach.bmp", "browse.bmp", "calc.bmp", "cascade.bmp", "copy.bmp" }
   local n, nRow, nCol

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL FONT oFont

   nRow  :=  40
   nCol  :=  40

   for n := 1 to 5
      @ nRow, nCol BTNBMP aBtn[ n ] FILE "c:\fwh\bitmaps\32x32\" + aBmp[ n ] ;
         PROMPT NtoCMonth( n ) ;
         SIZE 100,100 PIXEL OF oDlg TOP FLAT COLOR CLR_WHITE,CLR_GREEN NOBORDER ACTION ::ShowPopup()

      aBtn[ n ]:Cargo   := n
      aBtn[ n ]:oPopUp  := { |oBtn| BtnPopMenu( oBtn ) }

      nCol  += 120
   next

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

function BtnPopMenu( oBtn )

   local oPop
   local n

   MENU oPop POPUP 2007
   for n := oBtn:Cargo + 1 to 12
      MENUITEM NToCMonth( n )
   next
   ENDMENU

return oPop


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: BtnBmp and PopupMenu

Postby Silvio.Falconi » Sat Jun 23, 2018 9:53 am

Thank
can we erase or not show the part where is the black Arrow ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: BtnBmp and PopupMenu

Postby nageswaragunupudi » Sat Jun 23, 2018 11:50 am

Please make this modification
Code: Select all  Expand view  RUN
  for n := 1 to 5
      @ nRow, nCol BTNBMP aBtn[ n ] FILE "c:\fwh\bitmaps\32x32\" + aBmp[ n ] ;
         PROMPT NtoCMonth( n ) ;
         SIZE 100,100 PIXEL OF oDlg TOP FLAT COLOR CLR_WHITE,CLR_GREEN NOBORDER ; // ACTION ::ShowPopup()
         ACTION ( ::oPopup := { |oBtn| BtnPopMenu( oBtn ) }, ;
                  ::ShowPopUp(), ;
                  ::oPopup := nil )

      aBtn[ n ]:Cargo   := n
//      aBtn[ n ]:oPopUp  := { |oBtn| BtnPopMenu( oBtn ) }

      nCol  += 120
   next
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: BtnBmp and PopupMenu

Postby Silvio.Falconi » Sat Jun 23, 2018 3:34 pm

then when It show the menu it create the part with black arrow
on oldest release of my prg it not is showed
when I click on btnbmp it open a popupmenu near the btnbmp and I not see the part with black arrow
for my advice the black arrow can be usefull ony on a tbar control

for now I resolved with rem on METHOD PaintPopupSection()
on future we can apologize a logic variable to show or not the popupsection when the btnbmp is not on tbar


Image


We suggest

if ::oPopup != nil .and. GetClassName( GetParent( Self:hWnd ) ) = "TBAR"
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7066
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 78 guests