text on a panel - on init

text on a panel - on init

Postby Otto » Thu Apr 02, 2009 1:56 pm

Hello,

I have a window with a panel and would like to show a text on the panel.
It is working when I use a button to start the action to fire the oPanel:say but I don’t find a way to show
the text when starting the program automatically.
Thanks in advance
Otto
Code: Select all  Expand view
// FiveWin for Pocket PC -

#include "FWCE.ch"
#include "C:\FWPPC\INCLUDE\DLL.ch"


#DEFINE TRUE .T.
#DEFINE FALSE .F.

//SIZE 240,320
REQUEST DBFCDX
//----------------------------------------------------------------------------//

function Main()
    local oBtnEnde
   local oWnd
   local oTmy
   local oPanel1

   set default to (cFilePath( GetModuleFileName( GetInstance() ) ))

   if IsExeRunning( cFileName( HB_ArgV( 0 ) ) )
      MsgInfo( "The application is already running" )
      return nil
   endif

   set deleted on
   oTmy := Tmy():New()
   sysrefresh()
 
   DEFINE WINDOW oWnd TITLE "Next"
   
   oPanel1 := TPanel():New(105,1,230,240,oWnd,.T.,CLR_BLACK, CLR_YELLOW)
   oPanel1:oVScroll:SetRange( 0, 0 )
   
    //opanel1:Say( 195,169 ,"TEST" , RGB(250,28,3) , , , .T., .T. )  
 
   @ 1, 177 BUTTON oBtnEnde PROMPT "show" SIZE 50, 15 ACTION oTmy:printsay(opanel1) PIXEL
 
   ACTIVATE WINDOW oWnd  ON INIT oTmy:printsay(opanel1)
   
return nil

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

CLASS Tmy

   DATA   Version
   
   CLASSDATA lRegistered AS LOGICAL

        METHOD New() CONSTRUCTOR

        METHOD printsay

ENDCLASS

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

METHOD New( ) CLASS Tmy

        ::Version   := "2008-12"
       
return self
//----------------------------------------------------------------------------//

 
METHOD printsay(opanel1)
    //local hBmp
   
//  DEFINE BITMAP hBmp FILE CurDir() + "\KELLNER.BMP"
//  opanel1:SayBitmap( 50,50, hBmp, ,  )  
    opanel1:Say( 69,69 ,"TEST" , RGB(250,28,3) , , , .T., .T. )  
   
return NIL

//----------------------------------------------------------------------------//
 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: text on a panel - on init

Postby Antonio Linares » Thu Apr 02, 2009 4:50 pm

Otto,

Why don't you create a SAY control as child of the panel ?

@ ..., ... SAY oSay PROMPT "test" OF oPanel
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: text on a panel - on init

Postby Otto » Thu Apr 02, 2009 4:57 pm

Hello Antonio,
Thank you for your response.
I need more than one line of text and many say – objects and pictures.
Then the application is overloaded and slow. It should become a kind of touchflow navigation.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: text on a panel - on init

Postby Antonio Linares » Thu Apr 02, 2009 5:07 pm

Otto,

Then please try it this way:

oPanel:bPainted = { | hDC | oPanel:Say( ... ), ... }

When you want the panel to be repainted, simply do:

oPanel:Refresh()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: text on a panel - on init

Postby Otto » Thu Apr 02, 2009 6:18 pm

Hello Antonio,
I made the changes you suggested but I can’t get it working.
Here is my code.
Thanks in advance
Otto




Code: Select all  Expand view
// FiveWin for Pocket PC -

#include "FWCE.ch"
#include "C:\FWPPC\INCLUDE\DLL.ch"

#define SHFS_SHOWTASKBAR 1                      // 0x0001
#define SHFS_HIDETASKBAR 2                      // 0x0002 //2
#define SHFS_SHOWSIPBUTTON 4                    // 0x0004
#define SHFS_HIDESIPBUTTON 8                    // 0x0008 //8
#define SHFS_SHOWSTARTICON 16                   // 0x0010
#define SHFS_HIDESTARTICON 20                   // 0x0020 //32


#DEFINE TRUE .T.
#DEFINE FALSE .F.

//SIZE 240,320
REQUEST DBFCDX
//----------------------------------------------------------------------------//

