|
AVI capFileSaveDIB saves one AVI frame to bitmap file.
Is it possible to save AVI frame as bitmap directly to memory?
Constructive suggestions are appreciated.
Thanks for reading
Vaclav
|
|
|
|
|
When streaming, you can grab a frame from a callback set with
capSetCallbackOnVideoStream.
When not streaming, maybe capGrabFrame and a callback set with
capSetCallbackOnFrame.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Is there a third option? Like maybe you can fish it out of some lake or something?
led mike
|
|
|
|
|
Hi,
I was wondering if any of the experts could tell me If my usage of Named Pipes For Interprocess communication Async. is correct
First Server code
CreateNamedPipe ... using FILE_FLAG_OVERLAPPED
Overlappeda.hEvent = CreateEvent(&sa,FALSE,FALSE,TEXT("EVENTA"));
OverLappedb.hEvent = CreateEvent(&sa,FALSE,FALSE,TEXT("EVENTB"));
// Wait For Cleint to Connect
ConnectNamedPipe....
Now Client Code
filehandle = CreateFile
Get PID of Parent
PHANDLE = OpenProcess
myeventa = OpenEvent("EVENTA");
myeventb = OpenEvent("EVENTB");
// Duplicate hEvent of Overlaped.hEvent Created By Server
DuplicateHande(...myevanta... (Target Handle) myoverlappeda.hEventa
CreateThread.... to wait for I/O from Server
Mythread code
// wait For I/O from Server
for (;;)
{
WaitForSingleObject(myoverlappeda.hEvent...
// Read I/O
ReadFile(filehandle
go to proper function in Client
}
One the things I am not sure of is the WaitForSingleObject before The ReadFile
or After
The Way i have it Coded now if The event in the WaitForSingleObject gets signaled
will it Readfile go into a Wait Again ????? or since the WaitForSingleObject
Says there is data everyting will work ???
Thankx
|
|
|
|
|
ForNow wrote: I was wondering if any of the experts could tell me If my usage of Named Pipes For Interprocess communication Async. is correct
Well we can't see your code because you didn't follow the posting instructions for source code for this web site. That said, if you followed the documentation instructions for implementing named pipes and overlapped I/O in the same fashion you did the code posting instructions for this site, there is almost zero chance that your implementation is correct.
Good luck
led mike
|
|
|
|
|
Just read the the instuctions on how to post a message
re: source code it mentions 2 options the first of which <pre> </pre> tags I dont understand so I'll take the second options Check ignore HTML tags
Here it is
Server Code
pipehandle = CreateNamedPipe ( pipe_name,
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
PIPE_UNLIMITED_INSTANCES,
buf_size,
buf_size,
PIPE_TIMEOUT,
NULL);
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = NULL; // initailize security discriptor
sa.bInheritHandle = TRUE;
over_read.hEvent= CreateEvent(&sa,
FALSE, // let Windows Re-set
FALSE, // Intially set off
TEXT("eventread"));
over_write.hEvent= CreateEvent(&sa,
FALSE, // let Windows Re-set
FALSE, // Intially set off
TEXT("eventwrite"));
memset(&si,0,sizeof(si));
si.cb= sizeof(si);
return_code = CreateProcess(NULL,
(LPCSTR) &herc_buff[0],
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi);
return_code = ConnectNamedPipe (pipehandle,&over_lapp);
In Client
filehdl = CreateFile(pipe_name,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
myevent_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,TEXT("eventread"));
myevent_write = OpenEvent(EVENT_ALL_ACCESS,FALSE,TEXT("eventwrite"));
parent_object = OpenProcess(PROCESS_ALL_ACCESS,FALSE,parent_process);
DuplicateHandle(parent_object,myevent_read,GetCurrentProcess(),overread.hEvent,0,FALSE,DUPLICATE_SAME_ACCESS);
DuplicateHandle(parent_object,myevent_write,GetCurrentProcess(),overwrite.hEvent,0,FALSE,DUPLICATE_SAME_ACCESS);
/* Create a thread to wait for Hercules to send back completed commands */
CreateThread(
NULL,
NULL,
my_thread_function,
lparam,
NULL,
&my_thread);
// code in my thread function
DWORD __stdcall my_thread_function(LPVOID lparam)
{
OVERLAPPED overwite;
char buffer[100];
int i;
while(1)
{
WaitForSingleObject(myevent_write,INFINITE,TRUE);
ReadFile(filehdl,
(LPVOID) &buffer[0],
100,
NULL,
(LPOVERLAPPED) &overwrite);
}
return 0;
}
Hope this is what u mean
|
|
|
|
|
ForNow wrote: Just read the the instuctions on how to post a message
Didn't read them very well then - there's a whole section on using the pre tag to keep formatting - and that also helps with for loops, as they look a bit like html...
(either that, or CP is messing up again. But I know which is more likely)
Iain.
|
|
|
|
|
I think I did what you wanted with the pre-tag in the Begining and end
<code> /* Following is the code to Create a Child Win32 GUI process from a
console application using Named pipes to read and write */
pipehandle = CreateNamedPipe ( pipe_name,
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
PIPE_UNLIMITED_INSTANCES,
buf_size,
buf_size,
PIPE_TIMEOUT,
NULL);
if (pipehandle == INVALID_HANDLE_VALUE)
errcd = GetLastError();
/* Create The Event for Async i/o */
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE; // Create Security descriptor
over_read.hEvent=CreateEvent(&sa
FALSE, // let Windows Re-set
FALSE, // Intially set off
TEXT("eventread"));
over_write.hEvent= CreateEvent(&sa,
FLASE // let Windows Re-set
FALSE, // Intially set off
TEXT("herceventwrite"));
GetCurrentDirectory(buff_len, (LPTSTR) &herc_buff[0]);
hold_ptr = strchr((char *) &herc_buff,0x00);
strcpy(hold_ptr,"\\HERCCMD.EXE ");
memset(&si,0,sizeof(si));
si.cb= sizeof(si);
/* create the Herc GUI process minimized */
return_code = CreateProcess(NULL,
(LPCSTR) &herc_buff[0],
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi);
/* Wait For HerCmd MainWidnow to Be Created */
// HERCMD window of Client
hercwind = NULL;
while (hercwind == NULL)
{
sysblk.hercwind = FindWindow(LPCTSTR) "HERCCMD",
(LPCTSTR) "HERCCMD");
}
/* wait for the pipe connection from hercGUI client */
return_code = ConnectNamedPipe (pipehandle,&herc_over);
// The Following is code where I get the address of a Proc
//
// that will
// live in the Server Console App Reading the
// requests the Client
// Below this code, is the actual procedure
void win_cmd()
{
int j = 1;
COPYDATASTRUCT cpd;
HMODULE hutil_module;
FARPROC hercgui_addr;
hutil_module = GetModuleHandle("HENGINE");
hercgui_addr = GetProcAddress(hutil_module,"hercgui_proc");
cpd.dwData = hercgui_addr;
cpd.cbData = 4;
cpd.lpData = &hercgui_addr;
SendMessage((HWND) hercwind, WM_COPYDATA, NULL, &cpd);
return;
}
// the routine to read data From Client
DLL_EXPORT void hercgui_proc(LPVOID lparam)
{
char buffer[30];
DWORD buffnum;
/* Wait for Commands */
for(;;)
{
ReadFile(sysblk.pipehandle,
&buffer[0],
19,
&buffnum,
(LPOVERLAPPED)
&sysblk.herc_over_read);
WaitForSingleObject(herc_over_read.hEvent,INFINITE,TRUE);
hercgui_process = 1;
ProcessPanelCommand(&buffer[4]); // process the command
// Write data back to Cleint
WriteFile(sysblk.pipehandle,
&hercgui_buff[0],
100,
&buffnum,
&sysblk.herc_over_write);
}
return;
}
// Client Code
// get parent PID
snap_shot = CreateToolhelp32SnapshotTH32CS_SNAPPROCESS,0);
process32.dwSize = sizeof(PROCESSENTRY32);
Process32Firstsnap_shot,&process32);
pid = GetCurrentProcessId(); // Get Current process id
while(pid != process32.th32ProcessID)
{
return_cde = Process32Next(snap_shot,&process32);
}
parent_process = process32.th32ParentProcessID;
// Create File for Named pipes
filehdl = CreateFile(pipe_name,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ |
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
if (filehdl == INVALID_HANDLE_VALUE)
errcd= GetLastError();
Create Events for OverLapped i/o
myevent_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,TEXT("eventread"));
if (myevent_read == NULL)
errcd= GetLastError();
myevent_write = OpenEvent(EVENT_ALL_ACCESS,FALSE,TEXT("eventwrite"));
if (myevent_write == NULL)
errcd= GetLastError();
parent_object = OpenProcess
(PROCESS_ALL_ACCESS,FALSE,parent_process);
if (herc_object == NULL)
errcd= GetLastError();
DuplicateHandle(parent_object,myevent_read,GetCurrentProcess(),overread.hEvent,0,FALSE,DUPLICATE_SAME_ACCESS);
DuplicateHandle(parent_bject,myevent_write,GetCurrentProcess(),overwrite.hEvent,0,FALSE,DUPLICATE_SAME_ACCESS);
/* Create a thread to wait for for messages from Server */
CreateThread(
NULL,
NULL,
hercgui_commands,
lparam,
NULL,
&herc_thread);
// Here is the Code for that thread
DWORD __stdcall hercgui_commands(LPVOID lparam)
{
OVERLAPPED herc_overlapped;
char buffer[100];
int i;
while(1)
{
WaitForSingleObject(myevent_write,INFINITE,TRUE);
ReadFile(filehdl,
(LPVOID) &buffer[0],
100,
NULL,
(LPOVERLAPPED) &overwrite);
}
return 0;
}
// Here is the code in the Cleint Where I Create the Remote Thread that lives in the Dos
// Console Server app
case WM_COPYDATA:
my_data_ptr = (COPYDATASTRUCT *) lParam;
hercgui_proc = my_data_ptr->dwData;
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
CreateRemoteThread(herc_object,
&sa,
NULL,
(LPTHREAD_START_ROUTINE) hercgui_proc,
lparam,
NULL,
&thread_id);
ShowWindow(hWnd, first_show);
return 1;
</code>
I know its a lot of code I tried to comment the Blocks with what I do
|
|
|
|
|
Hi,
I've searched high and low to solve this issue. I apologize in advance if it has been covered before. I'm using the VS 2008 MFC feature pack.
I have added a CVSListBox to a taskpane and wish the capture the event when the selected item in the CVSListBox has changed.
I'm pretty certain I've done what's required, but my OnItemChanged function does not seem to be called when I click on various items in the list.
Any help is much appreciated.
Header file of a subclassed CVSListBox
======================================
class CVSListBoxPtList : public CVSListBox
{
public:
CVSListBoxPtList(CWnd *p);
~CVSListBoxPtList();
protected:
afx_msg void OnItemChanged(NMHDR* pNMHDR, LRESULT* pResult);
DECLARE_MESSAGE_MAP()
private:
};
Implementation with message map
===============================
#include "stdafx.h"
#include "CVSListBoxPtList.h"
#include "Resource.h"
BEGIN_MESSAGE_MAP(CVSListBoxPtList, CVSListBox)
ON_NOTIFY(LVN_ITEMCHANGED, ID_PATHPOINTLIST, &CVSListBoxPtList::OnItemChanged)
END_MESSAGE_MAP()
CVSListBoxPtList::CVSListBoxPtList(CWnd *p)
{
Create("Path Points", WS_CHILD | WS_VISIBLE | WS_BORDER, CRect(1,1,1,1), p, ID_PATHPOINTLIST);
SetStandardButtons();
EnableBrowseButton();
AddItem("pathpoint1");
AddItem("pathpoint2");
AddItem("pathpoint3");
}
CVSListBoxPtList::~CVSListBoxPtList()
{
}
void CVSListBoxPtList::OnItemChanged(NMHDR* pNMHDR, LRESULT* pResult) <--- doesn't get called
{
//(I have a console window that comes up for debugging - hence the use of a printf statement for testing)
printf("New item clicked on!");
}
|
|
|
|
|
Isn't the notification being sent to the parent window of the list? I think you need to use something like ON_NOTIFY_REFLECT or somesuch to handle the message in the class of the control who originally sends the message. It's just a guess from me, i don't know CVSListBox so ignore me if i am wrong.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Hi,
Yup I tried ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, &CVSListBoxPtList::OnItemChanged) and that didn't work.
I also tried in the parent window (MainFrm) with ON_NOTIFY and that didn't work either.
Is there a better way to find where the message is being sent?
|
|
|
|
|
In case this helps anyone.
You can just override
virtual void OnSelectionChanged() {}
It's in the base class of CVSListBox.
I'm new to MFC. I can't understand the reasoning behind using message maps for some things and then override functions like this. Is it just an evolution of MFC towards sane C++ usage?
|
|
|
|
|
hi, i need to do a system in c++ to interact with a monitor that has a few buttons. This application will perform some task when these buttons are pressed. I'm not quite sure where to start. any help?
|
|
|
|
|
Do you need to make a shell or you want to make a win32 app?
|
|
|
|
|
the program will have GUI for user to do some settings. after which these settings will be save and user will interact with the monitor button.
|
|
|
|
|
Im sorry but I dont know you need declare button's event or ?
|
|
|
|
|
nuttynibbles wrote: hi, i need to do a system in c++ to interact with a monitor that has a few buttons
Hi, how do you communicate with such external device (if I got it...)?
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]
|
|
|
|
|
Hi guys,
In a number of CMS programs, I would like to have a HTML editor to edit some of the texts in an otherwise fixed layout. I have already written something that will work a CRichEditCtrl content into html code and that works fine. However, I would also like to be able to incorporate images and links into my text. Does anyone know of an html editor that I could use for this sort of thing?
I am only looking to edit the text. The layout of the site itself, the css codes and all that are handled separately. The html to be generated will be inserted into the pages of the site.
Thanks in advance.
WIlliam
|
|
|
|
|
|
|
Hai!
I have a multiline edit box in my MFC application , it is also enabled with auto V-Scroll, after all the data is being displayed, it goes to the initial position, i have to scroll to the end, for data verification, is there any way to make the cursor to stay at the end or last position after printing all the data ?
Thankyou !
|
|
|
|
|
kapardhi wrote: I have a multiline edit box in my MFC application , it is also enabled with auto V-Scroll, after all the data is being displayed, it goes to the initial position, i have to scroll to the end, for data verification, is there any way to make the cursor to stay at the end or last position after printing all the data ?
Do this...
extern CEdit* pEdit; // Some edit
pEdit.SetSel( 0, -1 ); // Move cursor to end
pEdit.SetSel( -1, -1 ); // Remove selection
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
hello !
what is happening is each time the data is entered into the multiline edit box the scroll bar goes to initial position and then comes down, it appears like blinking,
what i need is it must go down first and then decrease the size of scrollbar and stay at the end when data printed on the multiline edit box is completed!
thanks!
|
|
|
|
|
kapardhi wrote: what is happening is each time the data is entered into the multiline edit box the scroll bar goes to initial position and then comes down, it appears like blinking,
Can you try EM_REPLACESEL. Something like...
pEdit->SendMessage( EM_REPLACESEL,
TRUE,
(LPARAM)static_cast<LPCTSTR>( csTextToBeInserted ));
Tell us if the blinking problem does get solved.
modified on Wednesday, November 26, 2008 7:55 AM
|
|
|
|
|
I couldnot compile it my CEdit object is edtObj.
i did the following
CString str;
str = "Kaps";
edtObj.SendMessage (EM_REPLACESEL, TRUE, (LPARAM) static_cast (str));
it was giving following error
syntax error : '('
|
|
|
|
|