|
okey dokey.
I have 2 classes:
class imageViewer{...};
class camData{...};
imageViewer has a function called funcA();
camData has a function called funcB();
I wanted to call funcA; in funcB();
i.e.:i've tried both:
<br />
#include "imageViewer.h"<br />
void camData::funcB()<br />
{<br />
..<br />
imageViewer::funcA();<br />
}<br />
I get this error:
error C2352: 'ImageViewer::showPicture' : illegal call of non-static member function
-AND-
<br />
#include "imageViewer.h"<br />
void camData::funcB()<br />
{<br />
..<br />
funcA();<br />
}<br />
I get this error:
error C3861: 'showPicture': identifier not found
could someone please tell me my idiotic mistake.....
thanks,
Kitty
Kitty5
|
|
|
|
|
Well, in order to call a function (non-static) from a class, you first need to have an instance of your class. So, doing something like that (suppose MyClass is a class that defines funcA):
MyClass A;<br />
A.funcA();
You cannot simply do
MyClass::funcA();
|
|
|
|
|
:Cedric,
thanks very much for your advice.
I knew it was something simple that I was missing...
thanks!
Kitty
Kitty5
|
|
|
|
|
kitty5 wrote: ..
imageViewer::funcA();
To make such call possible. finA() must be static function of class imageViewer .
|
|
|
|
|
What is the maximum number of entry points a Win32 dll can export? if no limitation, would too many entry points affect performance or cause any other issues?
Thanks in advance!
Mike
|
|
|
|
|
By entry points I assume you mean exported functions?
Ordinals are limited to WORD size (16-bit, unsigned) but I don't know if you can have an
unlimited number of exports by name.
Exporting by ordinal instead of name saves DLL size and linking to the DLL is faster. I suppose
the more functions that need to be linked to, the longer it will take to link.
I'm sure this helps very little
Mark
|
|
|
|
|
Hello!
I would like to capture video from a camera, but I just can't find information about it... I found some articles, but there are no explanations there...
Maybe anybody knows where can I find information about it?
Thanks in advance!
|
|
|
|
|
I depends on the equipment you're using. If you're using a USB camera then you're halfway there.
The two biggie webcam manufacturers provide SDKs for their cameras; but, one involves signing an NDA.
The other is freely available. (But, of course, I forget who at the moment.)
Other cameras (analog) would require digitizers, which, I imagine, would be rather expensive. Compound that with whether an SDK is available.
Then of course, IP camera's are a whole other beast.
|
|
|
|
|
What about DirectX? Does it give me any tools?
|
|
|
|
|
There's Video for Windows (VFW) if the device supports it.
In DirectX there's DirectShow (SDK is in the Platform SDK, not the DirectX SDK) which will work
with both legacy VFW drivers as well as WDM drivers.
Mark
|
|
|
|
|
DirectShow is probably the best way...
http://www.codeproject.com/audio/DXCapture.asp
|
|
|
|
|
Thanks a lot!
I will try it...
Have a nice day!
|
|
|
|
|
Hi,
I am trying to get some raw data into a directshow custom filter and then video compress it using a codec available on the computer. I was looking at the help which shows recompressing of avi, but I fail to understand the Moniker. It says that you have to call to BindToObject but if you let the user select one, how do you pass that into that call.
Once I have IBaseFilter I think I know what to do.
But if anyone has like a sample procedure showing this, that would be awesome.
thanks in advance.
|
|
|
|
|
If you have the moniker then something like this...
pFilter = NULL;
hr = pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&pFilter);
if (SUCCEEDED(hr))
{
...
}
|
|
|
|
|
Hi Mark,
But in the sample once the pulldown menu is populated with all the names of the compressors the pMoniker is released.
So if there is like a DivX Codec Compressor in the list and I choose it, hows does the BindToObject call know that I want the DivX compressor.
Thanks again
|
|
|
|
|
Then you'll have to use similar code to enumerate the monikers and look for a name that matches.
You'll need a moniker to use BindToObject() to create an object with it.
Here's some code from one of my apps that was commented out (I now persist monikers so I haven't
used this code in a while). It was for capture device monikers but it should be very similar.
In fact, I probably ripped most (if not all) of it out of SDK sample code. Anyway, it gets a
moniker given a name (using the monikers display name). Maybe you can glean something useful
from it
IMoniker *MyClass::GetDSVideoDeviceMonikerByName(LPCTSTR pszName)
{
IMoniker *pRetMoniker = 0;
ICreateDevEnum *pDevEnum = NULL;
IEnumMoniker *pEnum = NULL;
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
CLSCTX_INPROC_SERVER, IID_ICreateDevEnum,
reinterpret_cast<void**>(&pDevEnum));
if (SUCCEEDED(hr))
{
hr = pDevEnum->CreateClassEnumerator(
CLSID_VideoInputDeviceCategory,
&pEnum, 0);
if (pEnum)
{
LPMALLOC pIMalloc;
if (S_OK != ::CoGetMalloc(1, &pIMalloc))
{
SAFE_RELEASE(pEnum);
SAFE_RELEASE(pDevEnum);
return 0;
}
TCHAR *pszBuf = new TCHAR[300];
IMoniker *pMoniker = NULL;
while (pEnum->Next(1, &pMoniker, NULL) == S_OK)
{
IPropertyBag *pPropBag;
hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,
(void**)(&pPropBag));
if (FAILED(hr))
{
pMoniker->Release();
continue;
}
LPOLESTR pszDisplayName;
if (S_OK == pMoniker->GetDisplayName(0,0,&pszDisplayName))
{
WideCharToMultiByte(CP_ACP, 0, pszDisplayName, -1, pszBuf, 300, 0, 0);
pIMalloc->Free(pszDisplayName);
pPropBag->Release();
if (!_tcscmp(pszName, pszBuf))
{
pRetMoniker = pMoniker;
break;
}
pMoniker->Release();
}
else
{
pPropBag->Release();
pMoniker->Release();
continue;
}
}
delete[] pszBuf;
SAFE_RELEASE(pIMalloc);
SAFE_RELEASE(pEnum);
}
SAFE_RELEASE(pDevEnum);
}
return pRetMoniker;
}
An alternative is to keep the list of monikers in a container of some kind so they only have to
be enumerated once.
|
|
|
|
|
cool thanks,
will check it out.
|
|
|
|
|
A Side question,
A Video Compression Filter will work if I am passing it individual frame pictures.
So if I have
Frame Source Filter -> Video Compression -> AVI Mux -> File Writer Filter
Will that work or will I have to add something else in between to pass in a frame?
|
|
|
|
|
godspeed123 wrote: Frame Source Filter -> Video Compression -> AVI Mux -> File Writer Filter
That should work as long as your source filter pushes frames correctly.
I tested in GraphEdit with a camera source and the Microsoft Video 1
compressor. Worked fine.
Mark
|
|
|
|
|
Hi,
I'm trying to build a framework based on Win32 calls wich follows the .Net's one that I know better and find much easier to implement for my future projects.
Currently I'm stuck at this point :
frmMain::frmMain(HINSTANCE hinstance)
: W32Window(hinstance, LoadIcon(hinstance,MAKEINTRESOURCE(2)))
{
SetText( "MyApplication" );
Maximize();
W32Button* b = new W32Button(hinstance);
b->SetPosition(400,400,60,80);
Controls()->Add(b);
//Controls()->Remove(b);
}
You can see here that I'm trying to add a previously orphan created button to a Form.
I someone here has already played with C# or VB.Net, then he will certainly be common with this.
I have two classes W32Window and W32Button.
W32Window Class own a static function W32Window::WindowProc just as W32Button own a static function W32Button::ButtonProc.
In W32Window constructor :
- I reference WNDCLASS W32Window if it wasn't done before ( with wc.lpfnWndProc = &W32Window::WindowProc )
- I also make CreateWindow( "W32Window",...) and I hold the returned hwnd in a private member of the W32Window current object
- I finally hold a pointer to the current W32Window object with SetWindowLong(GWL_USERDATA,(LONG) (this))
In W32Window::WindowProc :
- I get the W32Window object wich sends the message : p = (W32Window*) GetWindowLong(hwnd,GWL_USERDATA)
- switching the message, I call the specified function of the object. (OnClose() function for the message WM_Destroy etc...)
This system works very well wich the windows.
I 'm currently able to make several new W32Window(hinst) and .Show() with very few code lines in the main procedure.
I would like to do the same with buttons but the are some problems.
I like the way I call the specified object functions in the message handling procedure and I would like to keep the same idea for button.
But the Win32 class is already coded, so I first thought that I had to do a global subclassing, or a superclassing to give to the button his own lpfnWndProc.
Here is that I wrote in the W32Button constructor:
W32Button::W32Button(HINSTANCE hinstance)
{
static bool boo = false;
if (!boo)
{
WNDCLASS wc;
GetClassInfo(hinstance,"button",&wc);
wc.lpfnWndProc = &W32Button::ButtonProc;
wc.hInstance = hinstance;
wc.lpszClassName = "W32Button";
RegisterClass(&wc);
}
hwnd = CreateWindow("W32Button", "butt", WS_OVERLAPPED,
0, 0, 0, 0,
NULL, NULL, hinstance, NULL);
LONG style = WS_CHILD | WS_VISIBLE;
SetWindowLong(hwnd,GWL_STYLE,style);
SetWindowLong(hwnd, GWL_USERDATA, reinterpret_cast<long> (this));
SetPosition(0,0,20,20);
}
Then latter, in the Controls()->Add(b) :
void
W32WndCollection::Add(W32Wnd *w)
{
if ( Contains( w ) ) return;
m_wnds.push_back( w );
SetParent( w->getHWND() , m_container->getHWND() );
}
It work very well if I use a basic "button" control in the createwindow function, but if i superclass or subclass the button, my button does not display anymore...
Here is the code of button proc :
LRESULT WINAPI
W32Button::ButtonProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
W32Button* w = reinterpret_cast<w32button*> (GetWindowLongA(hwnd, GWL_USERDATA));
//return DefWindowProc(hwnd, uMsg, wParam, lParam);
return CallWindowProc( &W32Window::WindowProc , hwnd, uMsg, wParam, lParam);
}
I've tried both uncommented and commented return with no result...
Can someone help please?
Sorry for having beeing long.
|
|
|
|
|
I can't see where you are ever calling the default button window proc.
What happens if you do this....
add a
static WNDPROC lpfnDefButtonProc;
member to your W32Button class.
...
W32Button::W32Button(HINSTANCE hinstance)
{
static bool boo = false;
if (!boo)
{
WNDCLASS wc;
GetClassInfo(NULL,"button",&wc);
lpfnDefButtonProc = wc.lpfnWndProc;
wc.lpfnWndProc = &W32Button::ButtonProc;
wc.hInstance = hinstance;
wc.lpszClassName = "W32Button";
RegisterClass(&wc);
}
}
LRESULT WINAPI
W32Button::ButtonProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return CallWindowProc( lpfnDefButtonProc , hwnd, uMsg, wParam, lParam);
}
|
|
|
|
|
Hi, thanks for the reply.
You were right, I wasn't calling the right defaultproc.
It works right now (the button displays well on the window).
I've already tried the trick you gave me before but not the good way : I typed static WNDPROC lpfnDefButtonProc; in the class description (.h) and so I had an error with link edition... because I didn't wrote the function in .cpp.
Thank you it works now.
I still have a problem, because the WM_COMMAND message for the button seems not to be catched anymore when I click on it...
LRESULT WINAPI
W32Button::ButtonProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
W32Button* w = reinterpret_cast<w32button*> (GetWindowLongA(hwnd, GWL_USERDATA));
int i;
switch (uMsg)
{
case WM_CREATE:
i = 0;
break;
case WM_PAINT:
i = w->GetHeight();
break;
case WM_COMMAND:
i = w->GetHeight();
break;
default:
i = 0;
}
return CallWindowProc( oldButtonProc , hwnd, uMsg, wParam, lParam);
}
The debugger goes trough WM_PAINT, WM_CREATE, default, but never in WM_COMMAND.
I can't understand why, someone does ?
I assume that WM_COMMAND is the message wich is sent when you click on the buton, am I wrong ?
|
|
|
|
|
|
Hi,
I'm trying to open a file open dialog box; but, using the wince PPC 2003 SDK isn't allowing me to navigate to an arbitrary directory that the user will need. It only allows me to choose the 'All Folders', "Business", "My Music", "My Pictures", "Personal", "SysInfo" and "Templates" directories.
I used:
<pre>
<code>
void InitOFN(OPENFILENAME *ofn)
{
memset(ofn, 0, sizeof(ofn));
ofn->lStructSize = sizeof( OPENFILENAME );
ofn->hwndOwner = NULL;
ofn->lpstrFilter = _T("txt Files\0*.txt\0\0");
ofn->lpstrCustomFilter = NULL;
ofn->nMaxCustFilter = 0;
ofn->nFilterIndex = 0;
ofn->lpstrFile = _T("\\parent\\subdir1\\subdir2\\default.dir\\"); /*WATCH OUT!*/
ofn->nMaxFile = 1024;
ofn->lpstrFileTitle = NULL;
ofn->nMaxFileTitle = 0;
ofn->lpstrInitialDir = _T("\\parent\\subdir1\\subdir2\\default.dir\\");
ofn->lpstrTitle = _T("Select files for viewing:");
ofn->nFileOffset = 0;
ofn->nFileExtension = 0;
ofn->lpstrDefExt = NULL;
ofn->lCustData = 0;
ofn->lpfnHook = NULL;
ofn->lpTemplateName = NULL;
ofn->Flags = OFN_EXPLORER;
}
void CClassDlg::OnOK()
{
OPENFILENAME ofn;
InitOFN(&ofn);
CFileDialog dlg(TRUE);
dlg.DoModal();
//do more stuff
CDialog::OnOK();
}
</code>
</pre>
Ideally, I'd like to open a dialog that lets the user select the directory that contains their files. I'll settle to let the user select their file, then sneakily do a GetPathName (because that is what is truely important to me here).
Any thoughts? I reviewed Juan Paulo's CP writeup; but, I'd like to refrain from introducing third party STL implementations.
Thanks
{{so much for formatting! }}
|
|
|
|
|
Hi:
I've problems with the usage of this function...
I want to draw a portion of a bitmap inside the imagelist and the function fails.
The explanation:
I create the Imagelist with ImageList_Create and the
params: ILC_COLOR24|ILC_MASK;
I've a bitmap of 90*54 pixels loaded with the LoadImage fcn with this
params : LR_CREATEDIBSECTION|LR_DEFAULTSIZE
Then i loads the bitmap into the imagelist with AddMasked
But i only want to draw a certain part portion of the index 0 in the imagelist.
That's because the bitmap contains a series of 3 columns ("Buttons")with the posible states of them. then i need to extract only a portion of the bitmap inside the index of iml.
I don't know if i'm filling the struct badly, or what...
but if i use ImageList_DrawEx for the first "row" it works fine, but with the remaining y should use another function ( posibbly ImageList_DrawIndirect) but don't works
Please Help ME!!!!!!!
|
|
|
|
|