Click here to Skip to main content
       

ATL / WTL / STL

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
QuestionOpen file in basic MFC appmemberbkelly135 Dec '12 - 14:45 
Visual Studio 2008, Windows 7
I create the basic MFP application with Single or Multiple documents, then immediately compile and run it. Using the File -> Open option I can navigate to and open a file.
 
However, when looking through the code I do not recognize any variable that might be the handle to a file. How do I acces that file I just opened?
Thanks for your time

AnswerRe: Open file in basic MFC appmvpRichard MacCutchan5 Dec '12 - 21:24 
It's a while since I used MFC but I think the actual handle is held internally by the CDocument object. When you open the file the framework should call your OpenFile() method (I think that's its name) and you then load the data from the file using the CArchive object. The skeleton code should be there in your document class.
One of these days I'm going to think of a really clever signature.

GeneralRe: Open file in basic MFC appmemberbkelly139 Dec '12 - 11:36 
A search for OpenFile returned nothing. I looked around for CDocument and CArchive but did not recognize anything that looked like code to open a file.
Thanks for your time

GeneralRe: Open file in basic MFC appmvpRichard MacCutchan9 Dec '12 - 21:36 
I don't know where you were looking, but MSDN details CDocument::OnOpenDocument[^] and CArchive::Read[^] along with all the various other member functions of each class.
One of these days I'm going to think of a really clever signature.

Generalthe answer ismemberbkelly139 Dec '12 - 12:25 
Override OnOpenDocument, in the CDocument class. That function will be called with the selected file path.   You would normally open and read the file there.  
This answer was courtesy MSDN forums.
 
Thanks for your time
QuestionHow To Use Macro In dsp file(VC6.0 *.dsp file)memberyingkou27 Nov '12 - 14:37 
I want to use macro in .dsp file for load different file to workspace,just as below:
 
123 is a sub-folder of 04 project folder and there is a 04.rc and resource.h
 
!IF "$(CFG)" == "04 - Win32 Release"
RCF=..\\123\\04.rc
 
RCH=..\\123\\Resource.h
 
!ELSEIF "$(CFG)" == "04 - Win32 Debug"
RCF=..\\123\\04.rc
RCH=..\\123\\Resource.h
 
!ENDIF
 
# Begin Target
 
...
 
# Begin Source File
SOURCE=RCF
# End Source File
 
Begin Source File
SOURCE=RCH
# End Source File
 
# End Target
 
Open workspace by VC6 IDE, RC is not loaded and RCF and RCF are display as a file name in workspace but empty,why?how should I do for doing this work well。
Change macro definition as below,result is same
 
RCF=.\123\04.rc
RCH=.\123\Resource.h
AnswerRe: How To Use Macro In dsp file(VC6.0 *.dsp file)mvpRichard MacCutchan27 Nov '12 - 23:34 
The results of both parts of your !IF expression are the same. I have not used VC6 for many years, but the later versions need some other function to copy the source file to the project directory. Take a look at how the other files are handled.
One of these days I'm going to think of a really clever signature.

QuestionAccessibleObjectFromWindow returns E_ACCESSDENIEDmemberBianChengNan25 Nov '12 - 23:04 
I called
AccessibleObjectFromWindow(hPDFDoc, OBJID_NATIVEOM, IID_IDispatch, (void**)&pDisp );
to get an interface to access PDF files. but in xp it returns an error E_ACCESSDENIED. when in win7 it works fun. I guess that I didn't have enough authority.
I tried some setting on my computer, but all failed, I really have no more idea of this.
Any tip would be great helpful.
QuestionHow to use NTGraph3D Activex Control in Visual Studio 2010.memberDhrumilS23 Nov '12 - 0:44 
Visual Studio C++ provides facility for using ActiveX control in VC6.0 as well as in VC2010. I tried NTGraph3D activeX Control in VC6.0. It is working perfectly.
 
I tried the same in VC 2010. So for Visual Studio 2010, NTGraph3D ActiveX Control is not working.
 
So can anyone help me to solve this problem. Is there any change in properties ?
Newshacker240unionmemberhacker240union22 Nov '12 - 23:40 
hello everyone
we are hacker union Game source code group
We can help you get
someone or company file.photo.Record.Game source
 
code.
Have any questions about computer aspect need to
 
please contact us
plenty of Game source code. to sell or get to
 
designated game code
 

Yahoo Messenger:hacker240union
mail:hacker240union@yahoo.com.cn
Questioncopying AAComBSTR to BYTEmemberV K 220 Nov '12 - 20:56 
Can anybody help me in copying AAComBSTR to BYTE. Is there any API available which does this copy.
 

Your help is appreciated.
AnswerRe: copying AAComBSTR to BYTEmvpRichard MacCutchan20 Nov '12 - 21:28 
Try CComBSTR::BSTRToArray()[^].
One of these days I'm going to think of a really clever signature.

AnswerRe: copying AAComBSTR to BYTEmemberhacker240union22 Nov '12 - 23:27 
hello everyone
we are hacker union Game source code group
We can help you get
someone or company file.photo.Record.Game source
 
code.
Have any questions about computer aspect need to
 
please contact us
plenty of Game source code. to sell or get to
 
designated game code
 

Yahoo Messenger:hacker240union
mail:hacker240union@yahoo.com.cn
QuestionC++ Delegate/EventsmemberEdward G Dana14 Nov '12 - 17:15 
Greetings,
 
I just recently started some experiments with C++. I'm an experienced programmer, but not with C++, but, just for fun, I decided to implement this example C++ Delegate here on Code Project.
 
