News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Nasty qeditor feature

Started by sinsi, July 11, 2019, 07:57:26 PM

Previous topic - Next topic

sinsi

Found this one by accident. Edit any file, then drag and drop another file into the editor window and say goodbye to the original edit, no asking to save first.
Moral of the story: save often and let go of the mouse before you sneeze...

jj2007

My advice: Use a decent editor :badgrin:

Jokes apart: I just discovered by accident that Ms Word 2003 does something similar but equally dangerous: edit a macro in the VBA editor, exit Word, it will save them without asking.

So, where's the problem? I had a nice fat macro there, but for testing something I selected all, then inserted a say hello MsgBox... press Alt F4, Word quits without asking, on relaunch there is the MsgBox but the fat macro is gone forever :sad:

No idea whether newer versions are equally stupid - you have been warned :cool:

hutch--

You could probably put a confirmation into it but it is an editor for programmers and the idea was to reduce the number of message boxes that pop up. If you have the problem again use the UNDO button and it magically restores what was there first.

sinsi

Programmer or not,it's pretty basic to ask...
Undo doesn't work either.

felipe

I can confirm the feature, also after the file dragged and dropped you close qeditor and there will be no question asking if you want to save it either... :icon_idea:
But you know hutch that i'm very happy with qeditor anyway  :thumbsup:  :mrgreen:

felipe

#5
Probably hutch said:
Quote"drag and drop? yeah, fork that!"

 :joking:

hutch--

The problem is I did not design the drag and drop in rich edit controls. Within the control you set a flag if anything is modified in the text which you use to trigger the "Save" operation but the drag and drop does not necessarily set the flag to indicate modified text. Now I have not properly understood what the problem is.

I opened 2 files in two instances of QE and selected all of one file and dropped it into the other instance of QE and it just inserted the text at the caret location. Click on UNDO button and it just undoes the drag and drop.

In the instance that was dragged from which leaves the edit window empty, just click on UNDO and it puts the full selected text back into the edit window. In both instances the modified flag is set and you have the option to save either when closing the instance.

At best as I can tell, it is a problem when you drop a complete file from something like Winfile.exe where the new OPEN operation just sets the flag to clear without saving the original content.

This code is probably where the problem comes from.

      case WM_DROPFILES
        mov fname, DropFileName(wParam)
        invoke Read_File_Inx,hEdit,fname
        invoke SetWindowText,hWnd,fname

felipe

Quote from: hutch-- on July 12, 2019, 09:48:06 AM
Now I have not properly understood what the problem is.

I opened 2 files in two instances of QE and selected all of one file and dropped it into the other instance of QE and it just inserted the text at the caret location. Click on UNDO button and it just undoes the drag and drop.

In the instance that was dragged from which leaves the edit window empty, just click on UNDO and it puts the full selected text back into the edit window. In both instances the modified flag is set and you have the option to save either when closing the instance.

This is true i have the same result that you describe but... :thup:


Quote from: hutch-- on July 12, 2019, 09:48:06 AM
At best as I can tell, it is a problem when you drop a complete file from something like Winfile.exe where the new OPEN operation just sets the flag to clear without saving the original content.

This is the issue that sinsi and i were talking about, it can happen with some file like myfile.txt too... :icon_idea:

hutch--

I think I have tracked it down, I put a wrapper around the drag and drop code that will not let the operation continue if the edit content is not saved. Could I impose on you to test if this mod addresses the problem that sinsi reported ?

    ; ||||||||||||||||||||||||||||||||||||||||||||||||||||||||

      case WM_DROPFILES

        invoke SendMessage,hEdit,EM_GETMODIFY,0,0
        test eax, eax
        jnz @F
        mov fname, DropFileName(wParam)
        invoke Read_File_Inx,hEdit,fname
        invoke SetWindowText,hWnd,fname
        jmp DropOut
      @@:
        fn MessageBox,hWnd,"Please save existing content first","Current content is not saved",MB_OK

      DropOut:

    ; ||||||||||||||||||||||||||||||||||||||||||||||||||||||||

sinsi

 :thumbsup:

It just needs to pop the same "File is not saved, save it now ?" dialog up.

hutch--

I had a look at doing it that way but the internal structure uses 2 steps back before starting a new thread to save the file and there was no simple way to pass the dropped file name to the thread so I opted for a simpler technique that required the user to save the existing file first.

felipe

It does  :thup:. What are those bin files created when you run this qeditor version?

hutch--

They are the INI files but its more efficient to store them as binary rather than text so they have a "bin" extension. They were not designed to be edited.