| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 757 人关注过本帖
标题:请教高手,我是初学者,问题出在哪,谢谢啦!
只看楼主 加入收藏
radio983
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-6-11
收藏
 问题点数:0 回复次数:3 
请教高手,我是初学者,问题出在哪,谢谢啦!
# include <windows.h>
# include <stdio.h>

LRESULT CALLBACK WinSunProc(
    HWND hwnd,
    UINT uMag,
    WPARAM wParam,
    LPARAM lParam
)


int WINAPI WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
 )
{
    WNDCLASS wndcls;
    wndcls.cbClsExtra=0;
    wndcls.cbWndExtra=0;
    wndcls.hbrBackgroud=(HBRUSH)GetStockObject(BLACK_BRUSH);
    wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
    wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
    wndcls.hInstance=hInstance;
    wndcls.lpfnWndProc=WinSunProc;
    wndcls.lpszClassName="radio983";
    wndcls.lpszMenuName=NULL;
    wndcls.style=CS_HREDRAW | CS_VREDRAW;
    RegristerCLASS(&wndcls);

    HWND Hwnd;
    Hwnd=CreateWindow("radio983","抄袭编程",WS_OVERLAPPEDWINDOW,
        0,0,800,600,NULL,NULL,hInstance,NULL);
    ShowWindow(Hwnd,SW_SHOWNORMAL);
    UpdateWindow(Hwnd);

    MSG msg;
    while(GetMessage(&msg,NULL,0,0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}

LRESULT CALLBACK WinSunProc(
    HWND hwnd,
    UINT uMag,
    WPARAM wParam,
    LPARAM lParam
)
{
    switch(uMag)
    {
    case WM_CHAR:
        char szChar[20];
        sprintf(szChar,"char is %d,wParam);
        MessageBox(hwnd,szChar,"radio983",0);
        break;
    case WM_LBUTTONDOWN:
        MessageBox(hwnd,"mouse clicked","radio983",0);
        HDC=hdc;
        TextOut(hdc,0,50,"抄袭",strlen("抄袭"));
        ReleaseDc(hwnd,hdc);
        break;
    case WM_PAINT:
        HDC=hDC;
        PAINTSTRUCT ps;
        hDc=BeginPaint(hwnd,&ps);
        TextOut(hDc,0,0,"偷袭",strlen("偷袭"));
        EndPaint(hwnd,&ps);
        break;
    case WN_CLOSE:
        if(IDYES==MessageBox(hwnd,"是否真得结束?","radio983",MB_YESNO))
        {
            DestroyWindow(hwnd);
        }
        break;
    case WN_DESTORY:
        PostQuitMessage(0);
        break;
    default:
        return DfeWindowProc(hwnd,uMag,wParam,lParam);
    }
    return 0;
}

————————————————————————————————————————————
--------------------Configuration: winmain - Win32 Debug--------------------
Compiling...
winmain.cpp
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(12) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(12) : error C2143: syntax error : missing ';' before '__stdcall'
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(22) : error C2039: 'hbrBackgroud' : is not a member of 'tagWNDCLASSA'
        d:\vc98\include\winuser.h(1184) : see declaration of 'tagWNDCLASSA'
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(30) : error C2065: 'RegristerCLASS' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(58) : error C2001: newline in constant
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(59) : error C2146: syntax error : missing ')' before identifier 'MessageBoxA'
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(63) : error C2513: 'struct HDC__ *' : no variable declared before '='
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(63) : error C2065: 'hdc' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(65) : error C2065: 'ReleaseDc' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(68) : error C2513: 'struct HDC__ *' : no variable declared before '='
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(68) : error C2065: 'hDC' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(70) : error C2065: 'hDc' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(70) : error C2440: '=' : cannot convert from 'struct HDC__ *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(74) : error C2065: 'WN_CLOSE' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(74) : error C2051: case expression not constant
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(80) : error C2065: 'WN_DESTORY' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(80) : error C2051: case expression not constant
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(84) : error C2065: 'DfeWindowProc' : undeclared identifier
执行 cl.exe 时出错.

winmain.exe - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: include 
2008-06-11 16:05
ipx
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-6-12
收藏
得分:0 
代码已帮你改正确了,太不认真了.你很多字打错了
# include <windows.h>
# include <stdio.h>

LRESULT CALLBACK WinSunProc(
    HWND hwnd,
    UINT uMag,
    WPARAM wParam,
    LPARAM lParam
);//函数的声明,要;号


int WINAPI WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
)
{
    WNDCLASS wndcls;
    wndcls.cbClsExtra=0;
    wndcls.cbWndExtra=0;
    wndcls.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH);//你单词错了
    wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
    wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
    wndcls.hInstance=hInstance;
    wndcls.lpfnWndProc=WinSunProc;
    wndcls.lpszClassName="radio983";
    wndcls.lpszMenuName=NULL;
    wndcls.style=CS_HREDRAW | CS_VREDRAW;
    RegisterClass(&wndcls);//你单词错了

    HWND Hwnd;
    Hwnd=CreateWindow("radio983","抄袭编程",WS_OVERLAPPEDWINDOW,
        0,0,800,600,NULL,NULL,hInstance,NULL);
    ShowWindow(Hwnd,SW_SHOWNORMAL);
    UpdateWindow(Hwnd);

    MSG msg;
    while(GetMessage(&msg,NULL,0,0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}

LRESULT CALLBACK WinSunProc(
    HWND hwnd,
    UINT uMag,
    WPARAM wParam,
    LPARAM lParam
)
{
    switch(uMag)
    {
    case WM_CHAR:
        char szChar[20];
        sprintf(szChar,"char is %d",wParam);//掉了"
        MessageBox(hwnd,szChar,"radio983",0);
        break;
    case WM_LBUTTONDOWN:
        MessageBox(hwnd,"mouse clicked","radio983",0);
        HDC hdc;//定义句柄,但是没有初始化、
        hdc=GetDC(hwnd);
        TextOut(hdc,0,50,"抄袭",strlen("抄袭"));
        ReleaseDC(hwnd,hdc);
        break;
    case WM_PAINT:
        HDC hDC;
        PAINTSTRUCT ps;
        hDC=BeginPaint(hwnd,&ps);
        TextOut(hDC,0,0,"偷袭",strlen("偷袭"));
        EndPaint(hwnd,&ps);
        break;
    case WM_CLOSE:
        if(IDYES==MessageBox(hwnd,"是否真得结束?","radio983",MB_YESNO))
        {
            DestroyWindow(hwnd);
        }
        break;
    case WM_DESTROY :
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hwnd,uMag,wParam,lParam);
    }
    return 0;
}
2008-06-12 10:55
小帅哥飞絮
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-6-23
收藏
得分:0 
#include<windows.h>
#include<stdio.h>
LRESULT WINAPI WinProc(HWND hWnd,UINT Msg,WPARAM wParom, LPARAM lParom);
void input(HWND hWnd);
void show(HWND hWnd);
RECT rect1;
RECT rect2;
HDC hDC;
PAINTSTRUCT paint;
struct stu
{
    char name[10];
    int grade;
    struct stu *next;
};
struct stu head;
int WINAPIWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShouCmd)
{
    char *cName  = "mywindow";
        WNDCLASS wc;
    HWND hWnd;
    MSG Msg;
    wc.cbClsExtra =0;
    wc.cbWndExtra = 0;
    wc.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
    wc.hCursor = NULL;
    wc.hIcon =NULL;
    wc.hInstance = hInstance;
    wc.lpfnWndProc = WinProc;
    wc.lpszClassName =cName;
    wc.lpszMenuName =NULL;
    wc.style = CS_HREDRAW|CS_VREDRAW;
    RegisterClass(&wc);
    hWnd = CreateWindow(cName,TEXT("按键"),WS_OVERLAPPEDWINDOW,10,20,500,400,NULL,NULL,hInstance,NULL);
    ShowWindow(hWnd,nShowCmd);
    UpdateWindow(hWnd);
    while(GetMessage(&Msg,NULL,0,0))
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
      return Msg.message;
    }
LRESULT WINAPI WinProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
{
    static HWND hwndInput1;
    static HWND hwndInput2;
    static HWND hwndbutton;
    switch (Msg)
    {
    case WM_PAINT:
        hDC=BeginPaint(hWnd,&paint);
        rect1.top=20;
        rect1.left=10;
        rect1.right=90;
        rect1.bottom=40;
        rect2.top=60;
        rect2.left=10;
        rect2.right=90;
        rect2.bottom=80
            DrawText(hDC,"文件名:",-1,&rect2,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
        EndPaint(hWnd,&paint);
        return 0;
        case WM_CREATE
            hwndInput1=CreateWindow(TEXT("edit"),NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|ES_LEFT,110,20,280,20,hWnd,(HMENU)2,
            ((LPCREATESTRUCT)lParam)->hInstance,NULL);
             hwndInput2=CreateWindow(TEXT("edit"),NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|ES_LEFT,110,20,280,20,hWnd,(HMENU)3,
            ((LPCREATESTRUCT)lParam)->hInstance,NULL);
             hwndbutton=CreateWidow(TEXT("BUTTON"),TEXT("导入"),WS_CHILD|WS_CHILD|WS_VISIBLE,150,340,60,20,hWnd,()HMENU)1,
                 ((LPCREATESTRUCT)lParam)->hInstance,NULL);return 0;
             case WM_COMMAND:
                 {
                     switch(LOWORD)(wParam))
                     {
case1:input(hWnd);
      show(hWnd);
                     }
                 }
                 return 0;
    }
    case WN_DESTROY:
        PostQuitMessage(0);
        return 0;
    default:
        return
            DefWindowProc(hWnd,Msg,wParam,Iparam);
}
  return DefWindowProc(hWnd,Msg,wParam,lParam);
}
}
void input(Hwnd hWnd)
{
    static char filenname[50],name[10];
    staic int count,grade;
    static struct stu *newnode,*tail;
    static FILE*fp;
    GetDlgltemText(hWnd,2,filenmame,50);
    fp=fopen(filename,"r");
    if(fp==NULL)
    {
        MessageBox(hWnd,"文件名错误","错误",MB_OK);
        return;
    }
    tail=&head;
    head.next=NULL;
    while(!feof(fp))
    {
        count=fscanf(fp,"%s%d",name,&grade);
        if(count<2)break;
        newnode=(struct stu*)malloc()sizeof(struct stu));
        newnode->next=NULL;
        tail=newnode;
    }
    return;
}
void show(HWND hWnd)
{
    static char data[1000],str[5];
    static struct(stu *p;
    p=head.next;
strcpy(data,"");
while(p!=NULL)
{
    strcat(data,p->name);
    ltoa(p->grade,str,10);
    strcat(data,"");
    strcat(date,str);
    strcat(data,"\r\n");
    p=p->next;
}
SetDlgltemText(hWnd,3,data);
return;
}//求修改,谢谢
2017-06-23 16:55
小帅哥飞絮
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-6-23
收藏
得分:0 
#include<windows.h>
#include<stdio.h>
LRESULT WINAPI WinProc(HWND hWnd,UINT Msg,WPARAM wParom, LPARAM lParom);
void input(HWND hWnd);
void show(HWND hWnd);
RECT rect1;
RECT rect2;
HDC hDC;
PAINTSTRUCT paint;
struct stu
{
    char name[10];
    int grade;
    struct stu *next;
};
struct stu head;
int WINAPIWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShouCmd)
{
    char *cName  = "mywindow";
        WNDCLASS wc;
    HWND hWnd;
    MSG Msg;
    wc.cbClsExtra =0;
    wc.cbWndExtra = 0;
    wc.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
    wc.hCursor = NULL;
    wc.hIcon =NULL;
    wc.hInstance = hInstance;
    wc.lpfnWndProc = WinProc;
    wc.lpszClassName =cName;
    wc.lpszMenuName =NULL;
    wc.style = CS_HREDRAW|CS_VREDRAW;
    RegisterClass(&wc);
    hWnd = CreateWindow(cName,TEXT("按键"),WS_OVERLAPPEDWINDOW,10,20,500,400,NULL,NULL,hInstance,NULL);
    ShowWindow(hWnd,nShowCmd);
    UpdateWindow(hWnd);
    while(GetMessage(&Msg,NULL,0,0))
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
      return Msg.message;
    }
LRESULT WINAPI WinProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
{
    static HWND hwndInput1;
    static HWND hwndInput2;
    static HWND hwndbutton;
    switch (Msg)
    {
    case WM_PAINT:
        hDC=BeginPaint(hWnd,&paint);
        rect1.top=20;
        rect1.left=10;
        rect1.right=90;
        rect1.bottom=40;
        rect2.top=60;
        rect2.left=10;
        rect2.right=90;
        rect2.bottom=80
            DrawText(hDC,"文件名:",-1,&rect2,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
        EndPaint(hWnd,&paint);
        return 0;
        case WM_CREATE
            hwndInput1=CreateWindow(TEXT("edit"),NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|ES_LEFT,110,20,280,20,hWnd,(HMENU)2,
            ((LPCREATESTRUCT)lParam)->hInstance,NULL);
             hwndInput2=CreateWindow(TEXT("edit"),NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|ES_LEFT,110,20,280,20,hWnd,(HMENU)3,
            ((LPCREATESTRUCT)lParam)->hInstance,NULL);
             hwndbutton=CreateWidow(TEXT("BUTTON"),TEXT("导入"),WS_CHILD|WS_CHILD|WS_VISIBLE,150,340,60,20,hWnd,()HMENU)1,
                 ((LPCREATESTRUCT)lParam)->hInstance,NULL);return 0;
             case WM_COMMAND:
                 {
                     switch(LOWORD)(wParam))
                     {
case1:input(hWnd);
      show(hWnd);
                     }
                 }
                 return 0;
    }
    case WN_DESTROY:
        PostQuitMessage(0);
        return 0;
    default:
        return
            DefWindowProc(hWnd,Msg,wParam,Iparam);
}
  return DefWindowProc(hWnd,Msg,wParam,lParam);
}
}
void input(Hwnd hWnd)
{
    static char filenname[50],name[10];
    staic int count,grade;
    static struct stu *newnode,*tail;
    static FILE*fp;
    GetDlgltemText(hWnd,2,filenmame,50);
    fp=fopen(filename,"r");
    if(fp==NULL)
    {
        MessageBox(hWnd,"文件名错误","错误",MB_OK);
        return;
    }
    tail=&head;
    head.next=NULL;
    while(!feof(fp))
    {
        count=fscanf(fp,"%s%d",name,&grade);
        if(count<2)break;
        newnode=(struct stu*)malloc()sizeof(struct stu));
        newnode->next=NULL;
        tail=newnode;
    }
    return;
}
void show(HWND hWnd)
{
    static char data[1000],str[5];
    static struct(stu *p;
    p=head.next;
strcpy(data,"");
while(p!=NULL)
{
    strcat(data,p->name);
    ltoa(p->grade,str,10);
    strcat(data,"");
    strcat(date,str);
    strcat(data,"\r\n");
    p=p->next;
}
SetDlgltemText(hWnd,3,data);
return;
}//求修改,谢谢
2017-06-23 16:55
快速回复:请教高手,我是初学者,问题出在哪,谢谢啦!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.065851 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved