Solved

static contol position

Posted on 2002-07-10
3
181 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
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
gurly earned 50 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 96
fizzArray2 challenge 1 90
no14 challenge 14 70
JQuery serialize and unserialize 8 135
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

839 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