FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Combobox en buttonbar
Posts: 1364
Joined: Wed Jun 21, 2006 12:39 AM
Combobox en buttonbar
Posted: Tue Sep 24, 2013 02:40 PM
Quiero poner un ComboBox en una ButtonBar y me genera el siguiente error

Code (fw): Select all Collapse
     [   1] = O   TCOMBOBOX

Stack Calls
===========
   Called from:  => __ERRRT_SBASE( 0 )
   Called from: ../../../tobject.prg => TCOMBOBOX:ERROR( 0 )
   Called from: ../../../tobject.prg => (b)HBOBJECT( 0 )
   Called from: ../../../tobject.prg => TCOMBOBOX:MSGNOTFOUND( 0 )
   Called from: ../../../tobject.prg => TCOMBOBOX:LGROUP( 0 )
   Called from: C:\administrador\bar.prg => TBAR:PAINT( 764 )
   Called from: C:\administrador\bar.prg => (b)TBAR( 49 )
   Called from: C:\administrador\bar.prg => TBAR:DISPLAY( 0 )
   Called from: .\source\classes\CONTROL.PRG => TBAR:HANDLEEVENT( 1666 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3153 )
   Called from:  => UPDATEWINDOW( 0 )
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 964 )
   Called from: .\source\classes\MDICHILD.PRG => TMDICHILD:ACTIVATE( 248 )
   Called from: C:\administrador\conceptos.prg => TABLACONCEPTOS( 103 )
   Called from: C:\administrador\administrador.prg => (b)START( 43 )
   Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 973 )
   Called from: C:\administrador\administrador.prg => START( 43 )
   Called from: C:\administrador\administrador.prg => MAIN( 27 )

Sin embargo en la clase rpreview está implementado con el zoom. Alguien tiene idea de porqué este error ? Muchísimas Gracias.
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Combobox en buttonbar
Posted: Tue Sep 24, 2013 06:16 PM
Code (fw): Select all Collapse
#include "FiveWin.ch"

static oWnd

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

function Main()

   local oIco, oBar, oBmp, oCombo, cSituation
   LOCAL cSituacao := { "COMBOBOX1", "COMBOBOX2" }

   DEFINE ICON oIco FILE "..\icons\fax.ico"

   DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 ;
      TITLE "FiveWin sample" ;
      MENU  BuildMenu() ;
      COLOR "B/W" ;
      ICON oIco

   DEFINE BUTTONBAR oBar _3D SIZE 26, 27 OF oWnd

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\new.bmp" FLAT ;
      ACTION MsgInfo( "New" ) ;
      TOOLTIP "Creates a new document"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\open.bmp" FLAT ;
      ACTION MsgInfo( cGetFile( "*.*", "Select a document to open" ) ) ;
      TOOLTIP "Opens a document" WHEN .f.

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\floppy.bmp" FLAT ;
      ACTION MsgInfo( Time() ) TOOLTIP "Saves this document"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\printer.bmp" FLAT ;
      ACTION MsgInfo( "Prints this document" ) TOOLTIP "Print this document" GROUP

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\prop.bmp" FLAT ;
      ACTION PrinterSetup() TOOLTIP "Setup the printer"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\HelpInd.bmp" FLAT ;
      ACTION MsgInfo( Version() ) TOOLTIP "A multiple lines" + ;
      Chr( 13 ) + Chr( 10 ) + "tooltip!" GROUP

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Help.bmp" FLAT ;
      ACTION MsgInfo( "fivewin power!" ) TOOLTIP "fivewin power!"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Exit.bmp" FLAT ;
      ACTION oWnd:End() TOOLTIP "Exit this app" GROUP

   DEFINE MESSAGE OF oWnd ;
      PROMPT FWVERSION + " " + FWCOPYRIGHT ;
      NOINSET CENTERED KEYBOARD DATE CLOCK

   DEFINE BITMAP oBmp FILENAME "..\bitmaps\fiveback.bmp"

   oWnd:bPainted = { | hDC | BmpTiled( hDC, oWnd, oBmp ) }

   // COMBOBOX EN BUTTONBAR EN FIVEWIN 13.06
   @ 3, 300 COMBOBOX oCombo VAR cSituation ITEMS cSituacao OF oBar  ;
            PIXEL SIZE 120, 200 UPDATE STYLE CBS_DROPDOWNLIST

   ACTIVATE WINDOW oWnd ;
      VALID MsgYesNo( "Do you want to quit ?" )

