--------------------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);
}
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);
}
解决方案 »
- ■■新手问题:关于socket 服务端验证的问题
- IOCP问题
- 怎样获取本机发出的arp包的数量
- 有关完成端口客户端断开引发的问题
- 窗口类名问题~~~~~~~~~~
- 关于往word中插入Excel对象
- 一个小的基本程序,在编译的时候有错误,请高手们帮忙(急)
- bho能不能获得cookie或session的内容
- 请教大虾关于使用sock进行红外通讯的问题,就是IrSock的通讯??
- 请问如何给其他进程(可能没有窗口)发送消息,通知其自动关闭?
- 用MSXML4.0 里的函数时,许多地方会ASSERT传进去的指针是否为空,是不是意味着 如果指针不为空,会有内存泄漏呢?如果是,该如何解决?
- 为什么我这么创建CStatic在窗体上看不见!
和BOOL InitInstance(HINSTANCE hInstance,int nCmdShow)
函数参数个数不对,没看出来?
其他同上!
下面两个错误呢?
(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__ *'
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);
TranslateMessage函数参数错误,你没有写出来.去查MSDN吧
在仔细检查检查