标题:【求助】windows下的c
取消只看楼主
醉罪
Rank: 2
等 级:论坛游民
帖 子:140
专家分:24
注 册:2008-7-26
结帖率:100%
 问题点数:0 回复次数:1 
【求助】windows下的c
这个程序的源码是在书上看到的  但总是运行不了   提示的是第26行 'RegisterClassEX'没有定义  
郁闷   ------ 大家帮我看看到底是怎么回事啊

#include<windows.h>
INT PASCAL WinMain (HINSTANCE hinstance,HINSTANCE hPreinstance,LPSTR lpszCmdParam,INT nCmdShow);
LRESULT CALLBACK WndProc (HWND hMainwnd, UINT message, WPARAM wParam,LPARAM lParam);
INT PASCAL WinMain (HINSTANCE hinstance,HINSTANCE hPreinstance,LPSTR lpszCmdParam,INT nCmdShow)
 {
  HWND hMainwnd;
  MSG message;
  WNDCLASSEX myWC;
  char szAppName[] = "test";
  char szAppTitle[] = "用c语言编写的Windows程序";
  if(!hPreinstance)
  {
   myWC.cbSize=sizeof(WNDCLASSEX);
   myWC.style=CS_HREDRAW|CS_VREDRAW;
   myWC.lpfnWndProc=WndProc;
   myWC.cbClsExtra=0;
   myWC.cbWndExtra=0;
   myWC.hInstance=hinstance;
   myWC.hIcon=LoadIcon(NULL,IDI_APPLICATION);
   myWC.hCursor=LoadCursor(NULL,IDC_ARROW);
   myWC.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
   myWC.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
   myWC.lpszMenuName=NULL;
   myWC.lpszClassName=szAppName;

   RegisterClassEX(&myWC);   //这里出的问题
  }
  hMainwnd=CreateWindowEx(NULL,
                          szAppName, //窗口类名称
                          szAppTitle,//窗口标题
                          WS_OVERLAPPEDWINDOW,//窗口风格
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
                          NULL,
                          NULL,
                          hinstance,//实例句柄
                          NULL);
  ShowWindow(hMainwnd,SW_SHOWMAXIMIZED);
  UpdateWindow(hMainwnd);
  while(GetMessage(&message,NULL,0,0)) //从消息队列中取消息
   {
       TranslateMessage(&message); //转换消息
       DispatchMessage(&message);//派发消息
      }
      return message.wParam;
 }
 LRESULT CALLBACK WndProc (HWND hMainwnd,UINT message,WPARAM wParam,LPARAM lParam)
  {
      char message1[]="你按下了左键";
      char message2[]="你按下了右键";
      char message3[]="你按下了非系统键";
      switch(message)
      {
       case WM_RBUTTONDOWN:
            MessageBeep(MB_ICONINFORMATION);
            MessageBox(GetFocus(),message2,"消息框",MB_OK|MB_ICONINFORMATION);
            break;
     case WM_LBUTTONDOWN:
            MessageBeep(MB_ICONINFORMATION);
            MessageBox(GetFocus(),message1,"消息框",MB_OK|MB_ICONINFORMATION);
            break;
      
     case WM_KEYDOWN:
            MessageBeep(MB_ICONINFORMATION);
            MessageBox(GetFocus(),message3,"消息框",MB_OK|MB_ICONINFORMATION);
            break;
     case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
     default:
            break;
       }
       return DefWindowProc(hMainwnd,message,wParam,lParam);
      }
搜索更多相关主题的帖子: windows 
2008-09-19 19:03
醉罪
Rank: 2
等 级:论坛游民
帖 子:140
专家分:24
注 册:2008-7-26
得分:0 
RegisterClassEX
晕....就一个小写 浪费我这么多时间 谢谢ls的同学 呵呵
2008-09-19 19:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-234092-1-1.html




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

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