FitzChivalry Posted February 6, 2008 Share Posted February 6, 2008 Ok, so I'm not really that familiar with GUI's, but I've been working on this one for a bit. The idea is to use it to study paintings like flashcards. I have a bunch of pictures in the script directory, and when I run it like it is now it runs ok, but I have 2 main questions on how to improve it. 1. It stretches the pictures to funny proportions. I know that when using GUICtrlCreatePic if you leave the options for width and height undefined, it will default to the last used one. Is there any way to make it default to the actual picture size so it will look normal? 2. When I try and move to the next picture, my GUI wont refresh. It will still show the old picture unless you switch away from that window and then switch back. I'm temporarily working around this by using: ;This is the part i'm worried about, there has got to be a better way to do this.... $n=GUICtrlCreatePic(@ScriptDir &"\" & $piclist[$i],1,30,700,700) SplashImageOn("Test", @ScriptDir &"\" & $piclist[$i],700,700) sleep(50) SplashOff() ;-------------oÝ÷ ÛbrhzǺÇéx.§v-¢·ë!nëbßÙ§¢ÛÞ¯(Z¦n¶f²êÞ¶«z+mëmz¼É8h±æ«zl¶ªç¬¶*'±¼ºY¡×¢²)Üç^u·¥£(j|¨çßz¶§Êj+z'^jÊ'-¢)©®ÞÔájy,ßv®¶s` ¢6æ6ÇVFRfÇC´uT6öç7FçG2æS2fwC°¢6æ6ÇVFRfÇC´fÆRæS2fwC°¢6æ6ÇVFRfÇC´'&æS2fwC° ¢b33c·6Æ7BÒôfÆTÆ7EFô'&67&DF"ÂgV÷C²¢æ§rgV÷C²Â£µô'&F7Æb33c·6Æ7B ¤uT7&VFRgV÷C´×uT7GW&RgV÷C²ÃsÃsÂÓÂÓÂb33cµu5õ4¤T$õ²b33cµu5õ54ÔTåR ¤uT6WD&´6öÆ÷"Sdddb ¢b33c´'WGFöæÒuT7G&Ä7&VFT'WGFöâgV÷C´ç7vW"gV÷C²ÂÂRÂSÂ#R¢b33c´'WGFöæâÒuT7G&Ä7&VFT'WGFöâgV÷C´æWBgV÷C²ÂÂRÂSÂ#R ¤uT6WE7FFR¢b33c¶Ò¢b33c¶ãÔuT7G&Ä7&VFU267&DF"fײgV÷C²b3#²gV÷C²fײb33c·6Æ7E²b33c¶ÒÃÃ3ÃsÃs£²'VâFRuTVçFÂFRFÆör26Æ÷6V@¥vÆR ¢b33c¶×6rÒuTvWD×6r bb33c¶×6rÒb33c´'WGFöæFVà ×6t&÷ÂgV÷C´ç7vW"gV÷C²Âb33c·6Æ7E²b33c¶ÒÂ" uT7G&Å6WE7FFRb33c´'WGFöæâÂb33c¶wVöfö7W2 VæD` bb33c¶×6rÒb33c´'WGFöæâFVà ´×6t&÷ÂgV÷C¶6Æ6¶VBgV÷C²ÂgV÷C¶æWBgV÷C² b33c¶Òb33c¶³ bb33c¶fwC²b33c·6Æ7E³ÒFVâWDÆö÷ µF22FR'Bb33¶Òv÷'&VB&÷WBÂFW&R2v÷BFò&R&WGFW"vFòFòF2âââà b33c¶ãÔuT7G&Ä7&VFU267&DF"fײgV÷C²b3#²gV÷C²fײb33c·6Æ7E²b33c¶ÒÃÃ3ÃsÃs 7Æ6ÖvTöâgV÷CµFW7BgV÷C²Â67&DF"fײgV÷C²b3#²gV÷C²fײb33c·6Æ7E²b33c¶ÒÃsÃs 6ÆVWS 7Æ6öfb ²ÒÒÒÒÒÒÒÒÒÒÒÒÐ uT7G&Å6WE7FFRb33c´'WGFöæÂb33c¶wVöfö7W2 uT6WE7FFRb33c´uTôôåDõ VæD`¢¢bb33c¶×6rÒb33c´uTôUdTåEô4Äõ4RFVâWDÆö÷¥vVæ@ ¤×6t&÷ÂgV÷CµFæ·2gV÷C²ÂgV÷C´vööB¦ö"7GVGærb333²gV÷C² Link to comment Share on other sites More sharing options...
Zedna Posted February 6, 2008 Share Posted February 6, 2008 Try to use GUICtrlSetImage instead of GUICtrlCreatePic in your loop Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
FitzChivalry Posted February 7, 2008 Author Share Posted February 7, 2008 Try to use GUICtrlSetImage instead of GUICtrlCreatePic in your loopahh hah! That does seem to work better :-) many thanks!Anyone have any ideas about making the picture appear in it's normal size? Link to comment Share on other sites More sharing options...
Achilles Posted February 7, 2008 Share Posted February 7, 2008 Look for GuiCtrlSetPos() and _GDIPlus_ImageGetHeight and _GDIPlus_ImageGetWidth. So, because some of the GDI functions can be confusing, this is an outline of what you want: #Include <GDIPlus.au3> _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sFileName) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) GuiCtrlSetPos($yourCtrl, x, y, $width, $height) My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Tomb Posted February 7, 2008 Share Posted February 7, 2008 Ok, so I'm not really that familiar with GUI's, but I've been working on this one for a bit. The idea is to use it to study paintings like flashcards. I have a bunch of pictures in the script directory, and when I run it like it is now it runs ok, but I have 2 main questions on how to improve it. 1. It stretches the pictures to funny proportions. I know that when using GUICtrlCreatePic if you leave the options for width and height undefined, it will default to the last used one. Is there any way to make it default to the actual picture size so it will look normal? 2. When I try and move to the next picture, my GUI wont refresh. It will still show the old picture unless you switch away from that window and then switch back. I'm temporarily working around this by using: ;This is the part i'm worried about, there has got to be a better way to do this.... $n=GUICtrlCreatePic(@ScriptDir &"\" & $piclist[$i],1,30,700,700) SplashImageOn("Test", @ScriptDir &"\" & $piclist[$i],700,700) sleep(50) SplashOff() ;-------------oÝ÷ ÛbrhzǺÇéx.§v-¢·ë!nëbßÙ§¢ÛÞ¯(Z¦n¶f²êÞ¶«z+mëmz¼É8h±æ«zl¶ªç¬¶*'±¼ºY¡×¢²)Üç^u·¥£(j|¨çßz¶§Êj+z'^jÊ'-¢)©®ÞÔájy,ßv®¶s` ¢6æ6ÇVFRfÇC´uT6öç7FçG2æS2fwC°¢6æ6ÇVFRfÇC´fÆRæS2fwC°¢6æ6ÇVFRfÇC´'&æS2fwC° ¢b33c·6Æ7BÒôfÆTÆ7EFô'&67&DF"ÂgV÷C²¢æ§rgV÷C²Â£µô'&F7Æb33c·6Æ7B ¤uT7&VFRgV÷C´×uT7GW&RgV÷C²ÃsÃsÂÓÂÓÂb33cµu5õ4¤T$õ²b33cµu5õ54ÔTåR ¤uT6WD&´6öÆ÷"Sdddb ¢b33c´'WGFöæÒuT7G&Ä7&VFT'WGFöâgV÷C´ç7vW"gV÷C²ÂÂRÂSÂ#R¢b33c´'WGFöæâÒuT7G&Ä7&VFT'WGFöâgV÷C´æWBgV÷C²ÂÂRÂSÂ#R ¤uT6WE7FFR¢b33c¶Ò¢b33c¶ãÔuT7G&Ä7&VFU267&DF"fײgV÷C²b3#²gV÷C²fײb33c·6Æ7E²b33c¶ÒÃÃ3ÃsÃs£²'VâFRuTVçFÂFRFÆör26Æ÷6V@¥vÆR ¢b33c¶×6rÒuTvWD×6r bb33c¶×6rÒb33c´'WGFöæFVà ×6t&÷ÂgV÷C´ç7vW"gV÷C²Âb33c·6Æ7E²b33c¶ÒÂ" uT7G&Å6WE7FFRb33c´'WGFöæâÂb33c¶wVöfö7W2 VæD` bb33c¶×6rÒb33c´'WGFöæâFVà ´×6t&÷ÂgV÷C¶6Æ6¶VBgV÷C²ÂgV÷C¶æWBgV÷C² b33c¶Òb33c¶³ bb33c¶fwC²b33c·6Æ7E³ÒFVâWDÆö÷ µF22FR'Bb33¶Òv÷'&VB&÷WBÂFW&R2v÷BFò&R&WGFW"vFòFòF2âââà b33c¶ãÔuT7G&Ä7&VFU267&DF"fײgV÷C²b3#²gV÷C²fײb33c·6Æ7E²b33c¶ÒÃÃ3ÃsÃs 7Æ6ÖvTöâgV÷CµFW7BgV÷C²Â67&DF"fײgV÷C²b3#²gV÷C²fײb33c·6Æ7E²b33c¶ÒÃsÃs 6ÆVWS 7Æ6öfb ²ÒÒÒÒÒÒÒÒÒÒÒÒÐ uT7G&Å6WE7FFRb33c´'WGFöæÂb33c¶wVöfö7W2 uT6WE7FFRb33c´uTôôåDõ VæD`¢¢bb33c¶×6rÒb33c´uTôUdTåEô4Äõ4RFVâWDÆö÷¥vVæ@ ¤×6t&÷ÂgV÷CµFæ·2gV÷C²ÂgV÷C´vööB¦ö"7GVGærb333²gV÷C²that or just put 0, 0 as the width and height and GuiCtrlCreateImage makes atual size Link to comment Share on other sites More sharing options...
FitzChivalry Posted February 7, 2008 Author Share Posted February 7, 2008 that or just put 0, 0 as the width and height and GuiCtrlCreateImage makes atual size Cool, I didnt know that, but it works great. Zedna, for some reason when I was using GUICtrlSetImage, it would only work for the first 2 pictures that it showed, then stopped showing any more...not exactly sure why. What I ended up doing is using ;-------this now works ok.... just using setimage didnt work right, so now i'm using a combination ;$n=GUICtrlCreatePic(@ScriptDir &"\blank.jpg",1,30,0,0) $n = GUICtrlSetImage($n, @ScriptDir &"\blank.jpg") $n=GUICtrlCreatePic(@ScriptDir &"\" & $piclist[$i],1,30,0,0) ;~ $n = GUICtrlSetImage($n, @ScriptDir &"\" & $piclist[$i]) SplashImageOn("Test", @ScriptDir &"\blank.jpg",@DesktopWidth, @DesktopHeight -30) sleep(50) SplashOff() ;------------- I did this because my gui would never refresh to show the newest image displayed. I couldnt find any option to force the GUI to refresh itself, so doing the splash works.... not the most elegant solution, but it is working better then before. If anyone has any other suggestions to try I'd welcome them, but it seems to be working ok now.... Thanks for the help all!! Link to comment Share on other sites More sharing options...
Zedna Posted February 7, 2008 Share Posted February 7, 2008 (edited) GUICtrlCreatePic() use only once at begin then use ONLY GUICtrlSetImage() if you encounter refresh problems then use manual refresh instead by SplashImageOn() by: $gui = GUICreate(...) $pic = GUICtrlCreatePic(...) $pic_hWnd = ControlGetHandle($gui,"",$pic) DLLCall("user32.dll","int","InvalidateRect","hwnd",$pic_hWnd,"int",0,"int",0) Edited February 7, 2008 by Zedna SupaNewb 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now