begin process at 2008 08 29 05:07:03
1 233 502 membres
43 nouveaux aujourd'hui
14 291 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

MASQUER, AFFICHER LA BARRE DE MENU


Information sur la source

Catégorie :PPC :: Trucs & Astuces Source .NET ( DotNet ) Classé sous : coredll, taskbar, findwindow, hhtaskbar, setwindowpos Niveau : Débutant Date de création : 22/08/2006 Date de mise à jour : 22/08/2006 13:07:17 Vu : 14 077

Note :
10 / 10 - par 1 personne
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note

Description

Voici 2 methodes pour Masquer ou Afficher la barre de menu.
Pourquoi cette source? Tout simplement car cela fait un moment que je cherche à masquer ma barre de menu, et que j'ai mis un peu de temps avant de trouvé la solution.
Je met 2 methodes selon les gouts de chacun mais aussi selon les pda (j'en est 2 qui ne réagissent pas exectement pareil).

En esperant que cela vous seras utile.

Source

  • Première Methode
  • ---------------------------------------------------------------------------------------------------
  • public static class pdaTaskBar
  • {
  • [DllImport("Coredll.dll", EntryPoint = "FindWindow")]
  • private static extern System.IntPtr FindWindow(string lpClassName, string lpWindowName);
  • [DllImport("Coredll.dll", EntryPoint = "SetWindowPos", SetLastError = true)]
  • private static extern bool SetWindowPos(System.IntPtr IntPtr, System.IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
  • const int TASKBAR_SHOW = 0x40;
  • const int TASKBAR_HIDE = 0x64;
  • public static void HideTaskbar()
  • {
  • IntPtr taskBarHandle;
  • taskBarHandle = FindWindow("HHTaskBar", "");
  • SetWindowPos(taskBarHandle, IntPtr.Zero, 0, 0, 0, 0, TASKBAR_HIDE);
  • }
  • public static void ShowTaskbar()
  • {
  • IntPtr taskBarHandle;
  • IntPtr HWND_TOPMOST = new IntPtr(-1);
  • taskBarHandle = FindWindow("HHTaskBar", "");
  • SetWindowPos(taskBarHandle, HWND_TOPMOST, 0, 295, 240, 25, TASKBAR_SHOW);
  • //Pourrait eventuellement fonctionner
  • //IntPtr taskBarHandle;
  • //taskBarHandle = FindWindow("shell_traywnd", "");
  • //SetWindowPos(taskBarHandle, IntPtr.Zero, 0, 0, 0, 0, TASKBAR_SHOW);
  • }
  • }
  • ---------------------------------------------------------------------------------------------------
  • Seconde Methode
  • public static class pdaTaskVisibility
  • {
  • private const int SW_HIDE = 0x00;
  • private const int SW_SHOW = 0x0001;
  • [DllImport("coredll.dll", CharSet = CharSet.Auto)]
  • private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
  • [DllImport("coredll.dll", CharSet = CharSet.Auto)]
  • private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
  • [DllImport("coredll.dll", CharSet = CharSet.Auto)]
  • private static extern bool EnableWindow(IntPtr hwnd, bool enabled);
  • public static void ShowTaskbar()
  • {
  • IntPtr h = FindWindow("HHTaskBar", "");
  • ShowWindow(h, SW_SHOW);
  • EnableWindow(h, true);
  • }
  • public static void HideTaskbar()
  • {
  • IntPtr h = FindWindow("HHTaskBar", "");
  • ShowWindow(h, SW_HIDE);
  • EnableWindow(h, false);
  • }
  • }
  • ---------------------------------------------------------------------------------------------------
Première Methode
---------------------------------------------------------------------------------------------------
    public static class pdaTaskBar
    {
        [DllImport("Coredll.dll", EntryPoint = "FindWindow")]
        private static extern System.IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("Coredll.dll", EntryPoint = "SetWindowPos", SetLastError = true)]
        private static extern bool SetWindowPos(System.IntPtr IntPtr, System.IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);

        const int TASKBAR_SHOW = 0x40;
        const int TASKBAR_HIDE = 0x64;

        public static void HideTaskbar()
        {
            IntPtr taskBarHandle;
            taskBarHandle = FindWindow("HHTaskBar", "");
            SetWindowPos(taskBarHandle, IntPtr.Zero, 0, 0, 0, 0, TASKBAR_HIDE);
        }
        public static void ShowTaskbar()
        {
            IntPtr taskBarHandle;
            IntPtr HWND_TOPMOST = new IntPtr(-1);

            taskBarHandle = FindWindow("HHTaskBar", "");
            SetWindowPos(taskBarHandle, HWND_TOPMOST, 0, 295, 240, 25, TASKBAR_SHOW);

            //Pourrait eventuellement fonctionner
            //IntPtr taskBarHandle;
            //taskBarHandle = FindWindow("shell_traywnd", "");
            //SetWindowPos(taskBarHandle, IntPtr.Zero, 0, 0, 0, 0, TASKBAR_SHOW);
        }
    }
---------------------------------------------------------------------------------------------------
Seconde Methode

    public static class pdaTaskVisibility
    {
       
        private const int SW_HIDE = 0x00;

        private const int SW_SHOW = 0x0001;

        [DllImport("coredll.dll", CharSet = CharSet.Auto)]

        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("coredll.dll", CharSet = CharSet.Auto)]

        private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);

        [DllImport("coredll.dll", CharSet = CharSet.Auto)]

        private static extern bool EnableWindow(IntPtr hwnd, bool enabled);

        public static void ShowTaskbar()
        {

            IntPtr h = FindWindow("HHTaskBar", "");

            ShowWindow(h, SW_SHOW);

            EnableWindow(h, true);

        }
        public static void HideTaskbar()
        {

            IntPtr h = FindWindow("HHTaskBar", "");

            ShowWindow(h, SW_HIDE);

            EnableWindow(h, false);

        }
    }
