| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1538 人关注过本帖
标题:win32应用窗口问题,懂的进!
只看楼主 加入收藏
guer168
Rank: 2
等 级:论坛游民
帖 子:46
专家分:37
注 册:2010-3-19
结帖率:75%
收藏
 问题点数:0 回复次数:4 
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……………………
搜索更多相关主题的帖子: 应用 窗口 
2010-04-09 12:47
apull
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:三体星系
等 级:版主
威 望:216
帖 子:1487
专家分:9072
注 册:2010-3-16
收藏
得分:0 
去掉连接参数/MD试试看。
2010-04-09 14:43
秀痘魔导士
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:6
帖 子:250
专家分:1150
注 册:2009-12-23
收藏
得分:0 
属性-常规-MFC的使用-在共享 DLL 中使用 MFC
2010-04-09 16:07
guer168
Rank: 2
等 级:论坛游民
帖 子:46
专家分:37
注 册:2010-3-19
收藏
得分:0 
2楼的大哥不行呀,去了还是那个语句有问题呢!本来是想要写一个简单的窗口的!但是就是写不用来呢!我是用VS2008写的,写不出呢!如果可以把你们的代码给我看看,是那里出错了行不?

淘宝:http://guer168.  百度有啊http://youa.baidu.com/shop/75fb2a3584ed3e7d5e1e752d?from=hi
2010-04-09 20:15
ltyjyufo
Rank: 9Rank: 9Rank: 9
来 自:未来
等 级:蜘蛛侠
威 望:2
帖 子:353
专家分:1166
注 册:2009-10-25
收藏
得分:0 
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))  //这里的wcex应该是说你在最上面定义的那个吧
{
     MessageBox(NULL,
  lpText("Call to RegisterClassEx failed!"),
  lpCaption("Win32 Guided Tour"),
  NULL);
      return 1;
}


翱翔天空的雄鹰固然令人羡慕,却容易被禁锢于牢笼之中,只有那夜色中的蝙蝠才是真正自由的飞翔者....
2010-04-09 22:39
快速回复:win32应用窗口问题,懂的进!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015350 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved