CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2012
    Posts
    24

    Win32 API mapping system

    Hello,

    I've stumbled on the window and viewport problematic and I don't get it. My first thoughts were, I got a client area, where I set the viewport (size of the viewport and coordinates of the origin) and there I can draw and print out text. But when I'm digging deeper, there is a window-to-viewport transformation. But what kind of window is it? Is it an imaginary window? My application (a window) has its client area, where I set the imaginary window and viewport. But why do I need this window?

    Next thoughts were, that I can draw only inside this window/viewport defined by its extents, but I've tryed to draw outside the dimensions and its working. Btw. I can paint without using the SetMapMode() fce, so why there is this option?

    I know, that this system is because of transformation between logical units (mm, cm, m, inch etc.) and device units (pixels), but why when I'm using a screen, which is in pixels?

    Can someone help me please to explain it more in detail? :-)

    Thank you very much

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Win32 API mapping system

    Here are some links to some explanations. I don't know if you use MFC or not but native Win API isn't that different so you will probably be able to get it anyway.

    http://flylib.com/books/en/4.348.1.11/1/
    http://www.********.net/Free-VC-Draw...C-Tutorial.htm
    http://support.microsoft.com/KB/195028
    http://forums.codeguru.com/archive/i.../t-285557.html

    Edit: Those stars should be u c a n c o d e without the spaces. I don't know why it's replaced like that...
    Last edited by S_M_A; July 20th, 2012 at 04:32 AM.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Jul 2012
    Posts
    24

    Re: Win32 API mapping system

    Hi,

    thanks, I've read few articles, but still I'm confused. Thanks for the links, I'll check it and hopefully it will help. I'm not prgramming in MFC.

    Thanks

  4. #4
    Join Date
    Jul 2012
    Posts
    24

    Re: Win32 API mapping system

    I've read all the articles and it was really interesting, thank you for that. I'm still little bit confused of it. Even when I'm using the default mapmode MM_TEXT, there is the viewport and the window with predifined parametrs.
    What I don't understand is, how is it possible, that I can draw behind the boundaries of the window and during resizing the window I see them... I thought, that there is limitted size of the area (viewport), where I can draw.

    And another thing, using the origins of the window, its easy to scroll, so why is it not used for example for the scrollbars and the scrollbars use the ScrollWindow fce and you have to set all the things around it... this is much simpier...

  5. #5
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Win32 API mapping system

    I'm sorry but I feel I can't explain it better than those links I gave you.

    Whenever you experience that some things in Windows would be easier if done in another way keep in mind that MS is very reluctant to change things since that would break more or less every existing application out there. I.e. some things have a long history dating as far back as to Windows 1.0 http://en.wikipedia.org/wiki/Windows_1.0

    You also asked why all these mapping settings exists when the screen is in pixels and that's because most things in real life isn't measured in pixels... These mapping functions make it easier for instance a CAD software to present a proper scaled drawing regardless if on the screen or on a printer. The physical size of a pixel on screen is huge compared to the one on a laser printer so printing using pixels will produce something completely useless.

    Keep experimenting and you will probably end up realizing that most functions are not as stupid as you though when using them for the first time. They are there to assist you regardless of what kind of application you write by making drawing details a bit more abstract.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  6. #6
    Join Date
    Jul 2012
    Posts
    24

    Re: Win32 API mapping system

    Hey, you don't have to be sorry. You helped me really much. As you said, I've to experiment with it a little bit more and take it as a fact.
    The first thing I thought the mapping mode it is necessary for are CAD SWs. :-) But I was confused, why should I use it in my program, where I want to use just pixels... Now I'm cleverer. Thank you for help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured