?
Solved

static contol position

Posted on 2002-07-10
3
Medium Priority
?
184 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:sedgwick
[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:sedgwick
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:sedgwick
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 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