Results 1 to 6 of 6

Thread: CStatic and View

  1. #1

    Thread Starter
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471

    CStatic and View

    I have a CView which is one of three views that is seperated by
    SplitterWnds. In this view i would like to create a CStatic
    object which is in the entire size of the view. I would also like
    it resize when the splitter is moved (thus resizing the view).

    In the OnCreate function of my View i have the following

    Code:
    CRect rect;
    this->GetClientRect(&rect);
    
    m_wndStatic.Create("test", WS_CHILD | WS_VISIBLE | SS_GRAYRECT, rect, this, IDC_STATIC0;
    the create call fails (returns a 1).

    if i deflate the rect by say -10 units for each parameter (top, left,
    right, and bottom) a very small static object shows.

    What am i doing wrong? why is the call to GetClientRect not
    filling the CRect object?

    any help would be greatly appreciated.

    thank you
    Bababooey
    Tatatoothy
    Mamamonkey

  2. #2
    New Member
    Join Date
    May 2002
    Posts
    13
    OnCreate( _ ) method of a window class object used to reaponse the WM_CREATE. At the mean time, the window has just created but not shown yet. That's why the call to method GetWindowRect ( _ ) can get nothing.

    There are many way to correct this problem. One can be the following:

    In OnCreate( _ ) method:

    // some things done

    // then we create the static object
    m_wndStatic.Create("test",
    WS_CHILD | WS_VISIBLE | SS_GRAYRECT,
    CRect(0,0,10,10), this);

    return 0;


    In the method OnSize(UINT nType, int cx, int cy) , stretch the child window m_wndStatic face to fix the parent's size:

    CWnd ::OnSize(nType, cx, cy);

    m_wndStatic.MoveWindow(0, 0, cx, cy);

  3. #3

    Thread Starter
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    where can i put the creation of the static control then?

    i have it after my view calls the base class' OnCreate
    so it should be a window then?
    Bababooey
    Tatatoothy
    Mamamonkey

  4. #4

    Thread Starter
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    ok, nm i got it
    Bababooey
    Tatatoothy
    Mamamonkey

  5. #5

    Thread Starter
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    i' mhaving difficutly centering the static frame within the view
    Bababooey
    Tatatoothy
    Mamamonkey

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Uhhh
    CStatic::Create returns BOOL, where TRUE is defined as 1...
    This means it doesn't fail...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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