Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++ help] Making a window draggable by defined area

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Feb 06, 2009 5:24 pm    Post subject: [C++ help] Making a window draggable by defined area Reply with quote

So I'm working on a project in C++, and I want to make a custom window. So you know how default windows can only be drag+dropped by that toolbar at the top, right? Well, I want to make it so that I can define a space that users can use to drag+drop. Tried Google, found nothing. Help? Smile
Back to top
View user's profile Send private message Visit poster's website
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Fri Feb 06, 2009 5:32 pm    Post subject: Reply with quote

You could check if the left button is pressed when a WM_MOUSEMOVE message arrives and move the window, or something similar.

As for a defined space, just check the x,y coordinates? you could use PtInRect API to make things simpler.
Back to top
View user's profile Send private message MSN Messenger
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Feb 06, 2009 5:41 pm    Post subject: Reply with quote

The way i would do it...

Make a global boolean.
Check if mouse is clicked, if it is set boolean to true.
Check if mouse is unclicked, if it is set boolean to false.

On WM_MOUSEMOVE check if the boolean is true, and that the position of the click is within certain coordinates of your form.. if both of these are true..then call SetWindowPos with the output from GetCursorPos.
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Feb 06, 2009 5:55 pm    Post subject: Reply with quote

Thanks! Close thread please.
Edit: DON'T CLOSE THE THREAD! Read my bottom post please.


Last edited by talkerzero on Fri Feb 06, 2009 6:51 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Fri Feb 06, 2009 6:07 pm    Post subject: Reply with quote

smartz your solution would move the window over the mouse position Ie to foil this just move to edge of allowed area and drag window there the window will still be out of the allowed position..on the other hand this will own the window.. Wink

Code:

SetWindowPos(HandleToOurWindow,SWP_TOPMOST,left,top,width,height,SWP_NOMOVE|SWP_NOSENDCHANGING|SWP_NOSIZE);

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Feb 06, 2009 6:52 pm    Post subject: Reply with quote

All of these are great ideas, but I remember reading somewhere that there's an API for this.. is there?
Back to top
View user's profile Send private message Visit poster's website
arigity
Advanced Cheater
Reputation: 0

Joined: 03 Jul 2008
Posts: 65
Location: middle of nowhere.

PostPosted: Fri Feb 06, 2009 7:29 pm    Post subject: Reply with quote

on WM_LBUTTONDOWN check if the mouse position is in the range of an area thats considered movable. if it is send the message WM_NCLBUTTONDOWN

edit* wparam HTCAPTION lparam should be your current messsages lparam

_________________


Last edited by arigity on Fri Feb 06, 2009 7:52 pm; edited 2 times in total
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Fri Feb 06, 2009 7:30 pm    Post subject: Reply with quote

none that i know of...
and i know 'alot' of api's.
maybe not all but a vast majority..

with the solution i put forth the window wont resize wont move and it wil refuse to receive WM_WINDOWCHANGEPOS or some message.. w/e i dont care wabout the damn message name...

regards BanMe

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
Henley
Grandmaster Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 671

PostPosted: Fri Feb 06, 2009 9:04 pm    Post subject: Reply with quote

Code:
POINT Mouse;

//Mouse move //i used transparent image
GetCursorPos(&Mouse);
this->Top=Mouse.y-Y;
this->Left=Mouse.x-X;


I think that's what i did for my HBOT ._.
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Feb 06, 2009 11:14 pm    Post subject: Reply with quote

._Henley wrote:
Code:
POINT Mouse;

//Mouse move //i used transparent image
GetCursorPos(&Mouse);
this->Top=Mouse.y-Y;
this->Left=Mouse.x-X;


I think that's what i did for my HBOT ._.


But you are not coding your GUI, you are using BC++, no ?
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Feb 06, 2009 11:16 pm    Post subject: Reply with quote

Doesn't matter, I can replace this->Top and this->Left with SetWindowRect. Just one question..

Code:
this->Top = Mouse.y - Y


Where is the Y coming from? Mouse.y comes from POINT Mouse.. where is Y?
Back to top
View user's profile Send private message Visit poster's website
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Feb 06, 2009 11:22 pm    Post subject: Reply with quote

talker0 wrote:
Doesn't matter, I can replace this->Top and this->Left with SetWindowRect. Just one question..

Code:
this->Top = Mouse.y - Y


Where is the Y coming from? Mouse.y comes from POINT Mouse.. where is Y?


Probably OnMouseMove..so its the point on your form that the mouse is.
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Feb 06, 2009 11:32 pm    Post subject: Reply with quote

Thanks, solved my problem.

I know it's rather offtopic, but Henley, where did you get the images for HBOT? PerionCorner doesn't have UI related images.. Sad
Back to top
View user's profile Send private message Visit poster's website
Henley
Grandmaster Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 671

PostPosted: Fri Feb 06, 2009 11:56 pm    Post subject: Reply with quote

talker0 wrote:
Thanks, solved my problem.

I know it's rather offtopic, but Henley, where did you get the images for HBOT? PerionCorner doesn't have UI related images.. Sad

Uhh.. just take pic of it in MS and photoshop o.o(i used Paint.NET though)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites