Jul 25, 2008

Mfc Dialog Trouble - involving listboxes

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > C/C++ Programming

free web hosting

Mfc Dialog Trouble - involving listboxes

switch
hi,

im trying to add stuff to a listbox in a dialog called by my CDocument class

ie.

CODE
CMyDocument::DoSomeStuff()
{
CMyDialog dlg;
dlg.listbox.addString("whatever");

********

dlg.listbox.doModal();
}


do i need to add something at the ******* to refresh my listbox because at the moment it is appearing downright empty. i created it by making a dialog in the resource editor of vc++ .NET 2003 and then using add class wizard, and add member wizard to make the listbox an accessable control.

thanks for your time!

Reply

LuciferStar
try
List->InsertItem (&item);
List->InsertColumn (x,fd->name,LVCFMT_LEFT,strlen(fd->name)*6+16,1);

CODE


  List->DeleteAllItems( ); // 删除当前所有item

  res = mysql_store_result( myData );
  for ( int x = 0; fd = mysql_fetch_field( res ); x++ )
  {
   List->InsertColumn (x,fd->name,LVCFMT_LEFT,strlen(fd->name)*6+16,1);//获取column
  }
  LV_ITEM    item;
  item.mask = LVIF_TEXT;
  item.iItem = -1;
  while ( row = mysql_fetch_row( res ) )
  {
   j = mysql_num_fields( res );
   item.iItem+=1;
   for (int k = 0; k < j; k++ )
   {
    item.iSubItem = k;
    item.pszText=row[k];
    List->InsertItem (&item);
    List->SetItem (&item);
   }
  }

 

 

 


Reply

switch
hmmmm.... thanks but i think that is for mysql....

im using mfc in visual c++ .NET, so it isn't much of a help.

thanks for your time anyway.

Reply

switch
hi again, i finally got stuff sorted out. I was after the mfc dialog UpdateData(FALSE) method after the CListBox.AddString() method but i was putting UpdateData(FALSE) in the Dialog's OnCreate() method. because the control wasn't created yet, the listbox control could not be refreshed (i think).

thanks for your help!

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : mfc dialog involving listboxes

  1. Opengl And Mfc Dialog Based Application - some comments about using it together (7)
    AS you probably know you can create a simple OpenGL applications using WinAPI functionality only
    (you can create it using Microsoft Visual Studio), but if you are making somethink with real windows
    interface and want to create application with multiple windows/dialogs/buttons with Windows Styles
    etc... you can use MFC (Microsoft Foundation Classes) to do it ... But i did a 2 hours web search to
    find example of using OpenGL windows inside MFC created Dialog window. I found it and want to share
    my results now. My application is a simple OpenGL based tool, which shows Ope...
  2. Win32: Dialog Box And Accelerator - Win32 API programming (0)
  3. Program Flow - dialog problem (2)
    Hi, i have a quick question. I have a program that does alot of calculations near its completion.
    To indicate to the user that it is still working so they dont close it I have a dialog box with a
    progress bar pop up. when the dialog comes up, the regular execution of the original program stops
    until I close the dialog, so I was wondering if there is a way to tell the origianl program to keep
    running while the dialog is open(since the original program would be updating the progress metre).
    p.s. using MFC(not by choice) Thanks alot!...



Looking for mfc, dialog, trouble, involving, listboxes

Searching Video's for mfc, dialog, trouble, involving, listboxes
advertisement



Mfc Dialog Trouble - involving listboxes



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE