I have a form with the scroll bar is shown in figure
Have a control form in form 2, form 2 have a scroll bar, you can drag the up and down, the control class name is the Grid I can
Auto s=CRect (); The Grid - & gt; GetWindowRect (& amp; S); The Grid - & gt; The GetParent () - & gt; ScreeToClient (& amp; S) pDC-> DPtoLp (& amp; S); Get him on the screen coordinates, but the problem is coming, and, in the form of two logical coordinates, how to come out,
especially when I change the size of the form 2 by 4 or 5 pull , the object S is the table, but it looks like not ah, I am in control of the logical coordinates relative to the parent window didn't changed, just change the size of the window, I inside the control position did not change ah, if in the Grid - & gt; GetWindowRect (& amp; S); This come out as the coordinates of did not change the window size is not the same, really should also be different, but I have no change control relative to the parent window location,
CodePudding user response:
X coordinate minus the horizontal scroll bar pos
CodePudding user response:
reference 1st floor hurryboylqs response: x coordinate minus the horizontal scroll bar pos hello, excuse me horizontal scrollbar refers to me form 2,,, or just I form two parent window of the horizontal scroll bar, but my parent window window 2 no scroll bar, just drag the boundary of the two forms 1 and 2 in size CodePudding user response:
Auto s=CRect (); The Grid - & gt; GetWindowRect (& amp; S); The Grid - & gt; The GetParent () - & gt; ScreeToClient (& amp; S);//here is controls in the client area coordinates of the parent window CodePudding user response:
The reference 3 floor zgl7903 response: auto s=CRect (); The Grid - & gt; GetWindowRect (& amp; S); The Grid - & gt; The GetParent () - & gt; ScreeToClient (& amp; S);//here is controls in the client area coordinates of the parent window then I think is really,,, but I'm 4 there drag to change the window 1 and 2, the size of the thumbnails in window 1, you can see the window 2 things only drag to a location in the thumbnail to the right to see the form, if the window 1 are small, the thumbnail directly indicates something else You see, the following two figures CodePudding user response:
The reference 3 floor zgl7903 response: auto s=CRect (); The Grid - & gt; GetWindowRect (& amp; S); The Grid - & gt; The GetParent () - & gt; ScreeToClient (& amp; S);//here is controls in the client area coordinates of the parent window this let me very confusing I coordinate set is the control in the form of coordinate! pDC-> StretchBlt (sourcePos sourcePos. Left, top, (sourcePos. Width ()), (sourcePos. Height ()), The Grid - & gt; GetWindowDC (), 0, 0, Griddevicerect. Width (), griddevicerect. Height (), SRCCOPY);//the Grid is the control class, GetWindowDC into GetDC same () Only the window 2 drag to a location to display correctly, think impassability, please give some hints CodePudding user response:
Whether in understanding meaning of parameters is wrong? pDC-> StretchBlt (0, 0,//the target DC the starting position of the x, y , dstWidth, dstHeight,//the size of the target DC cx, cy PSrcDC,//the source DC 0, 0,//the source DC starting position Cx, srcWidth, srcHeight,//the source DC size, cy SRCCOPY); CodePudding user response:
You use absolute coordinates the coordinates must be changed, you should use relative coordinates, such as control of x in 1/3 of the width of the parent window location and the width of the control is 1/2 the width of the parent window, and so on, every time after the change of the parent window size, you retrieve the parent window's width, height, and the mobile controls CodePudding user response:
refer to 6th floor zgl7903 response: is to understand the meaning of the parameters is wrong? pDC-> StretchBlt (0, 0,//the target DC the starting position of the x, y , dstWidth, dstHeight,//the size of the target DC cx, cy PSrcDC,//the source DC 0, 0,//the source DC starting position Cx, srcWidth, srcHeight,//the source DC size, cy SRCCOPY); parameter does wrong,,, The original code is Auto sourcePos=CRect (); The Grid - & gt; GetWindowRect (& amp; SourcePos); The Grid - & gt; The GetParent () - & gt; ScreeToClient (& amp; SourcePos) Auto griddevicerect=CRect (); The Grid - & gt; The Grid - & gt; GetWindowRect (& amp; Griddevicerect); pDC-> DPtoLp (& amp; S); pDC-> StretchBlt (0, 0, SourcePos. Width (), sourcePos. Height (), PGrid - & gt; GetWindowDC (), 0, 0, Griddevicerect. Width (), griddevicerect. Height (), SRCCOPY); Like this refer to 6th floor zgl7903 response: is to understand the meaning of the parameters is wrong? pDC-> StretchBlt (0, 0,//the target DC the starting position of the x, y , dstWidth, dstHeight,//the size of the target DC cx, cy PSrcDC,//the source DC 0, 0,//the source DC starting position Cx, srcWidth, srcHeight,//the source DC size, cy SRCCOPY); moderators right, greatly, but I really don't know how to adjust the coordinates,,, adjust the driving for a long time, Change the code: //code 1 Auto sourcePos=CRect (); The Grid - & gt; GetWindowRect (& amp; SourcePos);//this should be the coordinates of the entire window Auto griddevice=sourcePos; The Grid - & gt; The GetParent () - & gt; ScreeToClient (& amp; SourcePos)//and then the coordinates of the coordinate transformation into window 2 pDC-> DPtoLp (& amp; SourcePos); And then again into the window 2 in logical coordinates pDC-> StretchBlt (sourcePos sourcePos. Left, top, SourcePos. Width (), sourcePos. Height (), 0, 0, griddevice width (), griddevice. Height (); SRCCOPY); The above code can perfect the thumbnail display under my control, But for the navigation bar is to change the window to see thumbnail images, and today I found my another question is, if I were in the parent window 2 above in with pDC drag a good ellipse, and change the location of the ellipse, I the form controls in the size of the navigation bar will change, see the following two figures The samples of what's going on,,, CodePudding user response:
refer to 7th floor tiger bobo response: you with absolute coordinates the coordinates must be changed, you should use relative coordinates, such as control of x in 1/3 of the width of the parent window location and the width of the control is 1/2 the width of the parent window, and so on, every time after the change of the parent window size, you retrieve the parent window's width, height, and mobile controls for Brother see upstairs, and this I did not change the size of the window 2, just drag a use PDC drew a original, form the navigation bar on the left figure is changed,,,