#include<windows.h>
#include<math.h>
#include<stdio.h>
int GetRoot(float a,float b,float c,double*root)
{
double delta,deltasqrt;
delta=b*b-4.0*a*c;
if(delta<0.0) return 0;
deltasqrt=sqrt(delta);
if(a!=0.0){
root[0]=(-b+delta)/(2.0*a);
root[1]=(-b-delta)/(2.0*a);
}else
if(b!=0.0) root[0]=root[1]=-b/c;
else return 0;
if(root[0]==root[1]) return 1;
else return 2;
}
char str[80];
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);//窗口过程
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow)
{
HWND hwnd;//窗口句柄
MSG msg;  //消息
WNDCLASS wndclass;   //窗口类
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName="Hello";//窗口类名
if(!RegisterClass(&wndclass))//注册窗口
{
MessageBox(NULL,"窗口注册失败!","HelloWin",0);
return 0;
}
hwnd=CreateWindow("Hello",//窗口类名
"Application窗口",       //窗口标题
WS_OVERLAPPEDWINDOW,        //窗口样式
CW_USEDEFAULT,              //窗口最初的x位置
    CW_USEDEFAULT,              //窗口最初的y位置
CW_USEDEFAULT,              //窗口最初的x大小
CW_USEDEFAULT,              //窗口最初的y大小
NULL,                       //父窗口句柄
NULL,                       //窗口菜单句柄
hInstance,                   //应用程序实例句柄
NULL                        //创建窗口参数
);
ShowWindow(hwnd,nCmdShow);//显示窗口
UpdateWindow(hwnd);       //更新窗口,包括窗口的客户区
    while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);  //转换某些键盘信息
DispatchMessage(&msg);   //将消息发送给窗口过程,这里是WndProc
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,
 WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
    static HWND hButton,hwndEdit[3];
char strEdit[80];
float a[3];
double root[2];
int i;
switch (message) {
case WM_CREATE:  //窗口创建产生的消息
hwndEdit[0]=CreateWindow("edit",
NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,
20,70,100,25,hwnd,NULL,NULL,NULL);
hwndEdit[1]=CreateWindow("edit",NULL,
WS_CHILD|WS_VISIBLE|WS_BORDER,
130,70,100,25,hwnd,NULL,NULL,NULL);
hwdnEdit[2]=CreateWindow("edit",NULL,
WS_CHILD|WS_VISIBLE|WS_BORDER,
240,70,100,25,hwnd,NULL,NULL,NULL);
        hButton=CreateWindow("button","Calculate",
WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
350,70,80,25,hwnd,NULL,NULL,NULL);
return 0;
case WM_COMMAND:    //命令消息,控件产生的通知代码在wParam的高字中
if(((HWND)lParam==hButton)&&(HIWORD(wParam)==BN_CLICKED))  
//按下按钮
{
//获取三个编辑框控件的内容,并将其转换成float数值
            for (i=0;i<3;i++){
GetWindowText(hwndEdit[i],strEdit,80);//获取编辑框内容
a[i]=(float)atof(strEdit); //将字符串转换成float数值
}
            int n=GetRoot(a[0],a[1],a[2],root);
if(n<1)strcpy(str,"方程无根!");
else sprintf(str,"方程的解为:%f,%f",root[0],root[1]);
MessageBox(NULL,str,"方程的根",0);
}
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,10,10,"请输入一元二次方程的系数:",25);
TextOut(hdc,10,40,"a",1);
        TextOut(hdc,120,40,"b",1);
TextOut(hdc,230,40,"c",1);
TextOut(hdc,10,90,str,strlen(str));
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY://当窗口关闭时产生的消息
PostQuitMessage(0);
return 0;
}
//执行默认的消息处理
return DefWindowProc(hwnd,message,wParam,lParam);
}
           错误:Compiling...
CreateControl.cpp
F:\c++代码\CreateControl\CreateControl.cpp(80) : error C2065: 'hwdnEdit' : undeclared identifier
F:\c++代码\CreateControl\CreateControl.cpp(80) : error C2109: subscript requires array or pointer type
F:\c++代码\CreateControl\CreateControl.cpp(82) : error C2440: '=' : cannot convert from 'struct HWND__ *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
执行 cl.exe 时出错.
上了一年c++基础,老师让自己看看MFC,实在有点茫然