MartinMcD Posted October 12, 2011 Report Share Posted October 12, 2011 Hello there, I have a tricky problem I'm hoping somebody might be able to help me with... I have a vi which runs as a child window within another vi window which I created using the SetParentWindow() method in user32.dll. This works great. The result is as in the image below where the excel document exists as a child window within Excel: I then use a property node to check the child panel bounds. This works fine normally. However, if I move the parent window (and hence the child window within it) then the child's panel bounds are not updated, which they should as they reflect global screen coordinates. If I move the child window just a smidgen then the child panel bounds are correctly updated to reflect the actual global position of the child. (I'm happy the property node doesn't update in my scenario, it's just I need a solution) I thought a way round this would be to get the size of the child window by using a windows api call instead. So, I'd like to use the the user32 GetWindowRect() method. However, I am not sure how to set up the main part of the call, namely the RECT structure pointer - I've done basic dll calls before but I've not passed in a pointer and I don't know how to create a structure of the right type. I have the window handle ready to pass in. If anybody can help me set this up it would be fantastic. I will keep trying myself and post back if I figure it out as well. Below is a screenshot of the setup: Thank you, Martin Quote Link to comment
Darin Posted October 12, 2011 Report Share Posted October 12, 2011 I would recommend downloading the examples from this page: https://decibel.ni.com/content/docs/DOC-2030 Inside the WINUTIL.LLB you will find the VIs you need to get the window handle and the window rect. Quote Link to comment
asbo Posted October 12, 2011 Report Share Posted October 12, 2011 The approach is pretty simple: re-create the RECT structure as a cluster, passing it in effectively as by-ref to the call, and out comes your coordinates! Check out the attachment to see it in action. GetWindowRect.LV2009.vi Quote Link to comment
MartinMcD Posted October 12, 2011 Author Report Share Posted October 12, 2011 No way that's fantastic! Thanks so much for the help with that, I've spent all day trying to sort this out. I had scheduled in to bang my head against a wall all of tomorrow as well, I'll have to find something else to do now Thanks so much, Martin Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.