'nCmdShow' : undeclared identifier 这个错误怎么改呀?

时间:2022-10-09 19:03:06
#include<windows.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
LRESULT CALLBACK WndProc(HWND ,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance ,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmcShow)
{
   HWND hwnd;
   MSG   Msg;
   WNDCLASS  wndclass;
   char  lpszClassName[]="基本绘图";
   char  lpszTitle[]="My_Drawing";
   wndclass.style=0;
   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(WHITE_BRUSH);
   wndclass.lpszMenuName=NULL;
   wndclass.lpszClassName=lpszClassName;
   if(!RegisterClass(&wndclass))
   {
       MessageBeep(0);

   }
   hwnd=CreateWindow(
lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
   
    ShowWindow( hwnd,  nCmdShow);
   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
 )
   
{
   HDC hdc;
   PAINTSTRUCT ps;
   HPEN  hP;
   HBRUSH hB;
   switch(message)
   {
   case WM_PAINT:
   hdc=BeginPaint(hwnd ,&ps);
   SetMapMode(hdc,MM_TEXT);
   Rectangle(hdc,130,60,270,200);
   hB=CreateHatchBrush(HS_CROSS,RGB(255,0,0));
   SelectObject(hdc,hB);
       Ellipse(hdc,130,70,270,190);
   hP=CreatePen(PS_DASHDOT,1,RGB(0,255,0));
   SelectObject(hdc,hP);
   MoveToEx(hdc,100,130,NULL);
   LineTo(hdc,300,130);
   MoveToEx(hdc,200,30,NULL);
   LineTo(hdc,200,230);
   EndPaint(hwnd,&ps);
   DeleteObject(hP);
   DeleteObject(hB);
   break;
   case  WM_DESTROY:
   PostQuitMessage(0);
   break;
   default:
   return DefWindowProc(hwnd ,message,wParam,lParam);
 



   }
     return 0;
}


Compiling...
ww.cpp
E:\VC\MSDev98\MyProjects\ww\ww.cpp(42) : error C2065: 'nCmdShow' : undeclared identifier
Error executing cl.exe.

ww.exe - 1 error(s), 0 warning(s)


10 个解决方案

#1


nCmdShow这个变量你从来没有定义过,怎么能用?
自己用一个合法的cmdshow值替换nCmdShow吧,例如换成SW_SHOWWINDOW

#2


WinMain(HINSTANCE hInstance ,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int  nCmcShow

改成nCmdShow

#3


引用 2 楼 ctolee 的回复:
WinMain(HINSTANCE hInstance ,HINSTANCE hPrevInst,LPSTR lpszCmdLine,intnCmcShow)

改成nCmdShow


up

#4


nCmdShow用SW_SHOW代替!

#5


引用 2 楼 ctolee 的回复:
WinMain(HINSTANCE hInstance ,HINSTANCE hPrevInst,LPSTR lpszCmdLine,intnCmcShow)

改成nCmdShow

UP

#6


LZ会了吧

#7


int WINAPI WinMain(HINSTANCE hInstance ,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmcShow)


int nCmcShow -> int nCmdShow

#8


搞定了 

#9


2楼正解,WinMain里的参数写错

#10


这么低级的编程错误。。。。还有LZ的编程风格很要人命。。。

#1


nCmdShow这个变量你从来没有定义过,怎么能用?
自己用一个合法的cmdshow值替换nCmdShow吧,例如换成SW_SHOWWINDOW

#2


WinMain(HINSTANCE hInstance ,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int  nCmcShow

改成nCmdShow

#3


引用 2 楼 ctolee 的回复:
WinMain(HINSTANCE hInstance ,HINSTANCE hPrevInst,LPSTR lpszCmdLine,intnCmcShow)

改成nCmdShow


up

#4


nCmdShow用SW_SHOW代替!

#5


引用 2 楼 ctolee 的回复:
WinMain(HINSTANCE hInstance ,HINSTANCE hPrevInst,LPSTR lpszCmdLine,intnCmcShow)

改成nCmdShow

UP

#6


LZ会了吧

#7


int WINAPI WinMain(HINSTANCE hInstance ,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmcShow)


int nCmcShow -> int nCmdShow

#8


搞定了 

#9


2楼正解,WinMain里的参数写错

#10


这么低级的编程错误。。。。还有LZ的编程风格很要人命。。。