|
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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
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 ?
|
|
|
|
|
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
|
|
|
|
|
Can anybody help me in copying AAComBSTR to BYTE. Is there any API available which does this copy.
Your help is appreciated.
|
|
|
|
|
|
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
|
|
|
|
|
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<tshapes>(&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.
Ed.
|
|
|
|
|
Take a look at function pointers[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Well, thanks, but that's not quite what I asked.
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.
|
|
|
|
|
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.
|
|
|
|
|
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#!
|
|
|
|
|
This is just me experimenting and playing. Seeing what I can do and make C++ do, for fun. 
|
|
|
|
|
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();
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
if(!CheckModule())
{
return FALSE;
}
}
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?
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
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:38am.
|
|
|
|
|
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.
|
|
|
|