|
this thing will work if u calling the set timer function in the view class itself..
Thanx
TAKE CARE
|
|
|
|
|
Thanks for the suggestion. In fact I have got my code working like that at the moment, but I have several timers and I wanted to assign each one its own handling function.
Thanks anyway
Ali
|
|
|
|
|
The problem is with the declaration of your TimerTakeSample function. I think its probably got something to do with that EXPORT (try removing it?) because the CALLBACK simply defines the function type as an _stdcall* and so that should compile.
|
|
|
|
|
Thanks for the suggestion, I've tried it but the compiler still doesn't want to know (still the same error message).
Thanks anyway
Ali
|
|
|
|
|
The actual problem is that the compiler is expecting a void (_stdcall*) (arglist...)function and your function has somehow been defined as a mere void (arglist...) function hence the error. Since the CALLBACK statement defines the (_stdcall*) you should not be having this issue, unless the EXPORT statement is doing something dopy (so try removing it), or the TimerTakeSample referred to in the SetTimer function is being linked to a different function? try specifying COxygraphView::TimerTakeSample(blah...) in your SetTimer function to make sure your linkage is correct (can't tell from your example where the SetTimer is being called from). I'm sure the answer will reveal itself
|
|
|
|
|
The function must be declared as static
Hope this helps,
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"
|
|
|
|
|
Haha, yes the declaration should be static void CALLBACK etc. well done ryan
|
|
|
|
|
To expand on Ryan's post - it's all to do with pointers to member functions. Take a look at this[^] site - it will explain all!
Phil
|
|
|
|
|
Thanks, the link looks really helpful, looks like I need to do some reading!
Ali
|
|
|
|
|
You're right changing the funstionto static gets rid of the compiler error. However, now I have more errors calling functions from the timer function. Looks like I need to read up on static functions!
Thanks for the help, much appreciated
Ali
|
|
|
|
|
You're welcome
Alison Pentland wrote:
However, now I have more errors calling functions from the timer function. Looks like I need to read up on static functions!
Good idea Your errors at the moment are probably because you're calling non-static members from your static function. You can't do that . The general way of using static functions as callbacks is to pass a pointer to the object as the lParam value that gets passed to the callback function, and then using that pointer to access the other class members.
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"
|
|
|
|
|
Declaring a member function of class as static will remove the need for an instance of the class to be associated with it - i.e. no this pointer. What this means is that it can't access any of the normal member functions/variables - precisely because there is no associated this pointer. However, supply the static function with a pointer to an instance of the class and you can access all functions/variables (even private ones) via that pointer - because the static function is still declared in the scope of the class.
In terms of pointers to functions, because a static member function has no associated this pointer you can obtain it's address directly (just like a C function) - this is why Ryan's suggestion worked. Any normal member function must have an associated this pointer with it, so even when you take the address of a member function you must still use it with a pointer to an instance of the class as well.
class CMyClass<br />
{<br />
public:<br />
void MyFn (void);<br />
static void MyStaticFn (CMyClass *);<br />
};<br />
<br />
typedef void(* FnPtr)(CMyClass*);
typedef void(CMyClass::* MemberFnPtr)();
<br />
CMyClass* pMyClass = new CMyClass;<br />
<br />
MemberFnPtr pMFn = &CMyClass::MyFn;<br />
pMyClass->MyFn();
pMyClass->*pMFn();
<br />
FnPtr pFn = &CMyClass::MyStaticFn;<br />
(*pFn)( pMyClass );
[edit]
You could try using the nIDEvent parameter of SetTimer to hold the pointer to your class instance - cast it back to the correct type and use within your static fn.
[/edit]
Hope this helps,
Phil
|
|
|
|
|
Hi Alison,
I am not sure that "static" is right method. See following:
The citation:
-The lpfnTimer callback function need not be named TimerProc, but it must be defined as follows:
-void CALLBACK EXPORT TimerProc(
- HWND hWnd, // handle of CWnd that called SetTimer
- UINT nMsg, // WM_TIMER
- UINT nIDEvent // timer identification
- DWORD dwTime // system time
-);
So, TimerProc should be a function insted class method.
|
|
|
|
|
Talik wrote:
So, TimerProc should be a function insted class method.
There is nothing wrong with using a static member. The compiler treats functions and static members in exactly the same way.
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"
|
|
|
|
|
Hi everyone,
Having a nightmare problem - hoping someone can help!
When I catch OnDropdown for a combo box and try programmatically selecting an item different than the current selection the control reselects a different item!
I have a list box, let's say it's got these items:
_________________
| Paul Maddox
| Paul Mdx
| Paul
|_________________
If "Paul Mdx" was selected last time, when I open the dropdown I want it to select "Paul".
So, I've hooked the OnDropdownMyCombo function and done:
m_combo.SetCurSel(m_combo.FindExactMatch(-1,"Paul"));
After the selection I do GetCurSel and GetLBText to double-check the correct selection is made, which it is.
However, the control will show "Paul Maddox" as being selected in the dropped down list, BUT "Paul" shown in the edit box.
If anyone has come across this or has any suggestions, I'm more than open to hear them!
Many thanks,
Paul.
|
|
|
|
|
The framework sets the new selection after OnDropdownMyCombo is called, so your code has no effect. Your code would work if you put it in the ON_CBN_SELCHANGE handler.
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
Hi all
I create a file by using CStdioFile.
I want to sent this file to Printer, which function should i use?
Thanks
|
|
|
|
|
- Use
ShellExecute()
ShellExecute(m_hWnd, "print", "MyFile.txt", NULL, NULL, SW_HIDE);
This will execute the program associated with the .txt extension and tell it to print the file.
- Use
system()
system("copy "MyFile.txt" lpt1:");
This will send the file to the printer using the DOS copy command. Note that the last (partial) page will probably not be printed, unless you send a formfeed.
- Use MFC's doc/view printing architecture. See the Printing section here on CP for more details.
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
hello world,
I develop video capture application, and i need to extract frames as bmp.
I use directshow to capture my 1394 dv, and vfw.h to extract frames.
capture is ok and works quitte well.
But (terrific 'but'!!)
when i try to use vfw.h functions, compilation gives no error, but i always have the sam linking errors
error LNK2001: unresolved external symbol _AVIFileInit@0
I tried everything, vfw32.lib seems to be the same version, it describes the same functions...
My project is not a commercial one, it has artistic purposes. Deadlines are getting closer and i am afraid to be late.
PLEASE HELP
Mr PIER
|
|
|
|
|
Go to Project | Settings | Link | Object/library modules, and add Vfw32.lib.
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
thanks
it helped,
but i can't launch AVIStreamOpenFromFile even if i close the directshow's capture graph, i don't understand why
any idea ??
|
|
|
|
|
Hi All,
I Want to use the newwindow event to not open the new window and open the
same link in parent window...I have declared the function like this..
DISP_FUNCTION_ID(CWebBrowser2, "NewWindow2",DISPID_NEWWINDOW2, OnNewWindow,
VT_EMPTY, VTS_BSTR VTS_I4 VTS_BSTR VTS_PVARIANT VTS_BSTR VTS_PBOOL)
and the function definition says..
void CBrowser::OnNewWindow(BSTR URL, long Flags, BSTR TargetFrameName,
VARIANT* PostData, BSTR Headers, BOOL FAR* Cancel)
{
if (m_pBrowserApp) {
COleVariant varEmpty;
if (Cancel != NULL )
*Cancel = TRUE;
m_pBrowserApp->Navigate(URL, &varEmpty, &varEmpty, &varEmpty, &varEmpty);
}
}
MSDN says it should work like this only..but unfortunately this is not
working for me..Pls helpAny help or pointers are higly appreciated..Thanks a
lot in advance..
Himanshu
|
|
|
|
|
Hi,
I've build an application with some documentation (in an Adobe PDF format), and I must build a button in my app to show this documentation.
Do you know wether I can open this file from my own program (please add some sample code, using "help.pdf", or something like it), if this isn't possible, can I do it with ms word (doc format help).
Thank you in advance,
Boudewijn
|
|
|
|
|
Use ShellExecute() :
ShellExecute(m_hWnd, "open", "help.pdf", NULL, NULL, SW_SHOW);
This assumes that Acrobat is installed.
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
Hi,
I need to have some kind of control to select a directory, just like a file:
There must be some kind of dialog, like an openFileDialog, wich can select directories, instead of jsut files.
Does anyone know wether there is such a control, and where can I find it in MFC?
Thank you in advance,
Boudewijn
|
|
|
|