Draw text and Draw Line in Window

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

spelman
Posts: 20
Joined: Thu Sep 22, 2011 5:38 pm

Draw text and Draw Line in Window

Post 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
User avatar
Rathinagiri
Posts: 5481
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Draw text and Draw Line in Window

Post 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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
spelman
Posts: 20
Joined: Thu Sep 22, 2011 5:38 pm

Re: Draw text and Draw Line in Window

Post 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
User avatar
Rathinagiri
Posts: 5481
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Draw text and Draw Line in Window

Post 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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
spelman
Posts: 20
Joined: Thu Sep 22, 2011 5:38 pm

Re: Draw text and Draw Line in Window

Post by spelman »

Hi Rathi,

Thanks , I'll look at that file.

Kind regards,

Steve
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Draw text and Draw Line in Window

Post 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
Viva INTERNATIONAL HMG :D
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: Draw text and Draw Line in Window

Post 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.


 

 
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Draw text and Draw Line in Window

Post 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
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Draw text and Draw Line in Window

Post 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 376 times
Viva INTERNATIONAL HMG :D
User avatar
Rathinagiri
Posts: 5481
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Draw text and Draw Line in Window

Post by Rathinagiri »

That's great! Thanks Esgici.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply