Page 1 of 4 123 ... LastLast
Results 1 to 15 of 56
  1. #1
    IcySeal's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    300
    Reputation
    34
    Thanks
    148
    My Mood
    Amused

    [Release] Decent Mouse Dragging Menu Code

    I actually used this code in my menu base a while back and for those of you who are tired of using the arrow keys to move your menu, here's a fresh change of pace.


    I wrote this code for the release whit made of Gellin's and Hans' bases. It can be adapted to other bases but you should do that yourself.



    We start with some global variables, declared in the global scope.
    Code:
    POINT pos, dragOffset;
    bool dragging=false;
    int width, height;
    We got 2 POINT structures, pos for taking in the mouse cordinates, and dragOffset for holding.
    Then we have a bool dragging that just is used to tell weather or not we're dragging the menu.
    Finally, we have the width and height variables. These AREN'T DEFINED and should be setup and changed according to your hack's needs.

    Then we use this handy function, courtesy of crash or whoever he got it from. This is just used to determine if the mouse is within a rectangle formed by a pair of points.
    Code:
    bool isMouseinRegion(int x1, int y1, int x2, int y2)
    {
    	POINT cPos;
    	GetCursorPos(&cPos);
    	if(cPos.x > x1 && cPos.x < x2 && cPos.y > y1 && cPos.y < y2){
    		return true;
    	} else {
    		return false;
    	}
    }
    Finally we got the meat of the code which should be put in your main thread or in your hooked function or w/e. I put in a bunch of comments and most of this should be understandable.

    Code:
    if(GetAsyncKeyState(VK_LBUTTON)<0){
    	GetCursorPos(&pos);
    	//ScreenToClient(GetForegroundWindow(),&pos);
    	//You can choose to include this or not.
    	if (!dragging){//if not currently dragging a window then see if our click is
    		if (isMouseinRegion(menux,menuy,menux+width,menuy+height)){
    			//^^ if inside the bounds of the window
    			//then setup the winodw so that it will drag
    			dragOffset.x = pos.x-menux;
    			dragOffset.y = pos.y-menuy;
    			dragging = true;
    		}
    	}else{//if we are dragging a window then
    		menux = pos.x - dragOffset.x;
    		menuy = pos.y - dragOffset.y;
    	}
    }else{
    	dragging = false;
    }
    Anyways there you have it, now you can make your menu's a little better.



    This is not noob-proof and if you follow my directions it shouldn't be hard to implement.
    Last edited by IcySeal; 09-15-2010 at 06:43 PM.

  2. The Following 12 Users Say Thank You to IcySeal For This Useful Post:

    fvestrgenrl (09-17-2010),GodHack2 (09-15-2010),hilolo (09-24-2010),markoj (09-15-2010),NOOB (04-22-2011),Nubzgetkillz (11-27-2010),S0aD (03-07-2011),Solify (09-17-2010),tahha (09-24-2010),Turbulence (03-22-2011),whit (09-15-2010),why06 (09-15-2010)

  3. #2
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,159
    Reputation
    490
    Thanks
    2,253
    Nice Release Seal.!!!!!!!!!!!!!

  4. #3
    GodHack2's Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    644
    Reputation
    38
    Thanks
    762
    My Mood
    Amused
    I <3 u !!! (No HOMO !!)





    beat this bitches ^^^^^^^

    Current Stats : Bored :/


    Respect list :
    Crash !
    Gordon'
    Markoj

  5. #4
    whatup777's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    CA Source Code Section
    Posts
    4,025
    Reputation
    147
    Thanks
    351
    My Mood
    Dead
    Totally Needed.

    *Sarcasm* /
    Quotes I live by.


    A foolish person learns from his mistakes, I wise person learns from others.
    Quote Originally Posted by AVGN View Post



    mhm

    i live in texas

    i was at the grocery store with my son. He saw a mexican guy, and he said "Look daddy! a mower man!"

    he's 4 yrs old

  6. #5
    Kanye's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Niggerville
    Posts
    3,293
    Reputation
    136
    Thanks
    217
    My Mood
    Breezy
    excellent.

  7. #6
    IcySeal's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    300
    Reputation
    34
    Thanks
    148
    My Mood
    Amused
    Here's another adapted for code demon's d3d base.

    Same as before, but took out width and height.
    Code:
    POINT pos, dragOffset;
    bool dragging=false;

    Crash's function blah blah blah.
    Code:
    bool isMouseinRegion(int x1, int y1, int x2, int y2)
    {
    	POINT cPos;
    	GetCursorPos(&cPos);
    	if(cPos.x > x1 && cPos.x < x2 && cPos.y > y1 && cPos.y < y2){
    		return true;
    	} else {
    		return false;
    	}
    }

    Code:
    if(GetAsyncKeyState(VK_LBUTTON)<0){
    	GetCursorPos(&pos);
    	//ScreenToClient(GetForegroundWindow(),&pos);
    	//You can choose to include this or not.
    	if (!dragging){//if not currently dragging a window then see if our click is
    		if (isMouseinRegion(dMenu.x,dMenu.y,dMenu.x+dMenu.w,dMenu.y+dMenu.h)){
    			//^^ if inside the bounds of the window
    			//then setup the winodw so that it will drag
    			dragOffset.x = pos.x-dMenu.x;
    			dragOffset.y = pos.y-dMenu.y;
    			dragging = true;
    		}
    	}else{//if we are dragging a window then
    		dMenu.x = pos.x - dragOffset.x;
    		dMenu.y = pos.y - dragOffset.y;
    	}
    }else{
    	dragging = false;
    }

  8. #7
    NOOBJr's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in NOOB
    Posts
    1,423
    Reputation
    112
    Thanks
    693
    Nice job icy!I had something like this already though

  9. #8
    LightzOut's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    185
    Reputation
    11
    Thanks
    25
    Nice release. /

  10. #9
    IcySeal's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    300
    Reputation
    34
    Thanks
    148
    My Mood
    Amused
    Quote Originally Posted by Zane Slayman View Post
    Nice job icy!I had something like this already though
    That's okay because some newbs might not have this so it's helpful to those who need it.

  11. #10
    CodeDemon's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    vagina
    Posts
    1,070
    Reputation
    50
    Thanks
    940
    My Mood
    Fine
    / nice work Seal, I used your mouse in region function in the PTC tester xD

  12. #11
    cosconub's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in the programming section MPGH Cash: $90,000,000,000
    Posts
    372
    Reputation
    -4
    Thanks
    39
    My Mood
    Psychedelic
    Seal the way i use is ALOT FASTER

    should i post it?

  13. #12
    Kanye's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Niggerville
    Posts
    3,293
    Reputation
    136
    Thanks
    217
    My Mood
    Breezy
    Quote Originally Posted by cosconub View Post
    Seal the way i use is ALOT FASTER
    Proof or GTFO

  14. #13
    whatup777's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    CA Source Code Section
    Posts
    4,025
    Reputation
    147
    Thanks
    351
    My Mood
    Dead
    Code:
    bool IsMouseOver( int x, int y, int w, int h )
    {
    	bool lolitsover;
    	POINT cur;
    	GetCursorPos(&cur);
    	if( cur.x >= x && cur.x <= x + w && cur.y >= y && cur.y <= y + h){
    		lolitsover = true;
    	} else {
    		lolitsover = false;
    	}
    	return lolitsover;
    }
    Mine. It might be bad since I just whipped it up.
    Last edited by whatup777; 09-15-2010 at 07:03 PM.
    Quotes I live by.


    A foolish person learns from his mistakes, I wise person learns from others.
    Quote Originally Posted by AVGN View Post



    mhm

    i live in texas

    i was at the grocery store with my son. He saw a mexican guy, and he said "Look daddy! a mower man!"

    he's 4 yrs old

  15. #14
    cosconub's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in the programming section MPGH Cash: $90,000,000,000
    Posts
    372
    Reputation
    -4
    Thanks
    39
    My Mood
    Psychedelic
    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

  16. #15
    CodeDemon's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    vagina
    Posts
    1,070
    Reputation
    50
    Thanks
    940
    My Mood
    Fine
    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
    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

Page 1 of 4 123 ... LastLast

Similar Threads

  1. [Release] Mouse Recorder With Code
    By DiMocK in forum Visual Basic Programming
    Replies: 14
    Last Post: 06-29-2010, 01:02 PM
  2. [Release]xTMx's MPGH Spammer Code
    By xTMx in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 5
    Last Post: 12-22-2009, 04:20 AM
  3. [RELEASE]simple mouse things
    By maarten551 in forum Visual Basic Programming
    Replies: 0
    Last Post: 10-10-2009, 09:09 AM
  4. [RELEASE] Decent Chams/Wallhack/X-Hair
    By Ryan in forum Combat Arms Hacks & Cheats
    Replies: 76
    Last Post: 09-29-2009, 06:55 AM
  5. Open Source Release. Semi-Useless Timer Source Code!
    By User1 in forum Visual Basic Programming
    Replies: 6
    Last Post: 09-20-2009, 02:55 AM