user-0 提问: 用C console程序翻译大师用汇编写的WINDOWS 窗口程序

回复:
user: user-1
content: _procwinmain 最后不能返回 0，必须返回 return DefWindowProc(hwnd, uMsg, wParam, lParam);

user: user-1
content: p2 和 p1 写反了，其中 RegisterClass 中 CreateWindow 中 ClassName 必须一直才可以。

user: user-2
content: console程序是字符界面，没有窗口、消息循环的概念。

user: user-0
content: 调试出来了，多谢大家的关注及adlay指导，定义WNDCLASSEX时少写了一个数据项，导致错误，另外windows 的窗口过程处理的消息返回值不都是0。  #include <windows.h> #pragma warning (disable:4047 4027 4133 4024 ) #include <stdio.h>  int _procwinmain(int,int,int,int); void mini(); //未初始化数据 int hinstance; int hWinMain; int *p1; int *p2; char *p; int m; int(*pro)()=_procwinmain; //字符串 char classname[] ="my class"; char captionmain[] ="window powered by console program"; char text[]="standard window of windows powered by console"; char* sz=classname; //定义结构 struct WNDCLASSEX{      int cbsize;      int style;      int lpfnwndproc;      int cbclsextra;      int cbwndextra;      int hinstance;      int hicon;      int hcursor;      int hbrbackground;      int lpszmenuname;      int lpszclassname;      int hiconsm;         };  struct POINT {      double x;      double y;         };  struct MSG{      int hwnd;      int message;      int wparam;      int lparam;      int time;      POINT pt;             };  struct RECT{     LONG left;     LONG top;     LONG right;     LONG bottom;     };  struct PAINTSTRUCT{   int hdc ;             int fErase;           RECT  rcPaint;          int fRestore  ;       int fIncUpdate ;   double RGB1;   double RGB2;         };  int main( ) {mini(); ExitProcess(NULL); }    void mini() { //在栈中定义局部变量，获取模块句柄，初始化局部变量 struct WNDCLASSEX stwindclass; struct MSG stmsg; p=classname; p1=(int*)p; p=captionmain; p2=(int*)p; hinstance= GetModuleHandle(NULL); RtlZeroMemory(&stwindclass,sizeof(WNDCLASSEX));  //注册窗口类 stwindclass.hcursor= LoadCursor(0,IDC_ARROW); stwindclass.hinstance=hinstance; stwindclass.cbsize=sizeof(WNDCLASSEX); stwindclass.style=(CS_HREDRAW|CS_VREDRAW); stwindclass.lpfnwndproc= pro; stwindclass.hbrbackground= COLOR_WINDOW+1; stwindclass.lpszclassname= sz;   RegisterClassEx(&stwindclass);   m=GetLastError();     //建立并显示窗口 m=hWinMain= CreateWindowEx(WS_EX_CLIENTEDGE,p1,p2,WS_OVERLAPPEDWINDOW,100,100,600,400,NULL,NULL,hinstance,NULL);   ShowWindow(hWinMain,SW_SHOWNORMAL);   UpdateWindow(hWinMain);  //消息循环 while(TRUE) {if (GetMessage(&stmsg,NULL,0,0)==0)    break;   else   { TranslateMessage(&stmsg);        DispatchMessage(&stmsg);   } }  }    int  _procwinmain(int hwnd ,int umsg,int wparam, int lparam) {      struct PAINTSTRUCT stps;    struct RECT strect;    int hDC;    if (umsg== WM_PAINT)         {hDC= BeginPaint(&stps,hwnd);         GetClientRect(hwnd,&strect);           DrawText(hDC,&text,-1,&strect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);          EndPaint(hwnd,&stps);         }     else         if(umsg== WM_CLOSE)         { DestroyWindow(hWinMain);           PostQuitMessage(NULL);         }         else         {     DefWindowProc(hwnd,umsg,wparam,lparam);             _asm mov m,eax                 printf("%d\n",m);//测试消息的数量，及返回值时多少             return;         }         return 0; }

user: user-0
content: 不知道，在没有定义这些结构的情况下，编译器老是报错，说有未定义标识符，本人比较菜，学化工出身的，编程都是自学的，求讲解的清楚些，在这里多谢了

user: user-3
content: 重定义了那么多 windows.h 中已经定义过了的结果，你怎么编译过的。。。。 返回 NULL 后用 GetLastError 看错误代码撒