Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

static contol position

Posted on 2002-07-10
3
Medium Priority
?
186 Views
Last Modified: 2013-11-20
i'd like to create dynamically static controls on a dialog.
each control need to be positioned next to a list item, as follows"
        |List Header1|List Header2|
        ---------------------------
static1 |item1       |            |
static2 |item2       |            |
static3 |item3       |            |
.
.
.
the problem is that i can't get to position them i the right place.
here's my code:

     CRect r;
     CLed* pLed; //CStatic derive class
//m_listCtrlActions - my list control
//m_arrLeds - CArray<CLed*, CLed*>

     for(int i=0; i<m_listCtrlActions.GetItemCount(); i++){
          m_listCtrlActions.GetItemRect(i, r, LVIR_BOUNDS);

          m_arrLeds.Add(pLed = new CLed());
          pLed->Create("", WS_CHILD|WS_VISIBLE|SS_CENTER|WS_BORDER,
               CRect(r.left,r.Height()+r.top, r.left+30, r.Height()+r.top+15), this);
     }

what i'm doing wrong?
0
Comment
Question by:Meir Rivkin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
gurly earned 200 total points
ID: 7145370
Try the following:


     for (i=0 ; i<m_listCtrlActions.GetItemCount() ; ++i)
     {
          CRect r;
          m_listCtrlActions.GetItemRect(i, r, LVIR_BOUNDS);
          m_listCtrlActions.ClientToScreen(r);
          ScreenToClient(r);
                m_arrLeds.Add(pLed = new CLed());
          pLed->Create("lala", WS_CHILD|WS_VISIBLE|SS_CENTER|WS_BORDER,
            CRect(r.left-r.Width(),r.top, r.left-30, r.Height()+r.top), this);
     }


The rect you get from CListCtrl::GetItemRect is relative to the top left corner of the list control.
0
 
LVL 42

Author Comment

by:Meir Rivkin
ID: 7145425
it doesn't look good, it display a half black rectangle for some reason.
i want the controls to be the same height as the item in the list while its width should be 50.

did u run it?
0
 
LVL 42

Author Comment

by:Meir Rivkin
ID: 7145435
sorry,it wasn't because of the location i just forgot to load the bitmap on the static control.

cheers for the comment.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question