return nil

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

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "Information"
      MENU
         MENUITEM "&About..." ;
            ACTION MsgInfo( FWDESCRIPTION ) ;
            FILENAME "..\bitmaps\16x16\info.bmp"
         SEPARATOR
         MENUITEM "&End..."  ;
            ACTION oWnd:End() FILENAME "..\bitmaps\16x16\exit.bmp"

      ENDMENU

      MENUITEM "&Clients"
      MENU
         MENUITEM "&New..." ;
            ACTION ( MsgStop( "New Clients" ),;
                     oWnd:Say( 5, 5, "New Clients...", "GR+/G" ) ) ;
            FILENAME "..\bitmaps\16x16\faces.bmp"

         MENUITEM "&Modify..."  ACTION MsgInfo( "Modif. Clients" ) ;
            FILENAME "..\bitmaps\edit.bmp"

         MENUITEM "&Delete..."  ACTION MsgAlert( "Del Clients" ) ;
            FILENAME "..\bitmaps\16x16\delete.bmp"

         SEPARATOR

         MENUITEM "&Browse..."  ACTION MsgInfo( "Browse Clients" ) ;
            FILENAME "..\bitmaps\16x16\browse.bmp"

      ENDMENU

      MENUITEM "&Utilities"
      MENU
         MENUITEM "&Calculator..." ACTION WinExec( "Calc" ) ;
            FILENAME "..\bitmaps\16x16\calc.bmp"

         MENUITEM "&Internet..." ;
            ACTION WinExec( "start iexplore <!-- w --><a class="postlink" href="http://www.fivetech.com">www.fivetech.com</a><!-- w -->", 0 ) ;
            FILENAME "..\bitmaps\16x16\explorer.bmp"
      ENDMENU
   ENDMENU

return oMenu

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

STATIC FUNCTION BmpTiled( hDC, oWnd, oBmp )

   local nWidth := oWnd:nWidth(), nHeight := oWnd:nHeight()
   local nRow := 0, nCol := 0, n
   local nBmpWidth  := oBmp:nWidth(),  nBmpHeight := oBmp:nHeight()

   if oBmp:hBitmap == 0
      return nil
   endif

   while nRow < nHeight
      nCol = 0
      while nCol < nWidth
         PalBmpDraw( hDC, nRow, nCol, oBmp:hBitmap )
         nCol += nBmpWidth
      end
      nRow += nBmpHeight
   end

return nil

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


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1364
Joined: Wed Jun 21, 2006 12:39 AM
Re: Combobox en buttonbar
Posted: Tue Sep 24, 2013 07:38 PM

Gracias Karinha por responder, efectivamente tu ejemplo funciona perfectamente. He hecho una pequeña modificación en la clase bar.prg ( que no me dibuje el borde ) y lo he incorporado a mi proyecto, es aquí donde da el error. Si utilizo la clase de FW que viene en la librería no ocurre. Tuve un problema similar con la clase TxBrowse, si incorporaba los fuentes a mi proyecto me daba error en algunas operaciones, esto no pasa si uso las librerias originales. Mi entorno de trabajo para este proyecto es FWH 12.04, Harbour 3.1.0 y BCC 5.82. Trabajando con xHarbour ninguno de los errores descriptos sucede. ¿ que puede estar ocurriendo ? Muchas gracias.

Saludos

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Combobox en buttonbar
Posted: Tue Sep 24, 2013 08:20 PM

Mis desculpas Horácio, no uso HARBOUR. Solo XHARBOUR.

Creo que el Maestro Antonio puede aydarte.

Salu2.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Combobox en buttonbar
Posted: Tue Sep 24, 2013 08:24 PM
Horacio
Yo uso

FWH 12.03 + Harbour
Harbour 3.2.0dev (Rev. 17516)
Copyright (c) 1999-2012, http://harbour-project.org/

y no he tenido nunca problemas con clases heredadas (ni con las versiones anteriores).
Puedes probar la clase que uso yo para que el BAR no tenga borde, simplemente añadiéndolo como un .PRG mas a tu proyecto, es lo que yo hago para no modificar las clases originales.
Y aprovecho para hacer una pequeña reflexión:
Todas las clases que contienen Define's en su código, que no son DATAs, y que están en el propio .Prg de la clase son más complicadas de crear "clases heredadas" si no copias también dichos defines en tu nuevo código. Porque no puedes modificar esos valores, ni siquiera en tu clase propia, ya que seguirían habiendo métodos en la clase original con esos mismos defines pero con otros valores y eso podría provocar un erróneo funcionamiento de la clase.
Suelen ser para controlar determinados aspectos sobre todo de tipo estético o de dimensiones del control.
Quizás habría que contemplar crear esos defines en ficheros .ch o convertirlos en DATAs, inicializadas a los valores que actualmente tienen los defines, dependiendo de su importancia ( mi humilde opinión ).
Lo mismo pasa con la clase XBrowse

Code (fw): Select all Collapse
//
// Programa: TBarC.Prg
//
#include "FiveWin.ch"
//----------------------------------------------------------------------------//

#define BAR_HEIGHT           28
#define GRAY_BRUSH            2

#define BAR_TOP               1
#define BAR_LEFT              2
#define BAR_RIGHT             3
#define BAR_DOWN              4
#define BAR_FLOAT             5

#define SM_CYBORDER           6
#define SM_CYCAPTION          4

#define COLOR_BTNFACE        15
#define COLOR_BTNSHADOW      16
#define COLOR_BTNHIGHLIGHT   20

#define GROUP_SEP            8

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

CLASS TBarC FROM TBar

CLASSDATA lRegistered AS LOGICAL
DATA lBorder

METHOD New( oWnd, nBtnWidth, nBtnHeight, l3D, cMode, oCursor, l2007, l2010,;
            lBorder, oBrush, aGrad ) CONSTRUCTOR

METHOD NewAt( nRow, nCol, nWidth, nHeight, nBtnWidth, nBtnHeight, oWnd, l3D,;
              cMode, oCursor, lBorder, oBrush, aGrad ) CONSTRUCTOR

ENDCLASS

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

METHOD New( oWnd, nBtnWidth, nBtnHeight, l3D, cMode, oCursor, l2007, l2010,;
            lBorder, oBrush, aGrad ) CLASS TBarC

   local oRect

   DEFAULT oWnd := GetWndDefault(), nBtnWidth := BAR_HEIGHT,;
           nBtnHeight := BAR_HEIGHT, l3D := .f., cMode := "TOP", l2007 := .F.,;
           l2010 := .F., lBorder := .F.

   oRect = oWnd:GetCliRect()

   ::nStyle = if( lBorder, nOR( WS_BORDER, WS_CHILD, WS_VISIBLE, WS_CLIPCHILDREN ),;
                          nOR( WS_CHILD, WS_VISIBLE, WS_CLIPCHILDREN ) )

   ::lBorder     = lBorder
   ::aControls   = {}
   ::nGroups     = 0
   ::oWnd        = oWnd
   ::nTop        = If( cMode == "BOTTOM", oRect:nBottom - nBtnHeight, -1 )
   ::nLeft       = If( cMode == "RIGHT", oRect:nRight - nBtnWidth - ;
                   If( l3D, 3, 0 ), -1 )
   ::nBottom     = If( cMode == "TOP", nBtnHeight, oRect:nBottom + 1 )
   ::nRight      = If( cMode == "TOP" .or. cMode == "BOTTOM",;
                       oRect:nRight,;
                   If( cMode == "LEFT", nBtnWidth + If( l3D, 3, 0 ), oRect:nRight + 1 ) )
   ::nBtnWidth   = nBtnWidth
   ::nBtnHeight  = nBtnHeight
   ::nId         = ::GetNewId()
   ::lDrag       = .f.
   ::lCaptured   = .f.
   ::nClrPane    = If( l3D, GetSysColor( COLOR_BTNFACE ), CLR_GRAY )
   ::lVisible    = .t.
   ::l3D         = l3D
   ::nMode       = AScan( { "TOP", "LEFT", "RIGHT", "BOTTOM", "FLOAT" }, cMode )
   ::oCursor     = oCursor
   ::lValidating = .f.
   ::l2007       = l2007
   ::l2010       = l2010

   ::SetColor( If( ValType( ::nClrText ) == "B", Eval( ::nClrText, .F. ), ::nClrText ), ::nClrPane )

   do case
      case l2007
           ::bClrGrad = { | lInvert | If( ! lInvert,;
                                        { { 0.25, RGB( 219, 230, 244 ), RGB( 207, 221, 239 ) },;
                                          { 0.75, RGB( 201, 217, 237 ), RGB( 231, 242, 255 ) } },;
                                        { { 0.25, RGB( 255, 253, 222 ), RGB( 255, 231, 151 ) }, ;
                                          { 0.75, RGB( 255, 215,  84 ), RGB( 255, 233, 162 ) } } ) }
      case l2010
           ::bClrGrad = { | lInvert | If( ! lInvert,;
                                        { { 1, RGB( 255, 255, 255 ), RGB( 229, 233, 238 ) } },;
                                        { { 2/5, RGB( 255, 253, 222 ), RGB( 255, 231, 147 ) },;
                                          { 3/5, RGB( 255, 215,  86 ), RGB( 255, 231, 153 ) } } ) }
      otherwise
           if Empty( aGrad )
           ::bClrGrad = { | lInvert | If( ! lInvert,;
                                        { { 0.25, RGB( 219, 230, 244 ), RGB( 207, 221, 239 ) },;
                                          { 0.75, RGB( 201, 217, 237 ), RGB( 231, 242, 255 ) } },;
                                        { { 0.25, RGB( 255, 253, 222 ), RGB( 255, 231, 151 ) }, ;
                                          { 0.75, RGB( 255, 215,  84 ), RGB( 255, 233, 162 ) } } ) }
           else
              if Empty( oBrush )
                 ::bClrGrad = { | lInvert | If( ! lInvert,;
                                            { aGrad[1], aGrad[2] } ,;
                                            { aGrad[3], aGrad[4] }  )  }
              else
                 ::SetBrush( oBrush )
              endif
           endif
   endcase

   ::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )
   ::Create()

   do case
      case ::nMode == BAR_TOP
           oWnd:oBar = Self
           oWnd:oTop = Self

      case ::nMode == BAR_LEFT
           oWnd:oLeft = Self

      case ::nMode == BAR_RIGHT
           oWnd:oRight = Self

      case ::nMode == BAR_DOWN
           oWnd:oBottom = Self
   endcase

