Solved

Bringing Modeless dialog with populated view control from main application

Posted on 2004-05-01
10
408 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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