---------------------------------------------------------------------------------------------------

Conclusion

Pour la seconde methode il y a un petit effet graphique qui donne l'impression que la barre de menu arrive du fond de l'écran.
Second point.
Si l'on cache la barre avec la methode 2 on peut la reafficher avec la methode 1 mais l'inverse n'est pas vrai.
22 août 2006 13:07:17 :
corrections syntaxique
  • signaler à un administrateur
    Commentaire de mickbad le 29/08/2006 17:21:38

    bien bien bien !

    Oui c'est bien de l'avoir mis ici (bravo, réellement) mais un jour si tu bloques longtemps sur ce genre de pbm va sur le site msdn.microsoft.com pour regarder un peu les API win32 (par exemple) car c'est typiquement le cas. Naturellement, ce site te donnera plutôt le code en C++ mais parfois en VB. Ceci dit peut importe le langage, c'est toujours la même chose du moment que tu sais comment faire appel aux api.

    Ton code est finalement connu sur les windows 9x/NT/gnagna car il permet aussi de virer la barre de menu !

    Ceci dit, il fallait connaitre le nom de la fenêtre gérant la barre des tâches sur les pockets ;))

    merci et continue dans le monde des APIs, c'est vraiment rigolo par moment :)
    .Mick.

Ajouter un commentaire

Discussions en rapport avec ce code source

user32 par Baguauda

Pub



Appels d'offres

Recherche developpeur ...
Budget : 700€
SITE MARCHAND LOCATION...
Budget : 3 000€
SITE MARCHAND POUR HOTEL
Budget : 4 000€

CalendriCode

Août 2008
LMMJVSD
    123
45678910
11121314151617
18192021222324
25262728293031

VS Express FR Gratuit !

VS Express en français et 100% gratuit !

Téléchargements

Logiciels à télécharger sur le même thème :

Boutique

Boutique de goodies CodeS-SourceS