PlanetSquires Forums

Please login or register.

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

Author Topic: WinFBE new code on GitHub  (Read 11529 times)

José Roca

  • Guru Member
  • *****
  • Posts: 3268
Re: WinFBE new code on GitHub
« Reply #30 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.

José Roca

  • Guru Member
  • *****
  • Posts: 3268
Re: WinFBE new code on GitHub
« Reply #31 on: June 28, 2016, 12:46:22 AM »

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

Code: [Select]
   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.
« Last Edit: June 28, 2016, 12:51:38 AM by Jose Roca »
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9287
  • Windows 10
    • PlanetSquires Software
Re: WinFBE new code on GitHub
« Reply #32 on: June 28, 2016, 09:12:52 AM »

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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9287
  • Windows 10
    • PlanetSquires Software
Re: WinFBE new code on GitHub
« Reply #33 on: June 28, 2016, 09:23:15 AM »

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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

  • Guru Member
  • *****
  • Posts: 3268
Re: WinFBE new code on GitHub
« Reply #34 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.
« Last Edit: June 28, 2016, 11:25:23 AM by Jose Roca »
Logged

José Roca

  • Guru Member
  • *****
  • Posts: 3268
Re: WinFBE new code on GitHub
« Reply #35 on: June 28, 2016, 10:43:38 AM »

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

  • Administrator
  • Guru Member
  • *****
  • Posts: 9287
  • Windows 10
    • PlanetSquires Software
Re: WinFBE new code on GitHub
« Reply #36 on: June 28, 2016, 11:40:44 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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9287
  • Windows 10
    • PlanetSquires Software
Re: WinFBE new code on GitHub
« Reply #37 on: June 28, 2016, 11:50:54 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:
Code: [Select]
       ''  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)
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

  • Guru Member
  • *****
  • Posts: 3268
Re: WinFBE new code on GitHub
« Reply #38 on: June 28, 2016, 12:19:17 PM »

There is an easier way. Just remove

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

  • Administrator
  • Guru Member
  • *****
  • Posts: 9287
  • Windows 10
    • PlanetSquires Software
Re: WinFBE new code on GitHub
« Reply #39 on: June 28, 2016, 08:21:21 PM »

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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

  • Guru Member
  • *****
  • Posts: 3268
Re: WinFBE new code on GitHub
« Reply #40 on: June 28, 2016, 11:07:02 PM »

New Spanish language file.

José Roca

  • Guru Member
  • *****
  • Posts: 3268
Re: WinFBE new code on GitHub
« Reply #41 on: June 29, 2016, 05:36:21 PM »

Code to add drag and drop files.

In OnCreate, add:

Code: [Select]
   ' // Enable drag and drop files
   DragAcceptFiles hwnd, CTRUE

In OnDestroy, add:

Code: [Select]
   ' // Disable drag and drop files
   DragAcceptFiles hwnd, FALSE

In frmMain_WndProc, add:

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

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

  • Administrator
  • Guru Member
  • *****
  • Posts: 9287
  • Windows 10
    • PlanetSquires Software
Re: WinFBE new code on GitHub
« Reply #42 on: June 29, 2016, 08:55:52 PM »

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.

Code: [Select]
      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
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

  • Guru Member
  • *****
  • Posts: 3268
Re: WinFBE new code on GitHub
« Reply #43 on: June 29, 2016, 09:23:41 PM »

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

  • Administrator
  • Guru Member
  • *****
  • Posts: 9287
  • Windows 10
    • PlanetSquires Software
Re: WinFBE new code on GitHub
« Reply #44 on: June 29, 2016, 09:45:54 PM »

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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer
Pages: 1 2 [3]