Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
AnswerRe: File move and compare in VC++ 6 MFC dialog based program?memberMaximilien22 Feb '11 - 13:54 
ajj100 wrote:
compare those files to the files in the directory

 
Compare what ? the size ? date created/modified ? what is inside ?
 
As David wrote, use ShFileOperation (with the appropriate parameters) and check the error code returned to help you there.
 
you can also use FindFirstFile/FindNextFile to search the file in the destination folder to see if the file is there and if it exists, then do any kind of comparision between the two.
 
M.
Watched code never compiles.

Questiontemplates & friendsmemberJoerg Koenig22 Feb '11 - 3:12 
Hello,
 
I'm currently migrating projects from VC6 to VS10 and encountered
a problem using template classes with friend template functions.
The following example was reduced to the minimum to reproduce
the problem. The code compiles without errors/warnings in VC6:
 
------------------- 8< --------------------------------
#include <StdAfx.h>    // nothing special inside this header.
#include <string>
using namespace std;
 
class factory;
 
class attribute {
    protected:
        attribute(const string & table, const string & column, factory * fac);
        attribute(const attribute & attr);
};
 

template <typename T, typename P>
class attributeimpl : public attribute {
    friend class attribute * MakeAttribute(
                const string & table,
                const string & column,
                factory * fac,
                T P::* member
            );
 
    typedef T P::* member_t;
 
    member_t    m_Value;
 
    protected:
        attributeimpl(const string & table, const string & column, factory * fac, member_t mem)
            : attribute(table, column, fac)
            , m_Value(mem)
        {
        }
 
        attributeimpl(const attributeimpl<T,P> & attr);
};
 

template <typename T, typename P> inline
attribute * MakeAttribute(
        const string & table,
        const string & column,
        factory * fac,
        T P::* member) {
    return    (attribute*)(new attributeimpl<T, P> (table, column, fac, member));
}
 

#define BindVar(CLASS,MEMBER,TABNAME,COLNAME) \
    MakeAttribute(TABNAME, COLNAME, this, &CLASS::MEMBER)
 

class factory {
    protected:
        factory();
};
 

class object {
    protected:
        object();
};
 

// --------------------------------------------------------------------

class myobj : public object {
    friend class myfac;
 
    string    m_name;
    string    m_surname;
};
 

class myfac : public factory {
    attribute * name;
    attribute * surname;
 
    public:
        myfac();
};
 

myfac::myfac() {
    name = BindVar(myobj, m_name, "customer", "name");
    vorname = BindVar(myobj, m_surname, "customer", "surname");
}
------------------- 8< --------------------------------
 

VS10 produces the following errors:
 

------------------- 8< --------------------------------
1>templ.cpp(44): error C2248: 'attributeimpl::attributeimpl' : cannot access protected member declared in class 'attributeimpl'
1> with
1> [
1> T=std::string,
1> P=myobj
1> ]
1> templ.cpp(28) : see declaration of 'attributeimpl::attributeimpl'
1> with
1> [
1> T=std::string,
1> P=myobj
1> ]
1> templ.cpp(85) : see reference to function template instantiation 'attribute *MakeAttribute(const std::string &,const std::string &,factory *,T myobj::* )' being compiled
1> with
1> [
1> T=std::string
1> ]
1>
1>Build FAILED.
------------------- 8< --------------------------------
 

AFAIK I don't need to explicitly declare a friend function. The compiler
should take the "friend" declaration to declare the function in the next
outer scope that is not a class (in the example this is the global scope).
But even if I explicitly declare the function "MakeAttribute()" in
the global scope and reference the friend declaration to ::, the compiler
gives me errors. In such a case VS10 says it cannot deduce the template
parameters T and P of "MakeAttribute()".
 
At this point I'm totally clueless... :-|
So how do I have to declare the friend function?
 
Jörg
 

AnswerRe: templates & friendssitebuilderMichael Dunn22 Feb '11 - 5:47 
Joerg Koenig wrote:
friend class attribute * MakeAttribute(
const string & table,
const string & column,
factory * fac,
T P::* member

 
Two things look wrong or suspicious:
Remove "class" after "friend"
What does "T P::* memeber" mean? You might need to add typename in there somewhere.
 
Also check out this FAQ[^]
--Mike--
Dunder-Mifflin, this is Pam.

AnswerRe: templates & friendsmvpCPallini22 Feb '11 - 9:49 
Joerg Koenig wrote:
friend class attribute * MakeAttribute(
const string & table,
const string & column,
factory * fac,
T P::* member
);

 
I think the correct declaration (inside attributeimpl class) should be:
 
template <typename T, typename P>
      friend attribute *  MakeAttribute(
                const string & table,
                const string & column,
                factory * fac,
                T P::* member
            );
 
However, the modified code has still troubles with the linker, on my VS 2010.
 

BTW: did the code author contributed to ATL? Roll eyes | :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

GeneralRe: templates & friendsmemberRajesh R Subramanian22 Feb '11 - 19:51 
CPallini wrote:
BTW: did the code author contributed to ATL?

 
Laugh | :laugh:
"Real men drive manual transmission" - Rajesh.

GeneralRe: templates & friendsmemberJoerg Koenig22 Feb '11 - 21:45 
CPallini wrote:
I think the correct declaration (inside attributeimpl class) should be:
 

template
friend attribute * MakeAttribute(
const string & table,
const string & column,
factory * fac,
T P::* member
);
 
However, the modified code has still troubles with the linker, on my VS 2010.

 
The example was not made to link correctly.
Anyway - your suggestion solved the problem.
I always believed that the compiler uses the template parameters from the class where the friend was declared in, but I was obviously wrong... Hmmm | :|
 

CPallini wrote:
BTW: did the code author contributed to ATL?

 
Sure not WTF | :WTF:
The whole library was written in plain C++ with STL. Roll eyes | :rolleyes:
 
Many thanks for the help!
Questionwindowless shockwaveflash control doesn't work properly individuallymemberfollowait21 Feb '11 - 22:01 
In CMyApp::InitInstance
// not work
SwfWnd * w = new SwfWnd;
SwfWnd->Create(...);
MSG msg;
While(GetMessage(&msg, SwfWnd->GetHWnd, 0, 0))
{
	TranlateMessage(&msg);
	Dispatch(&msg);
}
// work
SwfWnd * w = new SwfWnd;
SwfWnd->Create(...);
 
COtherDlg dlg;
dlg.DoModal();
 
Any way to make the 1st version work?
AnswerRe: windowless shockwaveflash control doesn't work properly individuallymemberAhmed Charfeddine22 Feb '11 - 0:24 
Did you assign the address of the control to the m_pMainWnd member of the CWinApp object before running the message loop ?
Push Framework - now released !
http://www.pushframework.com

GeneralRe: windowless shockwaveflash control doesn't work properly individuallymemberfollowait22 Feb '11 - 14:20 
tried, but still not work
if popup the context menu, it plays
QuestionProblem in Excel Automation.memberLe@rner21 Feb '11 - 21:41 
Hi,
 
i have created a dialog based application in vc 8 for excel automation .
//use this in stdafx.h class

#import \
 ".\MSO.DLL" \
rename("DocumentProperties","DocumentPropertiesXL") \
rename("RGB", "RGBXL")
// I changed OFFICE11 to OFFICE12, since I am using Excel 2007

// Microsoft VBA Objects
#import \
 ".\VBE6EXT.OLB"
 
// Excel Application Objects
#import ".\EXCEL.EXE" \
rename("DialogBox", "DialogBoxXL") rename("RGB", "RGBXL") \
rename("DocumentProperties", "DocumentPropertiesXL") \
rename("ReplaceText","ReplaceTextXL") \
rename("CopyFile","CopyFileXL") \
exclude("IFont","IPicture") no_dual_interfaces
 

 
When i m using the wrapper class, i m getting the following errors.
 
1>------ Build started: Project: Test_excel, Configuration: Release Win32 ------
1>Compiling...
1>StdAfx.cpp
1>e:\my projects\test_excel\release\mso.tlh(19948) : error C2059: syntax error : 'constant'
1>e:\my projects\test_excel\release\mso.tlh(19948) : error C2238: unexpected token(s) preceding ';'
1>e:\my projects\test_excel\release\mso.tlh(20352) : error C2059: syntax error : 'constant'
1>e:\my projects\test_excel\release\mso.tlh(20352) : error C2238: unexpected token(s) preceding ';'
1>e:\my projects\test_excel\release\mso.tlh(25155) : error C2589: 'constant' : illegal token on right side of '::'
1>e:\my projects\test_excel\release\mso.tlh(25155) : warning C4091: '' : ignored on left of 'long' when no variable is declared
1>e:\my projects\test_excel\release\mso.tlh(25155) : error C2143: syntax error : missing ';' before '::'
1>e:\my projects\test_excel\release\mso.tlh(25155) : error C2059: syntax error : '::'
1>e:\my projects\test_excel\release\mso.tlh(25242) : error C2589: 'constant' : illegal token on right side of '::'
1>e:\my projects\test_excel\release\mso.tlh(25242) : warning C4091: '' : ignored on left of 'long' when no variable is declared
1>e:\my projects\test_excel\release\mso.tlh(25242) : error C2143: syntax error : missing ';' before '::'
1>e:\my projects\test_excel\release\mso.tlh(25242) : error C2059: syntax error : '::'
1>e:\my projects\test_excel\release\excel.tlh(29621) : error C2059: syntax error : 'constant'
1>e:\my projects\test_excel\release\excel.tlh(29621) : error C2238: unexpected token(s) preceding ';'
1>e:\my projects\test_excel\release\excel.tlh(30002) : error C2059: syntax error : 'constant'
1>e:\my projects\test_excel\release\excel.tlh(30002) : error C2238: unexpected token(s) preceding ';'
1>e:\my projects\test_excel\release\excel.tlh(35825) : error C2059: syntax error : 'constant'
1>e:\my projects\test_excel\release\excel.tlh(35825) : error C2238: unexpected token(s) preceding ';'
1>e:\my projects\test_excel\release\excel.tlh(74947) : error C2059: syntax error : 'constant'
1>e:\my projects\test_excel\release\excel.tlh(74947) : error C2238: unexpected token(s) preceding ';'
1>e:\my projects\test_excel\release\excel.tlh(76532) : error C2059: syntax error : 'constant'
1>e:\my projects\test_excel\release\excel.tlh(76532) : error C2238: unexpected token(s) preceding ';'
1>e:\my projects\test_excel\release\excel.tlh(76979) : error C2059: syntax error : 'constant'
1>e:\my projects\test_excel\release\excel.tlh(76979) : error C2238: unexpected token(s) preceding ';'
1>e:\my projects\test_excel\release\excel.tlh(86803) : error C2589: 'constant' : illegal token on right side of '::'
1>e:\my projects\test_excel\release\excel.tlh(86803) : warning C4091: '' : ignored on left of 'long' when no variable is declared
1>e:\my projects\test_excel\release\excel.tlh(86803) : error C2143: syntax error : missing ';' before '::'
1>e:\my projects\test_excel\release\excel.tlh(86803) : error C2059: syntax error : '::'
1>e:\my projects\test_excel\release\excel.tlh(86932) : error C2589: 'constant' : illegal token on right side of '::'
1>e:\my projects\test_excel\release\excel.tlh(86932) : warning C4091: '' : ignored on left of 'long' when no variable is declared
1>e:\my projects\test_excel\release\excel.tlh(86932) : error C2143: syntax error : missing ';' before '::'
1>e:\my projects\test_excel\release\excel.tlh(86932) : error C2059: syntax error : '::'
1>e:\my projects\test_excel\release\excel.tlh(88372) : error C2589: 'constant' : illegal token on right side of '::'
1>e:\my projects\test_excel\release\excel.tlh(88372) : warning C4091: '' : ignored on left of 'long' when no variable is declared
1>e:\my projects\test_excel\release\excel.tlh(88372) : error C2143: syntax error : missing ';' before '::'
1>e:\my projects\test_excel\release\excel.tlh(88372) : error C2059: syntax error : '::'
1>e:\my projects\test_excel\release\excel.tlh(94797) : error C2589: 'constant' : illegal token on right side of '::'
1>e:\my projects\test_excel\release\excel.tlh(94797) : warning C4091: '' : ignored on left of 'long' when no variable is declared
1>e:\my projects\test_excel\release\excel.tlh(94797) : error C2143: syntax error : missing ';' before '::'
1>e:\my projects\test_excel\release\excel.tlh(94797) : error C2059: syntax error : '::'
1>e:\my projects\test_excel\release\excel.tlh(95039) : error C2589: 'constant' : illegal token on right side of '::'
1>e:\my projects\test_excel\release\excel.tlh(95039) : warning C4091: '' : ignored on left of 'long' when no variable is declared
1>e:\my projects\test_excel\release\excel.tlh(95039) : error C2143: syntax error : missing ';' before '::'
1>e:\my projects\test_excel\release\excel.tlh(95039) : error C2059: syntax error : '::'
1>e:\my projects\test_excel\release\excel.tlh(95143) : error C2589: 'constant' : illegal token on right side of '::'
1>e:\my projects\test_excel\release\excel.tlh(95143) : warning C4091: '' : ignored on left of 'long' when no variable is declared
1>e:\my projects\test_excel\release\excel.tlh(95143) : error C2143: syntax error : missing ';' before '::'
1>e:\my projects\test_excel\release\excel.tlh(95143) : error C2059: syntax error : '::'
1>Build Time 0:03
1>Build log was saved at "file://e:\My Projects\Test_excel\Release\BuildLog.htm"
1>Test_excel - 40 error(s), 8 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
How to correct these errors?
 
please help me for this.
 
Thanks in advance,

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid