|
Hello, first of all please turn the "Do not treat <'s as HTML tags" checkbox on when posting code, so that < s are shown properly. I reproduce here your code (with brackets):
template <class T>
bool SetCellStyle(int row, int column, const T & value)
void MyFunc(int value)
{
objectPointer->SetCellStyle<int>(row, column, value);
} Is MyFunc by chance a member function of a class template? If so, maybe you're being hit by a nasty problem with so called dependent contexts. Please try the following and report the results:
void MyFunc(int value)
{
objectPointer-> template SetCellStyle<int>(row, column, value);
} Did that work?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Oh, also, you don't really need the <int> part here. The following should suffice:
void MyFunc(int value)
{
objectPointer->SetCellStyle(row, column, value);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Hi!
Thanks. The whole problem was the <int> in the call. It behaves ok when I use
objectPointer->SetCellStyle(row, column, value) instead of
objectPointer->SetCellStyle<int>(row, column, value);
I have no idea why. I thought after VS 5.0 this problem disappeared. I am going to try it with VS 7 to see what happens.
Cheers,
Pankaj
<font size = "1">
/**
I'm the one who's gonna have to die
When it's time for me to die
So let me live my life
The way I want to
- Jimi Hendrix
*/</font>
|
|
|
|
|
Hi,
I have two projects
1. DLL project: Creating one .dll file
2. Application project: Which uses the .dll file created in Dll project
First I execute the Dll Project in Debug mode wherein it creates a .dll file. Now I copy this .dll file to the Debug folder of Application project. Now I execute the Application project in debug mode which uses the created .dll file.
How can I debug the DLL project (traversing .cpp files of DLL project by puting break points) i.e. I put a break point into a CPP file(X) of DLL Project and one break point in the CPP file(Y) of Applicatin project where it calls the function from dll file. When control reaches the break point in Y which calls to the function in dll file and if I press F5, control should go to the function in CPP file (X) of DLL project.
How to do this?
Thanks & Regards,
Neeraj
|
|
|
|
|
Insert the DLL project into .exe workspace from the projects menu
Set the exe project as active configuration
Make the exe project dependent on the dll project (porject dependencies)
Add a post build step to the dll project which copies the nuilt dll to the applications directory
Place breakpoints as required (works as VC knows about both)
Debug as required.
If you vote me down, my score will only get lower
|
|
|
|
|
I need to save few objects' to a file and reload them later on to memory.
I used something like that:
WriteFile(hFile, obj_ptr, sizeof(DATABASEINFO), &NumberOfBytesWritten, NULL);
and then:
ReadFile(hFile, CurrentObject, sizeof(DATABASEINFO), &NumberOfBytesRead, NULL);
where "CurrentObject" is a pointer to an allocated space for "DATABASEINFO" structure.
This method doesn't work. the Read operation reads nonsense.
Can anyone see the problem? is there a better way for doing this?
Thanks.
|
|
|
|
|
Make sure the structure members are on 1 byte boundaries. You can specify that using:
#pragma pack(1)
macro.
You can also specify it for complete project in project -> settings, C/C++ tab and there choose the Code generation category and set struct member alignment to 1 byte.
|
|
|
|
|
ok. it seems to do the work. but there is still a problem with pointers types. is there a simple way to handle them?
for example, in one structure i am holding a property from type char*. when writing the object to the file, the pointer is stored and not the string held in it, which is, of course - useless.
|
|
|
|
|
Of course, you cannot use this when your structure hold pointers !!!
What is a pointer ? A pointer is just a 32 bits variable that holds an adress (at this adress, the data is stored). So, when you write the pointer to the file, it just stores the adress and not the data.
If you want to save your structure, it would be a better idea to encapsulate the save/load functions inside your structure (if you don't use the MFC and/or don't want to use serialisation, you can do it yourself):
typedef struct
{
int DataCount;
int* pSomeData;
void SaveData(HANDLE* hFile)
{
DWORD NumberOfBytesWritten;
WriteFile(hFile, &DataCount, sizeof(int), &NumberOfBytesWritten, NULL);
WriteFile(hFile, pSomeData, sizeof(int)*DataCount, &NumberOfBytesWritten, NULL);
}
void LoadData(HANDLE* hFile)
{
DWORD NumberOfBytesRead;
ReadFile(hFile, &DataCount, sizeof(int), &NumberOfBytesRead, NULL);
pSomeData = new int[DataCount];
ReadFile(hFile, pSomeData, sizeof(int))*DataCount, &NumberOfBytesRead, NULL);
}
} YourStruct;
And from the outside it will look like:
YourStruct* pStruct = new YourStruct;
pStruct->SaveData(hFile);
Or for loading:
YourStruct* pStruct = new YourStruct;
pStruct->LoadData(hFile);
Hope this helps
|
|
|
|
|
|
Hi all
How can I share some memory allocated in one process by another process by using dll.?
Is there any way to accomlish this using other methods
Thanks in advance
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Maybe you can use memory-mapped files ? You can open a file-mapping object in memory from one process and access data in it within another process.
Take a look at the MSDN for file mapping (and file mapping functions...)
Hope this helps
|
|
|
|
|
Or...even look more locally...
http://www.codeproject.com/threads/ipc_tute.asp
http://www.codeproject.com/win32/cmemmap.asp
http://www.codeproject.com/threads/csharedstruct.asp
http://www.codeproject.com/threads/sm.asp
http://www.codeproject.com/threads/sharedmemipc.asp
http://www.codeproject.com/threads/memmapipc1.asp
http://www.codeproject.com/threads/SharedMemory_IPC_Threads.asp
That should get you pointed in the right direction
|
|
|
|
|
The recommended way to share data, is memory mapped files. Look up the functions CreateFileMapping and MapViewOfFile.
You could also create a shared section in your dll, I can't remember the procedure, but you should be able to find it on MSDN by searching for '#pragma' and 'shared'.
I don't think you can share memory allocated by new() or malloc() though...
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Hi
Thank you all, it was of great help.
See you all later
bye
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
I am using Visual Studio .NET 2003.
I would like to convert a CString into a std::string. With Visual C++ Ver 6.0 one could just use the std::string constructor, but now I get an error message with VS .NET 2003. Does anybody know?
I am the handsome one in the crowd.
|
|
|
|
|
Maybe forcing the conversion to a LPCSTR ?
Cstring cs=...;
std::string s=(LPCSTR)cs;
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Scenario :- I want to connect to multiple servers from a single client at a time and collect some information.
Is it possible to do this using CAsyncSocket in a single thread for each server?
When is CAsynSocket used instead of CSocket ?
Thanks in Advance,
Ajoy.
U Live And Let Others Live
|
|
|
|
|
Hi,
Be carefull with multithreading, CLOSING, I've experinced the pain.PLAN PROPERLY.
Sujan
|
|
|
|
|
Hello,
MSDN says the following about CSocket and CASyncSocket:
"You should probably consider using CAsyncSocket if you want Windows Sockets' ease of dealing with multiple network protocols in an MFC application but do not want to sacrifice flexibility. You might also feel that you can get better efficiency by programming the communications more directly yourself than you could using the more general alternative model of class CSocket."
So CSocket is a more easy to use class at the cost of some overhead. If you don't need high speed connections, multi network protocols, I'd stick with CSocket.
Hope this helps
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
|
I didn't knew that..
Als an alternative, you can use a Socket class found here on codeproject. There are many here, so it should be easy to find one.
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
I'm using code from MSDN article "Handling HTML Element Events" but DIID_HTMLElementEvents2 interface seems to be undefined.
It's not declared in mshtml.h, only DIID_HTMLElementEvents.
Where is DIID_HTMLElementEvents2 declared?
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|
|
I have write an application, use VC++ connect to Oracle database, and use Crystal Report to view data and print
Any one can help me, how to connect to Oracle and use Crystal report.
thanks.
|
|
|
|
|
The same problem i also have, but instead of Oracle database i am using MS Access as the database. Can Anybode let me know how to get the same thing using MS Access as the database.
I know how to connect to MS Acces database, but what i want to know is how to use Crystal Report to view data and print.
Regards,
Pankaj
|
|
|
|