|
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!!!!!!!
|
|
|
|
|
Savior999 wrote: but if i use ImageList_DrawEx for the first "row" it works fine, but with the remaining y should use another function
What do you mean by "row"?
LR_DEFAULTSIZE is for icons and cursors, right?
|
|
|
|
|
Hi, thanks for the reply
I use the imagelist with a bitmap containing three (say it) columns (that is the indexes of imagelist), then i've col 1, col 2 & col 3.
The bitmap contains the states of 3 "buttons", but all the "states" are all in the same col. Then i need to paint only a piece of the col.
Explanation:
My bmp is 90h * 54w px and the imagelist cut it in 3 cols of 90h * 18w px.
I need to paint only 18 * 18 px at a time.
I tried to use ImageList_DrawIndirect specifing the index and the x,y point where the Draw would begins to read, but it don't works.
PD: Yes, you are right... i typed unnecessarily, my mistake But it's not in my code
|
|
|
|
|
An image list has only one row. You're not going to be able to draw starting anywhere in the
image list except 0,0 for the given image index.
You'll need to layout your bitmap so its one long row (270x18) and index accordingly.
Mark
|
|
|
|
|
Hello
I have been using CMap class of MFC (containg CString objects) declaring it as CMap<cstring,lpcstr,cstring,lpcstr> m_mapInfo. I stored values in it of type CStrings as the key and value. I used to loop thru the m_mapInfo using POSITION pos = m_mapInfo.GetStartPosition() to get the pointer to first member and looping using
while(pos != NULL)
m_mapInfo.GetNextAssoc(pos,string1,strin2)
It worked fine, until I had to make my code UNICODE complaint. To make it UNICODE complaint, I had to change the template definition to CMap<lpcstr,lpcstr,lpcstr,lpcstr> m_mapInfo. I stored the keys and values by converting CStrings to WideCharToMultiByte(). The values are being set in the map but now when I do a POSITION pos = m_mapInfo.GetStartPosition() it returns pos = 0xffff, though the size of the map is coming correctly as the number of elements set.
Can someone help me out ?
Thanx
Vipin
|
|
|
|
|
Have you tried using the LPCTSTR type instead of the LPCSTR type? The 'T' types are already UNICODE and MBCS aware.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
vipin_nvk wrote: I stored the keys and values by converting CStrings to WideCharToMultiByte().
Why? CString objects can be used in Unicode and non-Unicode builds.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all:
The following is my program.
<br />
#define WIN32_LEAN_AND_MEAN<br />
#include <math.h><br />
#include <windows.h><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include "lapack\matrix_clapack.h"<br />
<br />
<br />
#define NDIM 2 <br />
#define M_PI 3.14<br />
<br />
int main (){<br />
<br />
integer i, j, info2;<br />
integer N, NRHS, LDA, LDB;<br />
doublecomplex *A;<br />
doublecomplex *B;<br />
static integer IPIV[NDIM], INFO;<br />
<br />
A = (doublecomplex*) malloc(NDIM*NDIM*sizeof(doublecomplex));<br />
B = (doublecomplex*) malloc(NDIM*sizeof(doublecomplex));<br />
<br />
N=NDIM; NRHS=1; LDA=NDIM; LDB=NDIM;<br />
<br />
for (i=0;i<N;i++){<br />
for (j=0;j<N;j++) {<br />
A[i+N*j].r = cos(M_PI*(i+1)*3.0/4.0); <br />
A[i+N*j].i = sin(M_PI*(j+1)/5.0); <br />
printf(" %f + %fi \n",A[i+N*j].r, A[i+N*j].i);<br />
}<br />
}<br />
<br />
B[0].r = 1.0; <br />
B[0].i = 1.0; <br />
B[1].r = 2.0;<br />
B[1].i = 3.0;<br />
<br />
<br />
info2 = zgesv_(&N, &NRHS, A, &LDA, IPIV, B, &LDB, &INFO);<br />
<br />
printf("info %d \n",INFO);<br />
<br />
for (i=0;i<N;i++)<br />
printf(" %f + %fi \n",B[i].r, B[i].i);<br />
}<br />
And here is the compiler message:
<br />
1>------ Build started: Project: test, Configuration: Debug Win32 ------<br />
1>Compiling...<br />
1>test.cpp<br />
1>Linking...<br />
1>test.obj : error LNK2019: unresolved external symbol _zgesv_ referenced in function _main<br />
1>D:\Project\test\Debug\test.exe : fatal error LNK1120: 1 unresolved externals<br />
1>Build log was saved at "file://d:\Project\test\test\Debug\BuildLog.htm"<br />
1>test - 2 error(s), 0 warning(s)<br />
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========<br />
<br />
I just want to try to test the LAPACK library. But what's the problem with this program please?
Thanks
Asura
|
|
|
|
|
The implementation of the zgesv_ function that is inside the LAPACK library could not be found during the linking process.
You have to add the LAPACK library, the .lib file, to the list of libraries you're building with.
Bring up the options for the project and add the path for the LAPACK lib-file to the "input libraries".
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|
|
Roger Stoltz wrote: Bring up the options for the project and add the path for the LAPACK lib-file to the "input libraries".
An easier way is to use a #pragma comment(lib "LAPACK.lib") (assuming LAPACK.lib is the lib file name) directive to link import libraries.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Ha, that one I didn't know about!
Thanks for the info, PJ. Nice to know. My 5 for that!
This day was not in vain after all, now that I've learnt something new...
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|
|
Thanks folks
for your valuable advice of Tcp over Udp.
As far as my requirements are concerned, it demands UDP.
Bcoz the scenario is such that we have to broadcast packets at the same
to n number of Machines across the network.That's the reason i need help
on Sending files over UDP protocol.
I have worked previously on TCP,but not on UDP.
As far as previous post is concerned,somebody said that it is similar
as creating Socket and Sending it using IP and Port.
I hope in UDP you are sending on a Broadcast IP and port,so how to do it.
Thankx in Advance.
Girish
Software Developer
|
|
|
|
|
Girish601 wrote: I hope in UDP you are sending on a Broadcast IP and port,so how to do it.
Create the socket with a call to CSocket::Create and set the nSocketType parameter to SOCK_DGRAM for UDP.
If the socket was successfully created you can use CSocket::SendTo for sending datagrams to whatever address and port you desire since both shall be provided as formal parameters.
If you're not using MFC you can use the raw socket API, but I think you get the picture.
Hope this helps
--
Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|
|
It is very similar, except that datagrams (UDP messages) have a maximum size, and there is no guaranteed delivery or sequencing/ordering of data.
With TCP, if you send 128KB of data with a single call, internally it will be broken up (if necessary) into smaller packets (either on your system or possibly further down the network) that will be reassembled on the receiving system.
With UDP, IIRC, if you try to send 32KB with a single call, only a certain amount of it will be sent (something like 1500 bytes, I think). You will need to break up the data yourself into packets and send them one at a time. Additionally, if you send 5 packets in a row (1,2,3,4,5 ), they may arrive on the other side out-of-sequence (1,2,4,5,3 ), or some may not make it at all (1,3,4,2 but no 5th datagram ).
Sending multiple-packets of data via UDP often requires that you implement your own packetizing logic so that you handle lost or out-of-sequence packets.
Broadcast, point-to-point, point-to-multipoint or multicast has nothing to do with your using TCP or UDP, IIRC. You can data using either style to a broadcast address (i.e. xxx.xxx.xxx.255), or to a multicast address (multicast router, for example).
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
James R. Twine wrote: Broadcast, point-to-point, point-to-multipoint or multicast has nothing to do with your using TCP or UDP, IIRC. You can data using either style to a broadcast address (i.e. xxx.xxx.xxx.255), or to a multicast address (multicast router, for example).
I'm currently doing some research on broadcast and multicast, as we plan to use it in one of our projects. All documents I found so far claim that broadcasing and multicasting require the use of UDP. This does make sense to me, as TCP requires an established connection and for broadcasing and multicasting you don't even know to how many recepicients you are talking.
Regards,
Tim
|
|
|
|
|
Tim Paaschen wrote: All documents I found so far claim that broadcasing and multicasting require the use of UDP. This does make sense to me, as TCP requires an established connection and for broadcasing and multicasting you don't even know to how many recepicients you are talking.
Interesting... I think that makes sense for things like using PING to try to ping a broadcast address, but not for multicast that is supported by the network hardware. Since one or more routers could handle connetions to multiple clients, and since the connections are one-way, connection or connection-less would not matter - clients would subscribe to the 'cast by subscribing to the multicast server. But then again, I have not been close to multicast for some time now, so my memory of it may be faulty.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|