FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Pocket PC Drawing with FWPPC
Posts: 48
Joined: Sun Oct 30, 2005 09:29 AM
Drawing with FWPPC
Posted: Tue Jun 06, 2006 06:58 PM

Hi All,

Is it possible to draw on a window with FWPPC?
Can I use the LineTo() function for example?

Anybody has a sample?

Many thanks,

Raymond

Raymond Fischbach
www.mouches.org
Posts: 48
Joined: Sun Oct 30, 2005 09:29 AM
Drawing with FWPPC
Posted: Wed Jun 07, 2006 04:43 PM
Hello,

I have made a small program to test the drawing.
I am facing a problem.
When I start the program, I see the drawing flashing on the screen.
Then the screen becomes completely white with the "Exit" button shown.
Here follows the small code :
// Draw on a window
#include "Fwce.ch"
#include "Winapi.ch"

FUNCTION Main()
LOCAL oWnd
LOCAL hDC
LOCAL hPen

DEFINE WINDOW oWnd TITLE "DESSIN "

hDC := oWnd:GetDC()
hPen := CreatePen(PS_SOLID,1,RGB(0,0,0))

@ 14.4, 1.0 BUTTON "&Exit"     SIZE 60, 35 ;
               ACTION (oWnd:End())

oWnd:aControls[1]:SetFocus()

MoveTo(hDC,100,100)
LineTo(hDC,150,150,hPen)
LineTo(hDC,050,050,hPen)
LineTo(hDC,200,200,hPen)

ACTIVATE WINDOW oWnd

RETURN nil


Anybody has an idea of what I am missing ?

Thanks in advance,
Raymond
Raymond Fischbach
www.mouches.org
Posts: 42
Joined: Wed Oct 26, 2005 01:20 PM
Drawing with FWPPC
Posted: Wed Jun 07, 2006 06:45 PM
Raymond,
When the window is painted, the drawing is lost. So, you need to load a function with your drawing instructions and place this in the PAINT callback. I have modified your example below.
// Draw on a window
#include "Fwce.ch"
#include "Winapi.ch"

FUNCTION Main()
LOCAL oWnd

DEFINE WINDOW oWnd TITLE "DESSIN "

@ 14.4, 1.0 BUTTON "&Exit"     SIZE 60, 35 ;
               ACTION (oWnd:End())

oWnd:aControls[1]:SetFocus()

ACTIVATE WINDOW oWnd ON PAINT MyPainting( oWnd )

RETURN nil

*******************************************************************************
FUNCTION MyPainting( oWnd )
*******************************************************************************
LOCAL hDC
LOCAL hPen
   hDC := oWnd:GetDC()
   hPen := CreatePen(PS_SOLID,1,RGB(0,0,0))

   MoveTo(hDC,100,100)
   LineTo(hDC,150,150,hPen)
   LineTo(hDC,150,050,hPen)
   LineTo(hDC,200,050,hPen)

RETURN Nil
Bill Simmeth

Merchant Software Corp

Marshall, Virginia USA
Posts: 48
Joined: Sun Oct 30, 2005 09:29 AM
Drawing with FWPPC
Posted: Wed Jun 07, 2006 07:19 PM

Hello Bill,

Many thanks, i works very well.

Best Regards,
Raymond

Raymond Fischbach
www.mouches.org
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Drawing with FWPPC
Posted: Wed Jun 07, 2006 09:36 PM
A ReleaseDC() method call is missing:
LOCAL hDC 
LOCAL hPen 
   hDC := oWnd:GetDC() 
   hPen := CreatePen(PS_SOLID,1,RGB(0,0,0)) 

   MoveTo(hDC,100,100) 
   LineTo(hDC,150,150,hPen) 
   LineTo(hDC,150,050,hPen) 
   LineTo(hDC,200,050,hPen) 
   
   oWnd:ReleaseDC()
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 48
Joined: Sun Oct 30, 2005 09:29 AM
Drawing with FWPPC
Posted: Thu Jun 08, 2006 08:10 AM

Thanks for the hint.

Regards,
Raymond

Raymond Fischbach
www.mouches.org

Continue the discussion