|
Hi.
I implemented a listview in a program. It works great, but not perfect. I have experience problems. First, the listview insert and display new item perfectly the if it was empty before insertion. For example.
// assume listview is empty
-----
CListView &lc = GetListCtrl();
for (int i = 0; i < 10; ++i)
lc.InsertItem(0, "testing");
-----
The code above will insert ten "testing" strings into the listview control. CListView will update the window with the ten items. However, let say that I want to add more items. Here is a technique I use.
-----
CListView &lc = GetListCtrl();
lc.DeleteAllItems();
int i;
for (i = 0; i < 10; ++i)
lc.InsertItem(i, "testing");
// inserting new lines
for (int j = i; i < 20; ++j)
lc.InsertItem(j, "new items");
Okay. The code above should work. However, sometimes CListView will not display the updated data. Again, in the example above, the program will not update the window with "new items." This seems to happen when I start to add a lot of items (100 or more). Is there some kind of a limit on the CListCtrl?
What is the proper way to add, remove, and clear a CListCtrl *and* properly redraw everything correctly?
Thanks,
Kuphryn
|
|
|
|
|
try doing
lc.UpdateWindow();
at the end of your loop
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
kuphryn wrote:
// inserting new lines
for (int j = i; i < 20; ++j)
lc.InsertItem(j, "new items");
I'd assume this is a typo, but just in case: you should be comparing j not i to 20:
for (int j=i; j<20; ++j)
--------
all the modern things
have always existed
they've just been waiting
to come out
and multiply
and take over Björk, The Modern Things
|
|
|
|
|
Try this for appending content to your list control:
for (int j=lc.GetItemCount(); (j < 20); ++j) {
lc.InsertItem (j, "A new item");
}
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks.
The reason it did not update the screen was because the window was focused. The solution is to redraw whenever the window is in focus.
Kuphryn
|
|
|
|
|
Thanks.
The reason it did not update the screen was because the window was focused. The solution is to redraw whenever the window is in focus.
Kuphryn
|
|
|
|
|
I am making a dialog based program with MFC and now I want to make a new class for node-management. But when I try to make one in classwizard it wants me to derive it from another class... but I don't want to. Or which class should I derive it from?
|
|
|
|
|
What about right click on the ClassView (TreeView at your left), New Class
and then make sure that the Combo named "Class Type" says Generic Class.
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Hey...I'm making a program in Win API with <windows.h>...
I'm having a problem where my program will look fine in one resolution, like 800x600, but when I run the program in 640x480 or 1024x768, it's much bigger or smaller than it should be.
Is there some sort of way to get the screen size and size the window according to it? How can I do this? Help would be appreciated =)
Thanks - Dave
|
|
|
|
|
Sure. Do this to get the screen size:
RECT rectScreen;
VERIFY (GetWindowRect (GetDesktopWindow()), &rectScreen));
or
RECT rectScreen;
VERIFY (SystemParametersInfo (SPI_GETWORKAREA, 0, &rectScreen, 0));
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi,
does anybody know of a way to create a small program (ie what functions to use) that can change the icons of executables, similar to a pared down MicroAngelo or IconChanger? I was looking at BeginResourceUpdate() etc, but they are NT-only. My program copies an executable to another folder with certain settings stored in an INI file; I want the user to be able to choose the icon of the executable, thus I need to change it when it is copied (hope that makes sense). Is there a good way of doing this?
If anybody has any ideas, I would be very grateful.
Many thanks,
Keith
|
|
|
|
|
As you pointed out, BeginResourceUpdate and related functions are NT/2k/XP only. Fortunately, Erik Kallen wrote an amazing clone of this set of functions that works for 9x/ME systems as well: see his article Updating Resources on Win9x.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your reply, I'll check it out.
Cheers,
Keith
|
|
|
|
|
I need to edit the compiler created com files
*.tli and *.tlh.
How can I do it? if it isn't posible then do I have to delete and then recreate the object?
thanks,
Aviv.
avivhal
|
|
|
|
|
You can do this, but it's probably not recommended. Just remove the #import statement after you've compiled the first time as that statement will continually overwrite your modifications. Also, make sure that both files are in the project so that they get compiled and linked.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Thanks but I couldnt find the #import anywhere in the project nor in the tli , tlh files.
it seems like the compiler ignores my changes completely and reloads the files from somewhere... I don't know where.
Aviv.
avivhal
|
|
|
|
|
I'm going to need some more info to go on then. What tli and tlh files are you referring to? How did they get added to your project?
As an example of what I'm getting at, if I want to use the C++ wrappers for the ADO 1.5 COM interface, I simply use a #import which automatically creates a tli and tlh file and adds them to my project's build. This #import is typically located in the stdafx.h file.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
How do you update an edit box that holds an int?
I have asigned an int called m_nNumber to the edit box... then i change it and I would like it to show the change in the edit box
|
|
|
|
|
Call UpdateData(FALSE)
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Thanks!I am grateful for people that answers my stupid newbee questions
|
|
|
|
|
Hey mate. We all started out where you are. Don't even worry about it.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
By the way, I'm assuming that m_nNumber is a DDX variable already associated with the control in your DoDataExchange function.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
I'm e-mailing using SMTP, and in most cases there's no problem, but many e-mails get bounced back with an error "Domain of sender address xxx@yyy.com does not exist" where the e-mail address it says is my sender address and is a valid e-mail address.
I'd really appreciate it if anyone can shed any light on this problem and how to fix this.
Thanks,
Mark
|
|
|
|
|
I´m creating an application that has a control bar. This control bar is dockable and has a combobox inside of it. I´ve created the resource dialog bar and added the combobox to it. When my app loads, my control bar doesn´t have the default control bar layout (with the border and that dragging grip on the left). I´ve readed MFC docs and it says that to a control bar use the default layout you need to define the dialog resource id with an id between AFX_IDW_CONTROLBAR_FIRST (59392) and AFX_IDW_CONTROLBAR_LAST (59647). I´ve defined an ID with AFX_IDW_CONTROLBAR_FIRST + 32 and after the resource editor goes completly nuts, stating that I can only define resourceID between 1 and 32767. Anyone know how to solve this ? Do I need to create this dialog bar in a different way ?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 Trank
I´ll take your brain to another dimension, I´ll take your brain to another dimension, I´ll take your brain to another dimension... Pay close attention...
|
|
|
|
|
Mauricio Ritter wrote:
Do I need to create this dialog bar in a different way ?
How are you creating it now? There are a few styles that control borders (CBRS_GRIPPER , etc.) that need to be present during creation.
--------
all the modern things
have always existed
they've just been waiting
to come out
and multiply
and take over Björk, The Modern Things
|
|
|
|