Page 1 sur 1

Conversion d'un code, petit soucis

Publié : mer. 13/janv./2016 21:00
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.

Re: Conversion d'un code, petit soucis

Publié : mer. 13/janv./2016 23:08
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 ?

Re: Conversion d'un code, petit soucis

Publié : jeu. 14/janv./2016 1:52
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.

Re: Conversion d'un code, petit soucis

Publié : jeu. 14/janv./2016 11:34
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

Re: Conversion d'un code, petit soucis

Publié : jeu. 14/janv./2016 13:19
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 ^^