The application of tool and Tangrammini components in software Framework four: Basic application

Source: Internet
Author: User

In the last article I introduced the Setcaption and setaction two methods, in this article I will do some basic application.

I've already installed the dialog box with the list control, the tree controls, and edit box three, and now I plan to insert a few nodes in the left side of the tree, and then click on the node to display some information in the edit box, and in the list Control does not display information, but after selecting different nodes in the tree control, the area (area 1th in the first article) displays some additional windows.

I plan to insert three nodes, one root node (ListView), two subnodes (ChildWindow1, ChildWindow2). Select the ListView node to display list control in area 1th, select the child nodes ChildWindow1 and ChildWindow2 display a different form in area 1th respectively. We first add two forms, where I add two dialog objects, corresponding to the generated CMyDialog1 and CMyDialog2 two classes.

Note: The steps to join the dialog box form are as follows:

Enter menu Insert->new form entry, pop-up New from dialog box;

In the New Class dialog box, enter CMYDIALOG1 in name and select CDialog in base class;

In the dialog ID we can customize the ID, here we do not make changes, the remaining items do not fix, and finally click OK to complete the exit;

Modify the added dialog box (Id:idd_mydialog1_dialog) property to select the style as Child,border to none;

Repeat steps 1 to 4 above to complete CMyDialog2 additions;

To distinguish the different interfaces of the two dialog boxes, I put a static Text in the above to make a distinction;

dialog box, we can create two instances of the dialog box, add the two variables of type cmydialog1* and cmydialog2* respectively in the Ctutorial1dlg class M_pmydialog1, m_pmydialog2 The OnInitDialog function body corresponds to two variable allocation space (NEW) and creates an instance (create) with the following code:

m_pMyDialog1 = new CMyDialog1(this);
  m_pMyDialog2 = new CMyDialog2(this);
  m_pMyDialog1->Create(IDD_MYDIALOG1_DIALOG,this);
  m_pMyDialog2->Create(IDD_MYDIALOG2_DIALOG,this);
Next we add the tvn_selchanged message that handles the tree control object. Open the main dialog box source, select the tree controls control and right mouse, select the "Events ..." menu item in the Pop-up shortcut menu, select Tvn_selchanged from the left example table, click the Add and Edit button, The handler function name is Onselchangedtree1,microsoft Visual C + + automatically jumps to the ONSELCHANGEDTREE1 function body, writes the code, finally follows: void Ctutorial1dlg::onselchangedtree1 (nmhdr* pnmhdr, lresult* pResult)
{
nm_treeview* Pnmtreeview = (NM_T reeview*) Pnmhdr;   
//Todo:add your control notification handler code here
*presult = 0;
Htreeitem hitem = pnmtreeview->itemnew.hitem;
if (hitem = NULL) return;   

CString stritemtext = M_wndtree.getitemtext (hitem);
M_wndedit.setwindowtext (_t ("selected: \") + Stritemtext + _t ("\"));

if (stritemtext.comparenocase _t ("ListView")) = = 0)
{
M_wndminictrl.setwnd (_t ("page1_s0001_s0000 "),
(Long) M_wndlist.getsafehwnd ());
}
Else if (Stritemtext.comparenocase (_t ("ChildWindow1")) = = 0)
{
M_wndminictrl.setwnd (_t ("Page1 _s0001_s0000 "),
(Long) M_pmydialog1->getsafehwnd ());
}
Else
{
M_wndminictrl.setwnd (_t ("page1_s0001_s0000"),
(long) M_pmydialog2->getsafe Hwnd ());
}
}

In Stritemtext, the title of the user Selection tree control node is saved, and the call Setwnd (...) is respectively corresponding to the node header. method to install the form object. and displays the user-selected node in edit box.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.