--------------------Configuration: Simpwin - Win32 Debug--------------------
Compiling...
Simpwin].cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Simpwin\Simpwin].cpp(19) : error C2660: 'InitInstance' : function does not take 2 parameters
C:\Program Files\Microsoft Visual Studio\MyProjects\Simpwin\Simpwin].cpp(24) : error C2660: 'TranslateMessage' : function does not take 4 parameters
C:\Program Files\Microsoft Visual Studio\MyProjects\Simpwin\Simpwin].cpp(45) : error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
        Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Error executing cl.exe.Simpwin.exe - 3 error(s), 0 warning(s)源文件如下://--------------------------------------------------------
//                     Simpwin.h
//--------------------------------------------------------LRESULT CALLBACK MainWndProc(HWND,UINT,WPARAM,LPARAM);BOOL InitApplication(HINSTANCE);BOOL InitInstance(HINSTANCE);char *hello="窗口外的世界很精彩,窗口内的天地也很奇妙!";//--------------------------------------------------------
//                       Simpwin.cpp
//--------------------------------------------------------#include <windows.h>
#include <string.h>
#include "Simpwin.h"
HINSTANCE hInst;
HWND   hWndMain;int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
MSG msg;
if(!InitApplication(hInstance))
return(FALSE); if(!InitInstance(hInstance,nCmdShow))
return(FALSE); while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg,NULL,0,0);
DispatchMessage(&msg);
} return (msg.wParam);}BOOL InitApplication(HINSTANCE hInstance)
{
WNDCLASS wcSimpwin; wcSimpwin.style=0;
wcSimpwin.lpfnWndProc =(WNDPROC)MainWndProc;
wcSimpwin.cbClsExtra =0;
wcSimpwin.cbWndExtra =0;
wcSimpwin.hInstance =hInstance;
wcSimpwin.hIcon =LoadIcon(NULL,IDI_APPLICATION);
wcSimpwin.hCursor =LoadCursor(NULL,IDC_ARROW);
wcSimpwin.hbrBackground =GetStockObject(WHITE_BRUSH);
wcSimpwin.lpszMenuName =NULL;
wcSimpwin.lpszClassName ="SimpwinWClass";
return(RegisterClass(&wcSimpwin));}BOOL InitInstance(HINSTANCE hInstance,int nCmdShow)
{ hInst=hInstance; hWndMain=CreateWindow(
"SimpwinWClass",
"我的窗口",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,hInstance,NULL); if(!hWndMain)
return FALSE; ShowWindow(hWndMain,nCmdShow);
UpdateWindow(hWndMain); return(TRUE);}
LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam){
HDC hdc;
PAINTSTRUCT ps; switch(message)
{ case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
TextOut(hdc,20,10,hello,lstrlen(hello));
EndPaint(hWnd,&ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return (DefWindowProc(hWnd,message,wParam,lParam));
} return(0);
}

解决方案 »

  1.   

    BOOL InitInstance(HINSTANCE);
    和BOOL InitInstance(HINSTANCE hInstance,int nCmdShow)
    函数参数个数不对,没看出来?
    其他同上!
      

  2.   

    谢谢
    下面两个错误呢?
    (1)c:\program files\microsoft visual studio\myprojects\simpwin\simpwin].cpp(24) : error C2660: 'TranslateMessage' : function does not take 4 parameters
    (2)c:\program files\microsoft visual studio\myprojects\simpwin\simpwin].cpp(45) : error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
      

  3.   

    剩一个错了,
    c:\program files\microsoft visual studio\myprojects\simpwin\simpwin].cpp(45) : error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
      

  4.   

    c:\program files\microsoft visual studio\myprojects\simpwin\simpwin].cpp(45) : error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
    h好象是填充窗口类结构的时候的背景.你用了GetStockObject()函数.没有把他转化成HBRUSH类型.一个强制转换类型就可以了
    wc.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH);
      

  5.   

    (1)c:\program files\microsoft visual studio\myprojects\simpwin\simpwin].cpp(24) : error C2660: 'TranslateMessage' : function does not take 4 parameters
    TranslateMessage函数参数错误,你没有写出来.去查MSDN吧
    在仔细检查检查