|
Hi,
I have a video playing in a video player. Irrespective of video player, I need the handle to the video being played. I have user-specified screen co-ordinates, now I need to convert the screen co-ordinates into frame co-ordinates of the video. To convert screen co-ordinates to video-frame co-ordinates and to further process video frames, I need handle to the video.
I am using Visual Studio and C++ for Win32 programming.
Any pointer?
Thanks
|
|
|
|
|
I found a technical document for adding multiple view to a single document project.
http://msdn.microsoft.com/en-us/library/s199bks0%28VS.80%29.aspx[^]
I made a form view and tried to create it in my project.
When I tried it first, it was succeeded. But when I made it again I got an error message.
It is my code copy from MSDN document.
CView* pActiveView = ((CFrameWnd*)m_pMainWnd)->GetActiveView();
m_pOldView = pActiveView;
m_pSearchView = (CView*)new CSearchMember;
CDocument* pCurrentDoc = ((CFrameWnd*)m_pMainWnd)->GetActiveDocument();
CCreateContext newContext;
newContext.m_pNewViewClass = NULL;
newContext.m_pNewDocTemplate = NULL;
newContext.m_pLastView = NULL;
newContext.m_pCurrentFrame = NULL;
newContext.m_pCurrentDoc = pCurrentDoc;
UINT viewID = AFX_IDW_PANE_FIRST+1;
CRect rect(0,0,0,0);
m_pSearchView->Create(NULL, NULL, WS_CHILD, rect, m_pMainWnd, viewID, &newContext);
m_pSearchView->SendMessage(WM_INITIALUPDATE, 0, 0);
In debugging mode, I could find a place occurred error.
BOOL CFormView::Create(LPCTSTR , LPCTSTR ,
DWORD dwRequestedStyle, const RECT& rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext)
{
ASSERT(pParentWnd != NULL);
ASSERT(m_lpszTemplateName != NULL);
m_pCreateContext = pContext;
#ifdef _DEBUG
if (!_AfxCheckDialogTemplate(m_lpszTemplateName, TRUE))
{
ASSERT(FALSE);
PostNcDestroy();
return FALSE;
}
Because of m_plszTemplateName, this error is occurred.
But I don't know how do I solve.
Please advise for me.
|
|
|
|
|
Are you wanting to create the additional views on the fly? or creating them in edition time (for instance a CFormView in Resource.h) and attaching / opening them in run-time? With or Without MFC?
If the second there is another approach to get it, I used it in VC6 with MFC. But it is quite long to explain, if it is not what you want / need.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
modified on Friday, January 22, 2010 4:52 AM
|
|
|
|
|
I already made a formview class with MFC. I want when I push the button(like as menu or toolbar), my application's view is changed from basic view to the formview made by me.
So I found that document from MSDN, I tried. But I got a error in Create function in CView. I don't know why that error is occurred. Just guess, it would be because of m_lpszTemaplateName.
Finally, I wanna make the additional view, and show that in my application, when I occur an event like as push a button or toolbar. The application view have to be changed between basic view and formview I made.
|
|
|
|
|
Take a look into the search[^] for more general info.
To add a different View to the running application (note the "add") you can check this[^] message I wrote quite a time ago and the other I point out in it, about this topic.
To do what you want of just changing the view you could improve/override one of my methods doing that when one view opens, then you go and close the previous one.
I hope it helps you.
EDIT: Searching for another thing I found this[^] I forgot to comment the step 2 of this link into my answers. In fact it is an important step missing. But as he says the code won't compile correctly, but it has the basics and you can complete it with my answers above.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
modified on Friday, January 22, 2010 9:51 AM
|
|
|
|
|
Hi all,
i want to generate generate random number in given minimum and maximum number range like 1 to 20;
i m using this.
srand((unsigned)time(0));
int random_integer;
int lowest=1, highest=20;
int range=(highest-lowest)+1;
for(int index=0; index<20; index++){
random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0));
cout << random_integer << endl;
}
but this generate some repeated numbers.
i want to generate random number but not repeated.
please help me for this.
thanks.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I think you just check with srand CRT functions, Please check this link, it shows how you can generate different numbers [^]
Величие не Бога может быть недооценена.
|
|
|
|
|
its generate any numbers,i want to generate numbers with in provide range.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
It can be done with it
just check this code below.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int i;
srand( (unsigned)time( NULL ) );
for( i = 0; i < 10;i++ )
printf( " %6d\n", rand()%20 );
return nRetCode;
}
Величие не Бога может быть недооценена.
|
|
|
|
|
if i had to do this, i'd use a std::set to keep track of numbers that have been generated.
std::set < int > foo;
for (int i=0;i<20;i++)
{
int z = rand() % 100;
if (foo.find(z) == foo.end())
{
foo.insert(z);
TRACE("+%d\n", z);
}
else
{
TRACE("skip %d\n", z);
}
}
|
|
|
|
|
error generated
error C2039: 'set' : is not a member of 'std'
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Le@rner wrote: error C2039: 'set' : is not a member of 'std'
You should #include <set>
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
thanks
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Extracting numbers from a bag...
const int N = 20;
int num[N];
int i;
for (i=0; i<N; i++)
{
num[i] = i+1;
}
for (int i=0; i<N-1; i++)
{
int r = rand() % (N-i);
int temp = num[N-1-i];
num[N-1-i] = num[r];
num[r]= temp;
}
for (i=0; i<N; i++)
{
cout << num[i] << endl;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Le@rner wrote: i want to generate random number but not repeated.
Something like:
void main( void )
{
int array[10] = {0};
int n = 10;
for (int i = 0; i < n; i++)
array[i] = i;
random_shuffle(array, array + 10);
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Assume there's a system with 2 objects. An object of class Boss and an object of class Worker. The object Boss does what all bosses do: tell workers what to do, drive big cars and stare out of the window. The same is true for the object Worker. It does what all workers do: staring the whole day at the screen (or out of the window) and try to solve all those silly things their boss came with. During this dull life the object Worker has one periodic highlight: Once a month it calls the object Boss and invokes the method GetSalary(). But for the Object Boss this is a big security risk: It only wants that real workers get salary.
So the problem is: a method is invoked but the object of that method wants to be sure that only specific objects may invoke that method. How to solve this?
Variables and functions may be defined as static, restricting their visibility to the module-level. Classes and methods may also use techniques like this but this is not going to work: Our object Boss is an 'interim': He's only added to a project when needed and if they pay him enough. The object Boss is a generic one.
I'm looking for solutions that can withstand a malicious programmer that creates his own object Worker or derives one from the class Worker to invoke GetSalary() as much as possible.
Another variant of this problem is an object that can be cloned but wants to do this only when asked from certain other objects (because it carries sensitive data) although its Clone-method is public.
Any suggestions? Concepts will be appreciated above code.
|
|
|
|
|
Conceptual answer: Didn't the boss hire the worker in some way? The boss should ideally be the manager for all the employees, that is, the boss should keep track of which workers that are entitled to salaries ...
|
|
|
|
|
|
in the method GetSalary(),the boss should check the worker is the real worker.
you should make some mechanism to check the real worker.
|
|
|
|
|
Iceman See my response to Adam.
|
|
|
|
|
The answer as par my design is:-
I believe boss should keep a base class Worker, with two derived classes, GoodWorker and BadWorker.
Now Boss can call based on the work
int workerCategory()
{
if( "good" == work )
{
Worker* pWorker = new GoodWorker();
}
pWorker->GetSalary();
}
class Worker
{
public:
void Work();
virtual void GetSalary();
};
class GoodWorker
{
public:
void Work()
{
}
void GetSalary()
{
...... Logic
}
};
class BadWorker
{
public:
void Work()
{
}
}
Величие не Бога может быть недооценена.
|
|
|
|
|
Thanks for your replies. I try to answer you all 3 at once:
First Matias: In real life a worker will be hired first, and this salary-thing wouldn't be a problem. Problem is that in my example there is only a boss and some workers. If you have access to this system you could easily derive a class from Worker (sub-class, inherit from, however you name it) that would have malicous code; so the worker gets salary twice a day.
Adam: I like your idea to make derived classes good worker and bad worker but i don't see how this can solve the problem: deriving a malicious class from Goodworker would be even simpler. But the idea to create a Badworker too is intriguing and maybe usefull, but i don't see how yet.
Iceman: I myself was thinking the same way, and maybe you can help me with some more ideas.
What i want is a worker-class that can not be tampered with. So it may not be derived and there may not be a another class that can have the same name. If I create Getsalary() like thiis: (in pseudo-code)
Class Boss
method Getsalary(oworker)
...
We can ensure that the argument oworker must be of class Worker (or a derived class) by strongtyping oworker. I found a way to check if oworker is not a derived one. And here OO stops: Boss can not be sure if it is the 'right' untampered version of Worker or just a fake.
I was thinking to implement some kind of shared secret, when the worker ask Salary it must solve a riddle first.
If the source of both objects is known this will not work, so at least one of them must be published in a DLL (or something) that hides the solving of the riddle...
Placing code in a DLL is not a strong one (you can replace it). So i need really good ideas how to create this kind of security.
Maybe it is possible to do some variable encryption, like this:
Boss calls a method of Worker. This decrypts a internal piece of data in Worker, Worker sends this data when it invokes Getsalary. Boss checks this data. If the data was ok salary is paid otherwise not.
Feel free to give me more suggestions and thanks so far...
|
|
|
|
|
Hi Gurus,
I am looking for an C++ subroutine for integration, accurate one.
Thanks
|
|
|
|
|
|
I mean mathematical integration of an array, e.g. integrate velocity waveform into displacement waveform.
Or integrate area under a curve y=f(x)
|
|
|
|