Hi! Just a general question. I have a HWND that I want to pass into GetWindowRect(HWND hwnd, LPRECT lprect) but the compiler is comming up with errors saying i can only use this: GetWindowRect(LPRECT lprect)
I found this in my afxwin2.inl so i certainly should be able to use it:
_AFXWIN_INLINE void CWnd::GetWindowRect(LPRECT lpRect) const
{ ASSERT(::IsWindow(m_hWnd)); ::GetWindowRect(m_hWnd, lpRect); }
1 2 3 4
HWND hWindow = *pWnd; //*pWnd is a pointer to a CWnd object
RECT rRect = { 0 };
GetWindowRect(&rRect); //but i want: GetWindowRect(hWindow, &rRect)
I know i'm doing something wrong. Please help !
(i'm a noobie :p)
You seem to be programming with MFC, and the class already has a wrapper to this WinAPI, and is called the same. So if you are trying to get the rectangle of the window controlled by a CWnd class, you just use this one. In your code I see you have a pointer to a CWnd. That means you can:
Hi! Yes I am using MFC. Thanks for the suggestion. The build went fine but the program crashed...msdn suggests fixing the order of operations but I don't see where I can do that...
in the debug (among many other errors) i see:
m_hWnd CXX0030: expression cannot be evaluated
and the program breaks exactly at:
{ ASSERT(::IsWindow(m_hWnd)); ::GetWindowRect(m_hWnd, lpRect); }
I guess the process stops in the assertion. That means the window hasn't been constructed by the time you call GetWindowRect(). Suggestion: Make sure you have created the window by calling Create() or CreateEx().
FYI, I don't know MFC. I have learned little bits here and there due to my need to maintain an ATL/MFC BHO, but that's about it.
Hmmm maybe i'm doing something wrong then. I'm trying to extract information from a window in another program that I don't control. I have the HWND to that window. Maybe there is a struc i can use to get an equivalent RECT for that window ?
ps: Ur replies make perfect sense so far so don't worry about how much MFC u know :)