FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Botones con y sin borde en Get..action
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Botones con y sin borde en Get..action
Posted: Tue Jan 20, 2009 02:40 PM
Hola,

En mi caso, a veces para la est茅tica del programa, me resulta inapropiado el borde del bot贸n en los get con acciones y en otros casos no.

Para resolverlo hice la siguiente modificaci贸n a la clase tGet:
......
CLASS TGet FROM TControl

   DATA   oGet, oBtn, bAction
   DATA   bMin, bMax
   DATA   nPos
   DATA   lReadOnly, lPassword
   DATA   cError, cBmpName
   DATA   hHeap
   DATA   cPicture
   DATA   lDisColors        // .t. Use standard disabled colors
   DATA   bPostKey
   DATA   lSpinner
   DATA   nOldClrPane      // Old background color, if color changed with focus
   DATA   lNoBorderBtn

.......

METHOD New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, cPict, bValid,;
               nClrFore, nClrBack, oFont, lDesign, oCursor, lPixel,;
               cMsg, lUpdate, bWhen, lCenter, lRight, bChanged,;
               lReadOnly, lPassword, lNoBorder, nHelpId,;
               lSpinner, bUp, bDown, bMin, bMax, bAction, cBmpName, lNoBorderBtn ) CONSTRUCTOR

.......

METHOD ReDefine( nId, bSetGet, oWnd, nHelpId, cPict, bValid,;
                    nClrFore, nClrBack, oFont, oCursor, cMsg,;
                    lUpdate, bWhen, bChanged, lReadOnly,;
                    lSpinner, bUp, bDown, bMin, bMax, bAction, cBmpName, lNoBorderBtn ) CONSTRUCTOR

........

METHOD New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, cPict, bValid,;
            nClrFore, nClrBack, oFont, lDesign, oCursor, lPixel, cMsg,;
            lUpdate, bWhen, lCenter, lRight, bChanged, lReadOnly,;
            lPassword, lNoBorder, nHelpId, lSpinner,;
            bUp, bDown, bMin, bMax, bAction, cBmpName, lNoBorderBtn ) CLASS TGet

 DEFAULT nClrFore  := GetSysColor( COLOR_WINDOWTEXT ),;
           nClrBack  := GetSysColor( COLOR_WINDOW ),;
           oWnd      := GetWndDefault(),;
           nHeight   := If( oFont != nil, oFont:nHeight, 12 ),;
           lDesign   := .f., lPixel := .f., lUpdate := .f.,;
           lCenter   := .f., lRight := .f.,;
           lReadOnly := .f., lPassword := .f.,;
           lSpinner  := .f.,;
           nRow      := 0, nCol := 0, lNoBorder := .f.,;
           bSetGet   := bSETGET( cText ),;
           lNoBorderBtn := .f.  

........

::hHeap     = 0
::bAction   = bAction
::cBmpName  = cBmpName
::lNoBorderBtn = lNoBorderBtn

........

Return Self

METHOD ReDefine( nId, bSetGet, oWnd, nHelpId, cPict, bValid, nClrFore,;
                 nClrBack, oFont, oCursor, cMsg, lUpdate, bWhen, bChanged,;
                 lReadOnly, lSpinner, bUp, bDown, bMin, bMax, bAction, cBmpName, lNoBorderBtn ) CLASS TGet

   DEFAULT oWnd     := GetWndDefault(),;
           nClrFore := GetSysColor( COLOR_WINDOWTEXT ),;
           nClrBack := GetSysColor( COLOR_WINDOW ),;
           lUpdate  := .f., lReadOnly := .f., lSpinner := .f.
           lNoBorderBtn:=.f. 

.........

 ::hHeap     = 0
 ::bAction   = bAction
 ::cBmpName  = cBmpName
 ::lNoBorderBtn = lNoBorderBtn 

.........

 ::hHeap     = 0
 ::bAction   = bAction
 ::cBmpName  = cBmpName
 ::lNoBorderBtn = lNoBorderBtn 

..........

Return Self

..........

METHOD CreateButton() CLASS TGet

   local oThis := Self
   
   if ValType( ::bAction ) == "B" .and. Upper( ::ClassName() ) == "TGET"
	 		//Se modifica para que al indicar que no se desee borde en bot贸n cambie a objeto 
                                                //btnbmp  sin borde
			//previamente se agreg贸 a la clase la variable lNoBorderBtn 
      IF ::lNoBorderBtn
         IF Empty( ::cBmpName )  	//no hay bmp
	@ 0, ::nWidth - ::nHeight BUTTONBMP ::oBtn OF Self ;
            	ACTION ( Eval( oThis:bAction, oThis ), oThis:SetFocus() ) ;
            	SIZE ::nHeight - 4, ::nHeight - 4 PIXEL TRANSPARENT
			     ::oBtn:SetText( "..." )
    	   ELSE 
				/*  
         @ 0, ::nWidth - ::nHeight BUTTONBMP ::oBtn OF Self ;
            ACTION ( Eval( oThis:bAction, oThis ), oThis:SetFocus() ) ;
            SIZE ::nHeight - 4, ::nHeight - 4 PIXEL BITMAP ::cBmpName
				*/
            IF At( ".", ::cBmpName)<>0  //si es .bmp 
         		   @0, ::nwidth - ::nHeight BTNBMP ::oBtn OF Self;
         		   ACTION ( Eval( oThis:bAction, oThis ), oThis:SetFocus() ) ;
         		   FILE ::cBmpName ;
         		   SIZE ::nHeight - 4, ::nHeight - 4 PIXEL NOBORDER TRANSPARENT
            ELSE   //si es un bmp
         	   	 @0, ::nwidth - ::nHeight BTNBMP ::oBtn OF Self;
         		   ACTION ( Eval( oThis:bAction, oThis ), oThis:SetFocus() ) ;
         		   RESOURCE ::cBmpName;
         		   SIZE ::nHeight - 4, ::nHeight - 4 PIXEL NOBORDER TRANSPARENT
            ENDIF
         ENDIF   
      ELSE
         if Empty( ::cBmpName )
            @ 0, ::nWidth - ::nHeight BUTTONBMP ::oBtn OF Self ;
               ACTION ( Eval( oThis:bAction, oThis ), oThis:SetFocus() ) ;
               SIZE ::nHeight - 4, ::nHeight - 4 PIXEL
            if Empty( ::oBtn:hBitmap )
               ::oBtn:SetText( "..." )
            endif      
         else   
            @ 0, ::nWidth - ::nHeight BUTTONBMP ::oBtn OF Self ;
               ACTION ( Eval( oThis:bAction, oThis ), oThis:SetFocus() ) ;
               SIZE ::nHeight - 4, ::nHeight - 4 PIXEL BITMAP ::cBmpName
         endif   
      ENDIF
			::oBtn:lCancel = .T. // so the GET VALID is not fired when the button is focused
			//JM
			   
      /*
      // We force a WM_NCCALCSIZE msg to be sent to the GET      
      SetWindowPos( ::hWnd, 0, 0, 0, 0, 0,;
                    nOr( SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, SWP_FRAMECHANGED ) )
      */              
   ENDIF   
   
return nil


Espero pueda ser de ayuda para alguien.
Saludos/Regards,

Jos茅 Murugosa

"Los errores en programaci贸n, siempre est谩n entre la silla, el teclado y la IA!!"
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: Botones con y sin borde en Get..action
Posted: Tue Jan 20, 2009 03:09 PM

un peque帽o detalle m谩s.....

para utilizarlo luego simplemente se pone

redefine get oGet ........action ......
oGet:lNoBorderBtn := .t. //elimina el borde del bot贸n..

Si alguien lo prefiere alrev茅s puede crear una variable lBorderBtn default .t. y establecerla .f. para sacar el borde, yo luego de hacerlo pens茅 que esta segunda opcion quedar铆a m谩s prolija pero ..... no me.... dio la voluntad.

Saludos/Regards,

Jos茅 Murugosa

"Los errores en programaci贸n, siempre est谩n entre la silla, el teclado y la IA!!"

Continue the discussion