0

We have a struct defined as :

typedef struct tagWINDOWPOS { /* wp */
   HWND hwnd;
HWND hwndInsertAfter;
int x;
int y;
int cx;
int cy;
UINT flags;
} WINDOWPOS;

Then we are sent a message...

WM_WINDOWPOSCHANGING
    WPARAM wParam
LPARAM lParam;
Parameters
wParam
This parameter is not used.
lParam
Pointer to a WINDOWPOS structure that contains information about the window's new size and position.

And this is the code which gets the message

case WM_WINDOWPOSCHANGING:
    WINDOWPOS * pWinPos;
pWinPos = lParam;
break;

lParam contains the address of the struct. Here we want to access to the struct.
But there is a problem with the code. pWinPos is a constant pointer, so we can't simply assign an address to it.

So, finally, here is my question...
How can I access to the WINDOWPOS struct whose address is given by lParam

Edited by happygeek: fixed formatting

2
Contributors
4
Replies
5
Views
12 Years
Discussion Span
Last Post by AhmedHan
0

pWinPos is not constant. but you do need a cast. either an old c style or a reinterpret_cast<WINDOWPOS*>(lParam)

0

Is

WINDOWPOS wp;
WINDOWPOS * pwp;
pwp = &wp;

convenient?

Then we can access to the sub-fields this way :

pwp->x
pwp->uflags
etc...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.