[Release] Decent Mouse Dragging Menu Code

Posts 16–30 of 56 · Page 2 of 4
Quote Originally Posted by CodeDemon View Post
The problem with that is, it wont check that the cursor is inside the box, it will move it no matter where the cursor is.

Guess what happens when you shoot, holding down the left mouse button? Menu goes all over the place /yea
Yep you correct.
hit pageup open hack move mouse. the one i use in my hack doesn't even make you click,
Quote Originally Posted by cosconub View Post
Code:
int MoveMenu;

if(MoveMenu1 > 0){

if( MoveMenu ) {
   POINT myCursor; 
   GetCursorPos(&myCursor); // get the cursor position.
   if(GetAsyncKeyState(VK_LBUTTON)) {
      menu.x = myCursor.x; // set the x of your menu to the cursor x position.
      menu.y = myCursor.y; // set the y of your menu to the cursor y position.
   }
}
}

i think thats right had to change stuff
Credits to Zanza

Yours is different from mine, it snaps to the cursor, mine gets an offset then moves accordingly. Also my code was adapted from my own base, and it could be better if I had worked harder on it, but I was downsizing from something much more complex.

Essentially here is what it was before.
Code:
if(GetAsyncKeyState(VK_LBUTTON)<0){
            GetCursorPos(&pos);
            //ScreenToClient(GetForegroundWindow(),&pos);
            if (!dragging){//if not currently dragging a window then see if our click is
                for(int i = 0; i < winStore.windowCount; i++){
                    if (((*(winStore.windowList + i))->visible) && (pos.x > (*(winStore.windowList + i))->position.x) && (pos.x < (*(winStore.windowList + i))->position.x + (*(winStore.windowList + i))->dims.cx) &&    (pos.y > (*(winStore.windowList + i))->position.y) && (pos.y < (*(winStore.windowList + i))->position.y + (*(winStore.windowList + i))->dims.cy)){
                        //^^ if inside the bounds of the window
                        //then setup the winodw so that it will drag
                        winStore.selectedWin =  *(winStore.windowList + i);
                        winStore.selected = i;
                        winStore.selectedWin->drag = true;
                        winStore.selectedWin->dragOff.x = pos.x-winStore.selectedWin->position.x;
                        winStore.selectedWin->dragOff.y = pos.y-winStore.selectedWin->position.y;
                        dragging = true;
                    }else{
                        //set all others to not be dragging
                        (*(winStore.windowList + i))->drag=false;
                    }
                }
            }else{//if we are dragging a window then
                winStore.selectedWin->position.x = pos.x - winStore.selectedWin->dragOff.x;
                winStore.selectedWin->position.y = pos.y - winStore.selectedWin->dragOff.y;
            }
        }else{
            dragging = false;
            for(int i = 0; i < winStore.windowCount; i++){
                (*(winStore.windowList + i))->drag = false;
            }
        }
Quote Originally Posted by IcySeal View Post



Yours is different from mine, it snaps to the cursor, mine gets an offset then moves accordingly. Also my code was adapted from my own base, and it could be better if I had worked harder on it, but I was downsizing from something much more complex.

Essentially here is what it was before.
Code:
if(GetAsyncKeyState(VK_LBUTTON)<0){
            GetCursorPos(&pos);
            //ScreenToClient(GetForegroundWindow(),&pos);
            if (!dragging){//if not currently dragging a window then see if our click is
                for(int i = 0; i < winStore.windowCount; i++){
                    if (((*(winStore.windowList + i))->visible) && (pos.x > (*(winStore.windowList + i))->position.x) && (pos.x < (*(winStore.windowList + i))->position.x + (*(winStore.windowList + i))->dims.cx) &&    (pos.y > (*(winStore.windowList + i))->position.y) && (pos.y < (*(winStore.windowList + i))->position.y + (*(winStore.windowList + i))->dims.cy)){
                        //^^ if inside the bounds of the window
                        //then setup the winodw so that it will drag
                        winStore.selectedWin =  *(winStore.windowList + i);
                        winStore.selected = i;
                        winStore.selectedWin->drag = true;
                        winStore.selectedWin->dragOff.x = pos.x-winStore.selectedWin->position.x;
                        winStore.selectedWin->dragOff.y = pos.y-winStore.selectedWin->position.y;
                        dragging = true;
                    }else{
                        //set all others to not be dragging
                        (*(winStore.windowList + i))->drag=false;
                    }
                }
            }else{//if we are dragging a window then
                winStore.selectedWin->position.x = pos.x - winStore.selectedWin->dragOff.x;
                winStore.selectedWin->position.y = pos.y - winStore.selectedWin->dragOff.y;
            }
        }else{
            dragging = false;
            for(int i = 0; i < winStore.windowCount; i++){
                (*(winStore.windowList + i))->drag = false;
            }
        }
I see what you did there. Downsizing was good idea. /
Quote Originally Posted by whatup777 View Post
I see what you did there. Downsizing was good idea. /
My original though you see had to take into account the fact that there was the possiblility of multiple windows that are being made, and that I also had wanted it to select a window when you dragged it as well as not pick up any other windows along the way.
Quote Originally Posted by IcySeal View Post


My original though you see had to take into account the fact that there was the possiblility of multiple windows that are being made, and that I also had wanted it to select a window when you dragged it as well as not pick up any other windows along the way.
And thats why tabs are good.
Quote Originally Posted by whatup777 View Post
And thats why tabs are good.
Which is why I added them aswell./yea
Quote Originally Posted by whatup777 View Post
And thats why tabs are good.
This code would allow you to add tabs quite easily, by positioning a window over another window. Since all the data for the windows are stored in objects they can be manipulated quite easily. Personally I would just keep one window for a regular menu, and add tabs, but this code would allow you to do a lot more which might be good if ur working on something like a d3d hack tool where u want more then one window.

I'm interested in looking through your base. Could you show me where to download it?
Quote Originally Posted by why06 View Post
This code would allow you to add tabs quite easily, by positioning a window over another window. Since all the data for the windows are stored in objects they can be manipulated quite easily. Personally I would just keep one window for a regular menu, and add tabs, but this code would allow you to do a lot more which might be good if ur working on something like a d3d hack tool where u want more then one window.

I'm interested in looking through your base. Could you show me where to download it?
perhaps the link in her sig?
Quote Originally Posted by why06 View Post
This code would allow you to add tabs quite easily, by positioning a window over another window. Since all the data for the windows are stored in objects they can be manipulated quite easily. Personally I would just keep one window for a regular menu, and add tabs, but this code would allow you to do a lot more which might be good if ur working on something like a d3d hack tool where u want more then one window.

I'm interested in looking through your base. Could you show me where to download it?
You understand the concept so thuroughly

The link is in my signature.


Quote Originally Posted by Kanye View Post
perhaps the link in her sig?
Sure let's go with that.
Quote Originally Posted by IcySeal View Post


You understand the concept so thuroughly

The link is in my signature.
Someones a happy camper. /
Damn Is C++ your first language? Dutch is mine.
Quote Originally Posted by cosconub View Post
Damn Is C++ your first language? Dutch is mine.
Assuming your talking to me, no C was. Though truly if you think that's alot, download my menu base and look through the classes i wrote.
good stuff rigght here,
Posts 16–30 of 56 · Page 2 of 4
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?