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
Drawing with FWPPC
- Raymond Fischbach
- Posts: 48
- Joined: Sun Oct 30, 2005 9:29 am
- Location: Belgium
- Contact:
- Raymond Fischbach
- Posts: 48
- Joined: Sun Oct 30, 2005 9:29 am
- Location: Belgium
- Contact:
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 :
Anybody has an idea of what I am missing ?
Thanks in advance,
Raymond
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
// 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
www.mouches.org
-
- Posts: 42
- Joined: Wed Oct 26, 2005 1:20 pm
- Location: Marshall, Virginia, USA
- Contact:
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.
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
// 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
Merchant Software Corp
Marshall, Virginia USA
- Raymond Fischbach
- Posts: 48
- Joined: Sun Oct 30, 2005 9:29 am
- Location: Belgium
- Contact:
- Antonio Linares
- Site Admin
- Posts: 42519
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 75 times
- Contact:
A ReleaseDC() method call is missing:
Code: Select all | Expand
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
- Raymond Fischbach
- Posts: 48
- Joined: Sun Oct 30, 2005 9:29 am
- Location: Belgium
- Contact: