Technology of moving window
The normal moving window is that when you dragging the window, there will be a dotted frame moving with the mouse before the left mouse buttom is upped, and the window move to the position where the mouse locate when you up the left mouse buttom.
Now, I want that the window moving with mouse without a dotted frame, but i don not know how to realize.:confused:
Re: Technology of moving window
What dotted frame are you talking about?
Re: Technology of moving window
Do you want to show the window contents while dragging?
This is an OS setting: Display properties --> Effects --> "Show window contents while dragging".
Re: Technology of moving window
Quote:
What dotted frame are you talking about?
Sorry! my english is too poor:p
see the picture below
http://www.programhome.cn/temp/dot.jpg
when you drag the Dialog there will be a dotted frame before the left mouse buttom upped.
i want the Dialog moving with the mouse direct when you drag the Dialog
Re: Technology of moving window
Quote:
Originally Posted by blacksource
when you drag the Dialog there will be a dotted frame before the left mouse buttom upped.
i want the Dialog moving with the mouse direct when you drag the Dialog
Well, it's like zerver said: It doesn't depend on your app, but is a system-wide setting that the user makes in the Display control panel.
Re: Technology of moving window
Quote:
Originally Posted by gstercken
Well, it's like zerver said: It doesn't depend on your app, but is a system-wide setting that the user makes in the Display control panel.
Good. Because I never seen that dotted frame on any of the PCs I used so far. ;) (at least I don't remember it)
Re: Technology of moving window
Quote:
Originally Posted by cilu
Good. Because I never seen that dotted frame on any of the PCs I used so far. ;) (at least I don't remember it)
Yes... Since NT4 or so, it is usually set to "Show window contents" by default. :)
Re: Technology of moving window
Quote:
Well, it's like zerver said: It doesn't depend on your app, but is a system-wide setting that the user makes in the Display control panel.
yea! you are right. i have seen that my friends compuer have not dotted frame, but i have a software on my computer when i drag the window there is no dotted frame. why?:confused:
Re: Technology of moving window
Quote:
Originally Posted by blacksource
yea! you are right. i have seen that my friends compuer have not dotted frame, but i have a software on my computer when i drag the window there is no dotted frame. why?:confused:
Well, what kind of software is that? Looks like it bypasses the system, and draws the windows on its own...
Re: Technology of moving window
Quote:
Well, what kind of software is that? Looks like it bypasses the system, and draws the windows on its own...
maybe you are right.
it is a music player
Re: Technology of moving window
I.e. Winamp draws whole window when dragging. This can be done in a few ways I guess, the one I found out is to create WM_MOVING message handler in following way:
Code:
void CTestDlg::OnMoving(UINT fwSide, LPRECT pRect)
{
CDialog::OnMoving(fwSide, pRect);
// TODO: Add your message handler code here
MoveWindow(pRect);
}
Probably there are better ways to do this.
Cheers,
Hob
BTW anyone knows why WM_NCLBUTTONUP handler is not called when I click LMB on caption and release it afterwards? However, it is called when I click LMB in client area, move cursor to caption and release the button. :confused:
Re: Technology of moving window
Hm... Wouldn't it be easier to simply turn that feature on in the Display control panel? ;)
Re: Technology of moving window
Quote:
Originally Posted by gstercken
Hm... Wouldn't it be easier to simply turn that feature on in the Display control panel? ;)
Yeah, but perhaps that's the desire behaviour for machines where users shouldn't be forced to set that feature, or where users cannot do that (due to missing rights).
Re: Technology of moving window
Quote:
Originally Posted by cilu
Yeah, but perhaps that's the desire behaviour for machines where users shouldn't be forced to set that feature, or where users cannot do that (due to missing rights).
Hm... But in that case, there's probably a good reason why the feature has been disabled by the user or admin - usually performance (on machines with a weak CPU or graphics adapter). And a well-behaved application should respect that, and not hog CPU time on it's own authority. ;)
Re: Technology of moving window
Quote:
Originally Posted by gstercken
Hm... But in that case, there's probably a good reason why the feature has been disabled by the user or admin - usually performance (on machines with a weak CPU or graphics adapter). And a well-behaved application should respect that, and not hog CPU time on it's own authority. ;)
Thats true, first thing I usually do after installing Windows is to turn off option 'Show window contents while dragging', right after disabling Windows startup/shutdown sounds. And I am really pissed when some app ignores my settings and behaves other way (vide Winamp). Probably developers think that their app looks sooo coooool that it should be visible all the time. I wonder when they will start to set 'Always on top' style.
Re: Technology of moving window
Quote:
Originally Posted by Hobson
And I am really pissed when some app ignores my settings and behaves other way (vide Winamp). Probably developers think that their app looks sooo coooool that it should be visible all the time. I wonder when they will start to set 'Always on top' style.
Fully agree! :yellow handshoe: :)
Re: Technology of moving window
Quote:
Originally Posted by zerver
This is an OS setting: Display properties --> Effects --> "Show window contents while dragging".
Quote:
Originally Posted by Hobson
I.e. Winamp draws whole window when dragging. This can be done in a few ways I guess, the one I found out is to create WM_MOVING message handler in following way:
if you cancel the effect of "Show window contents while dragging", you will find that when you are dragging the window the WM_MOVING does not happen only the LMB is upped
Re: Technology of moving window
i have an another question now.
why the function of IsWindowVisible always return zero?
That is a dialog create by MFC AppWizard
what should i do
Re: Technology of moving window
Quote:
Originally Posted by blacksource
why the function of IsWindowVisible always return zero?
How can we know, without seeing your code? Perhaps because that window is invisible? http://forums.codeguru.com/images/ie.../2006/06/1.gif
Quote:
Originally Posted by blacksource
That is a dialog create by MFC AppWizard
Hm... Sounds suspiciously like the modal main dialog of a "dialog-based" project... So where are you calling IsWindowVisible()?
Re: Technology of moving window
i call the function on CDockWndDlg::OnMove(int x, int y)
Re: Technology of moving window
Quote:
Originally Posted by blacksource
i call the function on CDockWndDlg::OnMove(int x, int y)
Hm... and that's all your code? I don't see any IsWindowVisible() call there.
Re: Technology of moving window
sorry, i call the function here
Code:
void CDockWndDlg::OnMove(int x, int y)
{
CDialog::OnMove(x, y);
// TODO: Add your message handler code here
RECT rect, rectMain;
// Get the rectangle of Docking Window
rect = (RECT)m_dlgDock.GetRect();
// Get the rectangle of Main Window
GetWindowRect( &rectMain );
// If Main Window is visible....beginning Docking
if( IsWindowVisible() )
{
// Check the station of docking
if( m_dlgDock.m_bDocked )
{
CRect rect;
// remember the rectangle position of Docking Window
rect = m_dlgDock.GetRect();
rect.OffsetRect(m_rectMain.left - x, m_rectMain.top - y );
// Move the Docking Window to Main Window
// m_dlgDock.MoveWindow( &rect );
}
}
GetWindowRect( &m_rectMain );
}
if i call m_dlgDock.MoveWindow( &rect ) direct without checking there will be an error when the initial of dialog
Re: Technology of moving window
Quote:
Originally Posted by blacksource
if i call m_dlgDock.MoveWindow( &rect ) direct without checking there will be an error when the initial of dialog
Okay, now I see what you are trying to do. The problem is that your OnMove() handler will be called once at the beginning during the window creation process - at that time, the window won't be created yet, and most of those calls will fail.
The correct way to handle this is not to test whether the window is visible, but whether it has a valid HWND attached to it - this is best done by testing m_hWnd against NULL.
Re: Technology of moving window
yeah.....
thanks gstercken