|
The simplest answer is yes, you definitely need to delete the ThreadA that pThreadA points to.
There are a few other things that strike me as notable/strange.
1. FuncPtr is static, and thus has no "this" context. "delete this" will result in a compile time error. Any member functions/variables will also be inaccessible from FuncPtr.
2. If you want to use "delete this", you need FuncPtr to accept a pointer to a the ThreadA object and use it to call an instance function.
e.g.:
int FuncPtr2()
{
// do stuff
return 1;
}
static int FuncPtr(void * param)
{
return ((ThreadA *)param)->FuncPtr2();
}
Now FuncPtr2 has an appropriate context to use "delete this". However, this is probably a bad idea. In my experience, it sometimes leads to strange bugs, and it's just not worth it. In addition, the behavior of "delete this" is undefined if the object "this" points to was allocated on the stack.
My suggestion would be to put some sort of checking mechanism into main. (I assume this is what Wait() is doing.) At the end of the function (or at the end of the relevant section), use this checking mechanism to wait for the thread to complete, and then delete the ThreadA object in the main method.
|
|
|
|
|
I had set the min value and max value to spin by
m_spin.SetRange(250,500);
But then, how to set the step value to spin.
It should increment like 250, 300, 350, 400, 450, 500
Can anyone help me out, please.
It is so urgent. I thank in advance.
Mughilan
|
|
|
|
|
Could not find anything that will do that what you are asking for by default. You have i guess customise it.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Will SetStep(50) not do what you require?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
CSpinButtonCtrl doesn't have a SetStep() method that I can find. I'd try providing a handler for the NM_RELEASEDCAPTURE message that calls GetPos(), adds or subtracts 50, then calls SetPos(). Of course, someone more knowledgable might have a better solution.
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
Indeed. I missed the reference to CSpinButtonCtrl . He'll need to use SetAccel() instead.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
DavidCrow wrote:
use SetAccel()
I wondered about that... I haven't used it, but is it possible to set the first element of the UDACCEL structure to [0,50]? If it doesn't choke on the 0 value for elapsed time I would expect it to do the job adequately, but the documentation doesn't elaborate on it much.
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
I am currently working on a very simple plugin framework for a C++ application. My proposal is as follows:
1 - All plugins are DLL's, and are uniquely identified by a string GUID constant within the DLL.
2 - All Plugins must contain a function called "InitDLL". InitDLL receives a structure defined as follows:
struct plugin_info
{
char* plug_guid;
char* plug_name;
char* plug_desc;
plug_send send_ptr;
};
In InitDLL, plug_guid, plug_name, and plug_desc are filled out. A local copy of send_ptr is kept in every plugin DLL.
3 - plug_send is a pointer to a function in the main program that receives events from the dll. It is defined as follows:
typedef void (*plug_send)(char* plug_guid, char* event, void* event_params_struct);
The local copy of send_ptr stored in the DLL can be called at any time to send events to the host application. Several structs will be defined for passing parameters (as the event_params_struct), and the struct used will depend on what event is being passed to the main application.
4 - Certain structs will also have pointers to functions in the DLL themselves. These functions will be used as callbacks, to allow the host application to send events back to the DLL.
5 - Both the host application and DLL's will have access to a public API, in the form of a C++ header file.
Does anyone see any major problems with this proposal, or will it work decently for a very basic plugin system? All feedback appreciated.
|
|
|
|
|
Sounds Good Enough to me.
This space is empty.
|
|
|
|
|
Hello, I am new to C++ and mostly started out in C#. Unfortunately Microsoft has not provided DirectShow for C# so now I must learn C++. Basically what I need to do is take some bitmaps and convert them to an AVI file. I have learned that the DirectShow SDK provides a way to do this using filters. An example comes with the SDK but unfortunately I cannot understand it and was hoping someone on codeproject can help me decipher how it works..
CPushPinBitmapSet::CPushPinBitmapSet(HRESULT *phr, CSource *pFilter)
: CSourceStream(NAME("Push Source BitmapSet"), phr, pFilter, L"Out"),
m_FramesWritten(0),
m_bZeroMemory(0),
m_iFrameNumber(0),
m_rtFrameLength(FPS_2), // Display 2 bitmap frames per second
m_iCurrentBitmap(0),
m_bFilesLoaded(FALSE)
{
Now, what exactly is this doing... is this instantiating a class which derives from something? and whats that "NAME" thing doing in there and a letter L before some quotes? Thanks in advance.
|
|
|
|
|
*CPushPinBitmapSet is derived from the class CSourceStream. The constructor of CPushPinBitmapSet invokes the constructor of CSourceStream with the 2 parameters that were passed to it.
*The first NAME(".." ) parameter of CSourceStream is just for debugging purposses, results in NULL when not debugging
*the L"..." is so the string is interpreted as being a wide-character string and not just multi byte string.
|
|
|
|
|
If I have a number that is 16 digits (or could be more) long (which I've declared as type 'double'), but which seems to get reformulated as a number with a decimal point and an exponent. How can I keep the computer from doing that type of reformulation and perserve the number in the long form that it originally received?
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
Double stores the data in IEEE format you dont have to worry how it stores the data or how the calculation is done.
When you print out the double use appropriate format, %f, so that you see the numbers properly.
This space is empty.
|
|
|
|
|
Thanks for replying.
The question is not about which format the numbers are stored, nor is it about how the data is stored. It's whether there is a method by which I can prevent the computer from storing it that way (using exponential notation). I would just like for the computer to store it in its long original format.
William
Fortes in fide et opere!
|
|
|
|
|
You cant achive that using double use long or __int64 instead.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
William,
using printf and friends, I don't believe you can, but check out gcvt in the documentation. While a little tricky to use, I believe it will let you do what you want.
Steve S
|
|
|
|
|
Hi,
It's the first time I'm using ActiveX Control. I'm working with VS .NET 2003 and I must say that I'm a beginner to C++ and MFC. My problem is after I have inserted an ActiveX Control (any ActiveX control), I can't insert any other controls, like a Button, Edit Control, etc. I select the control I want and when I click to insert it where I want, nothing happen!
This problem is only in my main dialog: the CFormView dialog.
I need help here, I tried a few things, but without success!
Thanks,
Dave
|
|
|
|
|
Ok, I found out that the ActiveX control seems to be a coincidence. It's more like a have reach a limit on the quantity of controls I can have in my dialog!!! Is it possible?
I can insert one more control, and after that, no more control can be inserted!!!
I don't know why it's doing this!
Dave
|
|
|
|
|
Davex_ wrote:
It's more like a have reach a limit on the quantity of controls I can have in my dialog!!! Is it possible?
The Visual C++ dialog edit only supports 256 controls on the dialog. Windows allows many more, of course, but you'll have to either manually edit the resource file, or create the controls at runtime.
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"
|
|
|
|
|
Thanks, that's exactly my problem! I did a fast count of 249 controls! I'll redesign my dialog.
|
|
|
|
|
Hi. I have a webcam and I want to capture frames from the webcam in my application. I am using c++ mfc programming. The main thing that I want to do is to capture frames at certain interval through my mfc application. Anyone got any advise or idea on how to do it? Thank you for any reply.
|
|
|
|
|
what does MFC have to do with a webcam?!
this question is silly, because when u know how to capture from a webcam, then u know how to do it from MFC.
Don't try it, just do it!
|
|
|
|
|
You'll probably need the DirectX SDK. DirectShow has some examples that capture from cameras and display the output in a window (see the playcap example)
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hello
please if anyone can help me in solving this prob.! I have to implement a C++ program which adds any 2 long numbers such as : 12345654151464 + 454645454 , or any other 2 similar numbers. I should use classes for this problem!
so any suggestion please ?
thank u !
|
|
|
|
|
use __int64 for big numbers, for very big numbers you have to code an own lib.
Don't try it, just do it!
|
|
|
|