Pointer to a structure

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Pointer to a structure

 
0
  #1
Dec 2nd, 2007
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
  1. MINMAXINFO *Info;
  2. Info = MINMAXINFO *wParam;
and several other variations to no avail.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,951
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Pointer to a structure

 
0
  #2
Dec 2nd, 2007
Just cast it the usual way:
  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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: Pointer to a structure

 
0
  #3
Dec 3rd, 2007
Thank-you Duoas, my adaptation is as follows and works as expected
  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;
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,951
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Pointer to a structure

 
0
  #4
Dec 3rd, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: Pointer to a structure

 
0
  #5
Dec 3rd, 2007
I also remebered the way I wanted to do it
  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?
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,951
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Pointer to a structure

 
0
  #6
Dec 3rd, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC