|
I think you should use the first method, with a modalless dialog, wich should include a progress control. Than you should add in the parent window, wich does all of your processing, a call to a user defined method like this:
void CYourParentDlg::ProcessIdleMessages()
{
MSG msg;
while(::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
::PostQuitMessage(0);
break;
}
if (!PreTranslateMessage(&msg))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
}
This method will process each message and it will respond to your 'Cancel' button.
|
|
|
|
|
Thanks to both of you for your help. I've been going nuts because I couldn't get either method to work. With the first one I got undefines on the PumpMessage call, and the second one I got undefines with the PreTranslateMessage call.
Then it finally dawned on me, I was trying to call them from an import class that wasn't derived from a Windows class! I guess that's why Mihai told me to do the processing within the parent window. I need to re-structure things. Stay tuned...
And thanks again.
|
|
|
|
|
I am developing a directshow filter, but there are errors when running in graphedt. I do not know how to debug the filter. Thanks for any information about the filter debug. BTW, I am using VS2005.
|
|
|
|
|
I want to send a float in SendMessage instead of a UINT, so I thought I'd use union. I am having issues with unions
(see below). So how does one SendMessage a float?
I gathered that if I make a union
union
{
int n;
float s;
}convert
and do
convert.n = 5;
Then convert.s should give me 5.0
However this is not what I am getting. convert.s doesn't have anything meanngful in it.
Is this not the right way touse a union?
thanks,
sb
|
|
|
|
|
float s = 5.0;
SendMessage(hWnd, msg, 0, (LPARAM) &s);
In the message handler routine, cast LPARAM back to a float .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Thank you.
Is the messageHandler for the sendMessage like
afx_msg LRESULT OnDrawCursorOnPlot2(WPARAM subsetIndex,LPARAM sampleNum);
or
afx_msg LRESULT OnDrawCursorOnPlot2(UINT subsetIndex, UINT sampleNum);
Where would I find this info? I tried the former, but when I cast the LPARAM back into float
I didn't get back what I sent in.
LRESULT CMagAnView::OnDrawCursorOnPlot2(WPARAM subsetIndex, LPARAM location)
{
float fX = (float)location;
}
and
m_pParentWnd->SendMessage(UDM_DRAWCURSOR,subsetIndex,(LPARAM)&fX);
thank you,
sb
|
|
|
|
|
messagehandler is always like:
afx_msg LRESULT OnDrawCursorOnPlot2(WPARAM subsetIndex,LPARAM sampleNum);
and in the handler you have to get the float value back as below:
LRESULT CMagAnView::OnDrawCursorOnPlot2(WPARAM subsetIndex, LPARAM location){<br />
float *fX = (float*)location;<br />
}
and sendmessage format is:
m_pParentWnd->SendMessage(UDM_DRAWCURSOR,(WPARAM)&subsetIndex,(LPARAM)&fX);
(hope you haven't declared subsetIndex as a poniter, if so no need to put & for subsetIndex )
cheers ...mil10.
|
|
|
|
|
Ah! Thanks!
I guess I got overawed by the LPARAM and didn't realize I needed to dereference the value.
I thank you much for the help.
|
|
|
|
|
Hi there,
meanwhile I've tested a couple of serial communication classes that I've found in the web. Some work and some not.
However, I couldn't find a working example that can transmit single characters. Many support sending strings, but I would need single characters, because I'd like to send to send data from a structure in this manner:
// pointer to structure for sending
const unsigned char *p = (const unsigned char *) &gKupParam;
uart_putc ('<'); // start character
for (i=0;i<sizeof(gKupParam);i++) {
uart_putc (*p++);
}
uart_putc('>'); // end character
|
|
|
|
|
Well, as this is a win32 machine, talking to a serial port is just lake writing data to a file. And sending a character is just like sending a *really* short string! And sending the contents of a structure is like sending it byte by byte...
void SendMyStruct (HFILE hComPort, MyStruct *myStruct)
{
WriteFile (hComPort, &myStruct, sizeof (MyStruct), NULL, NULL);
}
I'm doing the parameters by memory, so you will need to loom them up for yourself.
Iain.
|
|
|
|
|
Thank you for your advice. What class do you use?
|
|
|
|
|
fambi_mail wrote: What class do you use?
Actually, I don't use any classes for my serial communications. I've used MFC for the front end of any application, and a separate thread with overlapping I/O to deal with the serial port side of things. But then again, most of the comms has been *into* the PC, rather than fully two way. When you are multithreading, it can be a problem accessing MFC classes from more than one thread...
But I'm also a bit of a dinosaur control freak, and like doing things the raw way...
I've just a had a peek, and there are several classes to talk with the serial ports in http://www.codeproject.com/system/#Hardware[^]. Unfortunately, I haven't looked at them for quite some time, so I can't recommend any particular one.
Good luck!
|
|
|
|
|
|
A CEdit redraws itself if I call Invalidate, but then it creates its own PaintDC.
I would like to draw the CEdit to a memory DC to prevent flickering, but I can't find any CWnd method that accepts a DC for painting.
Thanks
Andre
|
|
|
|
|
I guess there is no "CWnd method that accepts a DC for painting".
if u only want "to prevent flickering" of the CEdit, I think you are in a hard way.
u may get better solution if u post the reason why you want to redraw the CEdit - normally CEdit can redraw itself if its text is changed.
A special image tool for Windows C++ programmers, don't miss it!
The world unique Software Label Maker is waiting for you and me ...
A nice hyper tool for optimizing your Microsoft html-help contents.
|
|
|
|
|
Hi, how can i access a usb device with winapi?
a short example will be very helpful!
bye
|
|
|
|
|
Have you searched CP, or Googled, for USB-related articles?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
|
If you want to read/write from/to a USB HID device a suggest to take a look on Jan Axelson's The HID Page[^]
BTW, a mouse is a HID device (I'm using his code in a big commercial project and it's working very good)
|
|
|
|
|
hi, which example do you use?
Visual C++ 6
Usbhidio_vc6 ???
at
------ Build started: Project: usbhidioc, Configuration: Debug Win32 ------
Compiling...
usbhidioc.cpp
c:\download\usbhidio_vc6\usbhidioc.cpp(12) : fatal error C1083: Cannot open include file: 'hidsdi.h': No such file or directory
usbhidiocDlg.cpp
c:\download\usbhidio_vc6\usbhidiocdlg.cpp(57) : fatal error C1083: Cannot open include file: 'hidsdi.h': No such file or directory
Generating Code...
Creating browse information file...
Microsoft Browse Information Maintenance Utility Version ..................
BSCMAKE: error BK1506 : cannot open file '.\Debug\usbhidioc.sbr': No such file or directory
where can i download the Windows Driver Development Kit for win xp??? hm at the microsoft page i only found ... to order...
cu
-- modified at 7:17 Tuesday 4th April, 2006
|
|
|
|
|
Hi,
what is the reason for the Cxyz& return value with *this parameter of = operators?
Dr-Kuulun
|
|
|
|
|
Not sure exactly what you are asking, but this is a pointer while *this is the actual object being pointed to. Since the operator= method is returning a reference to the actual object, that's why *this would need to be returned.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
if u define return type as Cxyz&, u should return *this, otherwise what you can return?
u can define return type other way, such as void or BOOL.
A special image tool for Windows C++ programmers, don't miss it!
The world unique Software Label Maker is waiting for you and me ...
A nice hyper tool for optimizing your Microsoft html-help contents.
|
|
|
|
|
The reason is simpler than you may think. Its is so that you can make multiple assignment work efficiently.
You expect this to work:
int a, b, c;
a = b = c = 1;
So you also accept this to work:
CFwibble a, b, c;
c.DoSomethingtoInitialisethestruct;
a = b = c;
But the last line is equivalent to:
a = (b = c);
which means b = c has to be something you can assign to another struct / class / object of the same kind.
You could make the return value xyz , but that would mean creating a temporary copy on the stack, which is inefficient. The xyz & means a reference to b is passed, so no temporary copy is made.
For proper purity, you should also make the reference const, to prevent b from being messed about with...
class xyz
{
...
const xyz &operator=(const xyz &rhs)
{
...
return *this;
}
};
I hope that made sense for you!
Iain.
-- modified at 19:54 Monday 3rd April, 2006
|
|
|
|
|
Iain Clarke wrote: CFwibble a, b, c;
5 just for the class name!
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|