Conversion d'un code, petit soucis

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Conversion d'un code, petit soucis

Message par Ar-S »

Code : Tout sélectionner

 HWND hProgman = FindWindow(_T("Progman"), 0);
  HWND hDesktopWnd = GetDesktopWindow();
 
  // If the main Program Manager window is found
  if (hProgman)
  {
	// Get and load the main List view window containing the icons (found using Spy++).
    HWND hShellViewWin = FindWindowEx(hProgman, 0, _T("SHELLDLL_DefView"), 0);
    if (hShellViewWin)
      hDesktopListView = FindWindowEx(hShellViewWin, 0, _T("SysListView32"), 0);
	else
		// When this fails (happens in Windows-7 when picture rotation is turned ON), then look for the WorkerW windows list to get the
		// correct desktop list handle.
		// As there can be multiple WorkerW windows, so iterate through all to get the correct one
		do
		{
			hWorkerW = FindWindowEx( hDesktopWnd, hWorkerW, _T("WorkerW"), NULL );
			hShellViewWin = FindWindowEx(hWorkerW, 0, _T("SHELLDLL_DefView"), 0);
		} while (hShellViewWin == NULL && hWorkerW != NULL);
 
		// Get the ListView control
		hDesktopListView = FindWindowEx(hShellViewWin, 0, _T("SysListView32"), 0);
  }
 
  return hDesktopListView;
Voilà ce que j'ai fait :

Code : Tout sélectionner

Procedure GetHandle()
hDesktopWnd=GetDesktopWindow_();
  Debug "hDesktopWnd = " +  hDesktopWnd
  
  hProgman = FindWindow_("Progman",0)
  Debug "hProgram : " + hProgman
  
    hShellViewWin=FindWindowEx_(hProgman, 0, "SHELLDLL_DefView", 0)       ;
    Debug "hShellViewWin : " + hShellViewWin
    
    If hShellViewWin
      Debug "hShellViewWin OK"
    
    hDesktopListView= FindWindowEx_(hShellViewWin, 0, "SysListView32", 0)
    Debug "hDesktopListView SysListView32: " + hDesktopListView
    
  Else
    hWorkerW = FindWindowEx_( hDesktopWnd, hWorkerW, "WorkerW", #Null )
    Debug "hWorkerW" + hWorkerW
    hShellViewWin = FindWindowEx_(hWorkerW, 0, "SHELLDLL_DefView", 0)
    Debug "hShellViewWin : " + hShellViewWin
    
    While hShellViewWin = NULL And hWorkerW <> NULL;
   ; Get the ListView control
      hDesktopListView = FindWindowEx_(hShellViewWin, 0, "SysListView32", 0)
      Debug "hDesktopListView : " + hDesktopListView
    Wend
    
  EndIf
Procedurereturn hDesktopListView
J'ai évidement un soucis avec cette ligne.

Code : Tout sélectionner

while (hShellViewWin == NULL && hWorkerW != NULL);
que j'ai changé en
While hShellViewWin = NULL And hWorkerW <> NULL;
Je ne pige pas comment le while peut lister plusieurs éléments.

Si quelqu'un à la solution ce serait top.
Merci.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Avatar de l’utilisateur
case
Messages : 1546
Inscription : lun. 10/sept./2007 11:13

Re: Conversion d'un code, petit soucis

Message par case »

salut ta boucle tourne en boucle car au début
hShellViewWin = 0
hWorkerW <> 0

donc boucle sans fin tant que
hShellViewWin = 0
hWorkerW <> 0

ce qui juste en lançant ta procedure est le cas pour moi
tu cherches a faire quoi ?

le code se suffit-il a lui même ?
ImageImage
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Conversion d'un code, petit soucis

Message par Ar-S »

C'est pour essayer de parer au bug chelou de mon cacheur d'icone de bureau.
Pour renvoyer un ShowWindow_(id_galere_de_l_afficheur_d_icone_Bureau, #SW_HIDE et SHOW)

Avec GetDesktopWindow() seul ça ne marche pas
J'ai vu qu'on pouvait appeler SysListView32
Mais le bug perdurait, j'ai fait d'autres recherche et j'ai lu que si SysListView32 renvoyait 0 ce qui n'arrive pas tout le temps (...) il fallait chercher du coté de hWorkerW, "WorkerW"

Les Api ça reste assez obscure pour moi mais je pensais être sur la bonne voix.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Re: Conversion d'un code, petit soucis

Message par Anonyme2 »

J'ai des cours en C qu'un copain m'a copié, le do while exécute au moins une fois le bloc d'instructions donc correspond au repeat until
c'est différent de While (expr) instr; qui évalue d'abord l'expression ce qui correspondrait à notre while wend.

Code : Tout sélectionner

Define .i
Procedure.i GetHandle()
      hProgman = FindWindow_("Progman",0)
      Debug "hProgram : " + hProgman
      
      hDesktopWnd=GetDesktopWindow_();
      Debug "hDesktopWnd = " +  hDesktopWnd
      
      ;   // If the main Program Manager window is found
      If hProgman
            hShellViewWin = FindWindowEx_(hProgman, 0, "SHELLDLL_DefView", 0)       ;
            Debug "hShellViewWin : " + hShellViewWin
            
            If hShellViewWin
                  Debug "hShellViewWin OK"
                  
                  hDesktopListView = FindWindowEx_(hShellViewWin, 0, "SysListView32", 0)
                  Debug "hDesktopListView SysListView32: " + hDesktopListView
                  
            Else
                  Repeat 
                        hWorkerW = FindWindowEx_( hDesktopWnd, hWorkerW, "WorkerW", #Null )
                        Debug "hWorkerW" + hWorkerW
                        
                        ; Get the ListView control
                        hDesktopListView = FindWindowEx_(hShellViewWin, 0, "SysListView32", 0)
                        Debug "hDesktopListView : " + hDesktopListView
                  Until (hShellViewWin = #Null And hWorkerW)
                     ;// Get the ListView control
                  hDesktopListView = FindWindowEx(hShellViewWin, 0, _T("SysListView32"), 0);
               
            EndIf
      EndIf
      ProcedureReturn hDesktopListView
EndProcedure
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Conversion d'un code, petit soucis

Message par Ar-S »

merci Denis,
la derniere ligne s'adapte ainsi
hDesktopListView = FindWindowEx_(hShellViewWin, 0, "SysListView32", 0);

sur le portable c'est ok, mais je vais voir sur la tour ^^
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Répondre