PlanetSquires Forums

Please login or register.

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

Author Topic: find and replace  (Read 670 times)

raymw

  • Senior Member
  • ***
  • Posts: 318
find and replace
« on: September 28, 2019, 09:25:04 AM »

Not sure if there is a simple solution, but if you have, say, characters such as  'xs.text' in your code, and you need to replace it with 'form1.xs.text' then if you search for 'xs' and replace with 'form1.xs' it goes on, and on and on. :D

Came across this in converting a c# program to fb, not sure if discussing how to do that somewhere?
Logged

raymw

  • Senior Member
  • ***
  • Posts: 318
Re: find and replace
« Reply #1 on: September 29, 2019, 01:53:23 PM »

Has folding been completely abandoned in winfbe editor? If not, remind me if/how to create fold points (I know it used to be on sub/end sub, etc., and that it wasn't high priority).
Logged

SeaVipe

  • Junior Member
  • **
  • Posts: 193
  • Windows 10
Re: find and replace - F8
« Reply #2 on: September 29, 2019, 02:48:10 PM »

Hi Ray,
Have a look at Menu item View/F8. I don't think Folding is quite ready for prime time. If I use folding too many times it stops working. Also, I don't use fold, but I can see its advantages.
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: 318
Re: find and replace
« Reply #3 on: September 29, 2019, 07:58:49 PM »

Hi Clive, none of it works for me. From a previous thread iirc, it was a bit irregular. If I try to fold anything it stays as it is. It's not a deal breaker, but it would have been handy, to save my rsi with trackball. Does the key words, function, end, etc have to be in a specific column, or can you add fold points where you wish.
Logged

SeaVipe

  • Junior Member
  • **
  • Posts: 193
  • Windows 10
Re: find and replace
« Reply #4 on: September 29, 2019, 09:04:30 PM »

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

SeaVipe

  • Junior Member
  • **
  • Posts: 193
  • Windows 10
Re: find and replace
« Reply #5 on: September 29, 2019, 09:09:22 PM »

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

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software
Re: find and replace
« Reply #6 on: September 29, 2019, 09:14:14 PM »

Folding is a pain in the butt because the logic is built directly into the scintilla editing dll and is written in C++. I have to modify that source and then re-compile the 32 and 64 bit dll's. I don't love folding that much!  hahaha

BTW, you have to ensure that the Folding Margin is enabled in order to use folding.
Environment Options... Code Editor... Show fold margin
« Last Edit: September 29, 2019, 09:19:57 PM by Paul Squires »
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Josť Roca

  • Guru Member
  • *****
  • Posts: 3205
Re: find and replace
« Reply #7 on: September 29, 2019, 09:44:43 PM »

> I don't love folding that much!

I never use it. Neither autocomplete nor codetips. I code faster without these gimmicks.

raymw

  • Senior Member
  • ***
  • Posts: 318
Re: find and replace
« Reply #8 on: September 30, 2019, 07:51:24 AM »

Thanks, I'd forgot you had to set the fold margin. As long as it doesn't lose code when folding/unfolding, it'll do. I find it useful some times, but not a major issue. Maybe the menu item could be greyed out if folding not enabled?
Logged

raymw

  • Senior Member
  • ***
  • Posts: 318
Re: find and replace
« Reply #9 on: September 30, 2019, 01:51:47 PM »

Still relating to the c# conversion, the nuts and bolts are working fine, but I was dreading the graphics, however for this particular program, it is merely plotting lines between a list of xy coordinates. I found Jose's code
Code: [Select]
########################################################################################
' Microsoft Windows
' File: DrawLine.bas
' Contents: GDI+ - DrawLine example
' Compiler: FreeBasic 32 & 64 bit
' Copyright (c) 2017 Josť Roca. Freeware. Use at your own risk.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################

#define UNICODE
#INCLUDE ONCE "Afx/CGdiPlus/CGdiPlus.inc"
#INCLUDE ONCE "Afx/CGraphCtx.inc"
USING Afx

CONST IDC_GRCTX = 1001

DECLARE FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
                          BYVAL hPrevInstance AS HINSTANCE, _
                          BYVAL szCmdLine AS ZSTRING PTR, _
                          BYVAL nCmdShow AS LONG) AS LONG

   END WinMain(GetModuleHandleW(NULL), NULL, COMMAND(), SW_NORMAL)

' // Forward declaration
DECLARE FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

' ========================================================================================
' The following example draws a line.
' ========================================================================================
SUB Example_DrawLine (BYVAL hdc AS HDC)

   ' // Create a graphics object from the window device context
   DIM graphics AS CGpGraphics = hdc
   ' // 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, 100.0, 500.0, 100.0)

END SUB
' ========================================================================================

' ========================================================================================
' Main
' ========================================================================================
FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
                  BYVAL hPrevInstance AS HINSTANCE, _
                  BYVAL szCmdLine AS ZSTRING PTR, _
                  BYVAL nCmdShow AS LONG) AS LONG

   ' // Set process DPI aware
   ' // The recommended way is to use a manifest file
   AfxSetProcessDPIAware

   ' // Create the main window
   DIM pWindow AS CWindow
   ' -or- DIM pWindow AS CWindow = "MyClassName" (use the name that you wish)
   pWindow.Create(NULL, "GDI+ DrawLine", @WndProc)
   ' // Change the window style
   pWindow.WindowStyle = WS_OVERLAPPED OR WS_CAPTION OR WS_SYSMENU
   ' // Size it by setting the wanted width and height of its client area
   pWindow.SetClientSize(600, 250)
   ' // Center the window
   pWindow.Center

   ' // Add a graphic control
   DIM pGraphCtx AS CGraphCtx = CGraphCtx(@pWindow, IDC_GRCTX, "", 0, 0, pWindow.ClientWidth, pWindow.ClientHeight)
   pGraphCtx.Clear BGR(255, 255, 255)
   ' // Get the memory device context of the graphic control
   DIM hdc AS HDC = pGraphCtx.GetMemDc
   ' // Draw the graphics
   Example_DrawLine(hdc)

   ' // Displays the window and dispatches the Windows messages
   FUNCTION = pWindow.DoEvents(nCmdShow)

END FUNCTION
' ========================================================================================

' ========================================================================================
' Main window procedure
' ========================================================================================
FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

   SELECT CASE uMsg

      CASE WM_COMMAND
         SELECT CASE GET_WM_COMMAND_ID(wParam, lParam)
            CASE IDCANCEL
               ' // If ESC key pressed, close the application by sending an WM_CLOSE message
               IF GET_WM_COMMAND_CMD(wParam, lParam) = BN_CLICKED THEN
                  SendMessageW hwnd, WM_CLOSE, 0, 0
                  EXIT FUNCTION
               END IF
         END SELECT

    CASE WM_DESTROY
         ' // Ends the application by sending a WM_QUIT message
         PostQuitMessage(0)
         EXIT FUNCTION

   END SELECT

   ' // Default processing of Windows messages
   FUNCTION = DefWindowProcW(hwnd, uMsg, wParam, lParam)

END FUNCTION
' ========================================================================================

and it works fine, and thanks to the comments, I more or less understand what each line is for. However, I am struggling in merging it with my existing code, which is based on Paul's Winfbe form designer, so much of the form information is hidden. It would help me, if someone more knowledgeable (most likely that's all of you) could use the graphics designer, create a form therein with a button, to generate one of Jose's graphic forms with a line on it, e.g. interface the drawline.bas code with that produced by the winfbe graphics designer.

Thanks,

Ray
Logged

SeaVipe

  • Junior Member
  • **
  • Posts: 193
  • Windows 10
Re: find and replace
« Reply #10 on: September 30, 2019, 03:27:31 PM »


Quote
interface the drawline.bas code with that produced by the winfbe graphics designer.
I too would like to know how to do that as I very much want to place a James Klutho GRID onto a WinFBE form.
Logged
Clive Richey
There is nothing government can give you that it hasn't already taken from you in the first place. Winston Churchill

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software
Re: find and replace
« Reply #11 on: September 30, 2019, 07:23:55 PM »

Here you go.... :-)

Create a Project and a main form called frmMain.
The example uses GDI+ so that will take some time for you to learn but it is a little better than regular GDI.

Code: [Select]
#INCLUDE ONCE "Afx/CGdiPlus/CGdiPlus.inc"
#INCLUDE ONCE "Afx/CGraphCtx.inc"

''
''  Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(frmMain)

dim shared pGraphCtx AS CGraphCtx ptr

const IDC_GRCTX = 2000


' ========================================================================================
' The following example draws a line.
' ========================================================================================
SUB Example_DrawLine (BYVAL hdc AS HDC)

   ' // Create a graphics object from the window device context
   DIM graphics AS CGpGraphics = hdc
   
   ' // 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, 100.0, 500.0, 100.0)

END SUB
' ========================================================================================


''
''
Function frmMain_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 hdc AS HDC = pGraphCtx->GetMemDc
   
   ' // Draw the graphics
   Example_DrawLine(hdc)
   
   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

Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

raymw

  • Senior Member
  • ***
  • Posts: 318
Re: find and replace
« Reply #12 on: September 30, 2019, 07:33:07 PM »

thanks, I'll let you know.
Not working for me, it opens the form, but no graphics drawing on it, Also, altering the values in  pGraphCtx->Clear BGR(255, 255, 255) does not change the background colour, so I guess the graphics is not being set up. Also trying to use console printing for debugging does not seem to show either., maybe the graphics is overwriting that? I've tried both 32 bit and 64 bit versions of winfbe. If it works for you, then maybe the default window properties are different.
« Last Edit: September 30, 2019, 08:44:16 PM by raymw »
Logged

raymw

  • Senior Member
  • ***
  • Posts: 318
Re: find and replace
« Reply #13 on: October 01, 2019, 07:36:30 AM »

Clive,

 Can you try Paul's code above, see if it works for you. Thanks

Ray

(anyone else, join in, of course)
( will the new version suite winfbe 1.93 (just released) solve it, I'm running 1.92)
« Last Edit: October 01, 2019, 07:40:46 AM by raymw »
Logged

SeaVipe

  • Junior Member
  • **
  • Posts: 193
  • Windows 10
Re: find and replace
« Reply #14 on: October 01, 2019, 12:01:03 PM »

I had no luck last night, Ray, I'll try again this morning.
Logged
Clive Richey
There is nothing government can give you that it hasn't already taken from you in the first place. Winston Churchill
Pages: [1] 2 3