首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

请教vc高手一个关于vc的有关问题,本人是初学者

2012-02-15 
请问vc高手一个关于vc的问题,本人是菜鸟 #include windows.h#include stdio.hLRESULTCALLBACKWinSunPr

请问vc高手一个关于vc的问题,本人是菜鸟

#include <windows.h>
#include <stdio.h>

LRESULT   CALLBACK   WinSunProc(
    HWND   hwnd,             //   handle   to   window
    UINT   uMsg,             //   message   identifier
    WPARAM   wParam,     //   first   message   parameter
    LPARAM   lParam       //   second   message   parameter
);


int   WINAPI   WinMain(
    HINSTANCE   hInstance,     //   handle   to   current   instance
    HINSTANCE   hPrevInstance,     //   handle   to   previous   instance
    LPSTR   lpCmdLine,             //   pointer   to   command   line
    int   nCmdShow                     //   show   state   of   window
)
{
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,             //   handle   to   window
    UINT   uMsg,             //   message   identifier
    WPARAM   wParam,     //   first   message   parameter
    LPARAM   lParam     //   second   message   parameter
)
{
switch(uMsg)
{
case   WM_CHAR:
char   szChar[20];
sprintf(szChar, "char   is   %d ",wParam);
MessageBox(hwnd,szChar, "weixin ",0);
break;
       
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:   winmain   -   Win32   Debug--------------------


Linking...
winmain.obj   :   error   LNK2001:   unresolved   external   symbol   "long   __stdcall   WinSunProc(struct   HWND__   *,unsigned   int,unsigned   int,long) "   (?WinSunProc@@YGJPAUHWND__@@IIJ@Z)
LIBCD.lib(crt0.obj)   :   error   LNK2001:   unresolved   external   symbol   _main
Debug/winmain.exe   :   fatal   error   LNK1120:   2   unresolved   externals
Error   executing   link.exe.

winmain.exe   -   3   error(s),   0   warning(s)

请问高手,我是一个新手,在学VC,感觉用VC做GUI确实不怎么容易啊。这个程序是一个初级的GUI的生成代码。好象是连接出错了,本人是才学,以前学C++一般都是编译出错,连接出错比较少,所以还请高手指点。实在感谢了!~还有前辈们能不能指点下学VC有是好的方法;或是初学者应该看什么样的书;能不能从前辈那借鉴点经验。我也知道C++build在生成gui方面要比VC容易点,但是先学了难的再转容易点的应该还是好点吧。谢谢指点!~```

[解决办法]
LRESULT CALLBACK WinSunProc 无定义
工程改为W32应用程序,你的是控制台
[解决办法]
这是干什么啊?

后边定义的窗口函数是干什么用的阿? 前边还声明了一个没有实现的
[解决办法]
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
这一局中 的WindowProc 改成 WinSunProc
[解决办法]
工程建错了,鉴定完毕

可以通过编译开关 ,或者建个win32 application

not console application

热点排行