Solved

static contol position

Posted on 2002-07-10
3
183 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa‚Ķ
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 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