CListCtrl - Programmer

This is a discussion on CListCtrl - Programmer ; Hello, I have a problem with my CListCtrl ! I have created a class which contains a CListCtrl and I have created a member function which adds a line in this control list! It's a control list with only 2 ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: CListCtrl

  1. CListCtrl

    Hello, I have a problem with my CListCtrl !

    I have created a class which contains a CListCtrl and I have created a
    member function which adds a line in this control list!

    It's a control list with only 2 columns of text.

    But I have a problem when I call this function outside this class ! I have
    tested this function and in the InitDialog() function there is no problem
    !!!

    Could someone help me?
    Thanks for all




  2. Re: CListCtrl

    Hallo "Salim GOMRI", you wrote...

    > Hello, I have a problem with my CListCtrl !
    >
    > I have created a class which contains a CListCtrl and I have created
    > a member function which adds a line in this control list!
    >
    > It's a control list with only 2 columns of text.
    >
    > But I have a problem when I call this function outside this class !


    Which kind of problem?! Nobody can help you, if you do not describe the
    problem a little more concretely. A small code example would be helpful.

    Greetings,
    Stephan
    --
    ....und Informatiker brauchen doch eine Freundin:
    Irgendjemand muss sie ja waschen und anziehen!

  3. Re: CListCtrl

    thanks for all man

    you are very cool !!


    "Mihajlo Cvetanovic" a écrit dans le message news:
    3F1E6948.6060705@RnEeMtOsVeEt.co.yu...
    > Salim GOMRI wrote:
    > > myDialog.DoModal();
    > > for (int i=0; i<80;i++) {
    > > str.Format("%d",i+1);
    > > myDialog.AddLine(i,str);
    > > }
    > > myDialog.SetRedraw();

    >
    > You can't manipulate controls before DoModal is called, because the
    > window (and the controls) don't exist yet. You can't do it after
    > DoModal because the window is already closed.
    >
    > You can manipulate controls from message handlers of your application.
    > In your case this for-loop should be in OnInitDialog message handler.
    > In your case for-loop doesn't need any data from outside, but if you
    > need a for-loop with some outside data, then you should pass that data
    > to some member of the myDialog object (before DoModal is called, and
    > ofcourse after myDialog is created), so that you'll have them in
    > OnInitDialog.
    >




  4. Re: CListCtrl

    Hello "Salim GOMRI", you wrote...

    > Yeah Stephan !
    >
    > I have got a function outside my dialog class which gives me
    > elements to put into the listctrl.
    >
    > This is the code :
    > CDialogHoles myDialog(NULL);
    > CString str=_T("");
    >
    > myDialog.DoModal();


    At this point the dialog will be shown modal. That means, that the
    program enters the dialogs modal loop and has no interaction with the
    application's main message loop anymore. The following lines of code are
    executed only after leaving the dialogues own message loop by closing
    the dialog box (OK or Cancel), but the problem is, that the dialogs
    window doesn't exist anymore after closing.

    > for (int i=0; i<80;i++) {
    > str.Format("%d",i+1);
    > myDialog.AddLine(i,str);
    > }
    > myDialog.SetRedraw();


    There are two ways to solve the problem:

    1. Create a modeless dialog.

    or

    2. Call the AddLine() method inside the dialogue class, for example by
    treating the message WM_INITDIALOG (virtual BOOL OnInitDialog() is the
    correct message handler).

    Hope that helps,
    Stephan
    --
    ....und Informatiker brauchen doch eine Freundin:
    Irgendjemand muss sie ja waschen und anziehen!

+ Reply to Thread