CListCtrl question: dock columns to right

I have a CListCtrl which is a child of a resizable dialog. (The list control
changes its size when the dialog is resizing).
I need that the columns of the list will always be aligned to the right.
All the columns (accept the first) have a fixed size.
In order to achieve this behaviour I catch the WM_SIZE event of the list
control and call to SetColumnWidth of the first column.
The width that I set to the first column is the width of the list control
minus the sum of the width of all other columns. (see code at
the end of the question).
Generally it works fine, but I get the most strange behaviour after doing
(as a user) the following:
1. Resize the dialog (make it smaller) so a vertical scroll-bar will pop in
the list.
2. scroll the list to the bottom.
3. Resize the dialog (enlarge it) so the scroll-bar will disappear.

Now I get an invalid appearence of the list-control:
There are seems to be empty items at the top (the first item is positioned
not at the top of the list control, it appears after some
empty lines...).

My code:
void CRightAlignListCtrl::OnSize(UINT nType, int cx, int cy)
    CListCtrl::OnSize(nType, cx, cy);


void CRightAlignListCtrl::RightAlign()
    // Get the list control size
    CRect r;

    int aColumnsWidth = 0;
    int aColumnCount = GetHeaderCtrl()->GetItemCount();
    for(int i = 1; i < aColumnCount ; i++)
         int aColWidth = GetColumnWidth(i);
         aColumnsWidth += aColWidth;

    int aFirstColumnWidth = r.Width() - aColumnsWidth;
    SetColumnWidth(0, aFirstColumnWidth);

Can anyone please help (suggest a fix to the problem or advise another
solusion to gain the desired behaviour) ??

yoav (105)
10/1/2003 2:20:57 PM
vc.mfc 33608 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 25


Similar Artilces:

Access 97 Runtime question
We are using Access 97 runtime for some of our staff. I noticed today that in reports if they right mouse click, they don't get a shortcut menu. I want them to be able to Export the report they are viewing. Would Access 2003 runtime have the shortcut menu? Thanks Kelvin "Kelvin Beaton" <kelvin dot beaton at mccsa dot c o m> wrote in message news:uiQA0i7zHHA.1168@TK2MSFTNGP02.phx.gbl... > We are using Access 97 runtime for some of our staff. > I noticed today that in reports if they right mouse click, they don't get > a shortcut menu. I want them to be...

Optimiztion question
I was looking at MSDN on optimizing queries ( and am unclear as to why a foreign key relationship affects the query in this case. At the beginning of the article it gives an example and starts out by saying: The sample screen shot in Figure 14.2 shows an execution plan that accesses only one table, although two tables are included in a join in the query. Because there is a declared foreign key relationship between the authors table and the titleauthor table, and the au_id column in the titleauthor table is not allowed to b...

How to use MSExcel to plot Column A against Col B?
I want to plot col A (x axis) against col B ( y axis). I cant seem to do it. Can anyone here please give me step by step primer. Thanks in advance. All I get is the graph of (1,2,............n) (x axis) against the n values of either col A or B. i.e 2 graphs instead of one. (In the old Lotus this was so simple: select the column for the X axis and then select the col for the Y and press enter, and you'd get the chart) Why is it so diff in Excel? Select the entire range you want to graph such as a2:b44>insert>chart>>>> -- Don Guillett SalesAid Software dguillett1@au...

Hope you folks can help me out with a strange one. I have several worksheets formatted in exactly the same way as follows: Col A - width 4 Col B - hidden Col C - width 4 Col D - Width 108 Col E - Width 3 Col F - Width 11 Col G - Hidden Col H - Width 11 & Empty My print range should be Cols A:G (I have used page setup to set the scaling to fit 1 page wide by [blank] pages tall, thus each sheet will print as many pages as required depending on number of rows] When I have the print range set to A:G only columns A:E show on the print preview (and also on the actual print out) and when I m...

initial default column width
Is there a way to configure Excel 2000 so that when I create a new Workbook or add a new Worksheet so that all the columns have a particular width instead of the default 64 pixels? TIA Create the workbook exactly the way you want it, then save it as a template with the name "Book.xlt" (no quotes) in you XLStart directory. It'll be then used as the template for new workbooks. Likewise, save a one-sheet workbook as a template, named "Sheet.xlt" for the template for Insert/Worksheet. In article <>, Bruceh <

Windows and Mac have two distinctly different units for column width.
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel I am trying to format columns for some data I am entering in a spreadsheet and when I enter &quot;15.00&quot;, which is the required width for these columns given by my professor, I end up with a column 15 inches wide. What I would prefer is for the options to be like the default options in Windows version of Excel. In Windows version of Excel, when you hover over the lines between the columns it gives you two numbers (e.g. 8.43 (64 pixels)). These are the default numbers for column width in Windows Excel....

Macros/Signatures Question
I have an Excel Workbook that I created for a PC Order Form. I set it up to only make certain rows visible based on the Machine Model that they choose. I digital signed the Worksheets and exported the Digital Signature Certificate and installed it on the User’s PCs. The code works great. The user opens the Workbook and it runs the Macros with no problem. The problem I have is when the user goes to save the Workbook. They get an error that “Excel can not sign VBA macros when saving to this file format. Do you want to remove the digital signature and continue saving this workbook?”...

How to assign unique number to column duplicates?
Hi All, I need to assign a unique number to a set of duplicates all in one column in Excel 2007. so columnA will has about 9000 numbers, some of them unique, and others are duplicates of 2-4 approx. I used to conditional formatting to show which are duplicates, but need to be able to assign a unique number to each set duplicates, that will be in sequential order... e.g. ColumnA ColumnB(unique ID) 01233 0001 01233 0001 01234 - 01255 0002 01255 0002 etc.... Any ideas please? I don't know how to do programming, just form...

Simple IMAP question
Hi, How do I enable shared calendar with free/busy information through IMAP ? When I add the "calendar" folder in IMAP it displays as a mail folder, not a calendar. Pierrot Is this calendar a mailbox or public folder? Why are you using IMAP instead of MAPI? MAPI is much more feature complete as it applies to this sort of thing. -- Ed Crowley MVP - Exchange "Protecting the world from PSTs and brick backups!" "Pierrot Robert" <> wrote in message news:%23NzXwrV6GHA.4352@TK2MSFTNGP05.phx.gbl... > Hi, > > How do I...

Exchange 2003 Question??
Dear all, I would like to know if there is an upgrade path from Exchange 2003 Standard Edition with SA to Exchange 2003 Enterprise Edition with SA? Thank you. Regards, Kueh. This might help;en-us;170280 -- Santhosh Sivarajan MCSE(W2K/NT4),MCSA(W2K3/W2K/MSG),CCNA,Network+ "KA Kueh" <> wrote in message news:exVKwgOKEHA.1040@TK2MSFTNGP10.phx.gbl... > Dear all, > > I would like to know if there is an upgrade path from Exchange 2003 Standard > Edition with SA to Exchange 2003 Enterprise Edition wit...

Macro Question #10
Hi, I am working with a text file that I imported into Excel. It is a transactional report of sales by customer. The data will have the customer number and name spread out over three cells. What I want to do is to create a macro that will contatenate all three cell and then perform a paste special and paste them into another cell in another column. Since the number of transactions by customer can vary the customer name and number can appear anywhere on the page. I created a macro to do this using the first customer which appears in cell B5 through D5. The next customer appears...

question about leaving messages on server
My husband and I have 1 POP mail account. I am accessing it from a computer in Virginia, where I'm staying with relatives. He is accessing the same account from California. I have my Outlook set up to keep messages on the server, but to delete them after 1 day (so that he will still get the messages, but the server won't get clogged). His email program, Eudora, is set up so the messages will be deleted from the server after he downloads them. Is there a chance I won't get some messages because he has his computer set up that way? (He downloads it 1st, then it gets deleted off serv...

Filter two columns with criterion applying to one or the other?
Hi, I am looking for a solution to the following filtering problem: I have two adjacent columns, so using a filter for both of them is no problem. But what I want to do and don't know how to do is this: I want to filter for values greater than x (a certain number, in my case 5000) in any of the two columns. I can filter both columns for x greater than 5000 but that filters out more than I want because there may be some cells with a value greater than 5000 in only one of the two columns. Is there a solution to this problem (using Excel alone or an add-on)? Peter Hi Peter you can use th...

Filtering question
Is there a way to expand the filter option so that it shows 1 row (or more), both above and below any row that contains the value I am looking for? Data|filter|autofilter examines each cell/row on its own. Maybe you can put the key value for each group on the rows you want. Then filter by that column. richzip wrote: > > Is there a way to expand the filter option so that it shows 1 row (or more), > both above and below any row that contains the value I am looking for? -- Dave Peterson ...

Vlookup, multiple times in one column summing corresponding
I have a list that contains common invoice numbers that appear multipl times in column A and need to use the vlookup function to find and su the corresponding amounts in column B. As you would be aware the following vlookup functio =VLOOKUP(A3,DATA,2,FALSE) will only return the one amount once i reaches a match and I need it to continue down the column and sum al matching invoice numbers. Column A Column B 145768 356.87 145769 678.90 145880 80.87 * 145769 103.55 145770 56.90 145769 78.32 145880 54.09 * The answer I�m looking to return is 145880 134.96 It has to be a vlookup sty...

Questions on migration from VS2005 to VS2010
Hi folks, As is the case every couple of years, I go through a nerve-wracking transition to a new development environment. The thing is, I've become really comfortable with VS2005, and our small team has a very simple and effective approach to development. I am nervous that VS2010 will negatively effect our productivity; but don't want to get too "far behind" toolset versions. So, that being said, I wanted to ask a few questions on what to expect when moving from VS2005 to VS2010 on an upcoming project. Your feedback is highly appreciated. Question...

New to Money 2006
I was using Money 2004 and upgraded it to 2006 last night (God only knows, why :)). I started to hate the idea of Passport and Web Publishing my account details and so did not choose the Passport option. I was able to install with regular Money stand alone password and still update all my accounts by downloading them from the respective financial institutions (as I used to do with 2004). The problem is with MBNA America. I want to download the credit card transactions. But the online setup process is asking me for passport setup. I looked at the description of this bank on Microsoft site...

