windows程序设计初学者有关问题 恳请各位的解答
windows程序设计菜鸟问题 恳请各位的解答
麻烦各位看看我的错误,编译错误提示在最后面,我已经用====标出来了,菜鸟级别,照书打出的程序。
错误信息:
1>------ Build started: Project: VC3.4.3, Configuration: Debug Win32 ------
1>Build started 2012/1/17 2:15:58.
1>InitializeBuildStatus:
1> Touching "Debug\VC3.4.3.unsuccessfulbuild".
1>ClCompile:
1> VC3.4.3.cpp
1>e:\visual studio 2010\vc3.4.3\vc3.4.3\vc3.4.3.cpp(3): warning C4651: '/D_UNICODE' specified for precompiled header but not for current compile
1>e:\visual studio 2010\vc3.4.3\vc3.4.3\vc3.4.3.cpp(3): warning C4651: '/DUNICODE' specified for precompiled header but not for current compile
1>e:\visual studio 2010\vc3.4.3\vc3.4.3\vc3.4.3.cpp(23): error C2440: '=' : cannot convert from 'char [8]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast//===================错误一
1>e:\visual studio 2010\vc3.4.3\vc3.4.3\vc3.4.3.cpp(29): error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'char [8]' to 'LPCWSTR'//错误二
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.65
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
请问各位这个错误怎么解决呢,网上的方法我试过了,把设置改成Use Multi-Byte Character Set(多字符集),用的是VS2010,开始选择的是MFC Application,直接点了finish,之后删除了原文件里面的所有文件,保留了头文件里面的文件,只建立了一个cpp文件如上图。万分感谢!!!!
还有一个问题,本人才接触Windows程序设计,现在用的是清华大学出版社的《VC++ 面向对象与可视化程序设计(第二版)》,目的是想先通过其入门,此题正是第三章最后的例子,请各位大牛推荐几本几本接下来可以看得书,非常感谢!
------解决方案--------------------
char lpszClassName[]="Windows";
char lpszTitle[]="My_Windows";
-->
TCHAR lpszClassName[]=_T("Windows");
TCHAR lpszTitle[]= _T("My_Windows");
------解决方案--------------------
#include<windows.h>
#include <stdio.h>
#include "StdAfx.h"
-->
#include "StdAfx.h"
#include<windows.h>
#include <stdio.h>
#include "stdafx.h"这句放在最前面
麻烦各位看看我的错误,编译错误提示在最后面,我已经用====标出来了,菜鸟级别,照书打出的程序。
- C/C++ code
#include<windows.h> #include <stdio.h> #include "StdAfx.h" LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdLine, int nCmdShow) { HWND hwnd; MSG Msg; WNDCLASS wndclass; char lpszClassName[]="Windows"; char lpszTitle[]="My_Windows"; 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.lpszClassName=NULL; wndclass.lpszClassName=lpszClassName;//=============================================错误一 if(!RegisterClass(&wndclass)) { MessageBeep(0); return FALSE; } 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) { switch(message) { case WM_DESTROY: PostQuitMessage(0); default: return DefWindowProc(hwnd,message,wParam,lParam); } return (0); }
错误信息:
1>------ Build started: Project: VC3.4.3, Configuration: Debug Win32 ------
1>Build started 2012/1/17 2:15:58.
1>InitializeBuildStatus:
1> Touching "Debug\VC3.4.3.unsuccessfulbuild".
1>ClCompile:
1> VC3.4.3.cpp
1>e:\visual studio 2010\vc3.4.3\vc3.4.3\vc3.4.3.cpp(3): warning C4651: '/D_UNICODE' specified for precompiled header but not for current compile
1>e:\visual studio 2010\vc3.4.3\vc3.4.3\vc3.4.3.cpp(3): warning C4651: '/DUNICODE' specified for precompiled header but not for current compile
1>e:\visual studio 2010\vc3.4.3\vc3.4.3\vc3.4.3.cpp(23): error C2440: '=' : cannot convert from 'char [8]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast//===================错误一
1>e:\visual studio 2010\vc3.4.3\vc3.4.3\vc3.4.3.cpp(29): error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'char [8]' to 'LPCWSTR'//错误二
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.65
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
请问各位这个错误怎么解决呢,网上的方法我试过了,把设置改成Use Multi-Byte Character Set(多字符集),用的是VS2010,开始选择的是MFC Application,直接点了finish,之后删除了原文件里面的所有文件,保留了头文件里面的文件,只建立了一个cpp文件如上图。万分感谢!!!!
还有一个问题,本人才接触Windows程序设计,现在用的是清华大学出版社的《VC++ 面向对象与可视化程序设计(第二版)》,目的是想先通过其入门,此题正是第三章最后的例子,请各位大牛推荐几本几本接下来可以看得书,非常感谢!
------解决方案--------------------
char lpszClassName[]="Windows";
char lpszTitle[]="My_Windows";
-->
TCHAR lpszClassName[]=_T("Windows");
TCHAR lpszTitle[]= _T("My_Windows");
------解决方案--------------------
#include<windows.h>
#include <stdio.h>
#include "StdAfx.h"
-->
#include "StdAfx.h"
#include<windows.h>
#include <stdio.h>
#include "stdafx.h"这句放在最前面