|
Consider looking in the MSDN Reference with keyword 'CSharedFile'. This MFC class is responsible for creating memory-based shared files. Memory files are just like disk files, with the exclusion that they reside in the RAM instead of the hard drive. Shared memory-files, in addition, are accessible from every process of a computer.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hello all !!
I have a SDI application in wich I plot points on a chart (every 13 msec I plot a new point). I created also a separate Thread in wich I acquire the points and store them in a buffer (from the Doc class). I cannot plot the points directly from that Thread (some conflicts appears and I have runtime errors).
So, the points are plotted on the OnIddle() event from the App class. Up to here, everything works fine !!
BUT, sometimes I need to display a dialog box and so, the points are no more plotted behind. So, I was thinking about two solutions: create a separate thread just for displaying the box. But I think that's a little bit heavy . (This is different message box so I wanted to create a function to wich I send the message box and that will create the Thread).
The other solution was to use modeless dialog but there, the problem is that I need to take some specific actions when the dialog is closed...
So, can anybody give me some guidelines or some help ?
Thanks a lots
|
|
|
|
|
In short:
Provide the support thread a pointer to the CWinApp-object of your main thread. Use this pointer to access the m_pMainWnd member and through it, the CWnd-wrapper of the main window.
More detail:
Considering that this is a single-process program, it would be possible for you to use pointers. Cross-thread pointers are a working and a valid solution for all types of applications. If you use MFC, however, you must remember to synchronize the threads properly.
This way, the support thread, once created, should have a pointer to the CWinApp-object of the main thread, and subsequently, it would have access to the m_pMainWnd variable of CWinApp, which is a CWnd-pointer to the application's main window, residing in the main thread. You could use this pointer's AfxMessageBox method to pop up a message box in the main thread's context without any errors. Just remember to pause the plot-messages when the messagebox is active, because no other messages are handled while a modal dialog (messagebox) is visible.
Communication is the key. Make communication functions and variables between your threads. Make the main thread 'speak' to the support thread, and vice versa. Let them know how the other one is doing, and what it is doing.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Antti Keskinen wrote:
Just remember to pause the plot-messages when the messagebox is active, because no other messages are handled while a modal dialog (messagebox) is visible.
Hum yes but that was my problem !! I want the points to be plotted behind the message box while it's active !!!
So, for you, is it possible doing such a thing using a separate Thread? Or the only solution is the use of modeless dialogs ?
Thanks for your response
|
|
|
|
|
I suspect that you may have to use a custom modeless dialog box to display your messages.
As far as I know, Window's ::MessageBox() (encapsulated by AfxMessageBox()) can only be displayed in a modal state, so whereever you create the dialog, the parent thread will be blocked.
If you really need to use AfxMessageBox(), then I suppose you could create a UI Thread to handle the blocking message dialog, but I think this would be an overkill.
I Dream of Absolute Zero
|
|
|
|
|
RChin wrote:
I suspect that you may have to use a custom modeless dialog box to display your messages.
Yep !
But the thing is I need to display several dialog boxes (when one is closed, I need another to open, and so on...). So I need to keep a pointer to the parent's window and send message to it.
Okay, so I think this is the best solution but it will be somewhat complicated to implement (I need to take also specific actions in the document in response of the user input) . So I that's why I was wandering about a separate Thread.
Thanks for help.
|
|
|
|
|
In this case, you have two solutions:
1. Pop up a modeless dialog in the main thread (easy)
2. Create a seperate thread which will pop up a modal message box (harder)
I would suggest trying method #1. It is by far the most easiest way to accomplish it. When creating the dialog class, add an OnClickButton handler and put it to call DestroyWindow instead of EndDialog . This will make sure that the underlying window object is properly destroyed when the dialog closes up. No other changes are needed for modeless dialogs to work smoothly. To create it, construct an object and call Create .
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi,
How do i extract the icon of an associated file.
any help will be helpfull.
Thanx in advance
Prakash.
The World is getting smaller and so are the people.
|
|
|
|
|
SHGetFileInfo() will retrieve the index of the file's icon in the system image list.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
The other way is:
1.Get full path to the associated program
2.Get default icon
3.Use ExtractIcon on it
Example: *.htm
1.Look for default value of HKCR\\*.htm (it is htmlfile)
2.Find default value of HKCR\htmlfile\DefaultIcon
This is C:\Program Files\Internet Explorer\iexplore.exe,1
3.Call ExtractIcon with iexplore.exe, first icon
Peter Molnar
|
|
|
|
|
Hi
Does anyone have the file window.h to linux?
I need the file for using QueryPerformanceCounter and QueryPerformanceFrequence.
Thank for your time
|
|
|
|
|
jsut the header file is not going to satisfiy your problem, you also need windows library also, now linking windows lib and .h file in linux,hummm well as far as i know, its not possiable..
you sould look for similar thing that linux offers.
regards,
prakash.
The World is getting smaller and so are the people.
|
|
|
|
|
|
I am using files with <fstream.h>. My objective is be appending data to a file in its first line, for example:
11111 -> 22222 -> 33333 -> 44444
11111 22222 33333
11111 22222
11111
My code, executed each five minutes:
arxiu.open(FileName,ios::app);
arxiu.seekp(ios::beg);
arxiu<<data<<endl;
arxiu.close();
... but="" it="" doesn't="" work...the="" code="" does:="" 11111="" -=""> 11111
22222
I'll thank any help.
|
|
|
|
|
Try the below code
I hope it may be work
else i will try and say
arxiu.open(FileName,ios::app);
arxiu.seekp(ios::end);
arxiu<
|
|
|
|
|
Sorry but It doesn't work.
thanks
Christian
|
|
|
|
|
I have been using a 3rd party manufactores PCI databus card API.
Now other people have been using a simular card and API within the company.
So the idear of each writing a library for their manufactures API with a common set of procedures was raised.
I am attempting to write my library first, but the only time I tried to create a library I kept running into problems, linking etc.
Any good examples/notes. The term Static library was muted.
Note the libray must be usable for Win32 MFC and Win32 console applications.
|
|
|
|
|
Hi, I have searched those articles and posts in CP, but found nothing talking about using the ActiveX control, Microsoft ADO Data Control, with Visual C++.NET (V7.0 / V7.1).
What I have learned:
1) Insert the adodc (ADO Data Control) into the dialog box.
2) Configure the properties (the connection string, the record sourcce, etc).
3) Bind to a MS DataGrid Control to display data.
What I would like to know about how to program the ADO Data Control / MS DataGrid Control in my code for the following purposes:
1) Enumerate all the tables / views in an Access Database.
2) Change the record source from Table_A to Table_B programmatically and refresh the MS DataGrid Control.
3) How to use ADO Data Control to navigate data without the MS DataGrid Control.
Thanks in advance!
Maxwell Chen
|
|
|
|
|
What I have learned:
1. The ADO Grid and ADO data control need fixed connection string. You have to start from some existing database and then after succesfull compilation figure out where this string is assigned to ADO control in order to provide your own.
2. The same procedure is applicable.
3. semms no way.
4. I am not sure that everything will work with Access 2000 database format.
default:
1. Create a global own database workspace, global dabase object, global connection string an so on. I do in by forward declaration in a separate header file like global.h. This file will be included in all relevant source files later when you actually switch from one database/table to an other.
2. in a global.cpp define those objects.
3. Table enumeration is given in the database object by a simple request to get a query/table N1,2,3 or by direct access to the system tables, hidden inside any Microsoft database.
4. I could not start ADO datagrid anyway. It was too much additional coding for my simple tasks.
5. You can combine several database in a one project by keeping several workspaces, databases and so on.
6. Once you get ADO table to work with any table prescibed, you can use objects dynamically in order to represent any table you want at any moment.
Serge Chychkan
|
|
|
|
|
HI. Now I'm trying to programming MS DataGrid Control, but have some problams. If you can - send me your project in zip. I'll trying help you.
My e-mail:
keeper_@km.ru
bilas.
|
|
|
|
|
Hi !
I'm using Visual C++ 6. During the night, there is a nightly build of our application and each morning, a batch will copy on my computer a 'fresh version' of the .h and .cpp files, as well as all other files used by Visual C++.
Since a few days, we are using a precompiled header, and now, each morning, when I try (after a small change) to recompile my app, I get this error :
fatal error C1853: '../debug/Sylvie.pch' is not a precompiled header file created with this compiler
What can I do to get rid of this problem. Right now, the only way I found is to rebuild the whole application, but it takes too much time !!!!
Any ideas ?
Thanks !
Jerome
|
|
|
|
|
Hi
Under Project, Settings,C++,Catagory, Precompiled Headers radio button Do not use pch.
Best Wishes and Happy Turkey Day,
ez_way
|
|
|
|
|
But I DO want to use pch, otherwise it takes too long to rebuild.
|
|
|
|
|
Rebuilding the application not build solves this problems.
The World is getting smaller and so are the people.
|
|
|
|
|
Yes, but I want to avoid to rebuild the whole application because it takes a long long time.
What I just want to know is why I get the problem I mentionned in my post, and how to avoid it WITHOUT having to rebuild all AND without getting rid of the precompiled header.
Jerome
|
|
|
|