PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4 5 ... 10
 21 
 on: April 11, 2021, 11:27:00 AM 
Started by ron77 - Last post by jermy
The code is stripped version of a vb6 program to edit odl files and compile them.
Only the parser and some other small parts of code could be used.
The problem was that vb6 puts everything in a container, completely useless and would have to be completely rewritten.
Now that we no longer use vb6, I no longer need the odl ide.

explain to me how to add more keywords to be highlighted 
Look for
Code: [Select]
' assumes one character long comment
Const COMMENT = "'"

Const DELIMITER = " {}[]()"

Dim shared RESERVED As String: RESERVED = " DIM LONG BOOLEAN IN DECLARE FUNCTION Ron77 "     
Const FUNC_OBJ As String = " ENTRY "
Const KEYWORD_PAD As String = " "     

And for the color's, look for
Code: [Select]
Private Sub Highlight(hEdit As hwnd, SyntaxType As long, StartPos As Long, Length As Long)
    dim cf AS CHARFORMAT2
        cf.cbsize            = sizeof(cf)
        cf.dwMask            = CFM_COLOR
     
    select case SyntaxType
          case 0             ' ColorComment
              cf.crTextColor = colors.Green ' colors.

afther pressing a dot behind 'colors' you get a drop-down list with built-in colors. 

 22 
 on: April 11, 2021, 10:35:09 AM 
Started by ron77 - Last post by ron77
hello jermy and everyone :)

