1. Re: WinClass Question for Al (part 2)
- Posted by Al Getz <Xaxo at aol.com> Dec 22, 2005
- 495 views
don cole wrote: > > > Sorry I took so long Al, > I had things to attend to. > > > Al Getz wrote: > > > > Hi again Don, > > > > > > I looked at your new program and it looks a lot better :) It ran > > fine this time, and i was able to try a few things out. Here's > > a short list of a few things i found that improves the picture handling > > and makes sure all pictures are unregistered before the viewer exits. > > (Note if one picture is not unregistered then it wont be possible to > > delete that pic from Win Explorer unless you first log off/log back on). > > > > 1. Fix that makes sure all pictures are unregistered before the > > viewer exits... > > > > Within the onChar routine: > > > > elsif char=27 then --escape key > > QuitApp() > > --(and rem out the four function calls to close windows) > > > > This changes allows WinMain to return properly so the short section > > of code that unregisters the last pic viewed and free's the GdiPlus > > library runs as planned. This code must be run before the viewer > > shuts down completely. QuitApp() simply calls PostQuitMessage(0). > > > This fixed the problem of not being able to delete picture with a 2nd party > program. > > > 2. I noticed that when we scroll a pic to the right, left, up or down, > > if there are only two pics in the directory the viewer might move > > to a different pic (the other one) instead of simply scrolling, so > > changing the code for the arrow keys fixes this problem... > > > > Also within the onChar routine: > > > > elsif char=38 then --arrow up > > VertScrollAmount=VertScrollAmount+VertScrollIncrement > > retv=win:InvalidateRect(GetHandle(MainAppWindow),0,1) > > > > The only difference here is InvalidateRect replaces > > --DirListIndex=DirListIndex-1 > > --onClick_ButtonForward() > > which was an old trick to get the window to repaint. > > The new code will work even if there is only one pic left. > > The above has to be changed for all four arrow keys too, which > > each have their own way of changing the scroll amount but should > > all now use InvalidateRect instead of the old way. > > I'm glad you showed me this I had a hard time figuring out how to > repaint the window. I tried onPaint_MainAppWindow() and call_func to > onPaint_MainAppWindow(). I finally settled for onClickButtonForward() > which I was not happy with, but it worked. > > > 3. The example: > > ?GdipDisposeImage(TargetDirName&newtemp) > > --unregisters the picture so it can delete > > was really just an example of unreg'ing the pic, but you probably dont > > want the result to be printed to console so of course you can use: > > > > atom void > > void=GdipDisposeImage(TargetDirName&newtemp) > > I changed this to rstv=GdipDisposeImage(TargetDirName&newtemp) because it > was already declared. > BTW what does rstv stand for? > > > or something like that if you wish. > > > > > > BTW, that new 'Help' screen is very nice! The viewer really needed > > something like that. I sometimes forget the proper key for a given > > function myself and dont feel like looking up the text file he he. > > I'm glad you liked the help screen. I added the arrow keys which I don't > think > were in the version I send you. > > I made all the changes you suggested and everything seems to work fine. > I plan on uploading to the archives soon. > Thank you very much for all your help. > > Don Cole > A Bug is an un-documented feature. > A Feature is a documented Bug. Hi there Don, You mean the arrow keys for scrolling the pic left right, up down? The one you sent had that too. Works nice btw. Oh yeah, by 'rstv' i think you mean 'retv' ? retv is just short for retval which is short for "return value". I've used this var for functions that return a value but is probably not going to be actually needed at that point in the program. It's similar to using 'void', but sometimes if the function returns a boolean i like to use 'bool' instead to show that the function returns a bool ... in case that code needs debugging it's nice to know what the function is returning without having to look it up again. I meant to ask you... was your intention with this viewer to stop directory wrap around (ie after the last picture the viewer jumps back to the beginning of the directory...first pic) or was that an accident? Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's"