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. GetWindowRect problem in CFormView::OnInitialUpdate()

GetWindowRect problem in CFormView::OnInitialUpdate()

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 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.
  • H Offline
    H Offline
    hanlei0000000009
    wrote on last edited by
    #1

    void CMyView::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); RECT rect; GetWindowRect(&rect); // rect.top is 227 } void CMyView::OnBnClickedBtnTest() { RECT rect; GetWindowRect(&rect); // rect.top is 30, why? } After OnInitialUpdate() until I clicked test button(run OnBnClickedBtnTest() ), nothing to do.

    D N 2 Replies Last reply
    0
    • H hanlei0000000009

      void CMyView::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); RECT rect; GetWindowRect(&rect); // rect.top is 227 } void CMyView::OnBnClickedBtnTest() { RECT rect; GetWindowRect(&rect); // rect.top is 30, why? } After OnInitialUpdate() until I clicked test button(run OnBnClickedBtnTest() ), nothing to do.

      D Offline
      D Offline
      dehseth
      wrote on last edited by
      #2

      I am not sure but maybe when you get the rectangle in button code, it gives the button's rectange. so plz check if your button's top is 30. if it is 30 then you need to find a way to get the view's rectangle

      1 Reply Last reply
      0
      • H hanlei0000000009

        void CMyView::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); RECT rect; GetWindowRect(&rect); // rect.top is 227 } void CMyView::OnBnClickedBtnTest() { RECT rect; GetWindowRect(&rect); // rect.top is 30, why? } After OnInitialUpdate() until I clicked test button(run OnBnClickedBtnTest() ), nothing to do.

        N Offline
        N Offline
        Nitheesh George
        wrote on last edited by
        #3

        Hi, The MSDN says that "The GetWindowRect function retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen." So may be(am not sure) the window is created (0,0) as top left. Then it is moved to new Co Ordinates When it is displayed. that is why you are getting different co ordinates. My suggestion is that no need to bother about this co ordinates u just use rect. top, rect.left etc. so that your drawing or anything will positioned based on the parent window. thanks Nitheesh

        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