• Welcome to PlanetSquires Forums.
 

WinFBE new code on GitHub

Started by Paul Squires, June 26, 2016, 09:23:59 PM

Previous topic - Next topic

José Roca

The Find and Find Replace dialogs don't allow to paste text in the edit part of the combobox.

José Roca

#31
Just adding this code to the end of the CreateContextMenu function you get a context menu with icons.


   DIM hInst AS HINSTANCE = GetModuleHandle(NULL)
   AfxAddIconToMenuItem(hPopupMenu,  0, TRUE, AfxGdipIconFromRes(hInst, "IMAGE_UNDO"))
   AfxAddIconToMenuItem(hPopupMenu,  1, TRUE, AfxGdipIconFromRes(hInst, "IMAGE_REDO"))
   AfxAddIconToMenuItem(hPopupMenu,  3, TRUE, AfxGdipIconFromRes(hInst, "IMAGE_CUT"))
   AfxAddIconToMenuItem(hPopupMenu,  4, TRUE, AfxGdipIconFromRes(hInst, "IMAGE_COPY"))
   AfxAddIconToMenuItem(hPopupMenu,  5, TRUE, AfxGdipIconFromRes(hInst, "IMAGE_PASTE"))
   AfxAddIconToMenuItem(hPopupMenu,  7, TRUE, AfxGdipIconFromRes(hInst, "IMAGE_INDENT"))
   AfxAddIconToMenuItem(hPopupMenu,  8, TRUE, AfxGdipIconFromRes(hInst, "IMAGE_INDENT_REMOVE"))
   AfxAddIconToMenuItem(hPopupMenu, 10, TRUE, AfxGdipIconFromRes(hInst, "IMAGE_COMMENT"))
   AfxAddIconToMenuItem(hPopupMenu, 11, TRUE, AfxGdipIconFromRes(hInst, "IMAGE_COMMENT_REMOVE"))


It has never been so easy.

Paul Squires

Those icons look good in your screenshot but on my system they do not. They are very undefined and washed out. I believe I made a similar post a couple of weeks ago about icons in the top menus. I can't post a screenshot right now but I will as soon as I am able. Are you able to test at 96 dpi to see how the icons scale on your system?

Also, I am using Windows 10 at home and Windows 7 at work. I get the same "blurriness" on both systems.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Quote from: Jose Roca on June 27, 2016, 11:51:54 PM
The Find and Find Replace dialogs don't allow to paste text in the edit part of the combobox.

That's odd. I am able to paste text into the edit portion of the comboboxes.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

#34
I can paste if I use the context menu of the control, but if I press Ctrl-V, the control loses the focus and the text is pasted in the document.

José Roca

Regarding the icons, it must be that they aren't appropriate for the menus. There are some requirements that perhaps they don't satisfy. I have made a test with other icons at 96 DPI and they look fine (see capture).

Paul Squires

Quote from: Jose Roca on June 28, 2016, 10:40:26 AM
I can paste if I use the context menu of the control, but if I press Ctrl-V, the control loses the focus and the text is pasted in the document.

Ah, okay. You are correct the paste seems to happen in the active document instead. The Ctrl+V accelerator key must be taking precedence. I never noticed it because I always use Shift+Insert for pasting.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Quote from: TechSupport on June 28, 2016, 11:40:44 AM
Quote from: Jose Roca on June 28, 2016, 10:40:26 AM
I can paste if I use the context menu of the control, but if I press Ctrl-V, the control loses the focus and the text is pasted in the document.

Ah, okay. You are correct the paste seems to happen in the active document instead. The Ctrl+V accelerator key must be taking precedence. I never noticed it because I always use Shift+Insert for pasting.


Looks like I might have to do something like this:

       ''  EDIT MENU
      Case IDM_UNDO:               Function = SendMessageW( GetFocus(), Iif(GetFocus()=hEdit, SCI_UNDO, WM_UNDO), 0, 0)
      Case IDM_REDO:               Function = SendMessageW( hEdit, SCI_REDO, 0, 0)
      Case IDM_CUT:                Function = SendMessageW( GetFocus(), Iif(GetFocus()=hEdit, SCI_CUT, WM_CUT), 0, 0)
      Case IDM_COPY:               Function = SendMessageW( GetFocus(), Iif(GetFocus()=hEdit, SCI_COPY, WM_COPY), 0, 0)
      Case IDM_PASTE:              Function = SendMessageW( GetFocus(), Iif(GetFocus()=hEdit, SCI_PASTE, WM_PASTE), 0, 0)

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

There is an easier way. Just remove


pWindow->AddAccelerator( FVIRTKEY Or FCONTROL, VK_Z,  IDM_UNDO )
pWindow->AddAccelerator( FVIRTKEY Or FCONTROL, VK_X,  IDM_CUT )
pWindow->AddAccelerator( FVIRTKEY Or FCONTROL, VK_C,  IDM_COPY )
pWindow->AddAccelerator( FVIRTKEY Or FCONTROL, VK_V,  IDM_PASTE )


