Page 1 of 3
Draw text and Draw Line in Window
Posted: Thu Jun 14, 2012 5:22 pm
by spelman
Hi Everyone,
I wonder if someone could give me some help ...
I've been using the DRAW LINE IN WINDOW , and DRAW TEXT IN WINDOW commands.
My question is how to erase a line once drawn ? , or for that matter
text ...
I have looked in the example programs , but not really found anything
Kind regards,
Steve
Re: Draw text and Draw Line in Window
Posted: Fri Jun 15, 2012 4:38 am
by Rathinagiri
You can erase the whole window.
If you want to eliminate any one or some of the drawn object(s), you have to remove the stack of draw commands.
Actually whatever graph commands we issue are added to a system variable _HMG_SYSDATA [ 102 ]
(i being the window index which can be got from getformindex( windowname ). Using a small hack you can remove whatever command you added.
So, if you want to remove the first draw command from the stack, just use,
Code: Select all
getformindex( windowname )
adel( _HMG_SYSDATA [ 102 ] [i], 1 )
asize( _HMG_SYSDATA [ 102 ] [i], len( _HMG_SYSDATA [ 102 ] [i] ) - 1 )
And, when the window is re-painted, the command removed will not be used.
Re: Draw text and Draw Line in Window
Posted: Sat Jun 16, 2012 6:13 am
by spelman
Hi Rathi,
Thanks for the response.
It looks a bit more complicated than I thought. It sounds easier to erase the window and redraw all the elements.
When you say 'erase the window', do you mean destroy it , or is there a command to just clear the contents of the window?
Please forgive my ignorance of these windows programming issues , my experience comes from some years ago in
in the DOS field. BTW , is there a good free primer anywhere which explains the basics of what should and shouldn't be
done when programming in Windows. I've been having quite a bit of success using HMG and just bumbling along seeing what
works, but I get the feeling I could be missing some key concepts.
Thanks
Steve
Re: Draw text and Draw Line in Window
Posted: Sat Jun 16, 2012 6:47 am
by Rathinagiri
Hi Steve,
There is a command just to erase all the draw commands. You can find out from i_graph.ch file in c:\hmg\include folder.
IMHO 'Samples' folder is the best resource to know about window programming.
Re: Draw text and Draw Line in Window
Posted: Sat Jun 16, 2012 7:13 am
by spelman
Hi Rathi,
Thanks , I'll look at that file.
Kind regards,
Steve
Re: Draw text and Draw Line in Window
Posted: Mon Jun 18, 2012 4:21 pm
by esgici
spelman wrote:...
I've been using the DRAW LINE IN WINDOW , and DRAW TEXT IN WINDOW commands.
...
Hi Steve
Welcome aboard
Sorry for the late welcome
Regards from Turkiye
BTW, are you sure that you are using DRAW TEXT command with HMG (official ) ?
If so, could you please give a small (but working) example ?
Regards
--
Esgici
Re: Draw text and Draw Line in Window
Posted: Mon Jun 18, 2012 4:30 pm
by IMATECH
file:///C:/HMG/DOC/data/index.htm
Code: Select all
DRAW / ERASE / PRINT GRAPH
Drawing Commands
DRAW GRAPH ...
DRAW GRAPH IN WINDOW <window> ...
DRAW LINE IN WINDOW <WindowName> AT <nRow>,<nCol> ...
DRAW RECTANGLE IN WINDOW <WindowName> AT <nRow>,<nCol> ...
...
ERASE [ IN ] WINDOW <WindowName>
PRINT GRAPH [ OF ] <cWindowname> [ PREVIEW ] [ DIALOG ]
'Print Graph' command, prints BARS, POINTS, LINES or PIE graph
previously drawn using DRAW GRAPH command in the specified window.
Re: Draw text and Draw Line in Window
Posted: Tue Jun 19, 2012 1:15 am
by esgici
spelman wrote:... how to erase a line once drawn ?
Hi Steve
Code: Select all
#include <hmg.ch>
#define nMaxPenWidth 10
PROCEDURE Main()
aWinBackColor := { 0xF0, 0xF0, 0xF0 }
lDrawn := .F.
aColorS := { YELLOW ,;
PINK ,;
RED ,;
FUCHSIA ,;
BROWN ,;
ORANGE ,;
GREEN ,;
PURPLE ,;
BLACK ,;
WHITE ,;
GRAY ,;
BLUE }
nLineBRow := 0
nLineBCol := 0
nLineERow := 0
nLineECol := 0
nLinePenW := 0
nLineColr := 0
DEFINE WINDOW frmEraseLine ;
AT 138 , 235 ;
WIDTH 560 ;
HEIGHT 380 ; // BACKCOLOR GRAY ;
TITLE "Erasing drawn line" ;
MAIN ;
BACKCOLOR aWinBackColor ;
ON INIT Initialize()
ON KEY ESCAPE ACTION frmEraseLine.Release
@ 280, 100 BUTTON btnDraw CAPTION "&Draw" ACTION Draw1Line( .T. )
@ 280, 230 BUTTON btnEras CAPTION "&Erase" ACTION Draw1Line( .F. )
@ 280, 360 BUTTON btnExit CAPTION "E&xit" ACTION frmEraseLine.Release
END WINDOW // frmEraseLine
frmEraseLine.Center
frmEraseLine.Activate
RETURN // Main()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._
PROCEDURE Initialize()
frmEraseLine.btnEras.Enabled := .F.
RETURN // Initialize()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._
PROCEDURE Draw1Line( ;
lDrawLine ) // .T. : DRAW, .F. : ERASE
LOCAL nOldColor := nLineColr
IF lDrawLine
nLineBRow := HB_RandomInt( 0, frmEraseLine.WIDTH / 2 )
nLineBCol := HB_RandomInt( 0, frmEraseLine.HEIGHT / 2 )
nLineERow := HB_RandomInt( nLineBRow , frmEraseLine.WIDTH )
nLineECol := HB_RandomInt( nLineBCol, frmEraseLine.HEIGHT )
nLinePenW := HB_RandomInt( 1, nMaxPenWidth )
WHILE nOldColor = nLineColr
nLineColr := HB_RandomInt( 1, LEN( aColorS ) )
ENDDO
DRAW LINE IN WINDOW frmEraseLine AT nLineBRow, nLineBCol ;
TO nLineERow, nLineECol ;
PENCOLOR aColorS[ nLineColr ] ;
PENWIDTH nLinePenW
lDrawn := .T.
ELSE
DRAW LINE IN WINDOW frmEraseLine AT nLineBRow, nLineBCol ;
TO nLineERow, nLineECol ;
PENCOLOR aWinBackColor ;
PENWIDTH nLinePenW
RESTORE WINDOW frmEraseLine
lDrawn := .F.
ENDIF lDrawLine
frmEraseLine.btnDraw.Enabled := !lDrawn
frmEraseLine.btnEras.Enabled := lDrawn
RETURN // Draw1Line()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._
I hope that help you
Regards
--
Esgici
Re: Draw text and Draw Line in Window
Posted: Tue Jun 19, 2012 7:42 pm
by esgici
esgici wrote:spelman wrote:... how to erase a line once drawn ?
Well ...
No anyone responded
Does that means no anyone liked it
May be ... A tool is valuable as much as need for it.
A little modification made: ErasLine() became a separate procedure.
Enjoy !
Regards
--
Esgici
- ErasLine.zip
- Erase Line .prg & .hbp
- (1.07 KiB) Downloaded 375 times
Re: Draw text and Draw Line in Window
Posted: Wed Jun 20, 2012 4:21 am
by Rathinagiri
That's great! Thanks Esgici.