PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: WinFBE Suite 1.9.4 (October 1, 2019)  (Read 1327 times)

raymw

  • Senior Member
  • ***
  • Posts: 355
Re: WinFBE Suite 1.9.4 (October 1, 2019)
« Reply #15 on: October 18, 2019, 01:09:13 PM »

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

SeaVipe

  • Senior Member
  • ***
  • Posts: 229
  • Windows 10
Re: WinFBE Suite 1.9.4 (October 1, 2019)
« Reply #16 on: October 18, 2019, 03:35:09 PM »

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)

Logged
Clive Richey
There is nothing government can give you that it hasn't already taken from you in the first place. Winston Churchill

raymw

  • Senior Member
  • ***
  • Posts: 355
Re: WinFBE Suite 1.9.4 (October 1, 2019)
« Reply #17 on: October 18, 2019, 08:40:08 PM »

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

Code: [Select]
''
' 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).

Code: [Select]
' 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.
Logged

Josť Roca

  • Guru Member
  • *****
  • Posts: 3215
Re: WinFBE Suite 1.9.4 (October 1, 2019)
« Reply #18 on: October 18, 2019, 09:33:01 PM »

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.
« Last Edit: October 18, 2019, 09:39:38 PM by Josť Roca »
Logged

Josť Roca

  • Guru Member
  • *****
  • Posts: 3215
Re: WinFBE Suite 1.9.4 (October 1, 2019)
« Reply #19 on: October 18, 2019, 09:37:05 PM »

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

  • Senior Member
  • ***
  • Posts: 355
Re: WinFBE Suite 1.9.4 (October 1, 2019)
« Reply #20 on: October 19, 2019, 06:58:15 AM »

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

Josť Roca

  • Guru Member
  • *****
  • Posts: 3215
Re: WinFBE Suite 1.9.4 (October 1, 2019)
« Reply #21 on: October 19, 2019, 10:33:46 AM »

You can send personal messages.

raymw

  • Senior Member
  • ***
  • Posts: 355
Re: WinFBE Suite 1.9.4 (October 1, 2019)
« Reply #22 on: October 19, 2019, 11:17:46 AM »

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.
Logged
Pages: 1 [2]