WinFBE Suite 1.9.4 (October 1, 2019)

Started by Paul Squires, October 01, 2019, 08:22:23 PM

Previous topic - Next topic

raymw

I have not got to the cause of the apparent peculiar behaviour of my commented code mentioned in my post #11 above. Anyway, I've started again, and found that I can generate lines form outside the frmmain form, but the frmmain form needs to either have its size changed or hide the form and then show it again before the lines are visible. I mentioned in another thread, that when a form is loaded, it seems to do a move and resize. A manual move does not cause a 'visible redraw', but a resize does.

SeaVipe

Hi Ray,
If all you're trying to do is fire Form1_resize, then Form1.Width = Form1.Width + 1 will do that (of course).
:o)

Clive Richey

raymw

Thanks for the suggestion Clive. Not exactly what i was getting at, but the resize is 'smoother' compared to hiding/showing form. It is the resizing of the graphic that i am aiming for.
Anyway, if you want to play, then I've attached code below. Design a form, named form1, (just for a change...) have a form load event and have a button with a click event and a textbox. The idea being to enter a number in the text box, click the button, and it draws a line related to the number entered. Make this the main file in winfbe

''
' named as "start18oct.bas"
''  Remove the following Application.Run code if it used elsewhere in your application.
   application.Run(form1)
  #include "oct18test.bas"

''
''
Function Form1_Button1_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
   
   dim v as single
     
  v=val(form1.text1.text)
  drawahdc(v)

'uncomment the four comments below for a number of lines

'          for j as integer = -1000 to 1000 step 10
'             v=j
'             drawahdc(v)
'          next

        plotform.width = plotform.width+1
        plotform.width = plotform.width-1
       
   Function = 0
End Function

''
''
Function Form1_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
   plotform.Show
   Function = 0
End Function


Also create another form, named plotform, and select closed, resize and load events and use the code for that form as below (change the #include "oct18test.bas" in above code to match the name by which you saved the following code).

' You should always include a resource file that references a valid manifest.xml
' file otherwise your application will not properly display Windows themed controls.
' Sample resource.rc and manifest.xml files can be found in the WinFBE \Settings folder.
' The following WinFBE directive includes the resource in your application. Simply
' uncomment the line.
' If you are using WinFBE's project management features then delete the following line
' because a resource file will be generated automatically.
'     '#RESOURCE "resource.rc"

' named as "oct18test.bas"

#INCLUDE ONCE "Afx/CGdiPlus/CGdiPlus.inc"
#INCLUDE ONCE "Afx/CGraphCtx.inc"
   
''
''  Remove the following Application.Run code if it used elsewhere in your application.


dim shared pGraphCtx AS CGraphCtx ptr
dim shared ahdc as hdc

const IDC_GRCTX = 2000



SUB drawahdc(v 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)
   graphics.DrawLine(@blackPen, 100.0, 200.0, 500.0, v)
 
END SUB
' ========================================================================================


''
''
Function plotform_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
   ' // Add a graphic control
   pGraphCtx = new CGraphCtx( sender.pWindow, _
                              IDC_GRCTX, "", _
                              0, 0, _
                              sender.ClientSize.Width, _
                              sender.ClientSize.Height)
   pGraphCtx->Clear BGR(255, 255, 255)
 
   ' // Get the memory device context of the graphic control
     DIM thdc AS HDC = pGraphCtx->GetMemDc
        ahdc=thdc
   
   ' // Draw a line
       drawahdc(80)
     
   function = 0
End Function


''
''
Function plotform_FormClosed( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
   if pGraphCtx then Delete pGraphCtx
   Function = 0
End Function

''
''
Function plotform_Resize( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
   
               
   Function = 0
End Function



When you run the program, then a line is drawn, and entering a number in the form1.text1 field and clicking the button, draws another line (provided the number is not 80, you will see it). The part that I'm now trying to sort out, is to be able to resize the graphic, without losing the lines. At  the moment the graphic is created, sized and located by the attributes given in the cgraphctx constructor, but I've not found an example or information on how to alter those values after construction. It may be necessary to destroy the object and recreate in the new size, hopefully not.

José Roca

#18
Just after you create the control, set its Resizable property to TRUE: pGraphCtx->Resizable = TRUE.

You can change its size with the CWindow methods MoveWindow or SetWindowPos.

If resizable, the virtual buffer is set to the size of the control. If the control is made smaller and then bigger, part of the contents are lost. Therefore, the caller must redraw it. Resizable and stretchable are mutually exclusive.

José Roca

BTW regarding a post that you seem to have deleted:

Quote
As you may know, I am struggling with getting to grips with the cgigraphics, for various reasons. However, I am coming across a number of what I think are typos/errors in the winfbx help file. Do you want me to send any that I spot to you, or to Paul, as I'm not knowing who is looking after that part of winfbe? The sort of thing, 'simple' instead of 'single' mix up of width and height, and the like.

If you find errors in the documentation, please report them. I maintain the documentation of the WinFBX framework and Paul the ones about the WinFBE editor and the WinFormsX.

raymw

Thanks Jose for your help wrt the graphics. It was an email I sent you wrt the typos, not a post on here. If you and Paul want them reported, then it may be as well to have a separate thread or similar, so they could be collected together, or would pm's/emails be better? It is most likely not many.

José Roca


raymw

OK, thanks, Jose. I've got into a bit of a tangle with trying to do the resize. Then I decided an interim way out, is to simply make the graphic much bigger then whatever I may need for whatever I'm drawing. Even if I had sorted out the resizing, I would still have to adjust the position of whatever was there, zoom factor/whatever. Most forms only resize by dragging right and bottom borders anyway.

Joerg B.

#23
Quote from: Joerg Buckel on October 03, 2019, 02:14:19 PM
Hello Paul

I noticed that in the 64bit version of Winfbe, the program does not open the template window.
When I try this, WinFBE crashes.

In the 32bit Version the "problem" does not occur.
Dodicat has the same problem in the FreeBasic forum.
https://freebasic.net/forum/viewtopic.php?f=8&t=25215&start=600

The "problem" appears in the different versions of WinFBE.

If I take your source code and compile with
Quote-x "..\WinFBE64.exe" -gen gcc -target win64
, I get as a result a 64bit version in which the Templates window works without problems.
Greeting from Germany

Joerg