|
Why on in CFrameWnd you wouldn't rout fosus to the view/CPropertySheet/CPropertyPage (ActivePage)
You can get view from frame and set on view focus to any control.
I guess when frame gets focus back it don't remembers what control on the view was active.
|
|
|
|
|
Thanks for your help, but I guess I havn't got it right.
How do I know after returning which control has had the focus before? Is this stored somewhere in a CWnd object?
Do I have to call OnSetFocus() ( via SetFocus()) for all the windows ( CFrameWnd -> CView -> CPropertySheet -> CPropertyPage )? This is what I have done but that hasn't worked right. The only positive effect was that I coould set the focus on the first control on the page.
Some further help would be appreciated.
|
|
|
|
|
If you not keep information where focus was, nobody will do it for you. You can keep information obdatined from OnKillFocus(...) Why is so important to have focus on particar control. Why not set focus on View or PropSheet if you want. Unless while you was in other app, programmaticaly PropPage switched to another page and you want switch it back when focus will be set to your app. Other than that I don't know.
Anyway you as the developer need to deside preserve focus or not.
|
|
|
|
|
Hi everybody!
Im trying to develop an application to control my webcam using DirectShow instead of Video for Windows. Everything works ok, I mean, I connect the driver of the camera and I can see the image of the webcam. But what I haven´t been able to do is capturing a still image. The problem is the following instruction:
IPin *pPin = 0;
hr = pBuild->FindPin(pCap, PINDIR_OUTPUT, &PIN_CATEGORY_STILL, 0,
FALSE, 0, &pPin);
Where "pCap" is a IBaseFilter intarface, and it controls the capture, and "pBuild" is a "ICaptureGraphBuilder2" interface. With this instruction, I get this error: "E_FAIL".
Ive been reading the specifications of my webcam (Creative NX PRO) and it has support for DirectShow. It also has a button that allows to take photos using hardware trigger (thats why I suppouse that it has a "Pin_Category_Still").
If anybody knows any other way to take a photo, please tell me.
I appreciate any idea you can tell me about it.
Thank you very much for your help!
PerroFlaco
|
|
|
|
|
Have you been able to get it to work in GraphEdit? Play around with it there and see what pins go where and then you can easily translate it into code.
|
|
|
|
|
I don't even know that GraphEdit exits! . Ill take a look and see what happens. By the way, can you see what PIN are available using GraphEdit? I hope this help me to solve this problem.
Thanks Mark!
|
|
|
|
|
GraphEdit comes with the DirectX SDK, so you should already have it. It will show all filters and all pins, you drag connections between then and then play it. It's very helpful for trying out things out quickly in DirectX. If you can get it to work in GraphEdit that's a big step, then you just get your code to look like the graph.
|
|
|
|
|
The filter graph itself does not provide a still capture pin. The FindPin method does search the filter graph for any still capture pin (in this case), but if there is none, it will return E_FAIL.
Try to connect a filter that does have a still capture pin.
Don't try it, just do it!
|
|
|
|
|
Ok, but, how can I find a filter that have a still capture pin? I dont know how to do it. I have been looking for it in the "msdn" help, but I have not found anything at all
Please help! .
|
|
|
|
|
hiho@ll
first i have to say i need to solve this problem using linux, but i think it's a more c++ related question than linux
what i need:
explanation: i know that templates can generalize the datatype used for a class
so the class can work with an int, string, char, pointers
simply with different data types
my problem is something similar
i need a template for instaniating a class
this means, i want a configuration file, which says which class i need to use for the job i have to do
something like a string to object converter
i thought about make a abstract class and inherit from this and instantiate the needed class using the string
but the point is, i don't know how (or if this is possible) instantiate a object where the only knowledge of which object type to use is my configuration string
i hope it's understandable
greet@ll
|
|
|
|
|
ThinkingPrometheus wrote:
first i have to say i need to solve this problem using linux, but i think it's a more c++ related question than linux
...
the point is, i don't know how (or if this is possible) instantiate a object where the only knowledge of which object type to use is my configuration string
It's not a C++ related question. You need to use C# or Java (Class.forName(..)) to do that.
|
|
|
|
|
The typical C++ approach to this would be like so:
1. Create an abstract base class that defined the interface common to all classes that might be instantiated with this mechanism. Assuming the popular musical example, make this base class an "Instrument" and give it virtual methods like "Play", "Tune", "ThrowAway", etc.
2. Create all classes that need instantiating so, and make sure they all derive from this base class: Flute, Piano, Viola, etc.
3. Read your configuration file, and evaluate it using a simple (or powerful) parser, like so:
<br />
Instrument* parse(const char* word) {<br />
Instrument* result = NULL;<br />
if (!strcmp(word, "Flute")) {<br />
Instrument = new Flute();<br />
} else if (!strcmp(word, "Viola")) {<br />
Instrument = new Viola();<br />
} else ...<br />
...<br />
}<br />
return Instrument;<br />
}<br />
|
|
|
|
|
Hello,
Since you mention templates, I have to say the following. Templates take advantage of the symantics between objects. For example, all the operations they perform on the objects, is the same for every valid type that you can pass in the template specification.
You canno't do something like this at runtime like you can do with templates. You can mimic this behaviour by creating a "typeless" variable type like class CVar{/*...*/}; This type can be any type you want, like the VARIANT type used in scripting.
If the class that you need to create is always the same, but with other variable types, you can do something like the typeless variable above. I think that you need that, since you mentioned templates.
If you need to construct different classes with different behaviour, the inheritance / interface solution, that an other CPian already posted, is the way to go.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Use a class factory pattern - of sorts.
On each class you want to create derive it from base class with a Clone() and Key(), implement the Clone function in each derived class to create a new class and a Key() containing the class name.
Then create a static copy of your class, that you want to be able to create, so that on startup it registers itself dynamically with a Class factory object.
Then use your parser to search the class factory for the key, say in a map<base class> of registered objects - and do a Clone() to create a new one, and do a basic thing.
<br><br><hr color="navy"><small>"<i>Je pense, donc je mange.</i>" - Rene Descartes 1689 - Just before his mother put his tea on the table.<small>
<small>Shameless Plug - <a target="_new" href='http://www.codeproject.com/csharp/ESTransactions.asp'>Distributed Database Transactions in .NET using COM+</a></small>
|
|
|
|
|
thx@ll for the answer
but i did it a little bit different
my problem was for linux, and there is a linux way
but maybe there is a port for windows so i describe how it works with linux:
what i wanted is that i can load a class dynamically during runtime of my "core"
the problem: the only thing i (wanted to) know was the class name (and the function name for instantiating an object)
first you have to create a class, where all your classes are derived from
so i made a server class with a GetInstance method which simply calls
new MyObject();
depending on which class you want
next you can use dlopen to load the library file
and dlsym to get an object using the GetInstance function
void *hndl = dlopen("libnewshapes.so", RTLD_NOW);
if(hndl == NULL){
cerr << dlerror() << endl;
exit(-1);
}
void *mkr = dlsym(hndl, "maker");
shape *my_shape = static_cast<shape *()="">(mkr)();
and there is our shape object
for more information read http://www.linuxjournal.com/article/3687
|
|
|
|
|
Hi All,
I want to create a list view using CListView class. Can any body give me code to create that. I tried to create it in the OnInitialUpdate() of with following code but this is not working.I am not able to see these column names.Please help me.
void CTMSView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
// this code only works for a report-mode list view
ASSERT(GetStyle() & LVS_REPORT);
// Gain a reference to the list control itself
CListCtrl& theCtrl = GetListCtrl();
// Insert a column. This override is the most convenient.
theCtrl.InsertColumn(0, _T("Name"),LVCFMT_LEFT,100);
// The other InsertColumn() override requires an initialized
// LVCOLUMN structure.
LVCOLUMN col;
col.mask = LVCF_FMT | LVCF_TEXT;
col.pszText = _T("Contact Number");
col.fmt = LVCFMT_LEFT;
theCtrl.InsertColumn(1, &col);
// Set reasonable widths for our columns
theCtrl.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
theCtrl.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
}
|
|
|
|
|
Hi man
is the class CTMSView ur project base class
or is there other classes
and if there is Panes at ur project
MFC programmer
|
|
|
|
|
Make sure that CTMSView is derived from CListView . That's all there is to it.
B.R.Singh wrote:
...but this is not working.
Have you tried removing the second call to InsertColumn() and both calls to SetColumnWidth() ? In other words, if
theCtrl.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 100); does not work, the other code is just getting in the way at this point.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
Hi
i have build an application with dialog and buttons. Only i need to have administrator account that can modify smth in the application (not the source). So i decided to create a password verification box.
The problem is what is the best way 2 do it? and how can i store the password outside the source but encrypted in a way so that noone can understand it and for the administrator to be able to change it at runtime?
/\|-||\/|/\|)
|
|
|
|
|
Do it Unix style using 1 way encryption or hashing. There are plenty of sites there that can offer detailed descriptions of how it works but basically it's like this. You take the password and hash it using something like MD5 or SHA-1, then you store that password in plaintext. Then when you want to authenticate your user in the program, you ask for the password, you take that password and hash it and then compare that hash with the stored hash, if they match, then it's probably the right password and you let them in. This should be pretty good, you can add "salting" or a random string to the password if you want to prevent precompiled dictionary attacks...
Take a look at http://www.codeproject.com/cpp/csha1.asp
[^]
|
|
|
|
|
I know the compiler options for a multi-threaded program in VC++. Is there also a preprocessor #define that indicates multi-threading? So that I can do e.g. something like
#ifdef _MULTI_THREAD
# define doSomething(x) doSomethingMulti(x)
#else
# define doSomething(x) doSomethingSingle(x)
#endif
|
|
|
|
|
Since it is your process that actually creates those threads, wouldn't you be the best person to know whether or how many threads are in use?
It seems a bit hard expecting Microsoft to predict your source code.
What am I missing?
|
|
|
|
|
berndg wrote:
Since it is your process that actually creates those threads, wouldn't you be the best person to know whether or how many threads are in use?
It seems a bit hard expecting Microsoft to predict your source code.
I want to compile the whole program (my own code + MS code) either in 'single-threaded' or 'multi-threaded' mode. Depending on the threading-mode I want to call different functions. This should be done with macros (what else).
To make it work I need a #define similar to
#define _POSIX_THREADS
Yes, I can #define my own macro, but that's not the point.
What am I missing?
|
|
|
|
|