#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int data;
struct node *pre;
struct node *next;
} Node;
int get_int(void);
Node* get_node(void);
void insert(Node*p,Node* new_node);
int
main()
{
Node * p;
Node * head = (Node*)malloc(sizeof(Node));
head->pre = NULL;
head->next = get_node();
head->next->pre = head;
printf("please enter the number 'q' to quit:");
while (1)
{
p = get_node();
p->data = get_int();
if (p->data ==0)
break;
insert(head,p);
}
while (head->next!=NULL)
{
printf("%d ",head->next->data);
head->next = head->next->next;
}
return 0;
}
//得到整数
int
get_int(void)
{
int input;
char ch;
while (scanf("%d",&input)!=1)
{
while((ch=getchar())!='\n')
putchar(input);
printf(" is not an integer.\nPlease enter an integer value,such as 25,-178,or 3;\n");
}
return input;
}
//向链表插入新链
void
insert(Node*p,Node* new_node)
{
if (p->next->data == 0)
{
p->next->data = new_node->data;
return;
}
Node* scan = p->next;
while (1)
{
if (scan->data < new_node->data)
{
if (scan->next != NULL)
scan = scan->next;
else
{
scan->next = new_node;
new_node->pre = scan;
break;
}
}
else
{
new_node->pre = scan->pre;
new_node->next = scan;
scan->pre->next = new_node;
scan->pre = new_node;
break;
}
}
}
//获得新节点
Node*
get_node(void)
{
Node* new_node = (Node*)malloc(sizeof(Node));
new_node->next = NULL;
new_node->pre = NULL;
new_node->data = 0;
return new_node;
}
考虑到双链表容易增加删除链的性质,每输入一个数据就立即将其插入到链表中,输入完成排序也完成
MailMessage msg = new MailMessage();
msg.From =new MailAddress("1184349041@qq.com");
msg.To.Add(email);
msg.Subject = "激活";
StringBuilder sb = new StringBuilder();
sb.Append("点击激活");
sb.Append("<a href='http://localhost:2326/yanzheng.aspx?activecode="+activecode+"&id="+id+"'>激活</a>");
msg.Body= sb.ToString();
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
string yh= email.Substring(email.IndexOf('@') + 1);
string hh = "smtp." + yh;
client.Host =hh;
client.Port = 25;
NetworkCredential credential = new NetworkCredential();
credential.UserName = "1184349041";
credential.Password = "1niuguang.";
client.Credentials = credential;
client.Send(msg);
公司项目中一直存在着一个CHtmlView模块来显示URL,但是随着web页面的更新(加入HTML5 and 其它一些比较新的技术)越来越发现使用CHtmlView已经无法满足目前的需求。开始还是试着去修改一些东西去满足当前需要,不过好景不长终于有一天CHtmlView连我们目前的web页面都打不开了,于是决定采用Chrome来作为浏览器引擎。
嵌入到MFC 使用CEF#pragma once
#include <cef_client.h>
class CWebClient
: public CefClient
, public CefLifeSpanHandler
{
protected:
CefRefPtr<CefBrowser> m_Browser;
public:
CWebClient(void){};
virtual ~CWebClient(void){};
CefRefPtr<CefBrowser> GetBrowser() { return m_Browser; }
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE
{ return this; }
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
// 添加CEF的SP虚函数
IMPLEMENT_REFCOUNTING(CWebClient);
IMPLEMENT_LOCKING(CWebClient);
};
接下来就开始修改我们的视图类了:
// CWebView message handlers
int CWebView::OnCreate( LPCREATESTRUCT lpCreateStruct )
{
if ( CView::OnCreate(lpCreateStruct) == -1)
return -1;
CefRefPtr<CWebClient> client(new CWebClient());
m_cWebClient = client;
CefSettings cSettings;
CefSettingsTraits::init( &cSettings);
cSettings.multi_threaded_message_loop = true;
CefRefPtr<CefApp> spApp;
CefInitialize( cSettings, spApp);
CefWindowInfo info;
info.SetAsChild( m_hWnd, CRect(0, 0, 800, 600));
CefBrowserSettings browserSettings;
CefBrowser::CreateBrowser( info, static_cast<CefRefPtr<CefClient> >(client),
"http://192.168.1.21:8080/dialysis/web/page/nav/content.jsp", browserSettings);
return 0;
}调整大小:
void CWebView::OnSize( UINT nType, int cx, int cy )
{
CView::OnSize(nType, cx, cy);
if(m_cWebClient.get())
{
CefRefPtr<CefBrowser> browser = m_cWebClient->GetBrowser();
if(browser)
{
CefWindowHandle hwnd = browser->GetWindowHandle();
RECT rect;
this->GetClientRect(&rect);
// ::SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, SWP_NOZORDER);
::MoveWindow( hwnd, 0, 0, cx, cy, true);
}
}
}如果在编译CWebView出现连接错误可以把libcef_dll_wrapper工程的Runtime Library修改为Multi-threaded Debug DLL (/MDd) 并将Treat warnings as errors修改为No (/WX-)试试。