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

[pb4.40 b5, b6] buttonImageGadget refresh problem
https://www.purebasic.fr/english/viewtopic.php?f=4&t=39629
Page 1 of 1

Author:  Le Soldat Inconnu [ Fri Oct 23, 2009 1:20 pm ]
Post subject:  [pb4.40 b5, b6] buttonImageGadget refresh problem

Hi,

I have big program, and sometime, i have this problem :

I don't see any icon in my ButtonImageGadget

I move mouse over my buttonimagegadget and icon come back (it's icon in buttonimagegadget, not image)

look this screen-shoot :
Image

It's sometime, i don't see raison for this moment, and i see this problem on XP on 3 different computers, and a have bug report for my program on my website about this

I just see all window refresh (small flash on window) and all icon disappear




Edit : I find how to see crash all time, I will try do to example with small code this evening

Author:  Le Soldat Inconnu [ Fri Oct 23, 2009 5:28 pm ]
Post subject:  Re: [pb4.40 b5] buttonImageGadget refresh problem

Hi,

i do example of problem

run this code

left click on treegadget

press down arrow on keyboard

and all image disappear in ButtonImageGadget :|

On XP SP3, need enable theme XP in compilation option

__________________________
Salut,

J'ai fait un exemple du problème

il faut :
- Exécuter le code
- Cliquer dans le treegadget (il est vide mais c'est pas grave)
- Presser la flèche bas sur le clavier

Et toutes les images des ButtonImageGadget ont disparu :|

Sous XP Sp3, avec Theme Xp activé dans les options de compilations

Code:
; Auteur : Le Soldat Inconnu
; Version de PB : 4.3
; Barre & Menu

;{- Paramètres
#Fenetre_L = 680
#Fenetre_H = 630
#Objet_Creer_Fenetre_L = 300
#Objet_Creer_Fenetre_H = 320
#Fenetre_B = 5
#Zone_Gerer_L = 160
#Zone_Editer_L = 230
#Zone_Apparence_L = 180

#Espace_V = 12
#Espace_H = 8
;}

Enumeration ; Gadgets et menus
   #Zone_Creer
   #Zone_Supprimer
   #Zone_Renommer
   
   #Zone_EditionApparence_Barre
   #Zone_EditionApparence_Menu
   
   #Onglet
   
   #Editer_Arbre
   #Editer_Element_Ajouter
   #Editer_Element_Supprimer
EndEnumeration

; Création d'une icone
Global Icone
Image = CreateImage(#PB_Any, 16, 16, 32)
StartDrawing(ImageOutput(Image))
   Box(0, 0, 10, 10, $FF00FF)
StopDrawing()
Icone = ImageID(Image)

; Création de la fenêtre et de la GadgetList
If OpenWindow(0, 0, 0, #Fenetre_L + 2 * #Fenetre_B, #Fenetre_H + 2 * #Fenetre_B, "Fenetre", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_Invisible) = 0
   End
EndIf

x = #Fenetre_B
y = #Fenetre_B

ButtonImageGadget(#Zone_Creer, x, y, #Zone_Gerer_L, 28, Icone)
y + GadgetHeight(#Zone_Creer)
ButtonImageGadget(#Zone_Renommer, x, y, #Zone_Gerer_L, 28, Icone)
y + GadgetHeight(#Zone_Renommer)
ButtonImageGadget(#Zone_Supprimer, x, y, #Zone_Gerer_L, 28, Icone)
y + GadgetHeight(#Zone_Supprimer) + #Espace_V

x = #Fenetre_B + #Zone_Gerer_L + #Espace_H
y = #Fenetre_B
PanelGadget(#Onglet, x, y, #Fenetre_L - x + #Fenetre_B, #Fenetre_H - y + #Fenetre_B)

   AddGadgetItem(#Onglet, 0, "Onglet", Icone)
   Largeur = GetGadgetAttribute(#Onglet, #PB_Panel_ItemWidth) - #Fenetre_B * 2
   Hauteur = GetGadgetAttribute(#Onglet, #PB_Panel_ItemHeight) - #Fenetre_B * 2
   x = #Fenetre_B
   y = #Fenetre_B
   
   TreeGadget(#Editer_Arbre, x, y, Largeur - #Zone_Editer_L - #Espace_H, Hauteur, #PB_Tree_AlwaysShowSelection)
   x + Largeur - #Zone_Editer_L
   ButtonImageGadget(#Editer_Element_Ajouter, x, y, #Zone_Editer_L / 2, 28, Icone)
   ButtonImageGadget(#Editer_Element_Supprimer, x + #Zone_Editer_L - #Zone_Editer_L / 2, y, #Zone_Editer_L / 2, 28, Icone)
   
   AddGadgetItem(#Onglet, 1, "onglet 2", Icone)

   
CloseGadgetList()

; On affichage la fenêtre principale
HideWindow(0, 0)

Repeat
   Event = WaitWindowEvent(10)
   
   Select EventWindow()
         ;{- Fenêtre principale
      Case 0
         Select Event
            Case #PB_Event_CloseWindow
               Quitter = 1
         EndSelect
         ;}
   EndSelect
   
   
Until Quitter

End

Author:  netmaestro [ Fri Oct 23, 2009 6:50 pm ]
Post subject:  Re: [pb4.40 b5] buttonImageGadget refresh problem

Confirmed here, same OS and version.

Author:  srod [ Fri Oct 23, 2009 7:19 pm ]
Post subject:  Re: [pb4.40 b5] buttonImageGadget refresh problem

No problem on Vista. No problem on XP sp2 with PB 4.4 beta 3.

Confirmed though on XP sp 2 with PB 4.4 beta 5.

Author:  Le Soldat Inconnu [ Fri Oct 30, 2009 1:44 pm ]
Post subject:  Re: [pb4.40 b5] buttonImageGadget refresh problem

it's do the same problem this PanelGadget, you select first panel tab with key "Tab", you press right key and images disappear

------------------
Pareil avec le panelgadget, tu le sélectionnes avec les touches Tab et tu changes d'onglet avec la flèche droite, les images disparaissent



___________________________________________________
Solution

I find solution, you catch event #WM_KeyDown to redraw window, like this

La solution est de détecter l'évènement #WM_KeyDown pour forcer la fenêtre a se redessiner, mais c'est pas terrible comme solution

Code:
; Auteur : Le Soldat Inconnu
; Version de PB : 4.3
; Barre & Menu

;{- Paramètres
#Fenetre_L = 680
#Fenetre_H = 630
#Objet_Creer_Fenetre_L = 300
#Objet_Creer_Fenetre_H = 320
#Fenetre_B = 5
#Zone_Gerer_L = 160
#Zone_Editer_L = 230
#Zone_Apparence_L = 180

#Espace_V = 12
#Espace_H = 8
;}

Enumeration ; Gadgets et menus
   #Zone_Creer
   #Zone_Supprimer
   #Zone_Renommer
   
   #Zone_EditionApparence_Barre
   #Zone_EditionApparence_Menu
   
   #Onglet
   
   #Editer_Arbre
   #Editer_Element_Ajouter
   #Editer_Element_Supprimer
EndEnumeration

; Création d'une icone
Global Icone
Image = CreateImage(#PB_Any, 16, 16, 32)
StartDrawing(ImageOutput(Image))
   Box(0, 0, 10, 10, $FF00FF)
StopDrawing()
Icone = ImageID(Image)

; Création de la fenêtre et de la GadgetList
If OpenWindow(0, 0, 0, #Fenetre_L + 2 * #Fenetre_B, #Fenetre_H + 2 * #Fenetre_B, "Fenetre", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_Invisible) = 0
   End
EndIf

x = #Fenetre_B
y = #Fenetre_B

ButtonImageGadget(#Zone_Creer, x, y, #Zone_Gerer_L, 28, Icone)
y + GadgetHeight(#Zone_Creer)
ButtonImageGadget(#Zone_Renommer, x, y, #Zone_Gerer_L, 28, Icone)
y + GadgetHeight(#Zone_Renommer)
ButtonImageGadget(#Zone_Supprimer, x, y, #Zone_Gerer_L, 28, Icone)
y + GadgetHeight(#Zone_Supprimer) + #Espace_V

x = #Fenetre_B + #Zone_Gerer_L + #Espace_H
y = #Fenetre_B
PanelGadget(#Onglet, x, y, #Fenetre_L - x + #Fenetre_B, #Fenetre_H - y + #Fenetre_B)
   
   AddGadgetItem(#Onglet, 0, "Onglet", Icone)
   Largeur = GetGadgetAttribute(#Onglet, #PB_Panel_ItemWidth) - #Fenetre_B * 2
   Hauteur = GetGadgetAttribute(#Onglet, #PB_Panel_ItemHeight) - #Fenetre_B * 2
   x = #Fenetre_B
   y = #Fenetre_B
   
   TreeGadget(#Editer_Arbre, x, y, Largeur - #Zone_Editer_L - #Espace_H, Hauteur, #PB_Tree_AlwaysShowSelection)
   x + Largeur - #Zone_Editer_L
   ButtonImageGadget(#Editer_Element_Ajouter, x, y, #Zone_Editer_L / 2, 28, Icone)
   ButtonImageGadget(#Editer_Element_Supprimer, x + #Zone_Editer_L - #Zone_Editer_L / 2, y, #Zone_Editer_L / 2, 28, Icone)
   
   AddGadgetItem(#Onglet, 1, "onglet 2", Icone)
   
   
CloseGadgetList()

; On affichage la fenêtre principale
HideWindow(0, 0)

Repeat
   Event = WaitWindowEvent(10)
   
   Select EventWindow()
         ;{- Fenêtre principale
      Case 0
         Select Event
            Case #PB_Event_CloseWindow
               Quitter = 1
            Case #WM_KEYDOWN
               RedrawWindow_(WindowID(0), 0, 0, #RDW_INTERNALPAINT)
         EndSelect
         ;}
   EndSelect
   
   
Until Quitter

End

Author:  thyphoon [ Sun Nov 01, 2009 3:21 pm ]
Post subject:  Re: [pb4.40 b5] buttonImageGadget refresh problem

same Problem !

ImageGadget() run fine but not ButtonImageGadget()

Author:  Le Soldat Inconnu [ Fri Nov 06, 2009 4:51 pm ]
Post subject:  Re: [pb4.40 b5, b6] buttonImageGadget refresh problem

pb4.40 b6 don't correct problem

Author:  horst [ Fri Jan 15, 2010 10:32 am ]
Post subject:  Re: [pb4.40 b5, b6, final] buttonImageGadget refresh problem

My programs also suffered under the mysteriously disappearing button imanges, and I finally found the cause. It is Windows' (infamous) "underlined letters for keyboard navigation" option:

XP: Display properties / Appearance / Effects..
last checkbox:
[ ] Hide underlined letters for keyboard navigation until I press the alt key

(This option is also responsible for the no-show of the dotted lines around focussed buttons and checkboxes.)

Under Vista/7 the option seems to be an accesibility feature.

Anyhow: PureBasic is doing something wrong here (since we cannot advise our software users to uncheck this option, and a refresh on #WM_KEYDOWN is only a work-around).

Maybe this helps to locate the bug.

Author:  horst [ Sat Jan 16, 2010 6:03 pm ]
Post subject:  Re: [pb4.40 b5, b6, final] buttonImageGadget refresh problem

I found out that the button images disappear when the #LVN_KEYDOWN and #TVN_KEYDOWN notifications are processed by PureBasic for the first time.

BTW: The #WM_KEYDOWN work-around does not help, when a menu is opened by keyboard (like ALT+letter or ALT+space). So I made another work-around based on catching these notifications in the WindowCallback procedure.

Author:  Fred [ Mon Jul 29, 2013 5:21 pm ]
Post subject:  Re: [pb4.40 b5, b6] buttonImageGadget refresh problem

The problems seems to be gone, can anyone confirm ?

Author:  horst [ Mon Jul 29, 2013 6:54 pm ]
Post subject:  Re: [pb4.40 b5, b6] buttonImageGadget refresh problem

I had removed the work-around after the problem seemed to have gone, but just a few days ago a user of my MemPad program (PB 5.11) reported the same issue again: When the window is restored from the system tray, the image button gadgets would disappear, but reappear when the mouse is moved over the buttons. XP/SP3.

I was unable to reproduce the quirk (XP, Win7), and asked the user for more details. No response yet.

Author:  horst [ Tue Aug 13, 2013 8:40 am ]
Post subject:  Re: [pb4.40 b5, b6] buttonImageGadget refresh problem

Fred wrote:
The problems seems to be gone, can anyone confirm ?

I have been able to reproduce the bug again: The ImageButtons only disappear when the window is restored after a #WM_HOTKEY event. Doing an UpdateWindow_() fixes the problem.

Author:  Fred [ Tue Aug 13, 2013 10:30 am ]
Post subject:  Re: [pb4.40 b5, b6] buttonImageGadget refresh problem

Do you have a small snippet showing the issue ?

Author:  horst [ Tue Aug 13, 2013 1:58 pm ]
Post subject:  Re: [pb4.40 b5, b6] buttonImageGadget refresh problem

Fred wrote:
Do you have a small snippet showing the issue ?

Sorry, I was not able to reproduce the issue with a simple window construct.

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