Jump to content
  • Advertisement
Sign in to follow this  
Boltimus

Moving windows without a title bar

This topic is 4882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I finished creating a neat window, using rgns, etc to get a nice window. The thing is, in setting up the window regions the title bar is no longer rendered. So m next question is, how do I allow for the user to move the window? I tried an initial cheesey approach as shown below, but the window flickers like crazy. Is there a better way??? The code below utilizes the WM_MOUSEMOVE window message. Anytime the user moves the mouse over the window region, then this code takes action...
case WM_MOUSEMOVE:

			new_time = GetTickCount();

			if ((new_time - old_time) > 100){

				old_time = new_time;

				mouse_old_x = mouse_x;
				mouse_old_y = mouse_y;

				mouse_x = LOWORD(lParam);
				mouse_y = HIWORD(lParam);

				if (mouse_new == 1){
					mouse_new = 0;
					mouse_old_x = mouse_x;
					mouse_old_y = mouse_y;
				}

				GetWindowRect(Main_Window_HWND, &win_coord);

				new_win_x = win_coord.left + mouse_x - mouse_old_x;
				new_win_y = win_coord.top  + mouse_y - mouse_old_y;

				if (new_win_x < 0) new_win_x = 0;
				if (new_win_y < 0) new_win_y = 0;

				if (wParam == MK_LBUTTON)
					MoveWindow(Main_Window_HWND, new_win_x, new_win_y, 800, 600, true);

			}

			return 0;

Share this post


Link to post
Share on other sites
Advertisement
I found the answer and will reply to this message since no one else knows how to do this.

(1) First just draw over the non-client area(this is the title bar, etc) by using the DC returned from GetWindowDC, do not use the DC returned by Begin paint, this will only give you the client area. GetWindowDC returns a DC that allows you to draw over everything.

(2) Next, have your program intercept the WM_NCPAINT message so that windows will use what you put here to draw the nonclient area. Basically what I did was combined the paint and ncpaint messages into one case....


case WM_PAINT: case WM_NCPAINT:

// .. your code goes here ...

return 0;




I hope this helps people in the future with similar problems!

Share this post


Link to post
Share on other sites
I did this a number of years ago, but I won't be able to look at the source code until I get home and dig the backup out of storage. I'll post if it's any different than Halo7's solution.

Ok.. this was still while I was in school, but what I did was handle left mouse clicks, and when the mouse clicked inside of my draggable region, I:

PostMessage(WM_NCLBUTTONDOWN, HTCAPTION);

Possibly not a good way to do it, but I claim ignorance :)

[Edited by - pragma Fury on June 7, 2005 7:29:42 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!