| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 420 人关注过本帖
标题:看看这代码怎样改
只看楼主 加入收藏
hg2625811
Rank: 1
等 级:新手上路
帖 子:14
专家分:2
注 册:2011-4-25
结帖率:0
收藏
已结贴  问题点数:20 回复次数:6 
看看这代码怎样改
#include <windows.h>
#include <stdio.h>

LRESULT CALLBACK WinSunProc
(
   HWND hwnd,
   UINT uMsg,
   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="Weixin2003";
    wndcls.lpszMenuName=NULL;
    wndcls.style=CS_HREDRAW | CS_VREDRAW;
    RegisterClass(&wndcls);

    HWND hwnd;
    hwnd=CreateWindow("Weixin2003","北京维新科学技术中心",WS_OVERLAPPEDWINDOW,
        0,0,600,400,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 WindowProc
(
     HWND hwnd,
     UINT uMsg,
     WPARAM wParam,
     LPARAM lParam
)
{
    switch(uMsg)
    {
    case WM_CHAR:
        char szChar[20];
        sprintf(szChar,"char is %d",wParam);
        MessageBox(hwnd,szChar,"weixin",0);
        break;
    case WM_LBUTTONDOWN:
        MessageBox(hwnd,"mouse clicked","weixin",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,"是否真的要结束","weixin",MB_YESNO))
        {
            DestroyWindow(hwnd);
        }
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hwnd,uMsg,wParam,lParam);
    }
    return 0;
}
--------------------Configuration: 2 - Win32 Debug--------------------
Compiling...
2.cpp
Linking...
2.obj : error LNK2001: unresolved external symbol "long __stdcall WinSunProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WinSunProc@@YGJPAUHWND__@@IIJ@Z)
Debug/2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

2.exe - 2 error(s), 0 warning(s)
不知道是哪里错了,和书上一个一个字的对,没有错,帮忙看下,谢谢!
搜索更多相关主题的帖子: include 
2012-03-11 18:41
hg2625811
Rank: 1
等 级:新手上路
帖 子:14
专家分:2
注 册:2011-4-25
收藏
得分:0 
没人回哦
2012-03-11 19:52
zd1505675319
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:139
专家分:178
注 册:2011-11-4
收藏
得分:7 
你看的孙鑫的视频?
2012-03-11 20:28
非死亡!
Rank: 8Rank: 8
来 自:四川
等 级:蝙蝠侠
帖 子:179
专家分:760
注 册:2011-10-31
收藏
得分:7 
程序代码:
#include <windows.h>
#include <stdio.h>

LRESULT CALLBACK WindowProc  //这里错了,我也改了,只是你把WindowProc写错了
(
   HWND hwnd,
   UINT uMsg,
   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=WindowProc;     //这里错了,我帮你改了
    wndcls.lpszClassName="Weixin2003";
    wndcls.lpszMenuName=NULL;
    wndcls.style=CS_HREDRAW | CS_VREDRAW;
    RegisterClass(&wndcls);

    HWND hwnd;
    hwnd=CreateWindow("Weixin2003","北京维新科学技术中心",WS_OVERLAPPEDWINDOW,
        0,0,600,400,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 WindowProc
(
     HWND hwnd,
     UINT uMsg,
     WPARAM wParam,
     LPARAM lParam
)
{
    switch(uMsg)
    {
    case WM_CHAR:
        char szChar[20];
        sprintf(szChar,"char is %d",wParam);
        MessageBox(hwnd,szChar,"weixin",0);
        break;
    case WM_LBUTTONDOWN:
        MessageBox(hwnd,"mouse clicked","weixin",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,"是否真的要结束","weixin",MB_YESNO))
        {
            DestroyWindow(hwnd);
        }
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hwnd,uMsg,wParam,lParam);
    }
    return 0;
}

能力 技巧
2012-03-11 21:03
hg2625811
Rank: 1
等 级:新手上路
帖 子:14
专家分:2
注 册:2011-4-25
收藏
得分:0 
谢谢

我就是看他的视频,开始学习vc,不知道你是不是学他的视频,学到哪里了,可以加我QQ625647666,以后交流下
2012-03-12 11:06
hg2625811
Rank: 1
等 级:新手上路
帖 子:14
专家分:2
注 册:2011-4-25
收藏
得分:0 
回复 4楼 非死亡!
谢谢

我就是看他的视频,开始学习vc,不知道你是不是学他的视频,学到哪里了,可以加我QQ625647666,以后交流下
2012-03-12 11:06
jfei
Rank: 4
来 自:郑州
等 级:业余侠客
帖 子:92
专家分:268
注 册:2011-8-27
收藏
得分:7 
呵呵额,啥样的人都有

虾米们!!!有意者加QQ 2434202652,2632939128联系我
2012-03-12 15:15
快速回复:看看这代码怎样改
数据加载中...
 
   



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

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