|
beeejay wrote: Ok i tried somthing similiar but the window is being drawn in my location and then in the location it would be had I not interfered.
It's working fine in MFC .
beeejay wrote: How are you calling this within the wndProcedure? Is there a window callback in mfc as there is in win32?
In WindowProc you will have to do something like
LRESULT WindowProc( ... )
{
switch( message )
{
case WM_MOVING:
OnMoving( ... );
}
DefWindowProc( ... );
}
In the previous given function you will have to convert functions from MFC to SDK format. Like passing the HWND as the first parameter as required, rest will be ok...
For eg:
::GetParent( hWndChild );
|
|
|
|
|
OK it doesn't look like there is an OnMoving function within the SDK. would your program function the same way if you were just to paste the contents of your method into the WM_MOVING case?
Thanks Alot,
Ben
|
|
|
|
|
beeejay wrote: OK it doesn't look like there is an OnMoving function within the SDK.
Heh, when did I say that . I was just calling that function when the event WM_MOVING happens, in order to isolate the code.
beeejay wrote: would your program function the same way if you were just to paste the contents of your method into the WM_MOVING case?
It won't. As I said you will have to convert MFC to SDK.
For eg: GetParent( hWndChild );
Anyway here is the SDK code and don't tell me again it doesn't work...;)
case WM_MOVING:
{
LPRECT lpRect = ( LPRECT )lParam;
static RECT rcPreviousCoords = *lpRect;
HWND pParentWnd = ::GetParent( hWnd );
if( !pParentWnd )
break ;
RECT crParentRect;
::GetClientRect( pParentWnd, &crParentRect );
::ClientToScreen(pParentWnd, (LPPOINT)&crParentRect);
::ClientToScreen(pParentWnd, ((LPPOINT)&crParentRect)+1);
if( lpRect->left <= crParentRect.left || lpRect->right >= crParentRect.right )
{
lpRect->left = rcPreviousCoords.left;
lpRect->right = rcPreviousCoords.right;
}
else
{
rcPreviousCoords.left = lpRect->left;
rcPreviousCoords.right = lpRect->right;
}
if( lpRect->top <= crParentRect.top || lpRect->bottom >= crParentRect.bottom )
{
lpRect->top = rcPreviousCoords.top;
lpRect->bottom = rcPreviousCoords.bottom;
}
else
{
rcPreviousCoords.top = lpRect->top;
rcPreviousCoords.bottom = lpRect->bottom;
}
return TRUE;
}
|
|
|
|
|
Ok I have somthing very similiar, but I am still having the same problem.
The window is drawn twice, once very quickly in my position( and then erased), and then once in position it would be in had i not intervened.
Here is the code for WM_MOVING:
RECT rect;
GetWindowRect( hWnd, &rect );
if ( rect.right > xMax )
rect.left = xMax - ( rect.right - rect.left );
if ( rect.left < xMin )
rect.left = xMin;
if ( rect.bottom > yMax )
rect.top = yMax - ( rect.bottom - rect.top );
if ( rect.top < yMin )
rect.top = yMin;
SetWindowPos( hWnd, HWND_TOP, rect.left, rect.top, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE );
return true;
Thanks alot
|
|
|
|
|
beeejay wrote: SetWindowPos( hWnd, HWND_TOP, rect.left, rect.top, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE );
Well this is the problem, you don't have to do this...
Why don't you try the code that I gave, and try to see the difference.
|
|
|
|
|
I was missing this little gem LPRECT lpRect = ( LPRECT )lParam;
Thanks alot,
It seems that the rect which GetWindowRect sets doesn't actually get used after my WM_MOVING hanlder is complete.
|
|
|
|
|
beeejay wrote: It seems that the rect which GetWindowRect sets doesn't actually get used after my WM_MOVING hanlder is complete.
Read what MSDN says about lParam as on WM_MOVING event...
<code>lParam: </code>
Pointer to a <code>RECT </code>structure with the current position of the window, in screen coordinates.
<code>To change the position of the drag rectangle, an application must change the members of this structure.</code>
|
|
|
|
|
I need to learn fast about the creation of ATL Composite Control Projects.
Where could I find abundant information about this??.
Maybe a tutorial in the WEB.
Maybe a book.
I have read a lot about ATL projects but I need something specific about Composite Controls. Something that teach me how should I move inside this kind of project.
I have some good skills with MFC and I'm learning general ATL stuff.
Thank you very much.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
|
Did you see C++ Libraries On codeproject
|
|
|
|
|
hi good day to everyone. why do i have this kind of warning to my functions?
warning C4100: 'nFaceRecNo' : unreferenced formal parameter
what does it mean? thanks for your reply
positive vibes
|
|
|
|
|
It means that the parameter "nFaceRecNo " isn't used in the function. The best way to get rid of this warning is as follows:
void Foo(int n)
{
}
void Foo(int)
{
}
Note that in the code without the warning I've removed any parameters which I don't use in the function from the function definition. It can still be present in the declaration. There are other ways of resolving this problem but this is how I normally deal with it.
Steve
|
|
|
|
|
thanks so much steve... problem solved here
positive vibes
|
|
|
|
|
We have several VC7 MFC and ATL applications and are wondering whether to port them over to VC8. The main reason is so that we don't have a mix of development environments - some projects using vs2003 and some using vs2005.
But are there any advantages as far as the libraries go - STL/ATL/MFC? I understand the main change is in the C runtime string functions to reduce buffer overflow problems. Any other changes for better or worse?
|
|
|
|
|
Yes, basically if you use C string functions, you'll get a warning. Beyond that, I see no compelling reason to change, there are some breaking changes for standards, but all reasonably obscure.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sir,
I want to learn how to make a web application in vc++.net.
Please send any link .
Thanks.
|
|
|
|
|
I don't believe you can use C++ for ASP.NET. Your profile says you know ASP.NET, why do you want to write a web app in c++ ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi..
Is there a way to prevent a file from being opened in windows ....
The System is not a part of any network..
There is No other users except Administrator is available in the system.
Thanks
Luck is Opportunity with hardwork
|
|
|
|
|
Asking the question again will not change the answer....
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Luck is Opportunity with hardwork
|
|
|
|
|
Sir,
I want to connect the database(Sql Server) to vc++.net 1.1 programically.I also want to use insert delete update queries in the form .Please help me or please send any link for the problem.
Thanks.
|
|
|
|
|
Did you search on codeproject?
|
|
|
|
|
it is the classic "hello,world" example, I am using VC++6.0,when I create a project and include the .h and .cpp file into it and compile, it pops out these errors:
--------------------Configuration: chapter 1_0 - Win32 Debug--------------------
Compiling...
hello.cpp
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/chapter 1_0.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
chapter 1_0.exe - 3 error(s), 0 warning(s)
[code]
//Hello.h
class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance ();
};
class CMainWindow : public CFrameWnd
{
public:
CMainWindow ();
protected:
afx_msg void OnPaint ();
DECLARE_MESSAGE_MAP ()
};
//Hello.cpp
#include <afxwin.h>
#include "Hello.h"
CMyApp myApp;
/////////////////////////////////////////////////////////////////////////
// CMyApp member functions
BOOL CMyApp::InitInstance ()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow (m_nCmdShow);
m_pMainWnd->UpdateWindow ();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////
// CMainWindow message map and member functions
BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT ()
END_MESSAGE_MAP ()
CMainWindow::CMainWindow ()
{
Create (NULL, _T ("The Hello Application"));
}
void CMainWindow::OnPaint ()
{
CPaintDC dc (this);
CRect rect;
GetClientRect (&rect);
dc.DrawText (_T ("Hello, MFC"), -1, &rect,
DT_SINGLELINE ¦ DT_CENTER ¦ DT_VCENTER);
}
|
|
|
|
|
See MSDN article Q126646.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Oh, I forgot the project setting: "using MFC in a shared DLL"
|
|
|
|