Drawing with FWPPC

Drawing with FWPPC

Postby Raymond Fischbach » Tue Jun 06, 2006 6: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
User avatar
Raymond Fischbach
 
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium

Postby Raymond Fischbach » Wed Jun 07, 2006 4: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 :
Code: Select all  Expand view  RUN
// 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
User avatar
Raymond Fischbach
 
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium

Postby Bill Simmeth » Wed Jun 07, 2006 6: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.
Code: Select all  Expand view  RUN
// 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
Bill Simmeth
 
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA

Postby Raymond Fischbach » Wed Jun 07, 2006 7:19 pm

Hello Bill,

Many thanks, i works very well.

Best Regards,
Raymond
Raymond Fischbach
www.mouches.org
User avatar
Raymond Fischbach
 
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium

Postby Antonio Linares » Wed Jun 07, 2006 9:36 pm

A ReleaseDC() method call is missing:
Code: Select all  Expand view  RUN
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Raymond Fischbach » Thu Jun 08, 2006 8:10 am

Thanks for the hint.

Regards,
Raymond
Raymond Fischbach
www.mouches.org
User avatar
Raymond Fischbach
 
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 37 guests