关于ActiveSkin遇到的问题

烟尘生 2011-10-24 10:31:07
学习使用activeskin 遇到问题

第一步:在msdn下载的破解版跟vc安装在同一个文件夹后
随便建了个MFC对话框
按照百度的教程说的 先在在stdafx.h 添加#include <atlbase.h>
#import "actskn43.ocx" no_implementation raw_interfaces_only raw_native_types
using namespace ACTIVESKINLib;
这三行代码,完事后代码如下~(其他的都没修改)~~~


// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#if !defined(AFX_STDAFX_H__A489C230_38C8_477A_9329_46AF22FC4655__INCLUDED_)
#define AFX_STDAFX_H__A489C230_38C8_477A_9329_46AF22FC4655__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers

#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <atlbase.h>
#import "actskn43.ocx" no_implementation raw_interfaces_only raw_native_types
using namespace ACTIVESKINLib;
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__A489C230_38C8_477A_9329_46AF22FC4655__INCLUDED_)


第二部:在对话框的.cpp文件中以下加代码
CComQIPtr<ISkin> m_pSkin=GetDlgItem(IDC_SKIN)->GetControlUnknown();//m_pSkin是应用程序全局量。
m_pSkin->LoadSkin(L"BlackSea");//如果ActiveSkin控件中已有皮肤,此句可省略。
m_pSkin->ApplySkin((int)m_hWnd);


完事代码如下(其他的都没修改)


// skin2Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "skin2.h"
#include "skin2Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
CComQIPtr<ISkin> m_pSkin=GetDlgItem(IDC_SKIN)->GetControlUnknown();//m_pSkin是应用程序全局量。
m_pSkin->LoadSkin(L"BlackSea");//如果ActiveSkin控件中已有皮肤,此句可省略。
m_pSkin->ApplySkin((int)m_hWnd);

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSkin2Dlg dialog

CSkin2Dlg::CSkin2Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CSkin2Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSkin2Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CSkin2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSkin2Dlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSkin2Dlg, CDialog)
//{{AFX_MSG_MAP(CSkin2Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSkin2Dlg message handlers

BOOL CSkin2Dlg::OnInitDialog()
{
//CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}

}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here

return TRUE; // return TRUE unless you set the focus to a control
}

void CSkin2Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CSkin2Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSkin2Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}


然后编译运行,出现10个错误

--------------------Configuration: skin2 - Win32 Debug--------------------
Compiling...
StdAfx.cpp
Compiling...
skin2Dlg.cpp
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(16) : error C2660: 'GetDlgItem' : function does not take 1 parameters
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(16) : error C2227: left of '->GetControlUnknown' must point to class/struct/union
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(17) : error C2143: syntax error : missing ';' before '->'
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(17) : error C2501: 'm_pSkin' : missing storage-class or type specifiers
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(17) : error C2371: 'm_pSkin' : redefinition; different basic types
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(16) : see declaration of 'm_pSkin'
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(17) : error C2143: syntax error : missing ';' before '->'
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(18) : error C2143: syntax error : missing ';' before '->'
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(18) : error C2501: 'm_pSkin' : missing storage-class or type specifiers
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(18) : error C2371: 'm_pSkin' : redefinition; different basic types
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(16) : see declaration of 'm_pSkin'
D:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Villean\skin2\skin2Dlg.cpp(18) : error C2143: syntax error : missing ';' before '->'
Generating Code...
Skipping... (no relevant changes detected)
skin2.cpp
Error executing cl.exe.

skin2.exe - 10 error(s), 0 warning(s)




求解~~~~我把CComQIPtr<ISkin> m_pSkin=GetDlgItem(IDC_SKIN)->GetControlUnknown();//m_pSkin是应用程序全局量。
m_pSkin->LoadSkin(L"BlackSea");//如果ActiveSkin控件中已有皮肤,此句可省略。
m_pSkin->ApplySkin((int)m_hWnd);
放在OnInitDialog函数中,虽然不报错了,但是界面没有替换~~
求高手解答啊~~~
...全文
74 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
烟尘生 2011-10-26
  • 打赏
  • 举报
回复
求助高手啊,难道是我发一大堆代码太乱没人回复啊
fishion 2011-10-24
  • 打赏
  • 举报
回复
不能在对话框类的函数外调用GetDlgItem
烟尘生 2011-10-24
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 fishion 的回复:]

不能在对话框类的函数外调用GetDlgItem
[/Quote]


那我把GetDlgItem那几行代码放对话框类内部,虽然不报错,但是对话框外观不变啊~~
ActiveSkin在VC中的使用方法(Rigel 2002/12/20) ActiveSkin控件的用法很简单,安装时也会带有一些例程。下面以一个基于MFC对话框的应用程序来讲一下ActiveSkin在VC中的使用方法和步骤 1、建立项目 建立一个新项目、选择对话框类型 2、在项目中加入ActiveSkin控件 Project -> Add to Project -> Components and Controls Gallery 进入Registered ActiveX Controls目录,找到ActiveSkin Control然后按Insert按钮,提示是否加入时按确定,下一个对话框询问是否加入CSkin类,不用更改,按确定,这样,这个控件就加到项目中来了,在工具条中会出现一个ActiveSkin控件的图标。 3、在对话框中加入ActiveSkin控件 在工具条上选中ActiveSkin控件,把它放置到对话框中的任意位置。 4、选择一个Skin(这一步也可以不做,可以在程序中加载一个skn文件) 在对话框的ActiveSkin控件上按鼠标右键,选择菜单ActiveSkin Object -> Load Skin,在弹出的选择文件对话框中选择一个.skn文件。控件安装时自带有skn文件,位于安装目录的skins子目录下。 5、在stdafx.h文件中增加以下代码:放在其他的include之后 #import "actskin4.ocx" no_implementation raw_interfaces_only raw_native_types using namespace ACTIVESKINLib; #include 6、在对话框的类中定义一个ISkin变量 CComQIPtr m_pSkin; 7、在对话框初始化的函数OnInitDialog中加入以下代码 m_pSkin = GetDlgItem(IDC_SKIN)->GetControlUnknown(); m_pSkin->ApplySkin((int)m_hWnd); 其中IDC_SKIN为所加入ActiveSkin控件的ID 8、运行。 如果想在程序中动态加入Skin可以用LoadSkin函数,如:m_pSkin->LoadSkin(L"B-Studio.skn"); 测试环境 Windows2000Prosfessional VC6.0 ActiveSkin4.25

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