well i made a second version of my text editor (which now i'm trying to make a basic IDE for freebasic from it) instead of "textbox" i use "richtext" component and i downloaded your TLB-IDE and added the parser and you are corrected it works to some extend it colors some freebasic commands like "string text in commas" or "dim" and "function" etc... however the code of the parser is a mess lots of line are commented and it's hard to figure what does what or who is what... i wish to make the parser better that is to color more FB commands and keywords yet it's hard to understand how to do so... i laso don't understand where are the data for the keywords/commands that is uses to color the commands...

i bring you the full code of the parser in the hope that someone can explain to me how to add more keywords to be highlighted - also for some reason i cannot use the tab in the richtext component although i clearly made sure that property "acceptTab" will be set to true... (it worked in the textbox component) - anyway here is the parser full code... any help will be appreciated...

file Parser.inc:

https://pastebin.com/dbkA0RTX

ron77

 23 
 on: April 11, 2021, 04:58:55 AM 
Started by Bumblebee - Last post by Bumblebee
I couldn't have written a backup program without CWSTR variables and arrays. My previous backup program written in VB6 did not manage files with non-latin characters properly. It was always on my "to be resolved" list.

I don't do enough programming to encounter enough problems to learn to replace old ways of doing things, with the new.

 24 
 on: April 10, 2021, 03:46:51 PM 
Started by jermy - Last post by jermy
It is being overwritten by the RichEdit control. Change the position of the ListBox.

yes that's it, thanks.

How can I be so blind? It must be because of corona.
Code: [Select]
          pWindow->SetWindowPos GetDlgItem(hwnd, IDC_LISTBOX), Null, pWindow->UnScaleX(pt.x) + 15, pWindow->UnScaleY(pt.y) + 27, 100, 80, SWP_SHOWWINDOW

 25 
 on: April 10, 2021, 03:31:10 PM 
Started by jermy - Last post by Josť Roca
It is being overwritten by the RichEdit control. Change the position of the ListBox.

 26 
 on: April 10, 2021, 03:21:01 PM 
Started by jermy - Last post by jermy
I tried that, then the first item is not visible.

 27 
 on: April 10, 2021, 03:10:20 PM 
Started by jermy - Last post by Josť Roca
> Why is the listbox only half displayed ?.

You only have made it 40 pixels tall. Make it bigger.

 28 
 on: April 10, 2021, 02:39:46 PM 
Started by jermy - Last post by jermy
Dear people,

The intention is that if you hit a dot on your keyboard that the list box will appear
Why is the listbox only half displayed ?.

Code: [Select]
#define UNICODE
#INCLUDE ONCE "Afx/CWindow.inc"
#INCLUDE ONCE "Afx/AfxRichEdit.inc"
USING Afx

#define IDC_RICHEDIT 1001
#define IDC_LISTBOX   1002

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

' ========================================================================================
' 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
   AfxSetProcessDPIAware

   DIM pWindow AS CWindow
   pWindow.Create( NULL, "CWindow with a Rich Edit control", @WndProc )
   pWindow.SetClientSize(600, 420)
   pWindow.Center

   ' // Add a rich edit control without coordinates (it will be resized in WM_SIZE)
   DIM hRichEdit AS HWND = pWindow.AddControl( "RichEdit", , IDC_RICHEDIT, "RichEdit box" )
 
      ' // Enable EN_MSGFILTER notifications for keyboard events.
   RichEdit_SetEventMask( hRichEdit, ENM_KEYEVENTS or ENM_MOUSEEVENTS )
   SetFocus hRichEdit

Dim as long  dwStyle     =  WS_VSCROLL  'WS_CHILD OR WS_VISIBLE OR WS_HSCROLL OR WS_VSCROLL OR WS_BORDER OR WS_TABSTOP OR LBS_STANDARD OR LBS_HASSTRINGS OR LBS_SORT OR LBS_NOTIFY
Dim as long  dwExStyle = 0 'WS_EX_CLIENTEDGE 'or WS_EX_TOPMOST
   ' // Adds a listbox
   DIM hListBox AS HWND = pWindow.AddControl("ListBox", Null, IDC_LISTBOX, "", 400, 8, 100, 40, dwStyle, dwExStyle, 0, Null, &HFFFFFFFF, Null)

   ' // Fill the list box
   DIM wszText AS WSTRING * 260
   FOR i AS LONG = 1 TO 5
      wszText = "Item " & RIGHT("00" & WSTR(i), 2)
      ListBox_AddString(hListBox, @wszText)
   NEXT i
   
   ' // Select the first item
   ListBox_SetCursel(hListBox, 0)
   updateWindow hListBox
   ' // Dispatch Windows messages
   FUNCTION = pWindow.DoEvents(nCmdShow)

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

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

Static pWindow as Cwindow ptr
 dim as LPNMHDR pnm
  dim as MSGFILTER ptr pmf

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

        Case WM_NOTIFY
               pnm = cast(LPNMHDR, lParam)
            if pnm->hwndFrom = GetDlgItem(hwnd, IDC_RICHEDIT) then
                select case pnm->code
                    case EN_MSGFILTER
                           pmf = cast(MSGFILTER ptr, pnm)
                        select case   pmf->msg
                              Case WM_KEYDOWN
                                  if pmf->wParam = 190 then         ' 190 = dot              ' GetPositionFromCharIndex
         
         ' get the cursor position in the rich edit box
         Dim as DWORD CursorPos
         SendMessage( pnm->hwndFrom, EM_GETSEL, NULL, cast(LPARAM, @CursorPos) )
       
         ' get the x and y coordinates from the cursor
         Dim pt As point
          SendMessage( pnm->hwndFrom, EM_POSFROMCHAR, cast(WPARAM,@pt), CursorPos )
         ' show the listbox
          pWindow->SetWindowPos GetDlgItem(hwnd, IDC_LISTBOX), Null, pWindow->UnScaleX(pt.x) + 15, pWindow->UnScaleY(pt.y) + 10, 100, 40, SWP_SHOWWINDOW

          updatewindow   pnm->hwndFrom
          SetFocus GetDlgItem(hwnd, IDC_LISTBOX)
                                 end if

                        end select
                End Select   
            end if       
 
 
      CASE WM_SIZE
         ' // If the window isn't minimized, resize it
         IF wParam <> SIZE_MINIMIZED THEN
            ' // Resize the controls
            DIM pWindow AS CWindow PTR = AfxCWindowPtr(hwnd)
            IF pWindow THEN
               pWindow->MoveWindow GetDlgItem(hwnd, IDC_RICHEDIT), 10, 10, pWindow->ClientWidth - 220, pWindow->ClientHeight - 220, CTRUE
            END IF
         END IF

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

   END SELECT

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

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


I've already tried everything that came to my mind, anyone else have an idea?

 29 
 on: April 10, 2021, 11:31:51 AM 
Started by Bumblebee - Last post by Paul Squires
Just as an aside, I changed all of my file I/O some time ago to completely avoid PB's built in intrinsic functions for the very reason that Jose explained earlier: They do not play well with unicode. Rather than try to juggle in my brain all the different scenarios where I could inter-disperse FB native code and WinFBX code, I decided to go 100% with WinFBX. Once you use Jose's classes a few times for binary and text streams, it becomes extremely easy. The classes also work perfectly with his CWSTR and CBSTR string types. It is easy to use the classes to write the variables as you have shown in your example above (ie. Print/Write). This post is not meant to pursuade you to abandon your approach, it is just my experience that in the longer run, using the WinFBX approach has been easier and more consistent for me.

 30 
 on: April 10, 2021, 09:28:57 AM 
Started by ji_vildaasen - Last post by ji_vildaasen
Thanks for the tips. I'm hoping to not have to learn to much new stuff to avoid the flicker, I dont really have much time to use on my programing hobby.

FBs ScreenRes function is usually used to create a window where you can draw with FBs gfx functions. There is a option to create a hidden "screen" which lets you use the drawing functions, but you need to show the result your self(like I do with StretchDIBits). FB.Image buffers are just a block of memory where the first 32bytes is a header with info on BBP and width and height of the buffer. After that the rest of the memory block contain the color of each pixel in the buffer.

Maybe I could create a child window and draw on that instead of directly on the "main" window.

Or maybe I can use the ValidateRect function in the WM_ERASEBKGND message to stop the background being drawn over the area I draw on with StretchDIBits? Will have to do some testing later..


Pages: 1 2 [3] 4 5 ... 10