|
Windows NT Service should do the trick.
|
|
|
|
|
I have written a MFC Screensaver and it runs just fine. There is one problem...when Yahoo Messenger displays a toast notification, the toast is displayed on top of my screensaver. This does not seem to happen with other, shipped-with-windows, screensavers. My screensaver window is already created with the WS_EX_TOPMOST flag. What more, if more, can I do to prevent this? Any tips, thoughts, pointers to another resource...???
I have already searched different groups and discussion boards but just can't find anything. If my answer is out there, I have failed in guessing the correct search keywords.
Thanks,
Randy
|
|
|
|
|
Hi, i need to get a handle to the file i opened.
pPos = mainApp->GetFirstDocTemplatePosition();
docTempl = mainApp->GetNextDocTemplate( pPos );
// docTempl now has the correct pointer.
The CDocTemplates holds more CDocuments that are opened. I need a handle from doctempl that i retrieved, to i can close the document (if it was open).
Anyone experience with this? thx, Jack.
|
|
|
|
|
A CDocument does not have a handle. If you want a handle to the file that the CDocument currently holds, use CreateFile() . Something like:
CString strFile = GetDocument()->GetPathName();
HANDLE hFile = CreateFile(strFile, GENERIC_READ, ...);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi everyone,
I am having problems trying to use a templated function.
I have a templated function like so:
template <class T>
bool SetCellStyle(int row, int column, const T & value)
Now I call the function like this for example:
void MyFunc(int value)
{
objectPointer->SetCellStyle<int>(row, column, value);
}
This results in the following error:
error C2275: 'int' : illegal use of this type as an expression.
I do not know why I am not allowed to do this. I would really appreciate some help here.
Thanks,
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>
|
|
|
|
|
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.
|
|
|
|