• the GetWindowRect() give me the window size and position;
  • the GetClientRect() give me the window size without inclued the scrollbars\menus\borders\others;
    so when 1 image is more big than client size, what size i can use? DC size?
    and if a child window position is more big than client size??? what size do i need? the DC size do the job?

Which size to use depends on what you want to use that size for, and I am not clear what you are trying to do. Can you give some more detail?

Also note that a DC (Device Context) doesn't really have a size. It is an infinite plane for you to draw on. Your window provides a view of that plane, and that view may or may not cover everything that is drawn there.

I don't have an answer to this but I believe the OP means if the content of a window holds an image or multiple images or some other content which is bigger than the physical window size (so I'd assume it would have scroll bars), then the size of the total content in it, for example a browser control.

Edited 2 Years Ago by Suzie999

Comments
thanks for correct my english too

Oh, OK. In that case I don't really know any answer either. I don't know of any API call to find out the total size of the "occupied" area of the DC. This makes sense because there is no guarrantee that Windows knows anything about data that falls outside of the client area. Suppose you were drawing a map in your window. One way would be to draw (in memory) a map of the whole area for which you have information, then just display a portion of that in your window. That would not be a viable strategy for something like Google Maps - you can't draw the whole earth and then just show one city block. Instead, your map would be virtual and you would only actually draw the area to be displayed. How could Windows know the size that would be occupied by the full map if you were to draw it at the same scale?

I guess there are 2 scenarios to consider.
The most likely case, and the easier to deal with, is that the window is in your own application. In that case your code needs to keep track of what you display in that window and the full data set if you are only displaying a portion of the available information. The solution is in your own code, not in the Windows API.

Less likely, but possible, is that the window is in another app - for example, you are writing some kind of screen scraper and want to get the full data not just the portion currently displayed. I don't think a generic solution exists here. I guess you could try to work it out by looking at the scroll bar settings compared to what is actually displayed, but you would need to scroll the target window to be sure you got all the available data - and then barf if you encounter a situation like the city block / whole earth map situation.

imagine the image is more big than the client size, so i can get the image size from the file or BITMAP structure. but if you edit the image and draw(with mouse, for example) something more big than the image size. doing these type of size, manualy will be very complex :(
and if i put a control with a position more big than that size???
these manualy will be very complex :(

let me ask you 1 thing: almost microsoft programs use win32 functions(directly or indirectly, maybe not the with Visual Studio .NET or above):

  • so when we draw more than the image size(maybe the mouse position can help me), how they change the scrollbar values?

  • when we put a control after client size(even only the control size), how they change the scrollbar values?(unless theres the create control parent messages)

I really do not mean to appear negative, as this interested me enough to do a search myself looking for ways and or an API, a search which unfortunately came up short. Of course that does not mean there is no API.

But what I concluded was that it must be the responsibility of the developer to keep track of what is in a window/control and what it's size is.

Maybe I don't understand correctly but if a user of your application is drawing something with it, then your application should be able to know where the user is drawing and what size that drawing is.

Edited 2 Years Ago by Suzie999

thanks to both for all information, maybe now i understand how can i get the 'DC size' ;)
thanks to both

See: ScrollWindowEx

The above ScrollWindowEx is exactly what you need to use. When you draw on the DC, draw on the entire DC. The entire width and height of your image.

When you want to clip a specific part to the client area, you may scroll it or set a clipping region. The clipping region will define the area that is drawn.

It can be done with a Bitblt/StretchBlt as well by specifying the drawing area.

Edited 2 Years Ago by triumphost

triumphost, that approach is a good approach that will work in many cases, but it is not always suitable. Take the maps example I gave above. It makes no sense to try and draw a map of the entire world and then bitblt one city block into your window. It makes no sense to prepare a display with details from thousands of database records and then copy just 20 records to your window. Sometimes it makes sense to prepare just the data you can immediately view.

triumphost: please give me an example for test it(just with windows message not entire code) ;)
i know use the function(i think lol), but i don't know if i need 1st show the scrollbars or something.

Edited 2 Years Ago by cambalinho

This question has already been answered. Start a new discussion instead.