Solved

Bringing Modeless dialog with populated view control from main application

Posted on 2004-05-01
10
405 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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 77
How to know only "File created" with EventLog 3 29
fizzArray  challenge 1 47
wait notify demo infinite loop 3 81
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now