|
Calling DoModal() from your worker thread probably won't work, and even if you do set up a message queue for the thread, showing the dialog on that thread defeats the purpose of having a worker thread.
The main thread should show the dialog. In OnInitDialog() , start the worker thread and pass it the dialog's HWND . When the thread's work is done, post a message (such as WM_APP ) to the dialog so it knows the thread's done and it can close itself.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Probably the simplest way would be to run the routine that does your processing within the dialog box that says "Please wait......" After completion, the routine can close the dialog box (CDialog::OnOK () would do the job). This would also enable you to give the dialog a button that may interrupt the processing (set a flag on pressing that button that you check in your proces's loop). Also, it would be easy to add a progress bar in your dialog box.
If you need a lot of variables from your parent dialog, you can simply pass a pointer to the parent to you modal dialog.
Success.
William
-- modified at 11:41 Thursday 16th February, 2006
|
|
|
|
|
You can try to begin another thread to show the message dialog. in this thread , call DoModal can implement it.
when you begin some job in the main thread, you begin the thread to show the message dialog. after you complete job in the main thread, you can kill the thread for show message dialog.
|
|
|
|
|
Hi,After I created my DLL using ATL. I call it by:
#import and CoCreateInstance
but when I use this dll in another windows (that hasn't Visual Studio)
I gives me Send Don't Send error message.
Please help me,
Thanks.
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
Maybe you should register the dll you created on another windows before you use it.
the command line is: regsvr32 (your dll name)
|
|
|
|
|
Hi,
I want to develop a keyboard application which assists user to type in a language other than english. User will type using English keyboard. My app will transliterates it to Unicode equivalent of other languages.
But this app should work across windows. I mean user can type in to note pad also using my app.
Any body give me hint how to do that ?
Thanks in advance
|
|
|
|
|
|
RajeshHegde8xp wrote: ny body give me hint how to do that ?
try keyboard hook
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thanks for reply,
Both anwsers are great. But for my problem keyboard hook seems to be good option.
But i checked examples of Keyboard hooks there we can listen key presses and record it. But i want to listen keypresses and modify key presses as user types.
Thanks again.
Regards
--Rajesh Hegde
|
|
|
|
|
I want to capture the drag or drop operation in the shell(explorer.exe).
What should I do?
|
|
|
|
|
Does anyone know how to get file size, if i work with files using ifstream class?
|
|
|
|
|
<br />
#include <iostream><br />
#include <fstream><br />
using namespace std;<br />
<br />
void main() {<br />
ifstream in("c:/boot.ini");<br />
in.seekg(0, ios::end);
streampos ps = in.tellg();
cout << "File size: " << ps << endl;
in.close();
}<br />
|
|
|
|
|
Thanks a lot!!!
Now i want to read the file into the memory and work with this memory like i worke as with file, i think using istream, but i can't make the istream object...
Here is my code:
<br />
ifstream shapefilef(ShapeFileName.c_str(),ios::binary);<br />
shapefilef.seekg(0,ios::end);<br />
streampos ps = shapefilef.tellg();<br />
int size = ps.seekpos();<br />
char* data = new char [size];<br />
shapefilef.seekg(0,ios::beg);<br />
shapefilef.read(data,size);<br />
istream shapefile(data);
Where is the mistake? I can't compile it... Something in constructor.
|
|
|
|
|
Have a try:
istrstream shapefile(data); // you must #include <strstream>
The istream not constructor like that istream(char* ...)
I think that you need istrstream
|
|
|
|
|
Following should work.
int fh = _open(file name, _O_APPEND , _S_IREAD | _S_IWRITE );<br />
int filesize = _filelength(fh);
Above code needs following header files
1. io.h
2. fcntl.h
3. sys\stat.h
I don't now how can we get file size using ifstream.h. I used above to get it.
We Believe in Excellence
|
|
|
|
|
Or use good old stat()/_stat() Then you won't have to open and close the file. And you don't have to worry about text/binary mode.
|
|
|
|
|
Is there any way to get the object pointer through a pointer to its' member variable?
|
|
|
|
|
If you are within the scope of the class, the object pointer is always available thru keyword "this". If you are outside, then you have used some mechanism to obtain the pointer to the function of an object. This mechanism must have used the object or its pointer, therefore, in that case there is no problem of obtaining the pointer to the object.
|
|
|
|
|
outside the class
and know only one address
|
|
|
|
|
#define CK_CONTAINING_RECORD( PTR, TYP, FLD ) \
( (TYP*)( (byte*)(PTR) - (byte*)(&((TYP*)0)->FLD) ) )
class MyClass {
public:
long m_long;
};
long *lp = ...;
MyClass *op = CK_CONTAINING_RECORD(lp, MyClass, m_long);
...cmk
Save the whales - collect the whole set
-- modified at 0:26 Thursday 16th February, 2006
|
|
|
|
|
but the object is already there
|
|
|
|
|
Not safely. Only if you know the offset in memory of the member variable from the start of the class. Generally though, if you need to do this, you've got a bad design, so fix it.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
It doesn't mean you have a bad design. It can though.
In fact, usign that technique can allow you to create safer versions of such things as std::list which have all sorts of bookkeeping issues in complex system. Systems like this are common in operating systems.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
How to check whether a CArray is empty or not?
For ex: If you have a char x.
You can do if(x==NULL), then print"Error".
How can you do this kind of testing with a CArray? What is used in the place of NULL?
|
|
|
|
|
CArray::GetCount
Regards,
Nish
|
|
|
|