| View previous topic :: View next topic |
| Author |
Message |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Fri Feb 06, 2009 5:24 pm Post subject: [C++ help] Making a window draggable by defined area |
|
|
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?
|
|
| Back to top |
|
 |
Zerith Master Cheater
Reputation: 1
Joined: 07 Oct 2007 Posts: 468
|
Posted: Fri Feb 06, 2009 5:32 pm Post subject: |
|
|
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 |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Fri Feb 06, 2009 5:41 pm Post subject: |
|
|
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 |
|
 |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Fri Feb 06, 2009 5:55 pm Post subject: |
|
|
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 |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
|
| Back to top |
|
 |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Fri Feb 06, 2009 6:52 pm Post subject: |
|
|
| All of these are great ideas, but I remember reading somewhere that there's an API for this.. is there?
|
|
| Back to top |
|
 |
arigity Advanced Cheater
Reputation: 0
Joined: 03 Jul 2008 Posts: 65 Location: middle of nowhere.
|
Posted: Fri Feb 06, 2009 7:29 pm Post subject: |
|
|
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 |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
Posted: Fri Feb 06, 2009 7:30 pm Post subject: |
|
|
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 |
|
 |
Henley Grandmaster Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 671
|
Posted: Fri Feb 06, 2009 9:04 pm Post subject: |
|
|
| 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 |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Fri Feb 06, 2009 11:14 pm Post subject: |
|
|
| ._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 |
|
 |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Fri Feb 06, 2009 11:16 pm Post subject: |
|
|
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 |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Fri Feb 06, 2009 11:22 pm Post subject: |
|
|
| 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 |
|
 |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Fri Feb 06, 2009 11:32 pm Post subject: |
|
|
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..
|
|
| Back to top |
|
 |
Henley Grandmaster Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 671
|
Posted: Fri Feb 06, 2009 11:56 pm Post subject: |
|
|
| 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..  |
Uhh.. just take pic of it in MS and photoshop o.o(i used Paint.NET though)
|
|
| Back to top |
|
 |
|