Use Windows desktop search in Visual Studio

Source: Internet
Author: User
1. Create wizard dialog box

When using a specific software, we often use the wizard mode in this program to create new files, the most typical example is to create a webpage file or Word document in frontpage2000 or word2000 using a wizard. After seeing that all other programs can provide a user-friendly wizard dialog box, do you have any impulse? If any, use the following code to create a wizard dialog box:

The following is a reference clip:
Void cmy56_s1dlg: onwiz ()
{
Csheet sheet;
Sheet. setwizardmode ();
Int iret = sheet. domodal (); // return id_wizfinish or idcancel
}
// Reload bool cpropertypage: onsetactive () to control the displayed button

Bool cpage1: onsetactive ()
{
(Cpropertysheet *) getparent ()-> setwizardbuttons (pswizb_back | pswizb_next );
Return cpropertypage: onsetactive ();
}

Bool cpage2: onsetactive ()
{
(Cpropertysheet *) getparent ()-> setwizardbuttons (pswizb_back | pswizb_finish );
Return cpropertypage: onsetactive ();
}

  2. Computer Send and receive dataAs you know, when computers communicate with each other, the TCP protocol is generally used to establish a connection with the host with the specified IP address and communicate with each other. In this process, one Party must assume the server role and wait for the other party ( Customer Therefore, the server needs to establish a listener interface, and then wait for the connection. After a connection is established, a new interface is generated for communication. After creating a set of interfaces, the client can create a connection by simply calling the connection function. The order of data transmission, transmission, and receipt for connected communications is guaranteed. The following code uses the csocket provided by VC ++ to send and receive data:

The following is a reference clip:
/*
The server waits for a connection on port 6802. When the connection is established, the listener interface is closed.
The customer sends a connection request to port 6802 of the server.
*/

Bool cmy63_s1_serverdlg: oninitdialog ()
{
Cdialog: oninitdialog ();

Csocket socklisten;
// Create a local Interface
Socklisten. Create (6802, sock_stream, "127.0.0.1 ");
// Bind Parameters
Socklisten. BIND (6802, "127.0.0.1 ");
Socklisten. Listen (5 );
// Wait for the connection request. m_sockSend is the member variable for communication.
SockListen. Accept (m_sockSend );
// Disable the listener set Interface
SockListen. Close ();
// Start the timer and send data regularly

SetTimer (1,3000, NULL );
}

Void CMy63_s1_serverDlg: OnTimer (UINT nIDEvent)
{
Static iIndex = 0;
Char szSend [20];
Sprintf (szSend, "% 010d", iIndex ++ );
// Send TCP Data
Int iSend = m_sockSend.Send (szSend, 10, 0 );
}

BOOL CMy63_s1_clientDlg: OnInitDialog ()
{
CDialog: OnInitDialog ();
// Create a local Interface
M_sockRecv.Create ();
// Initiate a connection request
BOOL fC = m_sockRecv.Connect ("127.0.0.1", 6802 );
TRACE ("connect is % s", (fC )? "OK": "Error ");
// Start the timer to regularly receive data
SetTimer (1,3000, NULL );
}

Void CMy63_s1_clientDlg: OnTimer (UINT nIDEvent)
{
Char szRecv [20];
// Receive TCP Data
Int iRecv = m_sockRecv.Receive (szRecv, 10, 0 );
TRACE ("received % d byte", iRecv );
If (iRecv> = 0)
{
SzRecv [iRecv] = '';
M_szRecv = szRecv;
Updatedata (false );
}
}

  3. display the toolbar in parallel.

Suppose there are several toolbar in the Windows program window, now we Hope How can we achieve the parallel display of multiple toolbar? Here, we can use the following function to implement this function, which is obtained from the cj60lib function library. The function implemented in the following program is to display the leftof toolbar on the left side of the bar toolbar and display it together in parallel. The following is the main code to implement the function:

The following is a reference clip:
Void ccjmdiframewnd: dockcontrolbarleftof (ccontrolbar * bar,
Ccontrolbar * leftof)
{
Crect rect;
DWORD dw;
Uint N;
// Use MFC to adjust the size of all toolbar
// Ensure that getwindowrec is accurate
Recalclayout (true );

Leftof-> getwindowrect (& rect );
Rect. offsetrect (1, 0 );
DW = leftof-> getbarstyle ();
N = 0;
N = (DW & cbrs_align_top )? Afx_idw_dockbar_top: N;
N = (DW & cbrs_align_bottom & n = 0 )? Afx_idw_dockbar_bottom: N;
N = (DW & cbrs_align_left & n = 0 )? Afx_idw_dockbar_left: N;
N = (DW & cbrs_align_right & n = 0 )? Afx_idw_dockbar_right: N;
Dockcontrolbar (Bar, N, & rect );
}

 

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.