This example keeps the methods hooked into the delegate inside structs. In the example given these are: struct TShapes, struct TDerivedShapes and struct TThings. These are then initialized in this fashion: event += new MyEvent::T(&shapes, &TShapes::Square);
 
My question is this: is it necessary to store the methods to be hooked into these events into a struct? I assume this is done because the struct makes the address available to be used in the delegate. If the answer to this question is no, then how do you hook into the even just through standard methods within a normal C++ program? Please forgive the stupidity of my questions. Smile | :)
 
Ed.
AnswerRe: C++ Delegate/EventsmvpRichard MacCutchan14 Nov '12 - 20:57 
Take a look at function pointers[^].
One of these days I'm going to think of a really clever signature.

GeneralRe: C++ Delegate/EventsmemberEdward G Dana15 Nov '12 - 13:35 
Well, thanks, but that's not quite what I asked. Smile | :)
 
I was wondering if it was required to embed your methods in a struct for the example identified. If by your response you meant "yes, they must be embedded" then an explicit answer would be appreciated.
 
Thanks again.
 
Ed.
GeneralRe: C++ Delegate/EventsmvpRichard MacCutchan15 Nov '12 - 23:45 
Edward G Dana wrote:
Well, thanks, but that's not quite what I asked.
Sorry, I misunderstood. But I think your question should really be directed at the author of the article.
One of these days I'm going to think of a really clever signature.

AnswerRe: C++ Delegate/Eventsmemberpasztorpisti20 Nov '12 - 2:53 
C++ doesn't natively support delegates and delegate implementation in C++ is quite messy especially if you try to support methods with variable number of parameters and parameter types - it also involves super-ugly method pointer casting. Delegates are simply ugly in C++, I recommend never using them if it isn't necessary. (For me using delegates is necessary only if a used 3rd party library makes it necessary to use delgates in its public interface...) I always prefer using old-school listener interfaces with old-school virtual methods (classes with pure or empty-bodied virtual methods only) to listen for events. Always consider alternatives and prefer readability of the resulting code. It doesn't worth trying to shape C++ into C#!
GeneralRe: C++ Delegate/EventsmemberEDanaII20 Nov '12 - 16:23 
This is just me experimenting and playing. Seeing what I can do and make C++ do, for fun. Smile | :)
QuestionReturn FALSE in InitInstance causes crash in 64Bitsmemberkhaliloenit8 Nov '12 - 1:01 
I have an executable compiled with x64 configuration.
I need to test it on Windows 7 64 bits.
when I run it, it crash when I return FALSE in InitInstance function.
BOOL CMyApp::InitInstance()
{
    if (IsAppAlreadyStarted())
        return FALSE;
 
    InitCommonControls();
 
    CWinApp::InitInstance();
 
    // Initialize OLE libraries
    if (!AfxOleInit())
    {
        AfxMessageBox(IDP_OLE_INIT_FAILED);
        return FALSE;
    }
    AfxEnableControlContainer();
 
    if(!CheckModule())
    {
        return FALSE; // after call application crash
    }
}
 
when it is compiled with x32bits configuration and run on Windows 7 x64 there is no probleme.
Just when it is compiled with x64.
 
any help please?
AnswerRe: Return FALSE in InitInstance causes crash in 64BitsmemberAlbert Holguin10 Dec '12 - 4:30 
I'd venture to say that something in CheckModule() is causing the crash and not returning FALSE. Although by returning FALSE you are indicating a failure on initialization anyway, so I'm not sure how gracefully it's supposed to go down after that.
QuestionHow to get used dll's path information programetically?memberlitu kumar6 Nov '12 - 19:38 
Hi,
I'm using a .net dll in a Win32 application.
I want to print the DLL file location programetically.
 
I tried like as below , but it still displaying the EXE's (generated by my win32 app.) path -
-----------------------------------------------------------
HMODULE hmod = GetModuleHandle(TEXT("MyApp.dll"));
TCHAR szPath[MAX_PATH + 1] = {0};
DWORD dwLen = GetModuleFileName(hmod, szPath, MAX_PATH);
wprintf(L"CURRENT DIRECTORY: %s\n" ,szPath);
-----------------------------------------------------------
 
Please advice any new solution or any correction required (above code stuff) for the same.
AnswerRe: How to get used dll's path information programetically?mvpRichard MacCutchan6 Nov '12 - 21:40 
The chances are that hmod is NULL because MyApp.dll has not been loaded into memory as required by the GetModuleHandle()[^] function. Always check return values from API calls, do not just assume that it works.
One of these days I'm going to think of a really clever signature.

GeneralRe: How to get used dll's path information programetically? [modified]memberlitu kumar6 Nov '12 - 23:27 
Hi Richard,
 
You mean to initialize 'hmod' to NULL as below -
 

HMODULE hmod =NULL;
hmod= GetModuleHandle(TEXT("MyApp.dll"));
if(hmod!=NULL)
{
DWORD dwLen = GetModuleFileName(hmod, szPath, MAX_PATH);
wprintf(L"CURRENT DIRECTORY: %s\n" ,szPath);
}
====================================
If the above code stuff as per your indication,then 'GetModuleHandle' not returning NULL .
And it printing the path of EXE not of required 'MyApp.dll'
 
Kindly guide me if i understood the wrong thing.

modified 7 Nov '12 - 6:38.

GeneralRe: How to get used dll's path information programetically?mvpRichard MacCutchan7 Nov '12 - 4:54 
No, I mean the value returned from GetModuleHandle() is NULL if that library has not been loaded into your address space. In which case you will get the path of your executable. Check the link to the documentation that I gave you.
One of these days I'm going to think of a really clever signature.

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


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