CView OnInitialUpdate does NOT have correct size yet? - Programmer

This is a discussion on CView OnInitialUpdate does NOT have correct size yet? - Programmer ; I am running into a problem, I noticed OnSize gets called a 3 times in CView, 1st time is 0,0, 2nd time it has some kind of cx, cy, 3rd time it is finalized. The problem is in OnInitialUpdate I ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: CView OnInitialUpdate does NOT have correct size yet?

  1. CView OnInitialUpdate does NOT have correct size yet?

    I am running into a problem,

    I noticed OnSize gets called a 3 times in CView,

    1st time is 0,0, 2nd time it has some kind of cx, cy, 3rd time it is
    finalized.

    The problem is in OnInitialUpdate I call a function which requires the
    final size (3rd OnSize call's values) to work correctly. But
    OnInitialUpdate only gets up to the 2nd call's OnSize.

    I am sure someone has had this problem before? This is similar to
    that in OnInitialDialog, you do not want to query size information
    since the window might not be moved or centered etc.

    I have tried to put a PostMessage(WM_CUSTOM_MSG) in OnInitialUpdate
    and call my function in my Custom message handler. That is guaranteed
    to have the final size then. However I feel it's not a nice fix to
    the problem.

    If anyone knows how to solve this problem please help. Thanks in
    advance.

  2. Re: CView OnInitialUpdate does NOT have correct size yet?

    Hi,
    if your code needs to be called with proper size information, its better to
    place a call to this function inside OnSize() handler. This will solve the
    problem of further resizing of your View.
    Yes, the WM_SIZE message may be sent several times to window during its
    construction. Usually I check the existance of child controls in my OnSize
    handler and perform actual work only when all children are constructed.

    --
    WBR, Vitaly Brusentsev,
    AWinstall development team.
    http://www.awinstall.com mailto:vb@awinstall.com

    "jj3000" wrote in message
    news:3ed9e158.0310101548.4d27dd3d@posting.google.c om...
    > I am running into a problem,
    >
    > I noticed OnSize gets called a 3 times in CView,
    >
    > 1st time is 0,0, 2nd time it has some kind of cx, cy, 3rd time it is
    > finalized.
    >
    > The problem is in OnInitialUpdate I call a function which requires the
    > final size (3rd OnSize call's values) to work correctly. But
    > OnInitialUpdate only gets up to the 2nd call's OnSize.
    >
    > I am sure someone has had this problem before? This is similar to
    > that in OnInitialDialog, you do not want to query size information
    > since the window might not be moved or centered etc.
    >
    > I have tried to put a PostMessage(WM_CUSTOM_MSG) in OnInitialUpdate
    > and call my function in my Custom message handler. That is guaranteed
    > to have the final size then. However I feel it's not a nice fix to
    > the problem.
    >
    > If anyone knows how to solve this problem please help. Thanks in
    > advance.




+ Reply to Thread