Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Curious [Solved]

Curious [Solved]

Scheduled Pinned Locked Moved C / C++ / MFC
testingbeta-testingjsonhelpquestion
12 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gwenio
    wrote on last edited by
    #1

    While messing around with Windows programming I found something odd. When I have a window at (0,0), and the width is 1680, the height is 1050, and GetSystem metrics says that is the height and width of the screen; however the window does not fill up the entire screen. (e.g. there are exactly three pixels it does not cover on the right) Any thoughts was to what might be happening? --------------------- Okay, two things to add: - Since I had altered the message processing so that it would be as if the non-client area did not exist, I was using GetClientRect to find the values for position and size. It sets left and top to zero, so the position could have been wrong. :doh: - I had shifted the window up and to the left to place the 0,0 of the client area at 0,0 on the screen. Further testing shows that the calculations I had preformed were correct for a window with no style so this should not have been a problem. Therefore it would seem I have somehow managed to prevent the non-client area from being created, as all non-child windows normally have a border of some type and a caption even if those things are not specified in the style. Will confirm this later with a few more tests. --------------------- Apperently there is no non-client area if you eat the WM_NCCALCSIZE message, so my adjustments to the windows position to account for the non-client area was unneeded. This fact is not in the documentation of the message :(( . Would have saved a lot of trouble. So, my code was correct per the documentation of the Windows API, but it was something they forgot to mention that was the root of the problem (as I had expected, though I was looking in the wrong place).

    S L 2 Replies Last reply
    0
    • G Gwenio

      While messing around with Windows programming I found something odd. When I have a window at (0,0), and the width is 1680, the height is 1050, and GetSystem metrics says that is the height and width of the screen; however the window does not fill up the entire screen. (e.g. there are exactly three pixels it does not cover on the right) Any thoughts was to what might be happening? --------------------- Okay, two things to add: - Since I had altered the message processing so that it would be as if the non-client area did not exist, I was using GetClientRect to find the values for position and size. It sets left and top to zero, so the position could have been wrong. :doh: - I had shifted the window up and to the left to place the 0,0 of the client area at 0,0 on the screen. Further testing shows that the calculations I had preformed were correct for a window with no style so this should not have been a problem. Therefore it would seem I have somehow managed to prevent the non-client area from being created, as all non-child windows normally have a border of some type and a caption even if those things are not specified in the style. Will confirm this later with a few more tests. --------------------- Apperently there is no non-client area if you eat the WM_NCCALCSIZE message, so my adjustments to the windows position to account for the non-client area was unneeded. This fact is not in the documentation of the message :(( . Would have saved a lot of trouble. So, my code was correct per the documentation of the Windows API, but it was something they forgot to mention that was the root of the problem (as I had expected, though I was looking in the wrong place).

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      It might help you get an answer if you post the code you're using to get the dimensions of the screen.

      Steve

      G 1 Reply Last reply
      0
      • G Gwenio

        While messing around with Windows programming I found something odd. When I have a window at (0,0), and the width is 1680, the height is 1050, and GetSystem metrics says that is the height and width of the screen; however the window does not fill up the entire screen. (e.g. there are exactly three pixels it does not cover on the right) Any thoughts was to what might be happening? --------------------- Okay, two things to add: - Since I had altered the message processing so that it would be as if the non-client area did not exist, I was using GetClientRect to find the values for position and size. It sets left and top to zero, so the position could have been wrong. :doh: - I had shifted the window up and to the left to place the 0,0 of the client area at 0,0 on the screen. Further testing shows that the calculations I had preformed were correct for a window with no style so this should not have been a problem. Therefore it would seem I have somehow managed to prevent the non-client area from being created, as all non-child windows normally have a border of some type and a caption even if those things are not specified in the style. Will confirm this later with a few more tests. --------------------- Apperently there is no non-client area if you eat the WM_NCCALCSIZE message, so my adjustments to the windows position to account for the non-client area was unneeded. This fact is not in the documentation of the message :(( . Would have saved a lot of trouble. So, my code was correct per the documentation of the Windows API, but it was something they forgot to mention that was the root of the problem (as I had expected, though I was looking in the wrong place).

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        I use the following code to get the (correct) values:

        int cx = GetSystemMetrics(SM\_CXSCREEN);
        int cy = GetSystemMetrics(SM\_CYSCREEN);
        

        That appears to work fine on my system; what parameters are you using?

        It's time for a new signature.

        G 1 Reply Last reply
        0
        • L Lost User

          I use the following code to get the (correct) values:

          int cx = GetSystemMetrics(SM\_CXSCREEN);
          int cy = GetSystemMetrics(SM\_CYSCREEN);
          

          That appears to work fine on my system; what parameters are you using?

          It's time for a new signature.

          G Offline
          G Offline
          Gwenio
          wrote on last edited by
          #4

          Same parameters, and it is returning th expected values (the same as my screen resolution).

          L 1 Reply Last reply
          0
          • S Stephen Hewitt

            It might help you get an answer if you post the code you're using to get the dimensions of the screen.

            Steve

            G Offline
            G Offline
            Gwenio
            wrote on last edited by
            #5

            std::cout << ::GetSystemMetrics(SM_CXSCREEN) << '\t' << ::GetSystemMetrics(SM_CYSCREEN) << std::endl; The output is the expected value (my screen resolution), and the related output for the window size and position is what I expected as well (the as I passed to CreateWindowEx). However, since I can see that the window is smaller than the screen, it means one of the values is a lie.

            1 Reply Last reply
            0
            • G Gwenio

              Same parameters, and it is returning th expected values (the same as my screen resolution).

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Can you show all the code around your CreateWindowEx()?

              It's time for a new signature.

              G 1 Reply Last reply
              0
              • L Lost User

                Can you show all the code around your CreateWindowEx()?

                It's time for a new signature.

                G Offline
                G Offline
                Gwenio
                wrote on last edited by
                #7

                RECT r;
                x -= ::GetSystemMetrics(SM_CXFIXEDFRAME);
                y -= ::GetSystemMetrics(SM_CYCAPTION)+::GetSystemMetrics(SM_CYFIXEDFRAME);
                r.right = width;
                r.bottom = height;
                AdjustWindowRect(&r,0,0);
                obj.handle = CreateWindowExA(WS_EX_TRANSPARENT|WS_EX_TOPMOST,"CONTEXT",title,0,x,y,width,height,0,0,::GetModuleHandle(0),0);

                The WndProc associated with it is crafted to make it as though the non-client area does not exist; it is not drawn, it does not recieve input, hit tests return true only if the point is inside the client area, and WM_NCCALCSIZE returns WVR_VALIDRECTS|WVR_REDRAW (for now, I will do some custom checking later). For getting the size and position, I use GetClientArea, as the client is effectivly the entire window. The window is filled with a rectangle of its width and height when redrawing. Looking it over it might be that I should use SM_CXBORDER insead of SM_CXFIXEDFRAME, but that would not account for all the missing space.

                L S 2 Replies Last reply
                0
                • G Gwenio

                  RECT r;
                  x -= ::GetSystemMetrics(SM_CXFIXEDFRAME);
                  y -= ::GetSystemMetrics(SM_CYCAPTION)+::GetSystemMetrics(SM_CYFIXEDFRAME);
                  r.right = width;
                  r.bottom = height;
                  AdjustWindowRect(&r,0,0);
                  obj.handle = CreateWindowExA(WS_EX_TRANSPARENT|WS_EX_TOPMOST,"CONTEXT",title,0,x,y,width,height,0,0,::GetModuleHandle(0),0);

                  The WndProc associated with it is crafted to make it as though the non-client area does not exist; it is not drawn, it does not recieve input, hit tests return true only if the point is inside the client area, and WM_NCCALCSIZE returns WVR_VALIDRECTS|WVR_REDRAW (for now, I will do some custom checking later). For getting the size and position, I use GetClientArea, as the client is effectivly the entire window. The window is filled with a rectangle of its width and height when redrawing. Looking it over it might be that I should use SM_CXBORDER insead of SM_CXFIXEDFRAME, but that would not account for all the missing space.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Despite your previous comment, the above does not use SM_CXSCREEN/SM_CYSCREEN, thus the final values you are using to create your window may not be the full screen size. I also cannot see the point of your call to AdjustWindowRect() in the above. Nor do you show what are the values of width and height. Also what are the initial values of x and y?

                  It's time for a new signature.

                  G 1 Reply Last reply
                  0
                  • L Lost User

                    Despite your previous comment, the above does not use SM_CXSCREEN/SM_CYSCREEN, thus the final values you are using to create your window may not be the full screen size. I also cannot see the point of your call to AdjustWindowRect() in the above. Nor do you show what are the values of width and height. Also what are the initial values of x and y?

                    It's time for a new signature.

                    G Offline
                    G Offline
                    Gwenio
                    wrote on last edited by
                    #9

                    It is an inline function; x, y, width, and height are values passed to it. In the case this thread refers to: x = 0, y = 0, width = GetSystemMetrics(SM_CXSCREEN), height = GetSystemMetrics(SM_CYSCREEN). AdjustWindowRect causes the bottom and right member variables to be adjusted such that if you create a window using them, the height and width of the client area will be equal to the original values of those variables. This is simpler and less error prone than figuring it out myself. Do to the nature of the redraw code as it stood at the time I was doing this, everywhere that was not drawn to would be filled with black. I know this because I am doing the drawing with OpenGL and when I had a matrix out of place (it was the default matrix, so only the upper right was being drawn). So that is not an issue.

                    L 1 Reply Last reply
                    0
                    • G Gwenio

                      RECT r;
                      x -= ::GetSystemMetrics(SM_CXFIXEDFRAME);
                      y -= ::GetSystemMetrics(SM_CYCAPTION)+::GetSystemMetrics(SM_CYFIXEDFRAME);
                      r.right = width;
                      r.bottom = height;
                      AdjustWindowRect(&r,0,0);
                      obj.handle = CreateWindowExA(WS_EX_TRANSPARENT|WS_EX_TOPMOST,"CONTEXT",title,0,x,y,width,height,0,0,::GetModuleHandle(0),0);

                      The WndProc associated with it is crafted to make it as though the non-client area does not exist; it is not drawn, it does not recieve input, hit tests return true only if the point is inside the client area, and WM_NCCALCSIZE returns WVR_VALIDRECTS|WVR_REDRAW (for now, I will do some custom checking later). For getting the size and position, I use GetClientArea, as the client is effectivly the entire window. The window is filled with a rectangle of its width and height when redrawing. Looking it over it might be that I should use SM_CXBORDER insead of SM_CXFIXEDFRAME, but that would not account for all the missing space.

                      S Offline
                      S Offline
                      Stephen Hewitt
                      wrote on last edited by
                      #10

                      What are you actually trying to do? Made a window go fullscreen? If so read this[^] and this[^].

                      Steve

                      G 1 Reply Last reply
                      0
                      • S Stephen Hewitt

                        What are you actually trying to do? Made a window go fullscreen? If so read this[^] and this[^].

                        Steve

                        G Offline
                        G Offline
                        Gwenio
                        wrote on last edited by
                        #11

                        Yes and no, I am doing this because I had once tried to create a fullscreen window and I found an upper limit on the size of a window. This was to see if I had found how to work around that, which I seem to have done. The question is about the possible cause of an oddity I noticed in the process. Thanks for the links, I think they will be useful soon.

                        1 Reply Last reply
                        0
                        • G Gwenio

                          It is an inline function; x, y, width, and height are values passed to it. In the case this thread refers to: x = 0, y = 0, width = GetSystemMetrics(SM_CXSCREEN), height = GetSystemMetrics(SM_CYSCREEN). AdjustWindowRect causes the bottom and right member variables to be adjusted such that if you create a window using them, the height and width of the client area will be equal to the original values of those variables. This is simpler and less error prone than figuring it out myself. Do to the nature of the redraw code as it stood at the time I was doing this, everywhere that was not drawn to would be filled with black. I know this because I am doing the drawing with OpenGL and when I had a matrix out of place (it was the default matrix, so only the upper right was being drawn). So that is not an issue.

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #12

                          I suspect this may have something to do with your values of x and y which look like they may be negative. As I said earlier using values of x=0, y=0, cx=SM_CXSCREEN, cy=SM_CYSCREEN the window will fill the monitor. The values you are using are different from this, thus your results are different.

                          It's time for a new signature.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups