Solved

Bringing Modeless dialog with populated view control from main application

Posted on 2004-05-01
10
407 Views
Last Modified: 2013-11-20
Hi, experts

I have CHTMLView as my main application.
When menu item is clicked I would like to bring up my modal/modeless dialog
containing CListView/CListCtrl populated with items.
I need your suggestions for a proper way to do this before i get started.

Thank you
0
Comment
Question by:khlauster
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 19

Assisted Solution

by:mrwad99
mrwad99 earned 60 total points
ID: 10967825
I am sure you know how to create a dialogue; just create it on the handler (that will probably be in the view class) for the menu item that is clicked in.

>> containing CListView/CListCtrl populated with items.

You will need to add all the items to CListView/CListCtrl in OnInitDialog() within the dialogue class; this is the standard place to do such things.  Code specific to that depends on your requirements, but this is definitely the place to do it.

HTH !
0
 

Author Comment

by:khlauster
ID: 10967878
Hi, mrwad99!

I do have Dialog with clistview in it and can be called from my CHTMLView handler
The only thing in a classes pane for my CMyDlg class there is no OnInitDialog() vertual function provided(dialog was created from resource studio)

Any sugestion?

Thank you for your help
 
0
 
LVL 4

Assisted Solution

by:bkfirebird
bkfirebird earned 25 total points
ID: 10967891
Open Classwizard and create a function for the message WM_INITDIALOG ... that will give you InitDialog
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 19

Assisted Solution

by:mrwad99
mrwad99 earned 60 total points
ID: 10967894
If you are using MSVC++, you can open the class via class wizard, and then choose to add handler for the WM_INITDIALOG.  This will add this handler for you.

Be sure to add your code in the appropriate place (i.e. where it says TODO) !
0
 
LVL 19

Assisted Solution

by:mrwad99
mrwad99 earned 60 total points
ID: 10967896
bkfirebird: LOL, bet me by sixty seconds !
0
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 40 total points
ID: 10968221
>> When menu item is clicked I would like to bring up my modal/modeless dialog

Modal or modeless? Modal is simple. Use modeless only if you need to keep view active at the time when dialog is shown. To show modal dialog:

void CMyView::OnMenuItem()
{
    CMyDialog dlg(this);
 
    // Pass here required information for dialog initializing it's members.
    // For example, CMyDialog may contain some list (not list control, just list) which is filled here.
    // Use this information in OnInitDialog to show it in dialog controls.

    dlg.DoModal();
}


0
 

Author Comment

by:khlauster
ID: 10969302
Everything you suggested worked just fine,experts.
Only one thing left unclear for me:

In my OnInitDialog()
I am trying to use the following code to populate my CListView inside my dialog:

      GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT);

      GetListCtrl().InsertColumn(0, "Address", LVCFMT_LEFT, 100, 0);
      GetListCtrl().InsertColumn(1, "City", LVCFMT_LEFT, 100, 1);
      GetListCtrl().InsertColumn(2, "State", LVCFMT_LEFT, 100, 2);

But can not get to GetListCtrl() of CListView
After this one is solved I have to plit the points, I guess

Thank you very much for your participation
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 40 total points
ID: 10970249
GetListCtrl is function of CListView. In dialog you need to add member variable of CListCtrl type (open Class Wizard, select this dialog in combo box, select Member Variables tag). Add CListCtrl variable for list control (for example, m_list_ctrl). Code should be:

m_list_ctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT);
...
0
 

Author Comment

by:khlauster
ID: 10971642
Thank again for your help,experts!
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 10971644
Glad to help.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
zeroFront challenge 7 99
Line meaning 9 86
wordappend challenge 8 180
how to split multiple lines delimiter : 8 99
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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