Thanks Paul, for offering to look. I'm not sure if it will duplicate on your pc, but if you want to try, it was based on your code from a week or two back, I wanted to plot more than one line from some other 'form', not all at one go, so I moved things around a bit. Much of the cgi graphic help is based on .net, it seems, so it was pretty much guess work as to where the boundaries between the form, graphic and pen,brush were. Anyway, as usual, it gets in a bit of a mess, but this version was as near as I got, but I'm uncertain as to how much is from what is seen here, if unseen code is sort of hanging around from previous iterations.
the graphics drawing form
''
'' Remove the following Application.Run code if it used elsewhere in your application.
'dim shared pGraphCtx AS CGraphCtx ptr
const IDC_GRCTX = 2000
dim shared ngraphics as cgpgraphics =hdc
' ========================================================================================
' The following example draws a line.
' ========================================================================================
SUB Example_DrawLine (x1 as single,y1 as single,x2 as single,y2 as single)
' // Create a graphics object from the window device context
' // Draw the line
DIM blackPen AS CGpPen = CGpPen(GDIP_ARGB(255, 0, 0, 0), 3)
ngraphics.DrawLine(@blackPen, x1,y1,x2,y2)
?x1,y1
END SUB
' ========================================================================================
function makegraphics(byref sender as wfxform,byref e as eventargs) as lresult
pGraphCtx = new CGraphCtx( sender.pWindow, _
IDC_GRCTX, "drawing", _
px, py, _
sender.ClientSize.Width-100, _
sender.ClientSize.Height-100)
ahdc = pGraphCtx->GetMemDc
ngraphics =ahdc
DIM rxRatio AS SINGLE = ngraphics.GetDpiX / 96
DIM ryRatio AS SINGLE = ngraphics.GetDpiY / 96
ngraphics.ScaleTransform(rxRatio, ryRatio)
function=0
end function
''
''
Function frmMain_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
px=50
py=50
makegraphics(sender,e)
' pGraphCtx->Clear BGR(255, 255, 255)
function = 0
End Function
''
''
Function frmMain_FormClosed( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
if pGraphCtx then Delete pGraphCtx
Function = 0
End Function
''
''
Function frmmain_Resize( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
' DIM hdc AS HDC = pGraphCtx->GetMemDc
' // Draw the graphics
Example_DrawLine( 100,100,600,200)
example_drawline(60,60,400,200)
' pgraphcts.setvirtualbuffersize(80,80)
Function = 0
End Function
''
''
''
''
Function frmmain_Move( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
makegraphics(sender,e)
example_drawline(90,40,800,70)
Function = 0
End Function
''
''
the button form (start)
''
'' Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(start)
#include "paulsagain.bas"
''
''
SUB DrawLine (x1 as single,y1 as single,x2 as single,y2 as single)
' // Create a graphics object from the window device context
' DIM graphics AS CGpGraphics = ahdc
' ' // Get the DPI scaling ratios
' DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
' DIM ryRatio AS SINGLE = graphics.GetDpiY / 96
' // Set the scale transform
' graphics.ScaleTransform(rxRatio, ryRatio)
' // Draw the line
DIM blackPen AS CGpPen = CGpPen(GDIP_ARGB(255, 0, 0, 0), 3)
' ngraphics.DrawLine(@blackPen, x1,y1,x2,y2)
?x1,y1
END SUB
Function start_Click( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
Function = 0
End Function
''
''
Function start_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
frmmain.show
Function = 0
End Function
''
''
Function start_Button1_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
makegraphics(oform,esend)
example_drawline(val(start.text1.text),100,300,400)
' drawline(val(start.text1.text),100,400,300)
Function = 0
End Function
note this is altered since I mentioned first, but should explain - it only compiles/runs if makegraphics (oform,esend) is in the start_button function. Leave it out, line is not drawn, change oform/esend to other names, it does not compile. At one stage there was a dim shared graphics with oform and esend. but that was commented out, and since deleted, but it seems something is still hanging on. I would expect it to not compile with the makegraphics line, or if it did compile it would do so with anything instead of oform/esend.
Basically, what I'm trying to do, is draw a number of lines by clicking the button and changing the text value (that is not he ultimate goal, but if I can't do that, then I'll have to do something else). It only displays the last line. The size change and move for the frmmain lines also are not displayed at the same time, but you can see both sets of lines when the form is moved. Something obviously I do not understand, but it does not help when commented out code still appears to function. I've checked as best as I can in the include files code, but they have no oform or esend within.
edit to add.
The frmmain form, the first code window above, runs fine, no compile errors in the original project. It should run outside of the project. Copying the code, as above, and creating a frmmain form, with the various events needed, throws a number of compiler errors (referring to items that were once shared in the original project)
such as
Variable not declared, hdc
Variable not declared, pGraphCtx
Variable not declared, ahdc