upload form problem / server question / win xp / frontpage 2003 Want to create a form with upload file form field - i read on this forum that the server type i use is important - it should be a windows type server with frontpage extensions - i currently use a linux server with front page extensions - do i need to change to a windows server? Thanks for taking a looka t my question. Joyce Yes, you must have a Windows Server, just like you stated you read. -- Tom [Pepper] Willett Microsoft MVP - FrontPage Since 1997 --------------------------- "threademporium" <threademporiu...

Extract Values from a Column
I have a worksheet used to track time spent on various jobs. One column is for the JOB # while others are for descriptions, etc. I would like to have formulas or possible a macro (if necessary) to sum the time spent on different jobs. For example, say (for simplicity) that each row is equal to 1 unit of time. Then in this row I put 342 for JOB # 342. After the entire day I have worked on say 5 different jobs. I would like to have a cell that says "Total time spent on Job # 342" and then next to it a formula that would look at the column and count all the values that are equal t...

Outlook 2003 question #4
Hi ... I have 4 email accounts with outlook 2003 and they are all from the same isp provider ... My problem is when i am going to create an email to someone i can't tell which email account is sending the email to , its usually set a default ... What i mean is that when i view my email accounts they are listed as so and so default , # 1 , # 2 , # 3 , I don't know what 1 or 2 or 3 are ... Is there a way to notice which email account is which beside having numbers beside them ... I can't tell which is which ... It would be better if you could view the actual name of the ema...

HQ Reports
In the HQ report 'Work Orders - Detailed' one of the default columns is Order #. I am hoping to enable the magnifying glass on this field that would take me straight to the journal for that transaction. I do have my journals being uploaded. Is this a reasonable wish? Can you point me in the right direction? Thanks, Tom -- The worst words in business: "We''ve always done it that way" -- Stop Fishing for eMail. TT, Try; DrillDownFieldName = "[Order].ID" In the Order # column section. -- * Get Secure! - You must be usi...

Can I add more columns to a spread sheet or is limit 256 columns
I am trying to produce an Excel spread sheet with at least 370 columns in one spread sheet but the limit seems to be set at 256. Is it possible to increase this number? Grit your teeth and wait for the next version of XL (12), and you'll have all you need!<g> Check out the new specs here: -- Regards, RD --------------------------------------------------------------------------- Please keep all correspondence within the NewsGroup, so all may benefit ! --------------------------------------------------------------------------- "Pi...

Tax Collected Question
Is there a report to run that will show the tax that has been paid by the customer and not on the tax that was collected via a tender? Or is there a report to run that shows invoices have been paid by check, credit card, or cash that leaves out those tendered to account? We would like to be able to pay taxes on what has been paid to us and not what we are waiting on for payment. hi send me your email I will forward you some interesting reports for your below issue. "bevans22" wrote: > Is there a report to run that will show the tax that has been paid by the > custome...

When Generating Report don't show columns which are empty
Hi, >I have project in MS access. >In that project I am generating some reports for my company. >Now In my form I have one combobox(PalletNo_combo) >when I select an item from combobox and then click on search button then it will generate Report on search criteria. >Now in that report I have 15-20 fields like PalletNo,OrderDate,CustmerCode,ShippingLocation,Ca rtons,PartialCartons,ShippedDate,TotalQuantity,Shi ppedQuantity etc >Now when Report gnerated I have column PartialCarton which is empty sometimes bcz of Null value inside it. >So I don't want to show it in report...

Questions regarding Data center operation
Hi, I have over 8 years of IT experience but very new to the Data Center space and have 4 questions. If someone can answer, I would really appreciate! You can consider these questions more of a brainstorming ideas. 1. If a facilities capacity is re-classified as 5 MW lower than it was previously, what needs to happen here? 2. We need to expand Network capacity at a facility by 2 times but for only 20% more money, how can we do it? 3. Where to start if you are responsible for tech refresh in existing facility? 4. During tech refresh planning you find out about a delay in delivery...