Holger Posted May 17, 2004 Share Posted May 17, 2004 (edited) Hi there I don't know if it is normal or not, maybe a "not-deleting-a-gui-value"-problem. Please take a look at this code and if you test it out then look into the "GDI-Objects" of the task-manager in NT/2K/XP. expandcollapse popupGlobal $GUI_CHECKED = 1, $check1 GUI1() While GUIMsg() > 0 $n = GUIMsg(0) ; the same with $n = GUIRead() If $n = $check1 Then If GUIRead($check1) = $GUI_CHECKED Then GUIDelete() msgbox(0,"","check GDI") GUI2() Else GUIDelete() msgbox(0,"","check GDI") GUI1() EndIf EndIf WEnd GUIDelete() msgbox(0,"","check GDI") Exit Func GUI1() GUICreate("GUI1") $check1 = GUISetControl("checkbox","change",50,50,100,20) GUISetControlNotify() GUIShow() EndFunc Func GUI2() GUICreate("GUI2") $check1 = GUISetControl("checkbox","change",50,50,100,20) GUISetControlEx(-1,$GUI_CHECKED) GUISetControlNotify() GUIShow() EndFunc The GDI-object-number will bigger and bigger. For that sample only 1 step but if you have a lot more controls then the step will be also bigger. What I want to do is to switch between a small GUI and a GUI with more functions you know. Ok, I know it's a little problem but maybe there's a solution for it Thanks again, Holger Edited May 17, 2004 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
jpm Posted May 17, 2004 Share Posted May 17, 2004 (edited) Found, reuploaded 102.23A. I send to JON the correction. I hope it will merge it Thanks Edited May 17, 2004 by jpm Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 17, 2004 Administrators Share Posted May 17, 2004 Found, reuploaded 102.23A. I send to JON the correction. I hope it will merge itThanks Arrggh. I just uploaded the .23 version... Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
jpm Posted May 17, 2004 Share Posted May 17, 2004 Arrggh. I just uploaded the .23 version...Thanks Jon Link to comment Share on other sites More sharing options...
Holger Posted May 17, 2004 Author Share Posted May 17, 2004 Thanks Jon and JPM...BUT...there is still 'a' same problem!!! I will test it more and tell you where it happens, but for the moment here is the second 'problem-example'. I added only "GUISetControlFont" and the problem occurs again. Maybe in a future version it will be solved. expandcollapse popupGlobal $GUI_CHECKED = 1, $check1 GUI1() While GUIMsg() > 0 $n = GUIMsg(0) ; the same with $n = GUIRead() If $n = $check1 Then If GUIRead($check1) = $GUI_CHECKED Then GUIDelete() msgbox(0,"","check GDI") GUI2() Else GUIDelete() msgbox(0,"","check GDI") GUI1() EndIf EndIf WEnd GUIDelete() msgbox(0,"","check GDI") Exit Func GUI1() GUICreate("GUI1") $check1 = GUISetControl("checkbox","change",50,50,100,20) GUISetControlNotify() GUISetControlFont(-1,11,650) GUIShow() EndFunc Func GUI2() GUICreate("GUI2") $check1 = GUISetControl("checkbox","change",50,50,100,20) GUISetControlEx(-1,$GUI_CHECKED) GUISetControlNotify() GUISetControlFont(-1,11,650) GUIShow() EndFunc At the moment I live with it Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
jpm Posted May 17, 2004 Share Posted May 17, 2004 Thanks Jon and JPM...BUT...there is still 'a' same problem!!! I will test it more and tell you where it happens, but for the moment here is the second 'problem-example'. I added only "GUISetControlFont" and the problem occurs again. Maybe in a future version it will be solved. expandcollapse popupGlobal $GUI_CHECKED = 1, $check1 GUI1() While GUIMsg() > 0 $n = GUIMsg(0) ; the same with $n = GUIRead() If $n = $check1 Then If GUIRead($check1) = $GUI_CHECKED Then GUIDelete() msgbox(0,"","check GDI") GUI2() Else GUIDelete() msgbox(0,"","check GDI") GUI1() EndIf EndIf WEnd GUIDelete() msgbox(0,"","check GDI") Exit Func GUI1() GUICreate("GUI1") $check1 = GUISetControl("checkbox","change",50,50,100,20) GUISetControlNotify() GUISetControlFont(-1,11,650) GUIShow() EndFunc Func GUI2() GUICreate("GUI2") $check1 = GUISetControl("checkbox","change",50,50,100,20) GUISetControlEx(-1,$GUI_CHECKED) GUISetControlNotify() GUISetControlFont(-1,11,650) GUIShow() EndFunc At the moment I live with it It was easy to solve the first one because the color are memorized. It is not true for fonts so I think we will need to live with this one. Link to comment Share on other sites More sharing options...
Holger Posted May 17, 2004 Author Share Posted May 17, 2004 (edited) @jpm: don't know if it is alright so, but I added a line to 'ChangeFont'-c++-function and it works now!? //////////////////////////////////////////////////////////////////////////////////////////////// // // ChangeFONT() // //////////////////////////////////////////////////////////////////////////////////////////////// void CGuiBox::ChangeFONT(HWND hWnd, char *Font, int Size, int Weight, int nAttribute) { HFONT hFont; HDC hDC=GetDC(HWND_DESKTOP); int CyPixels=GetDeviceCaps(hDC,LOGPIXELSY); ReleaseDC(HWND_DESKTOP,hDC); hFont = CreateFont(0-(Size*CyPixels)/72,0,0,0,Weight, nAttribute & GUI_FONTITALIC, nAttribute & GUI_FONTUNDER, nAttribute & GUI_FONTSTRIKE, DEFAULT_CHARSET, OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY ,FF_DONTCARE,Font); SendMessage(hWnd,WM_SETFONT,(WPARAM)hFont,(LPARAM)TRUE); DeleteObject(hFont); // <- this one I added...hmmm... } // ChangeFONT() Edit: Shi... I see that was not correct...hmmm...difficult... I think I should learn c++ in a workshop... Regards Holger Edited May 17, 2004 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
jpm Posted May 18, 2004 Share Posted May 18, 2004 @jpm: don't know if it is alright so, but I added a line to 'ChangeFont'-c++-function and it works now!? //////////////////////////////////////////////////////////////////////////////////////////////// // // ChangeFONT() // //////////////////////////////////////////////////////////////////////////////////////////////// void CGuiBox::ChangeFONT(HWND hWnd, char *Font, int Size, int Weight, int nAttribute) { HFONT hFont; HDC hDC=GetDC(HWND_DESKTOP); int CyPixels=GetDeviceCaps(hDC,LOGPIXELSY); ReleaseDC(HWND_DESKTOP,hDC); hFont = CreateFont(0-(Size*CyPixels)/72,0,0,0,Weight, nAttribute & GUI_FONTITALIC, nAttribute & GUI_FONTUNDER, nAttribute & GUI_FONTSTRIKE, DEFAULT_CHARSET, OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY ,FF_DONTCARE,Font); SendMessage(hWnd,WM_SETFONT,(WPARAM)hFont,(LPARAM)TRUE); DeleteObject(hFont); // <- this one I added...hmmm... } // ChangeFONT() Edit: Shi... I see that was not correct...hmmm...difficult... I think I should learn c++ in a workshop... Regards HolgerTHe best I can do is to have the GuiDefaultFont not having this problem and perhaps the last used GuiSetControlFont. I don't want to memorise all unless it is more than mandatory ... Link to comment Share on other sites More sharing options...
Holger Posted May 18, 2004 Author Share Posted May 18, 2004 @jpm: thanks for trying to solve it Maybe I will use 2 GUI's and then show one and hide the other... Cool are the new GUI-functions: GUIGetControlState is very good Regards Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
Valik Posted May 18, 2004 Share Posted May 18, 2004 JP, you can always attach the original font as a property on control.... (SetProps and GetProps I think) GDI leaks aren't really something you can just safely ignore. The system has a limit (10,000 I think, but I can't remember). Once a program hits that number, it will crash. Even a slow leak will add up given that some people run scripts for extremely long periods of time. Link to comment Share on other sites More sharing options...
jpm Posted May 18, 2004 Share Posted May 18, 2004 JP, you can always attach the original font as a property on control.... (SetProps and GetProps I think)GDI leaks aren't really something you can just safely ignore. The system has a limit (10,000 I think, but I can't remember). Once a program hits that number, it will crash. Even a slow leak will add up given that some people run scripts for extremely long periods of time.I take a while to reach 10000 switching from one gui to another using different fonts each time. (French joke I am sure you already did)Nevertheless I was afraid to waste memory by memorizing the font handle. But JON convince already to do it and is ready for 102.24 no more leak on font usage.If I underdand the Windows API I am realeasing all gdi during GuiDelete. Link to comment Share on other sites More sharing options...
jpm Posted May 18, 2004 Share Posted May 18, 2004 @jpm: thanks for trying to solve it Maybe I will use 2 GUI's and then show one and hide the other... Cool are the new GUI-functions: GUIGetControlState is very good Regards Holger2 or several gui at the same time is more complicated than releasing the used gdi. Is corrected in 102.24 waiting more bug before release.I know that some will come. Link to comment Share on other sites More sharing options...
Holger Posted May 18, 2004 Author Share Posted May 18, 2004 @jpm: sounds great, thank you Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView 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