win32应用窗口问题,懂的进!
#include<Windows.h>#include<WinUser.h>
#include<afxwin.h>
//#include<iostream>
#include<stdio.h>
//using namespace std;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
);
{
{
WNDCLASSEX wcex;
wcex.cbSize=sizeof(WNDCLASSEX);
wcex.style=CS_HREDRAW|CS_VREDRAW;
wcex.lpfnWndProc=WndProc;
wcex.cbClsExtra=0;
wcex.cbWndExtra=0;
wcex.hInstance=hInstance;
wcex.hIcon=LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
wcex.hCursor=LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground=(HBRUSH)(COLOR_ACTIVEBORDER);
wcex.lpszMenuName=NULL;
wcex.lpszClassName=szWindowClass;
wcex.hIconSm=LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
} WNDCLASSEX, *PWNDCLASSEX;
WNDCLASSEX wcex;
if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,
lpText("Call to RegisterClassEx failed!"),
lpCaption("Win32 Guided Tour"),
NULL);
return 1;
}
hInst = hInstance;
HWND hWnd=CreateWindow(szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
500, 100,
NULL,
NULL,
hInstance,
NULL);
if (!hWnd)
{
MessageBox(NULL,
lpText("Call to CreateWindow failed!"),
lpCaption("Win32 Guided Tour"),
NULL);
return 1;
}
ShowWindow(hWnd,
nCmdShow);
UpdateWindow(hWnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
我在VS2008上调试出现下面的问题:------ 已启动生成: 项目: 自建窗口, 配置: Debug Win32 ------
正在编译...
自建窗口.cpp
d:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(24) : fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
生成日志保存在“file://c:\Documents and Settings\Administrator\桌面\C\自建窗口\自建窗口\Debug\BuildLog.htm”
自建窗口 - 1 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
当我用转到时指向的是下面红色的这个语句:// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#ifndef __AFX_H__
#define __AFX_H__
#ifndef __cplusplus
#error MFC requires C++ compilation (use a .cpp suffix)
#endif
#pragma once
/////////////////////////////////////////////////////////////////////////////
#ifdef _DLL
#ifndef _AFXDLL
#error Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
#endif
#endif
// Since MFC itself is built with wchar_t as a native type, it will not have
// the correct type info for types built with wchar_t typedef'd to unsigned
// short. Make sure that the user's app builds this type info in this case.
#ifndef _NATIVE_WCHAR_T_DEFINED
#define _AFX_FULLTYPEINFO
#endif
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, off)
#endif
#ifdef __ATLDBGMEM_H__
#error <atldbgmem.h> cannot be used in MFC projects. See AfxEnableMemoryTracking
#endif
#if defined(_MFC_DLL_BLD) && defined(_DEBUG)
#ifndef _CRTDBG_MAP_ALLOC
#define _CRTDBG_MAP_ALLOC
#endif
#endif
#ifndef _INC_NEW
#include <new.h>
#endif……………………