Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to lock taskbar in my program

How to lock taskbar in my program

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NianHawk
    wrote on last edited by
    #1

    As you know, we can lock taskbar manually, But I would like to lock taskbar by my own program. I try to do it by the following code: DWORD style = GetWindowLong(hShellTrayWnd,GWL_STYLE); style &= ~WS_SIZEBOX; SetWindowLong(hShellTrayWnd, GWL_STYLE, style); Unfortunately, it didn't work as I expected. Does anyone know how to do it? Your help would be greatly appreciated. Nothing impossible, Nothing sure

    N 1 Reply Last reply
    0
    • N NianHawk

      As you know, we can lock taskbar manually, But I would like to lock taskbar by my own program. I try to do it by the following code: DWORD style = GetWindowLong(hShellTrayWnd,GWL_STYLE); style &= ~WS_SIZEBOX; SetWindowLong(hShellTrayWnd, GWL_STYLE, style); Unfortunately, it didn't work as I expected. Does anyone know how to do it? Your help would be greatly appreciated. Nothing impossible, Nothing sure

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      I did do it sometime back but don't have the message number with me now. :doh: Maybe I can give it you tomorrow. This requires you to send a message to the taskbar asking it to lock itself. I did have the number but don't have it now. :)


      Nibu thomas A Developer Programming tips[^]  My site[^]

      N 1 Reply Last reply
      0
      • N Nibu babu thomas

        I did do it sometime back but don't have the message number with me now. :doh: Maybe I can give it you tomorrow. This requires you to send a message to the taskbar asking it to lock itself. I did have the number but don't have it now. :)


        Nibu thomas A Developer Programming tips[^]  My site[^]

        N Offline
        N Offline
        NianHawk
        wrote on last edited by
        #3

        Hi Tomas, Your help would be greatly appreciated, in fact I send WM+USER+336 to taskbar, but it didn't work, which make me feel that it can't be done by sending a message. And then I try another way below: CToolBar* trayWnd = (CToolBar*)FromHandle(hShellTrayWnd); DWORD barStyle = trayWnd->GetBarStyle(); barStyle |= CBRS_SIZE_FIXED; trayWnd->SetBarStyle(barStyle); It also didn't work, I was really frustrated, the style of taskbar vary every time even though I remove "trayWnd->SetBarStyle(barStyle)". For example, sometimes barStyle is 380, but sometimes it is 376, and other times, it is another value. it is very strange for me. Nothing impossible, Nothing sure

        N 1 Reply Last reply
        0
        • N NianHawk

          Hi Tomas, Your help would be greatly appreciated, in fact I send WM+USER+336 to taskbar, but it didn't work, which make me feel that it can't be done by sending a message. And then I try another way below: CToolBar* trayWnd = (CToolBar*)FromHandle(hShellTrayWnd); DWORD barStyle = trayWnd->GetBarStyle(); barStyle |= CBRS_SIZE_FIXED; trayWnd->SetBarStyle(barStyle); It also didn't work, I was really frustrated, the style of taskbar vary every time even though I remove "trayWnd->SetBarStyle(barStyle)". For example, sometimes barStyle is 380, but sometimes it is 376, and other times, it is another value. it is very strange for me. Nothing impossible, Nothing sure

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #4

          NianHawk wrote:

          Hi Tomas, Your help would be greatly appreciated, in fact I send WM+USER+336 to taskbar, but it didn't work, which make me feel that it can't be done by sending a message.

          Thanks. This works on both Windows XP, 2000...

          //custom message
          #define WM_USERDEF_LOCKTASKBAR 424

          static HWND hShellWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL);

          if(hShellWnd != NULL)
          ::PostMessage(hShellWnd, WM_COMMAND, MAKELONG(WM_USERDEF_LOCKTASKBAR, 0), NULL);
          else
          hShellWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL);

          This will work!:)


          Nibu thomas A Developer Programming tips[^]  My site[^]

          N 1 Reply Last reply
          0
          • N Nibu babu thomas

            NianHawk wrote:

            Hi Tomas, Your help would be greatly appreciated, in fact I send WM+USER+336 to taskbar, but it didn't work, which make me feel that it can't be done by sending a message.

            Thanks. This works on both Windows XP, 2000...

            //custom message
            #define WM_USERDEF_LOCKTASKBAR 424

            static HWND hShellWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL);

            if(hShellWnd != NULL)
            ::PostMessage(hShellWnd, WM_COMMAND, MAKELONG(WM_USERDEF_LOCKTASKBAR, 0), NULL);
            else
            hShellWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL);

            This will work!:)


            Nibu thomas A Developer Programming tips[^]  My site[^]

            N Offline
            N Offline
            NianHawk
            wrote on last edited by
            #5

            It did work well, thank a lot. I have another question if you wouldn't feel disturbed, Actually I use spy to monitor taskbar, if my program send such WM_COMMAND msg to taskbar, spy can capture it. But if I do it manually by using winxp functionality, spy didn't show this msg, that is why I always can't get this msg. Could you be so kind to teach me something about it? Nothing impossible, Nothing sure

            N 1 Reply Last reply
            0
            • N NianHawk

              It did work well, thank a lot. I have another question if you wouldn't feel disturbed, Actually I use spy to monitor taskbar, if my program send such WM_COMMAND msg to taskbar, spy can capture it. But if I do it manually by using winxp functionality, spy didn't show this msg, that is why I always can't get this msg. Could you be so kind to teach me something about it? Nothing impossible, Nothing sure

              N Offline
              N Offline
              Nibu babu thomas
              wrote on last edited by
              #6

              NianHawk wrote:

              It did work well, thank a lot.

              You are Welcome :)

              NianHawk wrote:

              I have another question if you wouldn't feel disturbed,

              Not at all.

              NianHawk wrote:

              Actually I use spy to monitor taskbar, if my program send such WM_COMMAND msg to taskbar, spy can capture it. But if I do it manually by using winxp functionality,

              Which functionality!:~

              NianHawk wrote:

              Could you be so kind to teach me something about it?

              Can you give me your email. I can send you a sample application, which demonstrates some useful messages related to the TaskBar. BTW here is a list if you are interested...

              /*DisplayStartupMenu*/ 305,
              /*DisplayRunDialog*/ 401,
              /*DisplayLogoffDialog*/ 402,
              /*ArrangeCascade*/ 403,
              /*ArrangeTileHrz*/ 404,
              /*ArrangeTileVrt*/ 405,
              /*ShowDesktop*/ 407,
              /*ShowDateTimeDialog*/ 408,
              /*ShowTaskbarPrps*/ 413,
              /*MinAll*/ 415,
              /*MaxAll*/ 416,
              /*ShowDesktop2*/ 419, /*Well you need to check this one. Make sure is this minimize all or show desktop.*/
              /*ShowTaskMngr */ 420,
              /*TaskBrCustomizeNtfy*/ 421,
              /*LockTaskbar*/ 424,
              /*HelpAndSuppCenter*/ 503,
              /*ControlPanel*/ 505,
              /*TurnOffCompDialog*/ 506,
              /*PrintersAndFaxesDialog*/ 510,
              /*FindFilesDialog*/ 41093,
              /*FindComputers*/ 41094


              Nibu thomas A Developer Programming tips[^]  My site[^]

              N 1 Reply Last reply
              0
              • N Nibu babu thomas

                NianHawk wrote:

                It did work well, thank a lot.

                You are Welcome :)

                NianHawk wrote:

                I have another question if you wouldn't feel disturbed,

                Not at all.

                NianHawk wrote:

                Actually I use spy to monitor taskbar, if my program send such WM_COMMAND msg to taskbar, spy can capture it. But if I do it manually by using winxp functionality,

                Which functionality!:~

                NianHawk wrote:

                Could you be so kind to teach me something about it?

                Can you give me your email. I can send you a sample application, which demonstrates some useful messages related to the TaskBar. BTW here is a list if you are interested...

                /*DisplayStartupMenu*/ 305,
                /*DisplayRunDialog*/ 401,
                /*DisplayLogoffDialog*/ 402,
                /*ArrangeCascade*/ 403,
                /*ArrangeTileHrz*/ 404,
                /*ArrangeTileVrt*/ 405,
                /*ShowDesktop*/ 407,
                /*ShowDateTimeDialog*/ 408,
                /*ShowTaskbarPrps*/ 413,
                /*MinAll*/ 415,
                /*MaxAll*/ 416,
                /*ShowDesktop2*/ 419, /*Well you need to check this one. Make sure is this minimize all or show desktop.*/
                /*ShowTaskMngr */ 420,
                /*TaskBrCustomizeNtfy*/ 421,
                /*LockTaskbar*/ 424,
                /*HelpAndSuppCenter*/ 503,
                /*ControlPanel*/ 505,
                /*TurnOffCompDialog*/ 506,
                /*PrintersAndFaxesDialog*/ 510,
                /*FindFilesDialog*/ 41093,
                /*FindComputers*/ 41094


                Nibu thomas A Developer Programming tips[^]  My site[^]

                N Offline
                N Offline
                NianHawk
                wrote on last edited by
                #7

                Thanks for your help. I mis-thought there had not benn reply yet because I didn't receive the response mail as usual, maybe last time I missed to check "Notify me by e-mail if someone answers this message". My email is : NianHawk@invalid.hotmail.com (please discard "invalid"). Which functionality! ===> I just lock the taskbar by taskbar menu. Best regards. Nothing impossible, Nothing sure

                N 1 Reply Last reply
                0
                • N NianHawk

                  Thanks for your help. I mis-thought there had not benn reply yet because I didn't receive the response mail as usual, maybe last time I missed to check "Notify me by e-mail if someone answers this message". My email is : NianHawk@invalid.hotmail.com (please discard "invalid"). Which functionality! ===> I just lock the taskbar by taskbar menu. Best regards. Nothing impossible, Nothing sure

                  N Offline
                  N Offline
                  Nibu babu thomas
                  wrote on last edited by
                  #8

                  NianHawk wrote:

                  Thanks for your help. I mis-thought there had not benn reply yet because I didn't receive the response mail as usual, maybe last time I missed to check "Notify me by e-mail if someone answers this message". My email is : NianHawk@invalid.hotmail.com (please discard "invalid").

                  Heh don't worry. I wrote an article on this subject. You can get the sample application from here[^]. Hope you will like it.


                  Nibu thomas A Developer Programming tips[^]  My site[^]

                  N 1 Reply Last reply
                  0
                  • N Nibu babu thomas

                    NianHawk wrote:

                    Thanks for your help. I mis-thought there had not benn reply yet because I didn't receive the response mail as usual, maybe last time I missed to check "Notify me by e-mail if someone answers this message". My email is : NianHawk@invalid.hotmail.com (please discard "invalid").

                    Heh don't worry. I wrote an article on this subject. You can get the sample application from here[^]. Hope you will like it.


                    Nibu thomas A Developer Programming tips[^]  My site[^]

                    N Offline
                    N Offline
                    NianHawk
                    wrote on last edited by
                    #9

                    Thanks a lot Nothing impossible, Nothing sure

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups