|
Hi.
I need to load a dialog from a resource script, (.rc file), at runtime. I mean, the resource file is not in the project, it was created outside the project and then, at runtime, I have to bind a CDialog class with some DIALOG template present in this .rc file. Is it possible?
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Well, anything is possible To load a script (text file) you need a compiler, basically a C-compiler. This will be messy. If you need to do heavy modifications of the resources at runtime I would instead recommend 1) loading compiled resources in a DLL and 2) using UpdateResource.
|
|
|
|
|
Thank you for answer.
Ok, I understand.
But 2 more questions, please.
1)
I have a resource file, and I have to compile it using, in example, VC compiler, ok?. What are the compiler options, (or where could I find it), to compile that script file into a dll. I mean without need to create a DLL project and so on. Because the guys that will create the resource script file, they don't know nothing about programming, they just put controls here and there using the VC 6.0 resource editor and nothing more. Then I will run, in example, a bat file to compile some given .rc files into a DLL.
2) Then that dll file will be load it at runtime by a VC program, (an OCX in particular), and it will use that dialog from dll and bind it to an existing CDialog derivated class.
Confusing?,
I thought in all this because we need to display many kind of dialogs, (and everyday a new one), and we want them outside the main project.
Maybe there's an easier way to handle this, but I can't figure out.
Thank you very much.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Ok, sounds reasonable. Compile the script.rc using rc (which is, I believe, in reality a preprocessor that converts stuff like BEGIN to { and END to }, DIALOG to a c struct and after that calling a C-compiler). The resource compiler produces a .res file, that you can link into a .dll with /DLL. Another option is to create a DLL project in MSVC and use the Project/Export makefile command in MSVC - you'll have a real fun experience trying to dechiper the output But it works
And then to load the dialog is a breeze; LoadLibrary and then LoadResource on the HMODULE returned, and then CreateDialog with the template loaded. Translate to the framework you're using.
|
|
|
|
|
Ok, I got it!
Thank you very much!
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
I am getting problem in ofstream and ifstream but only in vista envirnment with my visual studio 6.0 Visual C++ application.
I am trying to support drag and drop feature for my application vista. Instead of vertual lization i tried to save the drag and drop object file in the physical memory but When i am trying to ready the file if I do not create one more ofstream object it want read properly in vista. I can not write this kind of unknown code in my application. I need help to understand why my code required ofstream again after ifstream in order to read.
Where in one .cpp file producer application is creating one .txt file that has information of objects that is going to be dragged to the consumer application. That text file is created in the virtual memory so I changed the location to physical memory. as seen below.
That is all I have changed in producer side
CString fileNameWithoutPath = dbObjTransferID + ".txt";
/*char tmpPath[_MAX_PATH];*/
CString cTempPath= "C:\\Program Files\\Common Files\\";
//VERIFY(GetTempPath(_MAX_PATH, ctmpPath));
CString fullyQualifiedTmpFile;
fullyQualifiedTmpFile.Format("%s%s", cTempPath, fileNameWithoutPath);
ofstream outStream(fullyQualifiedTmpFile, ios::out | ios::trunc);
if (outStream.good())
{
Am_Default_Load_Save_Context.Reset();
Am_Default_Load_Save_Context.Save(outStream, Am_Value(listOfItemsToSave));
outStream.close();
*phGlobal = GlobalAlloc(GMEM_FIXED | GMEM_SHARE | GMEM_ZEROINIT,
fullyQualifiedTmpFile.GetLength() + 1);
const char * pStr = fullyQualifiedTmpFile;
memcpy(*phGlobal, pStr, fullyQualifiedTmpFile.GetLength());
bSuccess = TRUE;
}
else
bSuccess = FALSE;
IN THE CONSUMER SIDE:
I am opening the filed that I have created wich has object information and trying to read that file but if I do not put some ambiguious code in it, it want work without it. Once I try to create ifstream object to read that file, I HAVE TO CREATE ONE MORE OFSTREAM TO LET DATA READ CORRECTLY USING THE IFSTREAM FILE.
// copy the pFileName so that we can free the global memory.
CString fileName = pFileName;
GlobalUnlock(stgMedium.hGlobal);
GlobalFree(stgMedium.hGlobal);
ifstream inFile;
inFile.clear();
inFile.open(fileName, ios::in);
// This is the code I have to add in order to make drag and drop work.
// I DO NOT WHY ????
CString copyfileName = "C:\\dndNonUsedfile.txt";
ofstream nFile(copyfileName, ios::out);
if(inFile.good())
{
Am_Value amVal;
if(ReadTransferredDataFromFile(inFile, amVal))
if(amVal.Valid())
{
versionObj = amVal;
}
inFile.close();
CFile::Remove(fileName);
}
nFile.close(); //Code to support vista
Kreena Amin
Sr. software engineer
|
|
|
|
|
All i would like to do is read an XML file and create one.
I forgot how tricky this can be in C++ .
I am using things like:
MSXML2::IXMLDOMDocument2Ptr pDocument;
MSXML2::IXMLDOMElementPtr pDocRoot;
MSXML2::IXMLDOMElementPtr pFound_Element;
MSXML2::IXMLDOMNodePtr pTag;
In my stdafx.h
I placed :
#import <msxml4.dll>
using namespace MSXML2;
I keep getting Cannot open type library file: 'msxml4.dll': No such file or directory.
Has anyone done this before who can give some guidance/Help?
|
|
|
|
|
It's been a while since I used it but I would guess you don't have MSXML4 installed correctly (with any Service Packs) on your system. The installation should place it correctly and register it etc.
What version of Visual Studio and Windows are you running?
|
|
|
|
|
I am running visual studio version 7 and XP SP 2
|
|
|
|
|
Can you recommend a decent link for this download?
|
|
|
|
|
umm Microsoft.com ??
|
|
|
|
|
take a look at tinyXML.
true, it doesn't do everything MSXML does (no DTD, XSL or XSLT support), but if you don't need that, you can save yourself the pain of dealing with COM, DLLs and #imports. plus, you get the source, so you're not stuck fighting the blackbox that is MSXML*.
|
|
|
|
|
LCI wrote: I keep getting Cannot open type library file: 'msxml4.dll': No such file or directory.
Does the file exist on the development machine? Are the search paths set correctly?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
If you just want to get it working for now, use this
#import <msxml3.dll>
However, be forewarned if your using VC++ 2003 and trying the "using namespace MSXML2;" line in your stdafx.h file. See this post for a "solution" to the ambiguous symbols errors that might creep up...
VC++ 2003 "ambiguous symbol errors"[^]
|
|
|
|
|
hi,
I think u have to either download a patch which is available in ms patch downloads. I think the build of yours is a debug one, try in the release mode.
becoz i faced similar problem when i downloaded the xml sdk. I am not sure , try this. If it works or not take it as a note.
See u.
|
|
|
|
|
kanduripavan wrote: I think the build of yours is a debug one
That's usually what I build with until release day. I'm not having any problems with my XML apps so I'm not sure what your response refers to.
Did you mean to post to the OP?
|
|
|
|
|
I had downloaded one version of msxml sdk,which ran perfectly alright in the release mode but not in the debug version. Faced similar difficulties like i was not able use the tlb (import lib). I then browsed and found that there was a patch for that release, so have to download that again and after then only i was able to build my application in debug mode.
thats it.
|
|
|
|
|
Hi,
I'd like to be able to display a ToolTip on a keyboard keypress. This is so when a user enters a dodgy value into a CEdit control it pops up a tooltip telling them to enter a correct value. I have created a derived class from CEdit called CEditX so I can use my validation methods on my CEdits, but I can't find a way to add the tooltips!
Thanks,
David.
|
|
|
|
|
|
I've managed to actually add tooltips to my controls now. Any ideas how i tie these to keyboard keypresses? I can't find any information on this.
There are inbuilt dialogs in MFC that do what I'm trying to achieve, but are added as a property on the resource. For example if you set a field to "Password: True" whenever you press Caps Lock within the field a tooltip (balloon style) appears at the caret position, rather than at the mouse position.
Thanks.
|
|
|
|
|
dsclee wrote: There are inbuilt dialogs in MFC that do what I'm trying to achieve, but are added as a property on the resource.
I have no idea what that means. what is an "inbuilt dialog"? And how do you add a dialog as a property?
dsclee wrote: For example if you set a field to "Password: True" whenever you press Caps Lock within the field a tooltip (balloon style) appears at the caret position, rather than at the mouse position.
Well a tooltip isn't magical, it's just a window, take a look at one in Spy++. You can make a window do anything you want including set it's position.
|
|
|
|
|
I wrote a c++ ATL dll, and now want to call it from another c++ app. What exactly do I need to do be able to call it?
In the h file for the ATL dll
STDMETHOD(MyFunction)(BSTR OutputDirectory, BSTR DlgTitle, BSTR BatchFileName, BSTR ResultsFileName, int ObjectStartNumber);
plus other functions
I tried to include this h file but got these errors:
error C2079: 'CSFilter' uses undefined class 'ATL_NO_VTABLE'
error C2239: unexpected token ':' following declaration of 'CSFilter'
error C2059: syntax error : 'public'
error C2448: '<unknown>' : function-style initializer appears to be a function definition
fatal error C1004: unexpected end of file found
Error executing cl.exe.
thanks,
sb
|
|
|
|
|
ns wrote: I tried to include this h file but got these errors:
ns wrote: error C2079: 'CSFilter' uses undefined class 'ATL_NO_VTABLE'
CSFilter Sorry, that is ATL_NO_VTABLE is undefined. You have not included the definition for it in your project.
|
|
|
|
|
I just took the .h file straight from my ATL dll project and did a #include in the test harness project.
What is it I need to do?
thanks,
sb
|
|
|
|
|
ns wrote: What is it I need to do?
You need to configure your project to include any dependent header files and resolve any dependent library files to successfully compile and link.
|
|
|
|