CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C/C++ >  C++ 语言

请哪位高手帮我解决一下有关Windows编程的问题吧?

楼主chumliu(楚明)2003-11-01 11:43:39 在 C/C++ / C++ 语言 提问

以下是我写的在Windows下建立一个窗口的程序,不知道为什么在注册窗口时总是返回0。希望哪位朋友能够帮我调一下,感激不尽,谢谢!  
   
  /*  
      Name:   cMain.cpp  
      Copyright:   Cite  
      Author:   Chum   Liu  
      Date:   10-10-03   08:48  
      Description:   Main   function,   it   will   call   cFrame   class  
  */  
   
  #include   <windows.h>  
  #include   "cFrame.h"  
   
  main()  
  {  
          cFrame*   app   =   new   cFrame();  
          app->lpClassName   =   NULL;  
          app->setTitle   =   "CiteSoft   Logon";  
          app->BackStyle   =   CS_HREDRAW   |   CS_VREDRAW;  
          app->X   =   200;  
          app->Y   =   200;  
          app->Width   =   400;  
          app->Height   =   300;  
          app->hWndParent   =   NULL;  
          app->hMenu   =   NULL;  
          app->lpParam   =   NULL;  
          app->Show();  
  }  
   
   
   
  /*  
      Name:   cFrame.h  
      Copyright:   Cite  
      Author:   Chum   Liu  
      Date:   10-10-03   08:48  
      Description:   Initialize   windows  
  */  
   
  #ifndef   CFRAME_H_  
  #define   CFRAME_H_  
  #include   <windows.h>  
   
   
  LRESULT   CALLBACK   WndProc   (HWND,   UINT,   WPARAM,   LPARAM)   ;  
   
  class   cFrame   {  
          public:  
                  LPCTSTR   lpClassName;  
                  LPCTSTR   setTitle;  
                  DWORD   BackStyle;  
                  int   X,   Y,   Width,   Height;  
                  HWND   hWndParent;  
                  HMENU   hMenu;  
                  LPVOID   lpParam;  
                  cFrame();  
                  int   Show();  
  };  
  #endif  
   
   
   
  /*  
      Name:   cFrame.cpp  
      Copyright:   Cite  
      Author:   Chum   Liu  
      Date:   08-10-03   15:51  
      Description:   Create   window   function   in   Windows   NT  
  */  
   
  #include   <windows.h>  
  #include   "cFrame.h"  
   
  /***********************************************************************  
    *   Function   for   initialize   window  
    */  
  cFrame::cFrame()   {  
          HINSTANCE   hInstance;  
          static   TCHAR   szAppName[]   =   TEXT   ("cWlogon")   ;  
          HWND                   hwnd   ;  
          MSG                     msg   ;  
          WNDCLASS           wndclass   ;  
          cFrame               cFrame;  
           
          wndclass.style                   =   cFrame.BackStyle   ;  
          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   (LTGRAY_BRUSH)   ;  
          wndclass.lpszMenuName     =   NULL   ;  
          wndclass.lpszClassName   =   szAppName   ;  
   
          if   (!RegisterClass   (&wndclass))   {  
                  MessageBox   (NULL,   TEXT   ("This   program   requires   Windows   NT!"),    
                                                  szAppName,   MB_ICONERROR)   ;  
                  return   0   ;  
          }  
  }  
   
  /***********************************************************************  
    *   Function   for   create   window  
    */  
  int   cFrame::Show()   {  
          HINSTANCE   hInstance;  
          cFrame               cFrame;  
          static   TCHAR   szAppName[]   =   TEXT   ("cWlogon")   ;  
          HWND                   hwnd   ;  
          MSG                     msg   ;  
          WNDCLASS           wndclass   ;  
          hwnd   =   CreateWindow   (szAppName,  
                                                    TEXT   (cFrame.setTitle),  
                                                    cFrame.BackStyle,  
                                                    cFrame.X,  
                                                    cFrame.Y,  
                                                    cFrame.Width,  
                                                    cFrame.Height,  
                                                    cFrame.hWndParent,  
                                                    cFrame.hMenu,  
                                                    hInstance,  
                                                    cFrame.lpParam)   ;  
   
          ShowWindow   (hwnd,   SW_SHOWNOACTIVATE)   ;  
          UpdateWindow   (hwnd)   ;  
   
          while   (GetMessage   (&msg,   NULL,   0,   0))  
          {  
                  TranslateMessage   (&msg)   ;  
                  DispatchMessage   (&msg)   ;  
          }  
          return   msg.wParam   ;  
  }  
   
  LRESULT   CALLBACK  
  WndProc   (HWND   hwnd,   UINT   message,   WPARAM   wParam,   LPARAM   lParam)  
  {  
          static   int     cxChar,   cxCaps,   cyChar   ;  
          HDC                   hdc   ;  
          int                   i   ;  
          PAINTSTRUCT   ps   ;  
          TCHAR               szBuffer   [10]   ;  
          TEXTMETRIC     tm   ;  
           
          switch   (message)  
          {  
                  case   WM_CREATE:  
                          hdc   =   GetDC   (hwnd)   ;  
           
                          GetTextMetrics   (hdc,   &tm)   ;  
                          cxChar   =   tm.tmAveCharWidth   ;  
                          cxCaps   =   (tm.tmPitchAndFamily   &   1   ?   3   :   2)   *   cxChar   /   2   ;  
                          cyChar   =   tm.tmHeight   +   tm.tmExternalLeading   ;  
           
                          ReleaseDC   (hwnd,   hdc)   ;  
                          return   0   ;  
                   
                  case   WM_COMMAND:  
                          switch(   wParam   )  
                          {  
                           
                          }  
                          break;  
   
                  case   WM_CLOSE:  
                          DestroyWindow(   hwnd   );  
                          return   0;  
                         
                  case   WM_DESTROY   :  
                          PostQuitMessage   (0)   ;  
                          return   0   ;  
          }  
          return   DefWindowProc   (hwnd,   message,   wParam,   lParam)   ;  
  }  
  问题点数:0、回复次数:0Top

相关问题

  • 有关Windows编程,Help Me
  • 有关Windows版本的编程问题
  • 有那位大师可以帮忙?有关Windows状态区的编程
  • 各位大虾帮帮我这只鸟吧!有关windows编程学习的问题!!!
  • 有关socket编程
  • 有关IE编程
  • 有关interbase编程
  • 有关ADO编程
  • 有关xpbutton编程
  • windows sdk 编程

关键词

  • date
  • cframe
  • wndclass
  • backstyle
  • cxchar
  • hwnd
  • szappname
  • app
  • hinstance
  • hmenu

得分解答快速导航

  • 帖主:chumliu

相关链接

  • C/C++ Blog
  • C/C++类图书
  • C/C++类源码下载

广告也精彩

反馈

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