Author Topic: Open/Save Windows dialogs now repaired for both 32/64 bit versions.  (Read 237 times)

Offline Petr

  • Forum Resident
  • Posts: 1354
  • The best code is the DNA of the hops.
For the program to function properly, it is important to keep writing the mask when calling GetSaveFileName. At the end, I added a small program to the file that filters the file extension in 64 bits (the dialog already correctly returns the extension selection number, but stubbornly refused to filter the mask. So I did so. I also made some adjustments in the file

I tested this program as it is in both 32 and 64 bit IDE and it works properly.

Repaired small bug (added condition to end to file

SierraKen find next bug, if is file overwrited. This bug is repaired in version 3.

« Last Edit: June 28, 2020, 07:00:28 PM by Petr »

Offline bplus

  • Forum Resident
  • Posts: 4589
  • B+ nots
Thanks Petr, I was testing save, canceled and it returned ".jpg" should it return "", ie nothing?

Offline Petr

  • Forum Resident
  • Posts: 1354
  • The best code is the DNA of the hops.
Thank for report. Bug repaired, source reuploaded.
« Last Edit: June 28, 2020, 06:45:28 AM by Petr »

Offline SpriggsySpriggs

  • Seasoned Forum Regular
  • Posts: 259
  • DIM JohnSilver AS LONG, yarn AS STRING
    • My GitHub
@Petr your way of making it attach the extension at the end is the exact same way that I was doing it this afternoon but for some reason Ken's code wouldn't save the image even though the filename was correct. Good work. I'll update the Wiki with your code.

Offline SierraKen

  • Forum Resident
  • Posts: 950
Petr, I found another bug. When the user Saves a picture as the same name of an existing picture, first it asks if you want to overwrite it, which is good, but then when it saves it, it saves with a second extension to it. For example, if you save over another one called picture.jpg, it will save the file as picture.jpg.jpg
So, I found a way around this in my own Paint Pixels 7 program by calculating the number of characters of nm$ with LEN and then reducing the characters from nm$ with RIGHT$. Below is what I made. Also, just so you know, your OPEN and SAVE dialogue has the exact same OFN commands which shouldn't be done. Because when you open a file, it has nothing to do with overwrite. So, I put in the same OFN commands as I did yesterday and it works fine. If you need help with my code, please ask. But THANK YOU for fixing the other Save problem I had, at least I don't need to add the .jpg anymore. I also used your idea and letting the user to my program save as JPG, PNG, or BMP. :))))
If you need help with my code below, please ask.  Oh also, there's a very slight minor bug as well, which I have no idea if it can be fixed, but when the user switches directories to open a picture file and looks on the JPG, PNG, BMP list for some reason it's adding a part of the _TITLE text after that on that same list. LOL

Code: QB64: [Select]
  1. 'Saving Section
  2. saving:
  3. nm$ = GetSaveFileName("Save Image", ".\", "JPG Image (.jpg)|*.jpg|PNG Image (.png)|*.png|BMP Image (.bmp)|*.bmp", 1, OFN_OVERWRITEPROMPT + OFN_NOCHANGEDIR, _WINDOWHANDLE)
  4. IF nm$ = "" THEN GOTO skipsave:
  5. IF RIGHT$(nm$, 8) = ".jpg.jpg" OR RIGHT$(nm$, 8) = ".png.png" OR RIGHT$(nm$, 8) = ".bmp.bmp" THEN
  6.     letters = LEN(nm$)
  7.     nm$ = LEFT$(nm$, letters - 4)
  8. _DELAY .25
  9. Result = SaveImage(nm$, 0, 0, 0, _WIDTH(img), _HEIGHT(img)) 'first zero is your screen, second zero is X start, 3th zero is y start
  10. _DELAY .25
  11. nm$ = ""
  12. skipsave:
  13. dMode = 1
  14. m = 1
  16. 'Loading Section
  17. loading:
  18. nm$ = GetOpenFileName$("Open Image", ".\", "JPG Image (.jpg)|*.jpg|PNG Image (.png)|*.png|BMP Image (.bmp)|*.bmp", 1, OFN_FILEMUSTEXIST + OFN_NOCHANGEDIR + OFN_READONLY, _WINDOWHANDLE)
  19. IF nm$ = "" THEN GOTO skipopen:
  20. l = 0
  21. i& = _LOADIMAGE(nm$, 32)
  22. s& = i&
  23. i& = 0
  24. screenx = _WIDTH
  25. screeny = _HEIGHT
  26. picture& = _NEWIMAGE(screenx, screeny, 32)
  27. skipopen:
  28. dMode = 1
  29. m = 1
« Last Edit: June 28, 2020, 04:19:52 PM by SierraKen »

Offline Petr

  • Forum Resident
  • Posts: 1354
  • The best code is the DNA of the hops.
Thanks for report. First bug - overwriting under the same name without adding new extension if extension already exist solved in BM file (download version 3 for try). What you thing with OFN commands? I have none problems with adding part of _TITLE to opendialog windows here. Is not your _TITLE changed, when is open/save dialog run?

You still do the same error with using Steve library. Again, your row 10 in your source code is writed badly.
« Last Edit: June 28, 2020, 07:25:48 PM by Petr »

Offline SierraKen

  • Forum Resident
  • Posts: 950
I just mean that OFN_OVERWRITEPROMPT is only for SAVE because it detects to see if you are saving to an existing file name. I added a couple more to my OPEN file area for different things that are only designated for OPEN. I learned about all of these in your file in the comments.

Thanks for fixing the bug Petr and telling me how to fix the _TITLE problem. I added SLEEP commands to the end of the SAVE and LOAD areas so that it wouldn't automatically go to the loop at the same time you are doing the Open or Save dialogs. People just have to select what they want to do before they start drawing again, no big deal. :) I'm about ready to post my newest update to the Paint Pixels 7 thread again. THANKS!