CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

Windows编程编译问题

楼主taozai()2002-04-04 18:00:42 在 VC/MFC / 基础类 提问

下面是我的源码:  
  //   WinExam3.cpp   :   Defines   the   entry   point   for   the   application.  
  //  
   
  #include   "stdafx.h"  
  #include   "WinCtrl.h"  
   
  OPENFILENAME   ofn;  
  HWND   hStatusBar,hToolBar;  
  HINSTANCE   hInst;  
  int   RightEnd[2];  
  LPNMHDR   lpNmHdr;  
  LPTOOLTIPTEXT   lpTText;  
  //Define   the   tool   buttons  
  TBBUTTON   tbButton[]=  
  {  
  STD_FILENEW,IDM_NEW,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,  
  STD_FILEOPEN,IDM_OPEN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,  
  STD_FILESAVE,IDM_SAVE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,  
  0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0,0,0,  
  STD_CUT,IDM_CUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,  
  STD_COPY,IDM_COPY,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,  
  STD_PASTE,IDM_PASTE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0  
  };  
  LRESULT   CALLBACK   WndProc(HWND,UINT,WPARAM,LPARAM);  
  int   WINAPI   WinMain(HINSTANCE   hInstance,  
                                            HINSTANCE   hPrevInstance,  
                                            LPSTR           lpCmdLine,  
                                            int               nCmdShow)  
  {  
    //   TODO:   Place   code   here.  
  HWND   hWnd;  
  MSG   msg;  
  HACCEL   hAccel;  
  WNDCLASS   wndClass;  
  char   chMenuName[]   =   "MainMenu";  
  char   chClassName[]   =   "WinExam3";  
  char   chTitle[]   =   "The   Window   Example";  
  char   chAccelName[]   =   "MenuAccel";  
  wndClass.cbClsExtra   =   0;  
  wndClass.cbWndExtra   =   0;  
  wndClass.hbrBackground   =   (HBRUSH)GetStockObject(WHITE_BRUSH);  
  wndClass.hCursor   =   LoadCursor(NULL,IDC_ARROW);  
  wndClass.hIcon   =   LoadIcon(NULL,IDI_APPLICATION);  
  wndClass.hInstance   =   hInstance;  
  wndClass.lpfnWndProc   =   WndProc;  
  wndClass.lpszClassName   =   chClassName;  
  wndClass.lpszMenuName   =   chMenuName;  
  wndClass.style   =   0;  
   
  if(!RegisterClass(&wndClass))  
  {  
  MessageBeep(0);  
  return   0;  
  }  
  hWnd   =   CreateWindow(chClassName,chTitle,WS_OVERLAPPEDWINDOW,  
                                  CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,  
  NULL,NULL,hInstance,NULL);  
  ShowWindow(hWnd,nCmdShow);  
  UpdateWindow(hWnd);  
  InitCommonControls();  
  hInst   =   hInstance;  
  hAccel   =   LoadAccelerators(hInstance,chAccelName);  
  while(GetMessage(&msg,NULL,0,0))  
  {  
  if(!TranslateAccelerator(hWnd,hAccel,&msg))  
  {  
  TranslateMessage(&msg);  
  DispatchMessage(&msg);  
  }  
  }  
  return   msg.wParam;  
  }  
   
  LRESULT   CALLBACK   WndProc(HWND   hWnd,UINT   message,WPARAM   wParam,LPARAM   lParam)  
  {  
  static   char   chFilter[]   =   "Text   Files(*.txt)|*.txt   ||   All   Files(*.*)|*.*||";  
  static   char   chFileName[]   =   "";  
  static   RECT   rectClient;  
  switch(message)  
  {  
  case   WM_CREATE:  
  ofn.Flags   =   0;  
  ofn.hInstance   =   NULL;  
  ofn.hwndOwner   =   hWnd;  
  ofn.lCustData   =   0;  
  ofn.lpfnHook   =   NULL;  
  ofn.lpstrCustomFilter   =   NULL;  
  ofn.lpstrDefExt   =   NULL;  
  ofn.lpstrFile   =   NULL;  
  ofn.lpstrFileTitle   =   NULL;  
  ofn.lpstrFilter   =   chFilter;  
  ofn.lpstrInitialDir   =   NULL;  
  ofn.lpstrTitle   =   NULL;  
  ofn.lpTemplateName   =   NULL;  
  ofn.lStructSize   =   sizeof(OPENFILENAME);  
  ofn.nFileOffset   =   0;  
  ofn.nFilterIndex   =   1;  
  ofn.nMaxCustFilter   =   0;  
  ofn.nMaxFile   =   0;  
  ofn.nMaxFileTitle   =   0;  
  //Create   ToolBar  
  hToolBar   =   CreateToolbarEx(hWnd,WS_CHILD   |   WS_BORDER   |    
        WS_VISIBLE   |   TBSTYLE_TOOLTIPS,  
        ID_TOOLBAR,7,HINST_COMMCTRL,  
        IDB_STD_SMALL_COLOR,tbButton,  
        7,0,0,0,0,sizeof(TBBUTTON));  
  //Create   StatusBar  
  hStatusBar   =   CreateStatusWindow(WS_CHILD   |   WS_VISIBLE,  
          "",hWnd,ID_STATUSBAR);  
  //Set   StatusBar  
  GetClientRect(hWnd,&rectClient);  
  RightEnd[0]   =   rectClient.right   *   2   /3;  
  RightEnd[1]   =   rectClient.right;  
  SendMessage(hStatusBar,SB_SETPARTS,(WPARAM)2,(LPARAM)RightEnd);  
  SendMessage(hStatusBar,SB_SETTEXT,(WPARAM)1,(LPARAM)"Welcom   to   use   statusbar");  
  SendMessage(hStatusBar,SB_SETTEXT,(WPARAM)2,(LPARAM)"The   Application   is   ready");  
  break;  
  case   WM_COMMAND:  
  switch(LOWORD(wParam))  
  {  
  case   IDM_NEW:  
  SendMessage(hStatusBar,SB_SETTEXT,(WPARAM)1,(LPARAM)"");  
  }  
  break;  
  case   WM_NOTIFY:  
  break;  
  case   WM_DESTROY:  
  PostQuitMessage(0);  
  break;  
  default:  
  return   DefWindowProc(hWnd,message,wParam,lParam);  
  }  
  return   0;  
  }  
   
  //stdafx.h  
  //   stdafx.h   :   include   file   for   standard   system   include   files,  
  //     or   project   specific   include   files   that   are   used   frequently,   but  
  //             are   changed   infrequently  
  //  
   
  #if   !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)  
  #define   AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_  
   
  #if   _MSC_VER   >   1000  
  #pragma   once  
  #endif   //   _MSC_VER   >   1000  
   
  #define   WIN32_LEAN_AND_MEAN //   Exclude   rarely-used   stuff   from   Windows   headers  
   
  #include   <windows.h>  
  #include   <stdio.h>  
  #include   <commdlg.h>  
  #include   <stdlib.h>  
  #include   <commctrl.h>  
   
   
  //   TODO:   reference   additional   headers   your   program   requires   here  
   
  //{{AFX_INSERT_LOCATION}}  
  //   Microsoft   Visual   C++   will   insert   additional   declarations   immediately   before   the   previous   line.  
   
  #endif   //   !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)  
  编译出错信息:  
  --------------------Configuration:   WinExam3   -   Win32   Debug--------------------  
  Compiling...  
  WinExam3.cpp  
  Linking...  
  WinExam3.obj   :   error   LNK2001:   unresolved   external   symbol   __imp__InitCommonControls@0  
  WinExam3.obj   :   error   LNK2001:   unresolved   external   symbol   __imp__CreateStatusWindowA@16  
  WinExam3.obj   :   error   LNK2001:   unresolved   external   symbol   __imp__CreateToolbarEx@52  
  Debug/WinExam3.exe   :   fatal   error   LNK1120:   3   unresolved   externals  
  Error   executing   link.exe.  
   
  WinExam3.exe   -   4   error(s),   0   warning(s)  
  请高手指教,我的编译环境还需要设置什么?谢谢! 问题点数:50、回复次数:5Top

1 楼2ndboy(贱男春)回复于 2002-04-04 18:27:47 得分 0

commctrl.hTop

2 楼LoveTide(say no to ISO-8859-1、CVS)回复于 2002-04-04 18:34:37 得分 0

Alt+F7  
  Link:   加入一个   .lib   文件,具体是什么文件忘了,参考一下   msdn   吧Top

3 楼2ndboy(贱男春)回复于 2002-04-04 18:43:26 得分 50

COMCTL32.LIBTop

4 楼zhakewei(天外有天)回复于 2002-04-04 19:26:47 得分 0

老兄,继续努力吧!Top

相关问题

  • windows核心编程编译出错。
  • 用什么编译器编译<<windows网络编程>>中的源程序?
  • 用什么编译器编译<<windows网络编程>>中的源程序?
  • 学windows编程用什么编译器好?(除了VC之外)
  • <<Windows核心编程>>Source code 不能编译??
  • <<windows核心编程>>源代码不能通过编译
  • 《windows高级编程》中例子的编译设置?
  • WINDOWS网络编程 原代码 编译通不过是为何?
  • 编译windows核心编程源代码出错
  • Windows核心编程的源码编译问题,请高手指教

关键词

  • win32
  • tbstate
  • tbstyle
  • idm
  • enabled
  • std
  • hinstance
  • hwnd
  • button
  • defined

得分解答快速导航

  • 帖主:taozai
  • 2ndboy

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo