Sign in to follow this  
Followers 0
andybiochem

Graphic control borders

3 posts in this topic

Hi Guys,

Having a problem with GUICtrlCreateGraphic.

I want it to plot several lines within the control, but if any of the lines go outside of the designated size of the control, then they should not be visible.

Example....

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 445, 329, 210, 235)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$Graphic1 = GUICtrlCreateGraphic(90, 60, 261, 201)
GUICtrlSetBkColor(-1, 0xFFFFFF)

GUICtrlSetGraphic($Graphic1,$GUI_GR_LINE,30,30)
GUICtrlSetGraphic($Graphic1,$GUI_GR_LINE,60,-30)

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Form1Close()
exit
EndFunc

... I don't want the second line to breach the control boundary.

Is there a style setting or something that stops this happening??

Thanks!


- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites



#include <GUIConstants.au3>
Const $GWidth = 261
Const $GHeight = 201

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 445, 329, 210, 235)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$Graphic1 = GUICtrlCreateGraphic(90, 60, $GWidth, $GHeight)
GUICtrlSetBkColor(-1, 0xFFFFFF)

DrawLine($Graphic1, 30,30)
DrawLine($Graphic1, 60,-30)

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Form1Close()
exit
EndFunc

;Draw line and truncate outside boundaries
Func DrawLine($hGraphic, $XX,$YY)
    If $XX > $GWidth Then
        $XX = $GWidth
    ElseIf $XX < 0 Then
        $XX = 0
    EndIf

    If $YY > $GHeight Then
        $YY = $GHeight
    ElseIf $YY < 0 Then
        $YY = 0
    EndIf
    
    GUICtrlSetGraphic($hGraphic,$GUI_GR_LINE,$XX,$YY)
EndFunc

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
Const $GWidth = 261
Const $GHeight = 201

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 445, 329, 210, 235)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$Graphic1 = GUICtrlCreateGraphic(90, 60, $GWidth, $GHeight)
GUICtrlSetBkColor(-1, 0xFFFFFF)

DrawLine($Graphic1, 30,30)
DrawLine($Graphic1, 60,-30)

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Form1Close()
exit
EndFunc

;Draw line and truncate outside boundaries
Func DrawLine($hGraphic, $XX,$YY)
    If $XX > $GWidth Then
        $XX = $GWidth
    ElseIf $XX < 0 Then
        $XX = 0
    EndIf

    If $YY > $GHeight Then
        $YY = $GHeight
    ElseIf $YY < 0 Then
        $YY = 0
    EndIf
    
    GUICtrlSetGraphic($hGraphic,$GUI_GR_LINE,$XX,$YY)
EndFunc

Thanks for the quick reply, and whilst your script works for the example above, it wouldn't work for what I want to do with it.

In my original post I said I wanted to plot 'several' lines....maybe I should have added the word "thousand" after 'several'.

I want it to plot several thousand lines :)

...so that means if I start a third line, in your script it will start from the boundary, not beyond it. Sorry, didn't explain fully.

The only way I have thought of so far is to create a label with a background color over the top of what I don't want to see. I just thought there may be an easier way.


- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0