Botones dentro de la ventana principal

Botones dentro de la ventana principal

Postby Ramón J. » Thu Sep 23, 2021 11:39 am

Hola a todos

Veréis, me ha venido a la cabeza la idea de poner en la ventana principal unos botones, además de los que figuran en el menú. Si la memoria no me falla vi un ejemplo en samples de esto, pero no lo he visto.

La idea, ilustrada de forma sencilla de lo que pretendo hacer para que el usuario acceda directamente a la opción deseada sin necesidad de buscar en el menú, es esta:

Image

Sé que para poner un logo se usa la función:
[code]@ 4, 16 BITMAP oBmp FILENAME CURDRIVE() +":"+"\COMPARTIDO\REGSAT\WINSAT\BITMAPS\LOGOGVA.png" NOBORDER OF oWnd ;
ON CLICK( oBmp:lStretch := ! oBmp:lStretch, oBmp:Refresh( .t. ) )

ACTIVATE WINDOW oWnd MAXIMIZED ;
ON PAINT PalBmpDraw( hDC, 150, 250, oBmp:hBitmap )

Pero cuando se trata de poner botones, encima del logo por ejemplo, ¿cómo se haría?

Gracias
FWH 20.12 BCC7
Ramón J.
 
Posts: 152
Joined: Mon Feb 13, 2006 8:23 pm

Re: Botones dentro de la ventana principal

Postby cmsoft » Thu Sep 23, 2021 1:47 pm

Podrias manejarlo con un BRUSH
Code: Select all  Expand view

// Testing some nice brushes

#include "FiveWin.ch"

static oWnd

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

function Main()

   local oBrush, oBot := ARRAY(3)

   DEFINE BRUSH oBrush FILENAME "..\bitmaps\rainbow.bmp" STRETCH  // Este archivo sería tu logo

   DEFINE WINDOW oWnd TITLE "Testing brushes" ;
      BRUSH oBrush

   //DEFINE BUTTONBAR oBar _3D OF oWnd

   @  10, 10 BTNBMP PROMPT "Cambiar"+CHR(10)+"Fondo" OF oBot[1] ACTION ChangeBrush()    PIXEL SIZE 80,80
   @  10,150 BTNBMP PROMPT "Alguna"+CHR(10)+"Accion" OF oBot[2] ACTION MsgInfo("Algo")  PIXEL SIZE 80,80
   @  10,260 BTNBMP PROMPT "Salir"                   OF oBot[2] ACTION oWnd:End()       PIXEL SIZE 80,80

   ACTIVATE WINDOW oWnd

return nil

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

function ChangeBrush()

   local oBrush, oOldBrush

   static nBrush := 2

   nBrush = If( nBrush == 4, 1, ++nBrush )

   DEFINE BRUSH oBrush ;
      FILENAME "..\bitmaps\brush" + Str( nBrush, 1 ) + ".bmp" STRECH

   if Upper( oWnd:ClassName() ) == "TWINDOW"
      oWnd:SetBrush( oBrush )
   else  
      oWnd:oWndClient:SetBrush( oBrush )
   endif  

   oWnd:Refresh()

return nil
 
User avatar
cmsoft
 
Posts: 1191
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Botones dentro de la ventana principal

Postby karinha » Thu Sep 23, 2021 2:20 pm

Code: Select all  Expand view

// Testing Win32 XP Theme-aware bitmaped buttons
// Important: Use standard buttons on the resources!

#include "FiveWin.ch"

#Define COLOR_BTNFACE   15

#Define aPubGrad {| lInvert | If( lInvert, ;
                    { { 1 / 3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
                    { 2 / 3, nRGB( 255, 215,  84 ), nRGB( 255, 233, 162 ) }  ;
                    }, ;
                    { { 1 / 2, nRGB( 219, 230, 244 ), nRGB( 207 - 50, 221 - 25, 255 ) }, ;
                    { 1 / 2, nRGB( 201 - 50, 217 - 25, 255 ), nRGB( 231, 242, 255 ) }  ;
                    } ) }

FUNCTION Main()

   LOCAL oWnd, oBtnBmp, oBtnBmp2, lSetAlpha := .T., oBar, oBrush

   // Este archivo sería tu logo, deberas - CMSOFT
   DEFINE BRUSH oBrush FILENAME "..\bitmaps\rainbow.bmp" STRETCH  

   DEFINE WINDOW oWnd TITLE "FiveWin Theme-aware bitmaped buttons" BRUSH oBrush

   DEFINE BUTTONBAR oBar BUTTONSIZE 64, 52 _3DLOOK TOP OF oWnd 2007 GDIPLUS // NOBORDER

   oBar:bClrGrad := aPubGrad

   @ 12, 2 BUTTONBMP oBtnBmp OF oWnd ACTION BuildDialog() ;
      BITMAP "..\bitmaps\AlphaBmp\ichat.bmp"

   oBtnBmp:cToolTip = "AlphaBmp: Tooltip text"

   @ 17, 2 BUTTONBMP oBtnBmp2 OF oWnd ACTION MsgInfo( "Themes aware Button Bitmaps With Alpha Channel Support" ) ;
      BITMAP "..\bitmaps\AlphaBmp\text.bmp" PROMPT "Test" TEXTRIGHT SIZE 80, 100 ;
      MESSAGE "From source code"
     
   oBtnBmp2:cToolTip = "Tooltip text"

   DEFINE STATUSBAR OF oWnd PROMPT "StatusBar"
     
   ACTIVATE WINDOW oWnd MAXIMIZED

RETURN NIL

FUNCTION BuildDialog()

   LOCAL oDlg, oBtn
   
   DEFINE DIALOG oDlg RESOURCE "test"
   
   REDEFINE BUTTONBMP oBtn ID 1 OF oDlg BITMAP "button" ACTION MsgInfo( "click" )
   
   ACTIVATE DIALOG oDlg CENTERED
   
RETURN NIL

// FIN
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7239
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Botones dentro de la ventana principal

Postby nageswaragunupudi » Fri Sep 24, 2021 5:25 pm

We recommend using oWnd:DrawImage( cLogo, [aRect] ) for showing logo.
With this, the logo is displayed over any brush used but beneath all controls.

Example:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oWnd, oBrush
   local cLogo := "c:\fwh\bitmaps\windows.bmp"

   DEFINE BRUSH oBrush FILE "c:\fwh\bitmaps\backgrnd\beige2.bmp"
   DEFINE WINDOW oWnd BRUSH oBrush

   @  50, 50 BTNBMP PROMPT "Button" SIZE 150,80 PIXEL OF oWnd FLAT
   @ 150,150 BTNBMP PROMPT "Button" SIZE 150,80 PIXEL OF oWnd FLAT

   oWnd:bPainted := { || oWnd:DrawImage( cLogo ) }  // This line displays logo

   ACTIVATE WINDOW oWnd
   RELEASE BRUSH oBrush

return nil
 


Image
Regards

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


Return to FiveWin para Harbour/xHarbour

Who is online

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