These are standard Windows shortcuts and don't need an accelerator.

Paul Squires

Thanks Jose, I have now removed those accelerators.

I have uploaded all the changes that I have made today. I am just starting to add Project Management stuff so don't pay too much attention to that yet.

You will have to modify the Spanish language file for the last 5 or 6 entries.

I added a new option in "Environment Options" to allow the direct adding/editing of FreeBASIC keywords. Those changes take affect immediately for all open Scintilla windows.

I also added the Command Line dialog.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca


José Roca

Code to add drag and drop files.

In OnCreate, add:


   ' // Enable drag and drop files
   DragAcceptFiles hwnd, CTRUE


In OnDestroy, add:


   ' // Disable drag and drop files
   DragAcceptFiles hwnd, FALSE


In frmMain_WndProc, add:


      CASE WM_DROPFILES
         ' // Get the number of dropped files
         DIM hDrop AS HDROP = cast(HDROP, wParam)
         DIM nCount AS LONG = DragQueryFile(hDrop, &HFFFFFFFF, NULL, 0)
         IF nCount = 0 THEN EXIT FUNCTION
         DIM i AS LONG, nLen AS LONG, wszPath AS WSTRING * MAX_PATH
         FOR i = 0 TO nCount - 1
            nLen = DragQueryFile(hDrop, i, @wszPath, MAX_PATH)
            ' // Make sure it's a file, not a folder
            DIM fd AS WIN32_FIND_DATAW
            DIM hFind AS HANDLE = FindFirstFileW(@wszPath, @fd)
            IF hFind <> INVALID_HANDLE_VALUE THEN
               FindClose hFind
               IF (fd.dwFileAttributes AND FILE_ATTRIBUTE_DIRECTORY) <> FILE_ATTRIBUTE_DIRECTORY THEN
                  ' Create the new Scintilla window and load the file
                  DIM idx AS LONG
                  Dim pDoc As clsDocument Ptr = New clsDocument
                  pDoc->CreateCodeWindow(HWnd, False, False, @wszPath)
                  gpApp->AddDocument(pDoc)        ' Add the new document to the global app         
                  idx = gTTabCtl.AddTab( pDoc )   ' Add the new document to the top tabcontrol
                  gTTabCtl.SetFocusTab(idx)
               END IF
            END IF
         NEXT
         DragFinish hDrop
         EXIT FUNCTION


You must modify this part, that is not working well:


                  ' Create the new Scintilla window and load the file
                  DIM idx AS LONG
                  Dim pDoc As clsDocument Ptr = New clsDocument
                  pDoc->CreateCodeWindow(HWnd, False, False, @wszPath)
                  gpApp->AddDocument(pDoc)        ' Add the new document to the global app         
                  idx = gTTabCtl.AddTab( pDoc )   ' Add the new document to the top tabcontrol
                  gTTabCtl.SetFocusTab(idx)


The first time that I drop a file from explorer, nothing is displayed. The second time, both the first file dropped and the second are loaded and displayed.

You also need to check if the file is already loaded in the editor to no get the same file loaded twice.

Paul Squires

That's great code Jose - thanks! I have implemented it and just uploaded it to github. It seems to be working perfectly. To load the file I simply loaded them through OnCommand_OpenIncludeFile.


      If hFind <> INVALID_HANDLE_VALUE Then
         FindClose hFind
         If (fd.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> FILE_ATTRIBUTE_DIRECTORY Then
            gpApp->IncludeFilename = wszPath
            OnCommand_OpenIncludeFile(HWnd)
         End If
      End If

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

In clsApp.ProjectAddFile, the compiler complains about this line:

   FF_ListView_InsertItem( hLV, 0, 0, wzFile, pDoc )

changed to:

   FF_ListView_InsertItem( hLV, 0, 0, wzFile, cast(long, pDoc) )

In frmProjectManager_Show, the compiler complains about function result not set.

You always leave

pWindow->DPI = 96   ' eg. 144 or any other value (96 is default)

Maybe you should include the .exe in the .zip file.

Paul Squires

Thanks Jose - I have fixed those problems and uploaded the exe as well. I only started working on the project management stuff today so it is hardly functional at all. I expect to have much more of it completed tomorrow. I am trying to keep it simple. I also need to write the Project Options dialog where the user can specify things like choosing to compile to EXE, DLL or static lib; specify error compiler switches, debug switch, codegen switch, etc...

For every file added to a project you will be able to designate it as either (1) main file, (2) module, or (3) normal. Obviously there can only be one main file. If it is a module then it is compile to a standalone obj file and linked to the main file. If it is a normal file then it does nothing special. It our PowerBasic world we would use normal files and #INCLUDE them into the main file. In FreeBasic, you can compile files into object files and link them. By checking the filedate times against the source file you can possibly speed up compilation by not having to compile all files in a project.

Still lots of work to do in the project area.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer