PureBasic Forum
https://www.purebasic.fr/english/

MDIGadget + StringGadget + Numeric = MDI destroyed
https://www.purebasic.fr/english/viewtopic.php?f=4&t=53898
Page 1 of 1

Author:  bamsagla [ Mon Mar 11, 2013 8:08 pm ]
Post subject:  MDIGadget + StringGadget + Numeric = MDI destroyed

Hi everyone,

if I remember correctly, some time ago a similar problem has been described somewhere. Maybe it was marked as Done, but one problem remains.
The following example code creates a simple window with MDI-window including one StringGadget with the parameter #pb_string_numeric. If you touch a wrong key ONE time, windows displays his "Oh my god - you touched a wrong key...". But the SECOND and even more times you touch wrong keys (like alphabetic keys...) the message remains intact but some parts of the MDI are becoming "destroyed" (not redrawn), like parts of the light red background color and parts of the TextGadget...

Try for yourself (I tried on Windows 7 x64 with PB 5.00 and PB 5.11b2):

Code:
Define.i Wd, Sw, Md, Ev, Fi
Wd = OpenWindow(#PB_Any, 0, 0, 600, 400, "Test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
If Not Wd = 0
   SetWindowColor(Wd, RGB(255, 255, 255))
   If CreateMenu(#PB_Any, WindowID(Wd))
      OpenSubMenu("Window")
      Md = MDIGadget(#PB_Any, 0, 0, 400, 300, 0, 0, #PB_MDI_AutoSize)
      If Not Md = 0
         Sw = AddGadgetItem(Md, #PB_Any, "MDI-Test")
         If Not Sw = 0
            ResizeWindow(Sw, #PB_Ignore, #PB_Ignore, 400, 300)
            SetWindowColor(Sw, RGB(255, 100, 100))
            StringGadget(#PB_Any, 20, 20, 100, 25, "", #PB_String_Numeric)
            TextGadget(#PB_Any, 20, 45, 300, 25, "Please enter non-numeric values above!")
            Repeat
               Test = WaitWindowEvent(5000)
               Select Test
                  Case #PB_Event_CloseWindow: Fi = 1
               EndSelect
            Until Fi = 1
         EndIf
      EndIf
   EndIf
EndIf
End


Remember to type wrong values inside the StringGadget more than once.

Thanks for testing and responses, bamsagla.

Edit: Forgot to mention that everything works fine for me without MDI-Window (numeric StringGadget inside a simple window).
Edit2: Just for reviewing purposes - the Isxxx()-commands have been replaced by If-statements as Fred suggested.

Author:  Fred [ Tue Mar 12, 2013 10:56 am ]
Post subject:  Re: MDIGadget + StringGadget + Numeric = MDI partially destr

Fixed. BTW, don't use IsXXX() functions if not absolutely necessary as they are time consuming. #PB_Any returns 0 if it can't be created, so a regular IF is enough.

Author:  bamsagla [ Tue Mar 12, 2013 11:06 am ]
Post subject:  Re: [Done] MDIGadget + StringGadget + Numeric = MDI destroye

Hi Fred,
thanks for fixing and also thanks a lot for this hint.
That was a typical "validating the value of the value"... :oops:
Why creating easy code if there's a possibility for complicating things...? :twisted:
*fail with BOD*
Merci, bamsagla.

Author:  Fred [ Sat Nov 09, 2013 4:02 pm ]
Post subject:  Re: MDIGadget + StringGadget + Numeric = MDI destroyed

Reverted back hacks, so this bug is back.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/