02-28-2017 07:45 AM
Hello all,
how do I get the original size of the image contained within a picture control (which has been resized) ?
I thought I could simply do:
SetCtrlAttribute(pnl, ctrl, ATTR_FIT_MODE, VAL_SIZE_TO_IMAGE); GetCtrlAttribute(pnl, ctrl, ATTR_WIDTH, &W); GetCtrlAttribute(pnl, ctrl, ATTR_HEIGHT, &H);
But I still get the size of the control, not the image. Even if I call ProcessDrawEvents in between.
02-28-2017 08:12 AM
You may be running into this trouble if your picture controle is overlapped or hidden while you resize it: see Luis explanation in this discussion.
02-28-2017 08:39 AM
Hmmm, yes, that's the situation described: my control is behind a partially transparent other control (it's a background image which must be positionned precisely).
I read the thread you mention so I tried the following but it still doesn't work:
SetCtrlAttribute(pnl, ctrl, ATTR_ZPLANE_POSITION, 0); SetCtrlAttribute(pnl, ctrl, ATTR_FIT_MODE, VAL_SIZE_TO_IMAGE); ProcessDrawEvents (); GetCtrlAttribute(pnl, ctrl, ATTR_WIDTH, &P_W); GetCtrlAttribute(pnl, ctrl, ATTR_HEIGHT, &P_H); SetCtrlAttribute(pnl, ctrl, ATTR_FIT_MODE, VAL_SIZE_TO_PICTURE); SetCtrlAttribute(pnl, ctrl, ATTR_ZPLANE_POSITION, 255);
02-28-2017 09:48 AM
Well, the strange thing is that I don't need to play with the zplane position to have the correct dimensions of the control! I made a sample project for the original poster of the discussion I linked: now I have modified it placing a graph on top of the picture control but I get the correct height and width with no additional calls than load the picture and get the corresponding attributes!
I am attaching the project so you can play with it and see if and how our codes differ: maybe differences can help us understand what's happening.
02-28-2017 11:06 AM
Thanks. Your code works as expected. I modified it to look like mine (same kind of controls) and it still works. Mine doesn't. I'm gonna sleep on it...