Get a list of devices (Microsoft Visual Studio 2010) with interface design

Source: Internet
Author: User
Tags visual studio 2010

Similar to the last Fetch device list (Microsoft Visual Studio 2010), New Project->mfc...-> dialog-based completion Class View point open Item double click Caaadlg Click Caaadlg::oninitdial OG copies the last code to TODO and then configures the path like the last:

Make the following settings for the compiler:

Item-->** Properties (ALT+F7)
Configuration Properties-->c/c++--> General--Additional include directory--(the file path where the head file is located is added to the additional directory)


Item-->** Properties (ALT+F7)
Configure the properties-----------Add to the library directory (the directory where the Packet.lib;wpcap.lib is located)


Item-->** Properties (ALT+F7)
Configuration Properties--linker--Add dependency--add "; Packet.lib;wpcap.lib "

Item-->** Properties (ALT+F7)
Configuration Properties-->c/c++--> Preprocessor---preprocessor definition--add "; Have_remote "

The first step is to change the project-project Properties-Configuration Properties-connector-list file-embed list to "no". If it doesn't solve the problem, go to the second step.

Step Two: Check if the computer is a 64bit operating system, if so, continue with the following actions.

Find out if there are two cvtres.exe.

C:\Program Files (x86) \microsoft Visual Studio 10.0\vc\bin\cvtres.exe

C:\Windows\Microsoft.NET\Framework\v4.0.30319\cvtres.exe

Right-click Properties-Details, view both version numbers, delete/rename older versions, or reset the path variable.

The root of the solution is the second step, after removing the old version of Cvtres.exe, you do not need to set the configuration every time.


For example: Del C:\Program Files (x86) \microsoft Visual Studio 10.0\vc\bin\cvtres.exe


Modify the code as follows:


BbbDlg.cpp: Implementing Files

//


#include "stdafx.h"

#include "Bbb.h"

#include "BbbDlg.h"

#include "afxdialogex.h"

#include "Pcap.h"


#ifdef _DEBUG

#define NEW Debug_new

#endif



CAboutDlg dialog box for application "about" menu items


Class Caboutdlg:public CDialogEx

{

Public

CAboutDlg ();


dialog box data

enum {IDD = Idd_aboutbox};


Protected

virtual void DoDataExchange (cdataexchange* pDX); DDX/DDV Support


Realize

Protected

Declare_message_map ()

};


Caboutdlg::caboutdlg (): CDialogEx (Caboutdlg::idd)

{

}


void CAboutDlg::D odataexchange (cdataexchange* PDX)

{

CDialogEx::D odataexchange (PDX);

}


Begin_message_map (CAboutDlg, CDialogEx)

End_message_map ()



Cbbbdlg dialog box





Cbbbdlg::cbbbdlg (cwnd* pparent/*=null*/)

: CDialogEx (Cbbbdlg::idd, pparent)

{

M_hicon = AfxGetApp ()->loadicon (IDR_MAINFRAME);

}


void Cbbbdlg::D odataexchange (cdataexchange* PDX)

{

CDialogEx::D odataexchange (PDX);

DDX_Control (PDX, Idc_combo1, N_conbobox);

}


Begin_message_map (Cbbbdlg, CDialogEx)

On_wm_syscommand ()

On_wm_paint ()

On_wm_querydragicon ()

On_cbn_selchange (Idc_combo1, &cbbbdlg::oncbnselchangecombo1)

End_message_map ()



CBBBDLG message handlers


BOOL Cbbbdlg::oninitdialog ()

{

Cdialogex::oninitdialog ();


Add the "About ..." menu item to the System menu.


Idm_aboutbox must be within the scope of the system command.

ASSERT ((Idm_aboutbox & 0xfff0) = = Idm_aboutbox);

ASSERT (Idm_aboutbox < 0xf000);


cmenu* Psysmenu = GetSystemMenu (FALSE);

if (psysmenu! = NULL)

{

BOOL Bnamevalid;

CString Straboutmenu;

Bnamevalid = straboutmenu.loadstring (Ids_aboutbox);

ASSERT (Bnamevalid);

if (!straboutmenu.isempty ())

{

Psysmenu->appendmenu (Mf_separator);

Psysmenu->appendmenu (mf_string, Idm_aboutbox, Straboutmenu);

}

}


Sets the icon for this dialog box. When the main application window is not a dialog box, the framework automatically

Perform this action

SetIcon (M_hicon, TRUE); //Set Large Icons

SetIcon (M_hicon, FALSE); //Set Small icons


TODO: Add additional initialization code here

pcap_if_t *alldevs;

pcap_if_t *d;

int i=0;

Char Errbuf[pcap_errbuf_size];

/* Get a list of local machine devices */

if (PCAP_FINDALLDEVS_EX (pcap_src_if_string, NULL/* auth is not needed */, &alldevs, errbuf) = =-1)

{

Exit (1);

}

/* Print List */

for (d= Alldevs; d! = NULL; d= d->next)

{

if (d->description)

N_conbobox.addstring (CString (d->description));

}

/* No more device list required, release it */

Pcap_freealldevs (Alldevs);


return TRUE; Returns TRUE unless focus is set to the control

}


void Cbbbdlg::onsyscommand (UINT NID, LPARAM LPARAM)

{

if (NID & 0xfff0) = = Idm_aboutbox)

{

CAboutDlg dlgabout;

Dlgabout.domodal ();

}

Else

{

Cdialogex::onsyscommand (NID, LParam);

}

}


If you add a Minimize button to the dialog box, you need the following code

To draw the icon. For MFC applications that use the document/view model,

This will be done automatically by the framework.


void Cbbbdlg::onpaint ()

{

if (Isiconic ())

{

CPAINTDC DC (this); Device context for drawing


SendMessage (Wm_iconerasebkgnd, Reinterpret_cast<wparam> (DC). GETSAFEHDC ()), 0);


Center the icon in the workspace rectangle

int cxicon = GetSystemMetrics (Sm_cxicon);

int cyicon = GetSystemMetrics (Sm_cyicon);

CRect rect;

GetClientRect (&rect);

int x = (rect. Width ()-Cxicon + 1)/2;

int y = (rect. Height ()-Cyicon + 1)/2;


Draw icon

dc. DrawIcon (x, y, M_hicon);

}

Else

{

Cdialogex::onpaint ();

}

}


The system calls this function to get the cursor when the user drags the minimized window

Show.

Hcursor Cbbbdlg::onquerydragicon ()

{

Return static_cast

}




void Cbbbdlg::oncbnselchangecombo1 ()

{

TODO: Add control notification Handler code here

}

The view to run appears as follows:

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/89/58/wKioL1gQX0OTi6QJAAAfIVn4ZBw638.png-wh_500x0-wm_3 -wmp_4-s_2887779469.png "title=" w{6vedp[xflvuof%8 (~5gk3.png "alt=" Wkiol1gqx0oti6qjaaafivn4zbw638.png-wh_50 "/>


This article from the "12034896" blog, reproduced please contact the author!

Get a list of devices (Microsoft Visual Studio 2010) with interface design

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.