943,787 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 1303
  • C++ RSS
Dec 2nd, 2007
0

Pointer to a structure

Expand Post »
How would I declare a pointer to MINMAXINFO that is passed to WPARAM

In WM_GETMINMAXINFO wParam is a pointer to a place on the stack that holds MINMAXINFO. I've tried
C++ Syntax (Toggle Plain Text)
  1. MINMAXINFO *Info;
  2. Info = MINMAXINFO *wParam;
and several other variations to no avail.

Thanks
Similar Threads
Reputation Points: 47
Solved Threads: 17
Posting Whiz in Training
Tight_Coder_Ex is offline Offline
215 posts
since Feb 2005
Dec 2nd, 2007
0

Re: Pointer to a structure

Just cast it the usual way:
C++ Syntax (Toggle Plain Text)
  1. LRESULT CALLBACK MyWndProc(
  2. HWND hWnd,
  3. UINT uMsg,
  4. WPARAM wParam,
  5. LPARAM lParam
  6. ) {
  7. if (uMsg == WM_GETMINMAXINFO) {
  8. cout << "Max Window Size is ("
  9. << ((LPMINMAXINFO)lParam)->x << ", "
  10. << ((LPMINMAXINFO)lParam)->y << ")"
  11. << endl;
  12. }
  13. return DefWindowProc( hWnd, uMsg, wParam, lParam );
  14. }
Hope this helps.
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007
Dec 3rd, 2007
0

Re: Pointer to a structure

Thank-you Duoas, my adaptation is as follows and works as expected
C++ Syntax (Toggle Plain Text)
  1. case WM_GETMINMAXINFO:
  2. ((LPMINMAXINFO) lParam)->ptMinTrackSize.x = WndInfo.MaxWidth;
  3. ((LPMINMAXINFO) lParam)->ptMaxTrackSize.x = WndInfo.MaxWidth;
  4. ((LPMINMAXINFO) lParam)->ptMaxTrackSize.y = WndInfo.MaxHeight;
  5. ((LPMINMAXINFO) lParam)->ptMinTrackSize.y = WndInfo.MinHeight;
  6. break;
Reputation Points: 47
Solved Threads: 17
Posting Whiz in Training
Tight_Coder_Ex is offline Offline
215 posts
since Feb 2005
Dec 3rd, 2007
0

Re: Pointer to a structure

Heh, nice job. Sorry I goofed in my example and left the ptMaxSize part out:
((LPMINMAXINFO)lParam)->ptMaxSize.x

Good job on picking that up! Glad you got it working.
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007
Dec 3rd, 2007
0

Re: Pointer to a structure

I also remebered the way I wanted to do it
C++ Syntax (Toggle Plain Text)
  1. LPMINMAXINFO Info
  2. Info = LPMINMAXINFO (lParam)
I don't believe their is any advantage this way other than less to type and easier to read?
Reputation Points: 47
Solved Threads: 17
Posting Whiz in Training
Tight_Coder_Ex is offline Offline
215 posts
since Feb 2005
Dec 3rd, 2007
0

Re: Pointer to a structure

If your window procedure is small, then that way is an advantage because it is, in fact, less typing.

If your window procedure is very long then it is a disadvantage only because it separates what "info" is from where it is used.

But you are correct, they are otherwise identical.
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Dating Game
Next Thread in C++ Forum Timeline: encrypting text





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC