Use of menu bar and status bar

Source: Internet
Author: User

1. tool bar

Assume that a resource file menu bar (idr_menu1) has been created. Now you need to load the menu bar to our dialog box and add it in the oninitdialog () function. The Code is as follows:

// Todo: add additional initialization code // Add // load menu m_menu.loadmenu (idr_menu1); setmenu (& m_menu); m_menu.detach (); // because this is a class member variable, you can skip this sentence, but the local variable must have this

In this way, we can see our menu bar in the running interface. M_menu here is a member variable declared as cmenu. The last line of code is not added here.

After this is done, you can see the menu and perform operations, but the message response is not allowed. When performing a message response to a menu, it is said that the update_command_ui response can be implemented, but I tried and found that there was no response. Finally, I used the Response Message wm_command to implement the menu response. The Code is as follows:

Bool cimporttabledlg: oncommand (wparam, lparam) {// todo: Add dedicated code and/or call the base class int menuid = loword (wparam); caboutdlg dlgabout; cfiledialog fdlg (true, null, null, 6ul, _ T ("executable file (*. EXE) | dynamic link library (*. DLL) | "), (cwnd *) This); tchar szfilename [max_path]; Switch (menuid) {Case id_about: dlgabout. domodal (); break; Case id_open: fdlg. domodal (); lstrcpy (szfilename, fdlg. getpathname (); m_pro.resetcontent (); m_pro.addstring (szfilename); listimporttable (getprohandle (szfilename, false); break; Case id_exit: This-> enddialog (idok); break; default: break;} return cdialogex: oncommand (wparam, lparam );}

Attachment:

2. Status Bar

After a long tangle, I started to use cstatusbar for a long time and didn't show it. Finally, I had to switch to cstatusbarctr.

This method is relatively simple. paste the code first:

Initialization code:

// Set the status bar this-> m_statebar.create (ws_child | ws_visible | sbs_sizegrip, crect (0, 0, 0, 0), this, id_bar); crect RT; this-> getclientrect (& RT); int pnwidth [2] = {RT. width ()/2,-1}; this-> m_statebar.setparts (2, pnwidth); systemtime t; getlocaltime (& T); cstring STR; cclientdc (this); Str. format (_ T ("Current Time: % d seconds"), T. wyear, T. wmonth, T. wday, T. whour, T. wminute, T. wsecond); csize SZ; SZ = dc. gettextextent (STR); this-> m_statebar.settext (STR, 200, 0); this-> m_statebar.settext (_ T ("Preparing... "), 0, 0); settimer (id_bar, 10, null); // id_bar is a custom integer used to identify the status bar.

Status Bar update code:

Void cimporttabledlg: ontimer (uint_ptr nidevent) {// todo: add the message processing program code and/or call the default systemtime t; getlocaltime (& T); cstring STR; cclientdc DC (this); csize SZ; Switch (nidevent) {Case id_bar: Str. format (_ T ("Current Time: % d seconds"), T. wyear, T. wmonth, T. wday, T. whour, T. wminute, T. wsecond); SZ = dc. gettextextent (STR); this-> m_statebar.settext (STR, 1, 0); break; default: break;} cdialogex: ontimer (nidevent );}

The image in 1 already has the effect.

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.