Solved

static contol position

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now