|
A function pointer does't necessarily have to be associated with WM_TIMER, any function can be made into a function pointer.
-Saurabh
|
|
|
|
|
A related question is when I'm writing my own WndProc() with callback enabled as you described,
Should I always make the following default statement after switching on the message? Does it automatically know to call 'MyWindowProc'? Thanks! :
LRESULT CALLBACK MyWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
|
|
|
|
A callback function is a function which is called everytime some event occurs. This has application in many place most notably you can see them used for handling user interaction in GUI's. So whenever you press a button in a window, a function is called to handle the event that function is the callback function for that button.
To create callback function you need to get the pointer to that function and then using this pointer given function can be called whenever needed. So this might be use to differentiate a callback function from ordinary functions. When you find a function called only through a function pointer its definitely a callback function.
-Saurabh
|
|
|
|
|
Hi
Windows is Event driven architecture. so when ever a event occures, a corresponding callback procedure is called. for example when u move a mouse, WM_MOUSEMOVE event accure and will be notified or posted in message queue. A window procedure function or call back function which we defined when we creating a window with CreateWindow function called by a OS. if u r interested in handling of any event u can process that message or u can give to DefWndProc function and OS will take care of the perticular event. So for each window, a wndproc will be there to handle.
Parthi
|
|
|
|
|
A callback function is simply a function which is called to notify the program of some event. He's an example.
typedef void (__stdcall *PMyCallback)(int num);
void DoItNTimes(int n, PMyCallback pCB)
{
for (int i=0; i<n; ++i)
{
(*pCB)(i);
}
}
void __stdcall MyCallback(int num)
{
cout << num << endl;
}
DoItNTimes(10, &MyCallback);
Many functions in Windows (and many APIs in general) use this technique.
Steve
|
|
|
|
|
Hey everyone, I have the following issue: I am not able to build a release version of my app, although building a debug one works great.
So I looked up error 2005 and it said to put libcmt.lib & nafxcw.lib in the ignore directive... WHICH i DID
(results of ignoring libcmt.lib & nafcw.lib, but still adding them to additioanl linker depdendcies)
Here a choice selection of the more than 200 errors:
LIBCMT.lib(invarg.obj) : error LNK2005: __initp_misc_invarg already defined in Libcmtd.lib(invarg.obj)
LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in Libcmtd.lib(invarg.obj)
LIBCMT.lib(invarg.obj) : error LNK2005: __set_invalid_parameter_handler already defined in Libcmtd.lib(invarg.obj)
LIBCMT.lib(invarg.obj) : error LNK2005: __get_invalid_parameter_handler already defined in Libcmtd.lib(invarg.obj)
(results of ignoring libcmt.lib & nafcw.lib, but NOT including them to additional linker depencies)
nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMT.lib(new.obj)
nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMT.lib(delete.obj)
nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in LIBCMT.lib(new2.obj)
nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMT.lib(delete2.obj)
And finally, the library settings that work great for the debug verison:
ADDITIONAL LINKDER DEPENDICIES: user32.lib odbc32.lib odbccp32.lib scrnsave.lib comctl32.lib kernel32.lib gdi32.lib Nafxcwd.lib Libcmtd.lib Advapi32.lib
IGNORE LIBRARIES: Nafxcwd.lib Libcmtd.lib
(I tried with t he exact same libaries on the release version (of course changing nafxcwd.lib->nafcw.lib and libcmtd.lib->libcmt.lib for release version), with no effect.
Thanks in advance!
-- modified at 2:19 Saturday 22nd April, 2006
|
|
|
|
|
This basically means are you trying to link different version of CRT - C Run Time in same executable. To make sure you are using same version in Visual Studion 2005 go to Project --> Properties --> Configuration Properties --> Code Generation --> Runtime Library. There you should see either Multi-threaded (/MT) or Multi-threaded DLL (/MD). Now make sure all the static or dynamic libraries (except system libraries) you are including uses same switch.
-Saurabh
|
|
|
|
|
Thanks Saurabh:
I'm a real VC++ newbie, and I went to the runtime library settings. It's set to be Mutli-Threaded /MT. I then get confused at your next step: how do I make sure all the static or dynamic libraries are including the same switch? How do I specify this, and how do I know what switch they are using?
Many thanks!
|
|
|
|
|
You cannot check this for standard libraries which are shipped with Visual Studio, you have to check it only for any 3rd party libraries. If you don't have their source code then you cannot help it.
-Saurabh
|
|
|
|
|
Cool, I fixed it using the rather silly strategy of both including the library files, and simulteanously ignoring them. It sounds stupid, but its what Microsoft reccomends, and it works.
|
|
|
|
|
That's nice. Can you please explain exactly what you did? Are you using any 3rd party libraries or just the system libraries? Which libraries did you included and ignored?
-Saurabh
|
|
|
|
|
Sure, I'm only using system libraries... here they are:
user32.lib odbc32.lib odbccp32.lib comctl32.lib kernel32.lib gdi32.lib Advapi32.lib nafxcw.lib LIBCMT.lib LIBCPMT.lib
and ignored: nafxcw.lib; LIBCMT.lib; LIBCPMT.lib
I know it looks silly, but it makes it compile without problems... I wonder what the heck it means to include libraries only to ignore them.... oh well.
|
|
|
|
|
How can I have automatically the path of my SQL SERVER Database in my programme.
I am using Visual c++ 6.0
Thanks
I learn my self
|
|
|
|
|
what do you mean
mikobi wrote: the path of my SQL SERVER Database
do you mean the name of the database or the location of the mdf & ldf files ?
|
|
|
|
|
When you have a sql server running in your pc; when you point the mouse
it shows running-..... what i need is what is after running- . Whow can i have it in my program ?
|
|
|
|
|
dbinit.AddProperty(DBPROP_INIT_DATASOURCE, ...... // Here
It is what we write in the sentence above
I can say that it is database name; like \\COMPUTER
-- modified at 1:11 Monday 24th April, 2006
|
|
|
|
|
Hi,
I know IShellFolder::GetAttributesOf can get property of any sys folder. But how can I hide sys folder? which function can do it?
Nothing impossible, Nothing sure
|
|
|
|
|
Hi.
----------------------------------------
AtlWin.h some code about unsubclass window:
// unsubclass, if needed
LONG_PTR pfnWndProc = ::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC);
lRes = pThis->DefWindowProc(uMsg, wParam, lParam);
if(pThis->m_pfnSuperWindowProc != ::DefWindowProc && ::GetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC) == pfnWndProc)
::SetWindowLongPtr(pThis->m_hWnd, GWLP_WNDPROC, (LONG_PTR)pThis->m_pfnSuperWindowProc);
#if (_ATL_VER >= 0x0700)
// mark window as destryed
pThis->m_dwState |= WINSTATE_DESTROYED;
#else // !(_ATL_VER >= 0x0700)
// clear out window handle
HWND hWnd = pThis->m_hWnd;
pThis->m_hWnd = NULL;
// clean up after window is destroyed
pThis->OnFinalMessage(hWnd);
#endif // !(_ATL_VER >= 0x0700)
---------------------------------------
WINCORE.CPP some code about unsubclasswindow
// call default, unsubclass, and detach from the map
WNDPROC pfnWndProc = WNDPROC(GetWindowLongPtr(m_hWnd, GWLP_WNDPROC));
Default();
if (WNDPROC(GetWindowLongPtr(m_hWnd, GWLP_WNDPROC)) == pfnWndProc)
{
WNDPROC pfnSuper = *GetSuperWndProcAddr();
if (pfnSuper != NULL)
SetWindowLongPtr(m_hWnd, GWLP_WNDPROC, INT_PTR(pfnSuper));
}
Detach();
----------------------------------------------------
1.Why in ATL when "pThis->m_pfnSuperWindowProc == ::DefWindowProc " not need restore old wndproc, but in MFC without this compare?
2.Now i write subclass window(mulriple, like DefWindowProc -> My subclass -> CWnd subclass(CWindow subclass) or DefWindowProc -> CWnd subclass(CWindow subclass) -> my subclass), and can safe unsubclass window. which above code i can modification and use in my code?
Thanks.
|
|
|
|
|
i wanna know how i can use messenger or mail services in my code to send infromation to an id in background or in secret way.
|
|
|
|
|
Why do you want to do it in secret, are you writing spyware ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
i wanna know how can i use messenger or mail services in my code to send infromation to an id in background or in secret way.
|
|
|
|
|
hi
i'm working on a remote admin project but.and it is a big but, i have a problem with controlling file in remote pc.
i wanna see the whole file && dir as i am see in my pc.i mean visual control!i wanna a code more power than ftp trasnfer.
thanks for ur reply
|
|
|
|
|
I want to get index of the image loaded in a listctrl(Report view). The image is loading dynamically. eg:- On clicking the row 2, I just want to know which image (Image index) is displayed in the 2nd column of that listctrl(ie, In the cell (2,2)).(The purpose is if the image loaded is image1 then on Selection i want to change it to image2, otherwise I want to load image 1)
At least I want to know if there is an image in That particular cell of the list report
GetItem is not working properly.
Sandeep
Sanc
-- modified at 2:01 Saturday 22nd April, 2006
|
|
|
|
|
To get an image associated with the cell use
LVITEM litem;
litem.mask = LVIF_IMAGE;
litem.iSubItem = 2;// the subitem number
litem.iItem = 2;// the item number
litem.iImage = -1;
GetItem( &litem );
after u have called the GetItem function, the litem.iImage member of the LVITEM will contain the image index.
This function will return the image number only if u have set the LVS_EX_SUBITEMIMAGES extended style....
nave
|
|
|
|