function Main()
    local oBtnEnde
   local oWnd
   local oTmy
   local oPanel1
    local oBtnShow
   
   set default to (cFilePath( GetModuleFileName( GetInstance() ) ))

   if IsExeRunning( cFileName( HB_ArgV( 0 ) ) )
      MsgInfo( "The application is already running" )
      return nil
   endif

   set deleted on
   
 
   DEFINE WINDOW oWnd TITLE "Next"
   
   oPanel1 := TPanel():New(105,1,230,240,oWnd,.T.,CLR_BLACK, CLR_YELLOW)
   oPanel1:oVScroll:SetRange( 0, 0 )
   
   
   oPanel1:bPainted = { | oWnd:hDC | opanel1:Say( 195,169 ,"TEST" , RGB(250,28,3) , , , .T., .T. ) }

 
   @ 1, 177 BUTTON oBtnEnde PROMPT "Ende" SIZE 50, 15 ACTION ownd:end() PIXEL
 
   @ 1, 17 BUTTON oBtnShow PROMPT "show" SIZE 50, 15 ACTION oPanel1:Refresh() PIXEL
 
 
   ShFullScreen(oWnd:hwnd,SHFS_HIDESTARTICON )
   ShFullScreen(oWnd:hwnd,SHFS_HIDETASKBAR )
   ShFullScreen(oWnd:hwnd,SHFS_HIDESIPBUTTON )

   ACTIVATE WINDOW oWnd  ON INIT ( MoveWindow(oWnd:hWnd,0,0,240,320),;
      SHOWWINDOW( FINDWINDOW( 0, "Next" ), 9 ),;
      SETFOREGROUNDWINDOW( FINDWINDOW( 0, "Next" ) ),;
     oWnd:Setfocus(),oPanel1:Refresh())
   
return nil

//----------------------------------------------------------------------------//
 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: text on a panel - on init

Postby Antonio Linares » Thu Apr 02, 2009 6:44 pm

Otto,

My proposed code was fine but Class TPanel was not managing bPainted. So I have added Class TPanel at the bottom of the PRG and modified it properly.

This PRG is working fine:
Code: Select all  Expand view

// FiveWin for Pocket PC -

#include "FWCE.ch"

#define SHFS_SHOWTASKBAR 1                      // 0x0001
#define SHFS_HIDETASKBAR 2                      // 0x0002 //2
#define SHFS_SHOWSIPBUTTON 4                    // 0x0004
#define SHFS_HIDESIPBUTTON 8                    // 0x0008 //8
#define SHFS_SHOWSTARTICON 16                   // 0x0010
#define SHFS_HIDESTARTICON 20                   // 0x0020 //32


#DEFINE TRUE .T.
#DEFINE FALSE .F.

//SIZE 240,320
REQUEST DBFCDX
//----------------------------------------------------------------------------//

function Main()
    local oBtnEnde
   local oWnd
   local oTmy
   local oPanel1
    local oBtnShow
   
   set default to (cFilePath( GetModuleFileName( GetInstance() ) ))

   if IsExeRunning( cFileName( HB_ArgV( 0 ) ) )
      MsgInfo( "The application is already running" )
      return nil
   endif

   set deleted on
   
 
   DEFINE WINDOW oWnd TITLE "Next"
   
   oPanel1 := TPanel():New(105,1,230,240,oWnd,.T.,CLR_BLACK, CLR_YELLOW)
   oPanel1:oVScroll:SetRange( 0, 0 )
   
   
   oPanel1:bPainted = { | hDC | opanel1:Say( 195,169 ,"TEST" , RGB(250,28,3) , , , .T., .T. ) }

 
   @ 1, 177 BUTTON oBtnEnde PROMPT "Ende" SIZE 50, 15 ACTION ownd:end() PIXEL
 
   @ 1, 17 BUTTON oBtnShow PROMPT "show" SIZE 50, 15 ACTION oPanel1:Refresh() PIXEL
 
 
   ShFullScreen(oWnd:hwnd,SHFS_HIDESTARTICON )
   ShFullScreen(oWnd:hwnd,SHFS_HIDETASKBAR )
   ShFullScreen(oWnd:hwnd,SHFS_HIDESIPBUTTON )

   ACTIVATE WINDOW oWnd  ON INIT ( MoveWindow(oWnd:hWnd,0,0,240,320),;
      SHOWWINDOW( FINDWINDOW( 0, "Next" ), 9 ),;
      SETFOREGROUNDWINDOW( FINDWINDOW( 0, "Next" ) ),;
     oWnd:Setfocus(),oPanel1:Refresh())
   
return nil

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

// TPanel Class. Mainly used for Automatic Alignment techniques

#include "WinApi.ch"

#define SYS_COLOR_INDEX_FLAG  0x40000000
#define COLOR_BTNFACE         nOr( 15, SYS_COLOR_INDEX_FLAG )

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

CLASS TPanel FROM TControl

   DATA   nStart, nEnd

   CLASSDATA lRegistered AS LOGICAL

   METHOD New( nTop, nLeft, nBottom, nRight, oWnd ) CONSTRUCTOR

   METHOD Paint()
   METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint()

   METHOD Notify( nIdCtrl, nPtrNMHDR ) INLINE ::oWnd:Notify( nIdCtrl, nPtrNMHDR )

   METHOD VScroll( nWParam, nLParam )
   
ENDCLASS

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

METHOD New( nTop, nLeft, nBottom, nRight, oWnd, lPixel, nClrText, nClrBack ) CLASS TPanel

   DEFAULT nTop := 0, nLeft := 0, nBottom := 100, nRight := 100,;
           oWnd := GetWndDefault(), lPixel := .f.,;
           nClrBack := GetSysColor( COLOR_BTNFACE )

   ::nTop    = nTop
   ::nLeft   = nLeft
   ::nBottom = nBottom * If( lPixel, 1, SAY_CHARPIX_H )
   ::nRight  = nRight * If( lPixel, 1, SAY_CHARPIX_W )
   ::oWnd    = oWnd
   ::nStyle  = nOr( WS_CHILD, WS_VISIBLE, WS_VSCROLL, WS_BORDER )
   ::lDrag   = .f.
   ::nClrText = nClrText
   ::nClrPane = nClrBack
   ::nStart = 0
   ::nEnd   = -1000

   ::Register()

   if ! Empty( ::oWnd:hWnd )
      ::Create()
      ::oWnd:AddControl( Self )
      DEFINE SCROLLBAR ::oVScroll VERTICAL OF Self
      ::oVScroll:SetRange( 0, 100 )
   else
      ::oWnd:DefControl( Self )
   endif

return Self

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

METHOD Paint() CLASS TPanel

   local nTop, nLeft, nHeight, nWidth, nBevel

   if ValType( ::bPainted ) != nil
      Eval( ::bPainted, ::hDC )
   endif  

   if ::oClient != nil .and. ( nBevel := ::oClient:nClientBevel ) > 0
      nBevel  -= 1
      nTop    := nBevel
      nLeft   := nBevel
      nHeight := ::nHeight - nBevel - 1
      nWidth  := ::nWidth - nBevel - 1
      if ::oTop != nil
         nTop += ::oTop:nHeight
      endif
      if ::oBottom != nil
         nHeight -= ::oBottom:nHeight
      endif
      if ::oLeft != nil
         nLeft += ::oLeft:nWidth
      endif
      if ::oRight != nil
         nWidth -= ::oRight:nWidth
      endif
      WndBoxIn( ::hDC, nTop, nLeft, nHeight, nWidth )
   endif

return nil

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

METHOD VScroll( nWParam, nLParam ) CLASS TPanel

   local nScrollCode := nLoWord( nWParam )

   do case
         case nScrollCode == SB_LINEUP
              if ::nStart < 0
              ScrollWindow( ::hWnd, 0, 10 )
              ::nStart += 10
              ::oVScroll:SetPos( -::nStart )
           endif    

         case nScrollCode == SB_LINEDOWN
           if ::nStart > ::nEnd
              ScrollWindow( ::hWnd, 0, -10 )
              ::nStart -= 10
              ::oVScroll:SetPos( -::nStart )
           endif    
   endcase          

return 0    

//----------------------------------------------------------------------------//
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: text on a panel - on init

Postby Antonio Linares » Thu Apr 02, 2009 6:48 pm

Otto,

If you change this line, then you can see how it gets properly updated when you press "show" button:

oPanel1:bPainted = { | hDC | opanel1:Say( 195,169 , Time() , RGB(250,28,3) , , , .T., .T. ) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: text on a panel - on init

Postby Otto » Thu Apr 02, 2009 7:51 pm

Hello Antonio,

thank you so much. Perfect.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 5 guests