|
<a href="http://msdn.microsoft.com/en-us/library/5k9f064x(v=vs.80).aspx">http://msdn.microsoft.com/en-us/library/5k9f064x(v=vs.80).aspx</a>[<a href="http://msdn.microsoft.com/en-us/library/5k9f064x(v=vs.80).aspx" target="_blank" title="New Window">^</a>]
|
|
|
|
|
For some reason my pre tags aren't working sorry for thr giberich
I just googled AfXGetApp and the doc say the Thread pointed to My CWinApp
|
|
|
|
|
Exactly so, but I still don't know what your question is. Aside from the fact that you still seem to be having trouble understanding the Windows model, the use of threads and MFC.
|
|
|
|
|
How many more days do you want to spend trying to bend windows to do what you want?
Rather than try to make a worker thread a UI thread in order to get a message handler in it just add your own messaging. It is easy:
MyThread()
{
WaitForEvent();
WhileNotMessageQueueEmpty()
{
ReadMessageOffQueue();
ProcessMessage();
}
}
somewhere in your code.....
PutMessageOnQueue();
SignalQueueEvent();
and at shut down....
SignalQueueEvent();
And domnt forget your queue needs to be protected with a lock so it it thread safe.
==============================
Nothing to say.
|
|
|
|
|
|
Because you want to use windows messaging.
OK, keep struggling, keep wasting time, it is your choice.
==============================
Nothing to say.
|
|
|
|
|
There is only 1 object of a class derived from CWinApp in an MFC application. Any program with more than one object of a CWinApp derived class won't even compile. As CWinApp is derived from CWinThread that means the app object is a thread as well.
AfxGetApp (as generated by the code generator) always returns that one object. Always, no exceptions.
Now... Windows has two types of threads. We've been over that in other questions. If you want to use them in MFC you do one of the following:
- Worker threads are kicked off by AfxBeginThread. Call that with a pointer to the function you want it execute, it gives you a CWinThread, and off you go, woo hoo! CAVEAT if you call a USER function in your worker thread it gets a message queue BUT you won't be able to do anything with it as MFC doesn't know that it's changed. It's still just scheduling that single function (which could include a message loop but please don't try it...).
- UI threads are slightly harder - you have to derive your own class from CWinThread. Override InitInstance to create the window for your UI thread. Don't try and be clever and use an existing window - if you do messages for that window will be processed by whatever thread created the window, not what you want. Then call AfxBeginThread passing it a pointer to your derived class's RUNTIME_CLASS. You can't just assign an arbitary window pointer to m_pMainWnd and expect it to work - it won't.
|
|
|
|
|
I need some hint how to do this.
Most capAVI examples of callback let the callback function process the data.
I have static splitter with four views of the document and one of them does the callback stuff – semi real time video capture.
I need to “send” the video data from the callback function to the document so I can do processing and updating of the remaining views accordingly.
I though that I could just instantiate another view, but it would have to be in the initial templates to have access to the document. Little kludgy, but doable.
Ideally I would like to let view which runs the callback to send the data to the document, but I do not know how to do it.
I also do not have a clue how to access the callback return value.
Maybe that would work if I can return the data.
I am pretty much stuck.
Any help would be as always appreciated.
Thanks Vaclav
PS This is plain MFC doc/view in VC++ 6.0 ancient stuff, peppered with OpenCV and capAVI.
Addendum
I found this here and I think it will get me started
Callbacks, Threads, and MFC
-- modified 10-Jun-12 12:38pm.
|
|
|
|
|
hey guys....i need you all to help me to get an example of CONSTRUCTOR and DESTRUCTOR in derived class....and before helping me make sure your answer is correct and can help me,...Thanks
SuNiL
|
|
|
|
|
likescr7 wrote: make sure your answer is correct
Well, just in case I'm not up to the job, you could always read the documentation[^].
|
|
|
|
|
They're the same as for a base class, with one difference in the constructor - which is how it chains to the base class constructor to initialise it. Give it a go and post what you have here and we'll take it from there.
|
|
|
|
|
|
likescr7 wrote: and before helping me make sure your answer is correct
Where would be the fun, then?
Veni, vidi, vici.
|
|
|
|
|
lol
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
Help yourself![^]
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
likescr7 wrote: i need you all to help me to get an example of CONSTRUCTOR and DESTRUCTOR in
derived class
Certainly sounds like homework.
likescr7 wrote: before helping me make sure your answer is correct and can help me
Since it sounds like homework the only correct answer is one that says to do it yourself.
|
|
|
|
|
Hi!
Can any one explain with reference the following code:
(1)Where Data is encapsulated (At which line of code does the encapsulation)?
(2) Where Data Abstraction is done(At which line of code does the abstraction)?
<pre>
#include "iostream"
using namespace std;
class Rectangle
{
private:
float width,height,Area;
public:
Rectangle()
{
width = 35.0;
height = 25.0;
}
Rectangle(float w, float h)
{
width = w;
height =h;
}
void GetArea()
{
Area = width * height;
cout<<"Area of the rectangle is \t"<<Area<<endl;
}
~Rectangle()
{
}
};
void main()
{
Rectangle rect(55.0,35.0);
rect.GetArea();
}
</pre>
-- modified 9-Jun-12 3:20am.
|
|
|
|
|
Your <pre> tags have not been recognised: check your profile settings. For information on encapsulation and abstraction you should check some of these links[^].
|
|
|
|
|
Encapsulation is bundling data together with the operations that operate on them. Abstraction is anything that makes you think at a higher level, i.e. less of the implementation of a lump of code and data is visible by inspection of it's interface.
So maybe that'll give you an idea as to "which line" triggers those concepts.
Oh, and I forgot to mention that the term "data encapsulation" is meaningless - encapulation refers to the bundling of operations and data together.
|
|
|
|
|
Please help me solve it ..... urgent....
4 header files that serve as the class
specification file to implement the aggregation, composition and inheritance concept
for the Employee, Name, Addres and ShiftSupervisor.
employee
- number : string
- hireDate : string
+ Employee() :
+ Employee(string, string, string)
+ setName(string) : void
+ setNumber(string) : void
+ setHireDate(string) : void
+ getName() : string
+ getNumber() : string
+ getHireDate() : string
Name
- firstName : string
- lastName : string
+ setFirstName(string) : void
+ setLastName(string) : void
+ getFullName() :
Address
- street : string
- city : string
- state : string
- postcode : string
- country : string
+ setStreet(string) : void
+ setCity(string) : void
+ setState(string) : void
+ setPostcode(string) : void
+ setCountry(string) : void
+ getFullAddress() :
Shift
- salary : int
- bonus : double
+ ShiftSupervisor() :
+ ShiftSupervisor(string, string,
string, double, double) :
+ setSalary(double) : void
+ setBonus(dlouble) : void
+ getSalary() : double
+ getBonus() : double
i stuck until here
#ifndef NAME_H
#define NAME_H
#include<string>
using namespace std;
class Name
{
private:
string FirstName;
string LastName;
public:
Name();
Name(string FN, string LN);
void setFirstName(const string FN) { FirstName = FN; }
string getFirstName() { return FirstName; }
void setLastName(const string LN) { LastName = LN; }
string getLastName() { return LastName; }
void setFullName(const string FN, const string LN);
string getFullName(){return FirstName,LastName;}
};
#endif
#ifndef ADDRESS_H
#define ADDRESS_H
#include<string>
using namespace std;
class Address
{
private:
string Street;
string City;
string State;
string Postcode;
string Country;
public:
Address();
Address(String str,string ct,string st,string pc,string ctry);
void setStreet(const string str) { Street = str; }
string getStreet() { return Street; }
void setCity(const string ct) { City = ct; }
string getCity() { return City; }
void setState(const string st) { Statet = st; }
string getState() { return State; }
void setPostcode(const string pc) { City = pc; }
string getPostcode() { return Postcode; }
void setCountry(const string ctry) { Country = ctry; }
string getCountry() { return Country; }
void setFullAdress(const string str, const string ct, const string st,const string pc
const string ctry);
string getFullAddress(){return Street, City, State, Postcode, Country};
};
#endif
#ifndef SHIFT_H
#define SHIFT_H
#include<cstring>
using namespace std;
class ShiftSupervisor
{
private:
double salary;
double bonus;
public:
ShiftSupervisor()
{ salary=0;
bonus=0;
}
ShiftSupervisor(char ,char ,char ,double salary,double bonus);
void setSalary(double);
void setBOnus(double);
double getSalary();
double getBonus();
};
#endif
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include<string>
#include"Name.h"
#include"Address.h"
#include"Shift.h"
using namespace std;
#endif
|
|
|
|
|
David9637 wrote: Please help me solve it ..... urgent....
First you must explain what the problem is, we cannot guess from you just dumping the complete assignment here. And secondly, saying it's urgent will not get it solved any faster.
|
|
|
|
|
Sorry that I'm still a beginner.Actually i have out of my mind continue write the header file. And i don't know the header is write correctly or not... Above is the task for my assignment. hopefully you can help me...
|
|
|
|
|
Sorry but you need to be much more specific, no one here is going to write your assignment for you.
|
|
|
|
|
Inheritance is a "is a" relationship between two objects. If A is a subtype of B then "A is a B". Every behaviour of objects of class B is exhibited by objects of class A (this is called the Liskov Substitution principle). In your model all ShiftSupervisors are also Employees so derive ShiftSupervisor from Employee.
Composition is a "has a" relationship between two objects. If A is composed of B then every instance of A has an instance of B with the same lifetime associated with it. By same lifetime I mean an object of class B springs into life every time an object of class A is created and the object of class B is destroyed when the object of class A is destroyed. In your example and Employee has a name so give each object of class Employee a data member of class.
Aggregation is a more general form of composition. It's essentially the same (a "has relationship") but with a different lifetime. In your example more than one Employee can share the same address so when an Employee object is destroyed the address they live at is not necessarily wiped off the map. Give each Employee object a reference to, pointer to or a shared pointer (preferably) an object of class Address.
And while I'm on the subject your Name and Address classes are an okay representation of their UML. There are way too many get/set member functions on each of them (how many houses are going to change their state, city of country?). And women don't "set their surnames" when they get married, they change_surname_to instead. And you really don't need default constructors on them either, even if want to use the type in a collection class.
You want to define Employee next and when you've done that ShiftSupervisor. Have a crack at both and if you're having trouble we can look at the definitions and perhaps drop a few hints as to how to proceed.
modified 9-Jun-12 16:22pm.
|
|
|
|
|
I build the following code(copy from MSDN 2008 SP1)
#include <random>
#include <iostream>
typedef std::tr1::minstd_rand Myeng;
typedef std::tr1::mersenne_twister<unsigned int, 32, 624,
397, 31, 0x9908b0df, 11, 7, 0x9d2c5680,
15, 0xefc60000, 18> Myceng; int main()
{
Myeng eng;
Myceng ceng;
Myceng::result_type compval = ceng();
compval = compval;
std::cout << "W == " << Myceng::word_size << std::endl;
std::cout << "N == " << Myceng::state_size << std::endl;
std::cout << "M == " << Myceng::shift_size << std::endl;
std::cout << "R == " << Myceng::mask_bits << std::endl;
std::cout << "A == " << Myceng::parameter_a << std::endl;
std::cout << "U == " << Myceng::output_u << std::endl;
std::cout << "S == " << Myceng::output_s << std::endl;
std::cout << "B == " << Myceng::output_b << std::endl;
std::cout << "T == " << Myceng::output_t << std::endl;
std::cout << "C == " << Myceng::output_c << std::endl;
std::cout << "L == " << Myceng::output_l << std::endl;
std::cout << "min == " << ceng.min() << std::endl;
std::cout << "max == " << ceng.max() << std::endl;
ceng.seed(); std::cout << "a random value == " << ceng() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
Myceng ceng2(eng); ceng2.seed(eng);
Myceng ceng3(5UL); ceng3.seed(5UL);
return (0);
}
with Visual Studio 2010, but the compiler reports errors:
1>------ Build started: Project: Console, Configuration: Debug Win32 ------
1>Build started 2012-6-9 11:05:53.
1>InitializeBuildStatus:
1> Touching "Debug\Console.unsuccessfulbuild".
1>ClCompile:
1> Console.cpp
1> _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
1>z:\e\disk\vc\justtest\console\console.cpp(27): warning C4003: not enough actual parameters for macro 'min'
1>z:\e\disk\vc\justtest\console\console.cpp(27): error C2059: syntax error : '('
1>z:\e\disk\vc\justtest\console\console.cpp(28): error C2039: '<<' : is not a member of 'std::tr1::mersenne_twister<_Ty,_Wx,_Nx,_Mx,_Rx,_Px,_Ux,_Sx,_Bx,_Tx,_Cx,_Lx>'
1> with
1> [
1> _Ty=unsigned int,
1> _Wx=32,
1> _Nx=624,
1> _Mx=397,
1> _Rx=31,
1> _Px=-1727483681,
1> _Ux=11,
1> _Sx=7,
1> _Bx=-1658038656,
1> _Tx=15,
1> _Cx=-272236544,
1> _Lx=18
1> ]
1>z:\e\disk\vc\justtest\console\console.cpp(28): error C2039: 'ceng' : is not a member of 'std::tr1::mersenne_twister<_Ty,_Wx,_Nx,_Mx,_Rx,_Px,_Ux,_Sx,_Bx,_Tx,_Cx,_Lx>'
1> with
1> [
1> _Ty=unsigned int,
1> _Wx=32,
1> _Nx=624,
1> _Mx=397,
1> _Rx=31,
1> _Px=-1727483681,
1> _Ux=11,
1> _Sx=7,
1> _Bx=-1658038656,
1> _Tx=15,
1> _Cx=-272236544,
1> _Lx=18
1> ]
1>z:\e\disk\vc\justtest\console\console.cpp(28): warning C4003: not enough actual parameters for macro 'max'
1>z:\e\disk\vc\justtest\console\console.cpp(28): error C2059: syntax error : '('
1>z:\e\disk\vc\justtest\console\console.cpp(30): error C2039: 'ceng' : is not a member of 'std::tr1::mersenne_twister<_Ty,_Wx,_Nx,_Mx,_Rx,_Px,_Ux,_Sx,_Bx,_Tx,_Cx,_Lx>'
1> with
1> [
1> _Ty=unsigned int,
1> _Wx=32,
1> _Nx=624,
1> _Mx=397,
1> _Rx=31,
1> _Px=-1727483681,
1> _Ux=11,
1> _Sx=7,
1> _Bx=-1658038656,
1> _Tx=15,
1> _Cx=-272236544,
1> _Lx=18
1> ]
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:04.00
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
Any one can help?
|
|
|
|
|