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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to shake the window...

how to shake the window...

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
13 Posts 7 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.
  • M maharaja pandian

    hi, As i want to shake the window (like "BUZZ" in yahoo messenger ) .when i click a button on that window. reply early send reply

    K Offline
    K Offline
    khan
    wrote on last edited by
    #2

    #define Move(x, y) SetWindowPos(NULL,x,y,0,0,SWP_NOZORDER | SWP_NOSIZE);

    void CAsdfDlg::OnOK()
    {
    int x = 0;
    int y = 0;
    int i;
    for (i = 0; i < 20; i++)
    {
    Move(x,y);
    x += 20;
    y += 20;
    Sleep(100);
    Move(x,y);
    x -= 20;
    y -= 20;
    Sleep(100);
    }
    }

    Something like that. :) this is this.

    1 Reply Last reply
    0
    • M maharaja pandian

      hi, As i want to shake the window (like "BUZZ" in yahoo messenger ) .when i click a button on that window. reply early send reply

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

      Use MoveWindow. Set a shake boundary. So that it won't go beyond that. This must be fast too.


      Nibu thomas Software Developer

      1 Reply Last reply
      0
      • M maharaja pandian

        hi, As i want to shake the window (like "BUZZ" in yahoo messenger ) .when i click a button on that window. reply early send reply

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #4

        something like :

        /// keep original position

        for ( int i = 0; i < 10; i++ )
        {
        // this is your window.
        this->MoveWindow( posX+/- random value, posY +/- random value );
        }

        /// restore original position


        Maximilien Lincourt Your Head A Splode - Strong Bad

        1 Reply Last reply
        0
        • M maharaja pandian

          hi, As i want to shake the window (like "BUZZ" in yahoo messenger ) .when i click a button on that window. reply early send reply

          M Offline
          M Offline
          Monty2
          wrote on last edited by
          #5

          Don't use sleep and loops (the window will not get a chance to draw itself) use WM_TIMER instead


          C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg

          1 Reply Last reply
          0
          • M maharaja pandian

            hi, As i want to shake the window (like "BUZZ" in yahoo messenger ) .when i click a button on that window. reply early send reply

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #6

            RECT Rect; GetWindowRect(&Rect); for(int i=0;i<30;i++) { Sleep(20); MoveWindow(Rect.left,Rect.top,Rect.right,Rect.bottom,1); Rect.left+=10; Rect.top+=10; Rect.right-=20,Rect.bottom-=20; }

            M 1 Reply Last reply
            0
            • H Hamid Taebi

              RECT Rect; GetWindowRect(&Rect); for(int i=0;i<30;i++) { Sleep(20); MoveWindow(Rect.left,Rect.top,Rect.right,Rect.bottom,1); Rect.left+=10; Rect.top+=10; Rect.right-=20,Rect.bottom-=20; }

              M Offline
              M Offline
              maharaja pandian
              wrote on last edited by
              #7

              hi WHITESKY, As i use ur code in the event LButtonDown . but the application will hang for some time ,upto the execution of for loop the window not get moved(shake) reply early send reply

              M K H 3 Replies Last reply
              0
              • M maharaja pandian

                hi WHITESKY, As i use ur code in the event LButtonDown . but the application will hang for some time ,upto the execution of for loop the window not get moved(shake) reply early send reply

                M Offline
                M Offline
                Monty2
                wrote on last edited by
                #8

                As i told you earlier loop techniques will not work in this case, you will have to set a timer using SetTimer then handle WM_TIMER event and in the WM_TIMER event you will have to move the window.


                C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg

                M E 2 Replies Last reply
                0
                • M maharaja pandian

                  hi WHITESKY, As i use ur code in the event LButtonDown . but the application will hang for some time ,upto the execution of for loop the window not get moved(shake) reply early send reply

                  K Offline
                  K Offline
                  khan
                  wrote on last edited by
                  #9

                  Looking at your post, it seems like you are trying to use it in some Doc/View architecture. The code given above all works, but in a dialog. For a Doc/View architecture, you can use my code above, with this modification: #define Move(x, y) GetParent()->SetWindowPos(NULL,x,y,0,0,SWP_NOZORDER | SWP_NOSIZE); Notice the GetParent() function. this is this.

                  M 1 Reply Last reply
                  0
                  • K khan

                    Looking at your post, it seems like you are trying to use it in some Doc/View architecture. The code given above all works, but in a dialog. For a Doc/View architecture, you can use my code above, with this modification: #define Move(x, y) GetParent()->SetWindowPos(NULL,x,y,0,0,SWP_NOZORDER | SWP_NOSIZE); Notice the GetParent() function. this is this.

                    M Offline
                    M Offline
                    maharaja pandian
                    wrote on last edited by
                    #10

                    thanks khan ,i got it send reply

                    1 Reply Last reply
                    0
                    • M Monty2

                      As i told you earlier loop techniques will not work in this case, you will have to set a timer using SetTimer then handle WM_TIMER event and in the WM_TIMER event you will have to move the window.


                      C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg

                      M Offline
                      M Offline
                      maharaja pandian
                      wrote on last edited by
                      #11

                      thanks monty, send reply

                      1 Reply Last reply
                      0
                      • M Monty2

                        As i told you earlier loop techniques will not work in this case, you will have to set a timer using SetTimer then handle WM_TIMER event and in the WM_TIMER event you will have to move the window.


                        C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg

                        E Offline
                        E Offline
                        Eytukan
                        wrote on last edited by
                        #12

                        hey monty! why do you wanna use a timer here? i dont understand, i think the khan++ way'd work fine, wont it?:~


                        VuNic

                        1 Reply Last reply
                        0
                        • M maharaja pandian

                          hi WHITESKY, As i use ur code in the event LButtonDown . but the application will hang for some time ,upto the execution of for loop the window not get moved(shake) reply early send reply

                          H Offline
                          H Offline
                          Hamid Taebi
                          wrote on last edited by
                          #13

                          why hang your system? I worked with this code and it's not problem

                          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