return Self

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

METHOD NewAt( nRow, nCol, nWidth, nHeight, nBtnWidth, nBtnHeight, oWnd, l3D,;
              cMode, oCursor, lBorder, oBrush, aGrad ) CLASS TBarC
   local oRect

   DEFAULT oWnd := GetWndDefault(), nBtnWidth := BAR_HEIGHT,;
           nBtnHeight := BAR_HEIGHT, nHeight := BAR_HEIGHT,;
           l3D := .f., cMode := "TOP", lBorder := .f.    //FranciscoA May, 31/2013

   oRect = oWnd:GetCliRect()

  ::nStyle = if( lBorder, nOR( WS_BORDER, WS_CHILD, WS_VISIBLE, WS_CLIPCHILDREN ),;
                          nOR( WS_CHILD, WS_VISIBLE, WS_CLIPCHILDREN ) )

   ::lBorder     = lBorder
   ::aControls   = {}
   ::nGroups     = 0
   ::oWnd        = oWnd
   ::nTop        = nRow
   ::nLeft       = nCol
   ::nBottom     = nRow + nHeight - 1
   ::nRight      = nCol + nWidth - 1
   ::nBtnWidth   = nBtnWidth
   ::nBtnHeight  = nBtnHeight
   ::nId         = ::GetNewId()
   ::lDrag       = .f.
   ::lCaptured   = .f.
   ::nClrPane    = If( l3D, GetSysColor( COLOR_BTNFACE ), RGB( 240,240,240) ) //CLR_GRAY )
   ::lVisible    = .t.
   ::l3D         = l3D
   ::nMode       = AScan( { "TOP", "LEFT", "RIGHT", "BOTTOM", "FLOAT" }, cMode )
   ::oCursor     = oCursor
   ::lValidating = .f.
   ::l2007       = .F.
   ::l2010       = .F.

   ::SetColor( If( ValType( ::nClrText ) == "B", Eval( ::nClrText, .F. ), ::nClrText ), ::nClrPane )

   ::bClrGrad = { | lInvert | If( ! lInvert,;
                                  { { 0.25, nRGB( 219, 230, 244 ), nRGB( 207, 221, 239 ) },;
                                    { 0.75, nRGB( 201, 217, 237 ), nRGB( 231, 242, 255 ) } },;
                                  { { 0.25, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
                                    { 0.75, nRGB( 255, 215,  84 ), nRGB( 255, 233, 162 ) } } ) }

   ::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )
   ::Create()


return Self

//----------------------------------------------------------------------------//
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Combobox en buttonbar
Posted: Tue Sep 24, 2013 09:13 PM

Horacio,

Añade esta líneas a tu programa:

include "FiveWin.ch"

include "xhbcls.ch"

...

EXTEND CLASS TComboBox WITH DATA lGroup INIT .F.

Cristobal,

Totalmente de acuerdo contigo con el uso de las variables static en clases. Es algo que iremos modificando para que se pueda heredar sin ninguna limitación :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1364
Joined: Wed Jun 21, 2006 12:39 AM
Re: Combobox en buttonbar
Posted: Tue Sep 24, 2013 09:55 PM

Gracias a ambos por responder. Cristobal, yo hago lo mismo que vos. Tomo el fuente de la clase y lo incorporo a mi proyecto con las modificaciones que pretendo hacer. Y al hacerlo de esta manera me aparece el error, si quito el fuente funciona perfectamente. Antonio, probaré esta sugerencia. Muchas gracias.

Saludos

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Combobox en buttonbar
Posted: Tue Sep 24, 2013 10:34 PM
Antonio

con el uso de las variables static en clases. Es algo que iremos modificando para que se pueda heredar sin ninguna limitación


No solo las variables static. A mi me están dando más dolores de cabeza los #define de cada clase (.prg) no incluidos en ficheros .ch, ni ser DATAs

Saludos
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Combobox en buttonbar
Posted: Tue Sep 24, 2013 11:52 PM

Crsitobal,

Muy cierto, no habia caido en eso... gracias :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion