|
sorry for my poor explain ability,I am a beginner,my problem is:
I use one progress to show the status of the current read and current write,but I cant calculate the percent exactly, because all the time expenses is a sum of the reading time and the writting time,the reading procedure locates in "Tremesh" class, but the writting procedure locates in "CView" class, since I can't claculate the percent exactly, I creat a UI thread, the main job of this UI thread is changing a progress continously, It doesn't care about the percent associated with the reading and writting procedure.I hope behind this progress changing, my reading and writting are still working,
but I found, after I use a AfxBeginThread(RUNTIME_CLASS(CProgressThread))to begin the UI thread in the main reading and writting thread , It doesn't start until reading and writting thread ends, my intention is the UI thread should start accompanying with the reading and writting thread, not start after that.
how can i do, thanks.
|
|
|
|
|
So your trying to get the UI thread to run at the same time as your two working threads (read/write) and basically get the UI thread to increment the progress each call or iteration...?
What happens if and when your progress gets beyond 100%, it'll indicate a completion before it actually completes..?
I'm missing something here...if your total is the sum of the time (in seconds) expended for both functions (read/write) your going to have to calculate the number of iterations or calls the threads will receive or someother means of totals. I can't see how your gonna update your progressbar otherwise...?
For just updating a control I don't know if a worker thread is nessecary. It's to my understanding that UI threads are for responding to messages and require a message loop. I would think you could probably do the following:
UINT ProgressThread(LPVOID pParam)
{
CProgressCtrl* pControl = (CProgressCtrl*)pParam;
pControl->StepIt();
}
And start the thread like:
CProgressCtrl* pWnd = (CProgressCtrl*)GetDlgItem(IDC_PROGRESS);
CWinThread* pThread = AfxBeginThread(ProgressThread, (LPVOID)pWnd);
Your thread (i think) should start executing immediately after invocation. Why it's exectuing after your read/write functions go, I have no idea???
Perhaps you thread is being suspended somehow...?
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Another option is to post a windows message from your thread to the main UI thread. This prevents very bad things.
something like:
::PostMessage(MainWindowHWND, YOURMESS_INCREMENTPROGRESS, CURRENT, MAX);
// Rock
|
|
|
|
|
thank HockeyDude
thank CLaW
victorswan
|
|
|
|
|
I want to move picture by mouse, not just drag scrollbar.
Thanks in advance.
|
|
|
|
|
I'm not sure I fully understand you, but i think you want to
handle the picture boxes OnLButtonDown/OnLButtonUp and OnMouseMove.
Your probably going to want to handle the MouseMove in the parent window also/only.
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hello,
I have a problem with the icons in my program. I changed the default MFC icon to my own in VC++ 7. Now my own icon shows up in the top left corner when I run the program but in windows explorer and if I drag a link onto my desktop another icon appears next to the program name. The icon that appears is an icon I'm using for something else in my app... Can someone help me with this?
Regards,
Tobias
|
|
|
|
|
Hmmm. Maybe the system imagelist still has your icon cached or something? If you have TweakUI, it has a function to do this. Otherwise you can delete the ShellIconCache file under the \Winnt or \Windows folder.
___________
Klaus
[www.vbbox.com]
|
|
|
|
|
Thanks for the tip! Too bad it didn't work... Got any other tips?
|
|
|
|
|
Did you change both (large and small) icons?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I think the problem is that you only changed the "large" icon and not the "small" one. Open the resource editor and chose the lower resolution setting, and see if you get the original MFC IDR_MAINFRAME icon.
srs
|
|
|
|
|
Thanks for the tips! I didn't really understand where the choose a lower resolution function is in the resource manager. However, when I removed all the icons from my projekt, rebuilt it, added them again and rebuilt my projekt once more it worked. Very strange indeed...
Thanks again!
Regards,
Tobias
|
|
|
|
|
I am looking for a VU Meter (Realtime volume meter) for use in my C++ project. So far I have been able to find many components that use the windows built in mixer controls to read the peak meter value. This is not sufficient because not all sound card mixers support this. I need something more low level that can obtain the volume level from ANY soundcard
|
|
|
|
|
Hey,
How do I access a bitmap file to read pixels or write pixels? All I need to do is to get pixel color at (x,y) coordinates, then be able to write pixels in a similar way.
Thanks,
Gr3g
|
|
|
|
|
You can select it into a DC and use GetPixel/SetPixel, but unless you're not doing much of this and speed is not an issue, I'd recommend creating a DIBSection ( there are some good wrappers on this site ), which gives you a pointer to the underlying pixel data.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
How do you flush/clear out the message queue in MFC?
|
|
|
|
|
You can loop calling PeekMessage with PM_REMOVE flag till there are no more messages pending.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I want to use A CFile Object so I can use the following GDI+ object call.
static Bitmap* FromStream(
IStream* stream,
BOOL useEmbeddedColorManagement
);
Am I right in thinking I have to create a derrived object, to do this. Could anyone point me in the right direction.
Thanks Again
Rich
|
|
|
|
|
Say I have an array Stuff[100] how would I make that into a collection class I'm having trouble understanding this. I need to derive it from the CObList in MFC. Thanks for your time guys.
-CDudd![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Why do you need to write your own collection ? What are you making a container of ? I guess pointers to some MFC type ?
There seem to be some examples in MSDN for this, go to msdn.microsoft.com if you don't have MSDN on your PC. Personally, I'd use std::vector, but anyone know knows me remotely knew I'd say that. I'm not familiar with any benefits of CObList, but if it's a container specialised for MFC types, there may well be some, in which case I can't help too much except recommending you check the MSDN.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
If what you mean is how to have a CObList of 100 elements, you would have to insert them one by one using CObList::AddTail . The following restrictrions apply:- What you store are not
CObject s, but pointers to CObject created with new (CObList assumes responsibility for delete ing them later). In particular, you cannot store simple types like int s or struct s not deriving from CObject .
- When you retrieve an object stored in a
CObList (well, a pointer to it), you have to figure out its actual type and downcast (most usually what you store are not CObject s but some other class derive from this type.) If you don't mind me evangelizing just a little about STL, why don't you give std::vector or std::list a try? They are way more robust than MFC containers, platform-independent and a lot of fun Plus, Christian Grauss is writing a series of tutorials on STL to help newbies make a warm start.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Well for a class to use the CObList it has to be derived from CObList. So, if I made a CStuff class how would I derive and, use it to make it like an array?
-CDudd
I don't know how to use STL so that is why I don't use it.
![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Maybe I'm misunderstanding you here. What are you trying to do?- Create a list of 100
CStuff objects.
- Define
CStuff to behave as a CObist of fixed size (100).
- Other.
I don't know how to use STL so that is why I don't use it.
Don't mean to be offensive, but seemingly you don't know how to use CobList either and yet you're trying to.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I need a CStuff class to use all the functions of CObList so I can create a list of 100 CStuff objects.
-CDudd
No offense taken, your right I don't quite understand CObList...yet, but it's just one class others I know how to use. Since I don't know anything at all about STL I don't use it.
![Wink | ;)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_wink.gif)
|
|
|
|
|
You want CStuff to be an object AND to be the container that holds them ? Why ?
If you derive a class for CObList then it will BE a CObjList, which means you can add other functionality, AND use an instance of the class to be a container to hold other instances of it. It sounds like a hell of a bad idea to me though, unless I am missing something.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|