- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use dfwinty TYPE (T_SHELLEXECUTEINFO) SHINFO character($maxpath) :: bitmapfile, windir, paintdir integer*4 ret, ghWnd, hPaint, hPaintMenu, hPaintMenu1, hPaintMenuitem logical retlog ! Find the windows directory, stored in environment variable "WINDIR" ! Could also use "SystemRoot" environment variable LENGDIR=GETENVQQ("WINDIR", WINDIR) ! MSPaint is usually in the system32 sub-folder PAINTDIR=WINDIR(1:LENGDIR)//'\system32\mspaint.exe'C SHINFO%cbSize= sizeof(SHINFO) SHINFO%Fmask= SEE_MASK_NOCLOSEPROCESS SHINFO%hwnd= ghWnd SHINFO%lpVerb= loc('open'c) SHINFO%lpFile= loc(PAINTDIR) SHINFO%lpParameters=loc('"'//bitmapfile//'"'c ) SHINFO%lpDirectory= loc('C:'C) SHINFO%nShow= SW_HIDE retlog=ShellExecuteEx(SHINFO) if(SHINFO%hInstapp.lt.32) then ret=MESSAGEBOX(ghWnd,'Failed to find//launch MSPaint'C, & 'Problem saving the plot as JPEG file using MSPaint'C, & MB_ICONEXCLAMATION .OR. MB_OK) MainWndProc=0 return endif ! minimise this application's window so MSPaint's 'Save As' dialog can be seen ret=SendMessage(ghWnd,WM_SYSCOMMAND, SC_MINIMIZE,0 ) call sleepqq(1000) ! give program time to load hPaint=FindWindow_g1('MSPaintApp'c, NULL ) ! Get the handle to MSPaint window hPaintMenu=GetMenu(hPaint) ! Get the handle to the main menu hPaintMenu1=GetSubMenu(hPaintMenu,0) ! Get the handle to the first drop-down menu ! Get the handle to the 4th (zero-based) item in the drop-down menu hPaintMenuItem=GetMenuItemId(hPaintMenu1,3) ! Send a command that this menu item has been selected...this should launch the 'Save As' dialog ret=SendMessage(hPaint,WM_COMMAND, MAKEWPARAM(hPaintMenuItem,0), NULL) ! wait for display of Save As dialog and waste time in the loop ! for as long as the 'Save As' dialog exists... call sleepqq(1000) do while(FindWindow_g1('#32770(Dialog)'c, 'Save As' ).ne.NULL) end do call sleepqq(1000) ! make sure data is saved before sending command to exit MSPaint... ret=SendMessage(hPaint,WM_CLOSE, 0, 0 ) ! close MSPaint after 'Save As' dialog is completed ret=SendMessage(ghWnd,WM_SYSCOMMAND, SC_RESTORE,0 ) ! Restore application's window retlog=SYSTEMQQ('DEL '//bitmapfile) ! Delete unwanted bitmap file, if desired
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Message Edited by anthonyrichards on 06-27-2005 02:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have used the shown source code to use mspaint to save bitmaps (jpg, png) since a long time. We have changed our operating system towards Win 7 Prof 64 bit. Now the shown source code is not working.
I do use the following source code:
[bash] LENGDIR=GETENVQQ("WINDIR", WINDIR) ! MSPaint is usually in the system32 sub-folder PAINTDIR=WINDIR(1:LENGDIR)//'\system32\mspaint.exe'C ! ShellExecute Parameter definieren SHINFO%cbSize= sizeof(SHINFO) SHINFO%Fmask= SEE_MASK_NOCLOSEPROCESS !SHINFO%hwnd= xWnd SHINFO%lpVerb= loc('open'c) SHINFO%lpFile= loc(PAINTDIR) SHINFO%lpParameters=loc(bitmapfile ) SHINFO%lpDirectory= loc('C:'C) SHINFO%nShow= SW_HIDE ! MsPaint starten bSt=ShellExecuteEx(SHINFO) call sleepqq(500) ghPaint=FindWindow_g1('MSPaintApp'c, NULL ) ! Get the handle to MSPaint window hPaintMenu=GetMenu(ghPaint) ! Get the handle to the main menu hPaintMenu1=GetSubMenu(hPaintMenu,0) ! Get the handle to the first drop-down menu i = SetCursor(hSaveCursor) !/* Restores previous cursor */ ! #################################### ! Get the handle to the 4th (zero-based) item in the drop-down menu hPaintMenuItem=GetMenuItemId(hPaintMenu1,3) ! #################################### ! Send a command that this menu item has been selected...this should launch the 'Save As' dialog ! Use 'PostMessage' to prevent locking up of this dialog waiting for return from MSPAINT... iSt=PostMessage(ghPaint,WM_COMMAND, MAKEWPARAM(hPaintMenuItem,0), NULL) call sleepqq(500) [/bash]
Does anyone had the same problem? Any solution?
Thanks in advance
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
in the old days the program mspaint has been startet in the background. The 'save_as' dialog was shown.
Now there is no mspaint in the taskmanager and no 'save_as' dialog.
Thanks in advance
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why use Paint? Wouldn't it be easier, and less prone to future problems (no Paint), if you incorporate a JPEG compression/decompression library that should be available on sourceforge.net (e.g. http://gnuwin32.sourceforge.net/packages/jpeg.htm)
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
37 lines of FORTRAN code, excluding comments, IS pretty easy I think. I agree it all falls over when MSPAINT is no longer issued. If the menu options change, or window class names change, those problems should be 'easily' dealt with. I just thought, why not use code that exists to do the job, especially as MSPAINT offers so many image formats for free.
I would like to know if MSPAINT exists on the poster's system? If it does, perhaps it is a problem with window class id's or menu options. If not, then that's that and a freeware solution is required (for those of us not into image processing at the nuts and bolts level).
For further diagnostics, I think it would be wise to add and activate some MessageBox messages at certain stages through the calling code to gve information about return codes etc as the program code executes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The only thought I had was whether the handles were still integer(4) or whether they should be integer(HANDLE) on the Win7 64 bit system. I'm pretty sure mspaint.exeexists on my Win 7 laptop (in c:\windows\system32) but I haven't been able to run the given code on it yet.
$0.02
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>37 lines of FORTRAN code, excluding comments, IS pretty easy I think
With the proper library this may be one line of code, and you will never have to changethe programwhen:
MSPAINT goes away
MSPAINT is given a new face (drop down menues change)
parlez-vous franais
...
To protect against this .AND. use MSPAINT, I would suggest the user writes the internal format to file as-is, then calls an external program, preferably a script file, that performs the conversion file to file (optionally deleting input file too). The initial conversion program can be MSPAINT or other convient tool. Later if MSPAINT changes or your requirements change. you simply change thescript file to use that other program/utility/library.In this way, the compiled FORTRAN program need never to be updated (with regard to format exchange).A conversion utilityprogram will likely be much smaller than MSPAINT, so the overhead to write the temp file will be returned by the lower load time of the conversion program.
Finding an appropriate library and integrating it into y0ur application may take a few hours of web searching. You will have to be the judge as to how many hours this will save you (or the next person supporting the program) in the future.
Jim Dempsey
![](/skins/images/C4F7392A5C68ACA60290C9576F107044/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page