|
Hi, in my app i need pop-up menu which items depends on a situation. How should i insert new items to this menu and how should i handle it if i have no constants defined in resource.h
Thank you.
|
|
|
|
|
Using:
AppendMenu(HMENU hMenu,UINT uFlags,UINT_PTRuIDNewItem,LPCTSTR lpNewItem);
|
|
|
|
|
Has anyone every done anything with Active Directory Notification. I need to write a service that listens to LDAP and lets me know when things change such password changes, etc. I found the sample code on MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/ad/example_code_for_receiving_change_notifications.asp), however I'm unable to get the code to compile. I seem to be missing all of the header files.
-Any thoughts?
Thanks
|
|
|
|
|
hi
did u try to install the active directory SDK??
it contains all the header files u need.
good luck
The music in my heart I bore
Long after it was heard no more.
- William Wordsworth
|
|
|
|
|
Thank you very much. I will try that.
|
|
|
|
|
I have used the select(); function in an attempt to program a [Timed out] message into my program. In this case the host I am working with is www.ebay.com. You will notice that if you open a command prompt in windows and ping www.ebay.com that you will get four [timed out] output messages sent to the screen. I would like to do the same thing with my program and have chosen to use the select(); function to accomplish this task. The problem is that select(); returns the socket connected to www.ebay.com as readable. How could this be? If I can't use select(); to discover that I have not gotten a reply, how then will I know that no echo reply has been sent back to me?
Thank you,
Eric Sepich
|
|
|
|
|
Remember that a ping is performed at a lower level (ICMP) than a normal socket using select (TCP). Probably the reason you get no response by pinging www.ebay.com, is that the server is not responding to ping requests, and yet does respond to TCP requests (it would have to in order to serve HTTP!). Hence your select returns that it has connected.
|
|
|
|
|
Hi all,
I have an extention dll that export a dialog.
and i have an *.exe client that uses the dll and that dialog.
when even the mouse is over the dialog i want to play a wav here is the code i am using:
void CMyDlg::OnMouseMove(UINT nFlags, CPoint point)
{
HINSTANCE hInstance = AfxGetResourceHandle();
PlaySound(MAKEINTRESOURCE(IDR_BTN_CLICK),
hInstance,
SND_RESOURCE);
CDialog::OnMouseMove(nFlags, point);
}
the sound wav file is at the dll resources.....
the trouble is when look in debug mode at the value of hInstance, i see it points to the exe and not to the dll therefore the wav is not played....
how can i switch the resource???
i know there is a method called AfxSetResourceHandle()
but i don't know what to pass to it????
please help
thanks in advanced
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Use AFX_MANAGE_STATE(AfxGetStaticModuleState()) at the beginning of the offending functions in your extension DLL. This macro takes care of setting and restoring the resource handle.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, thanks for the reply
I've tried that already, and i got a compilation error:
mfcs42d.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already defined in GUILib.obj
mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in GUILib.obj
mfcs42d.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already defined in GUILib.obj
mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in GUILib.obj; second definition ignored
mfcs42d.lib(dllmodul.obj) : warning LNK4006: __pRawDllMain already defined in GUILib.obj; second definition ignored
remember i am using an extention dll and not regular one.....
can u still help?
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Yes, you're right. Try with AFX_MANAGE_STATE(AfxGetAppModuleState()) instead (and please tell us back )
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanks for the reply,
now it compiles. but the following code returns me the resource handle of the exe and not the dll:
AFX_MANAGE_STATE(AfxGetAppModuleState());
HINSTANCE hInstance = AfxGetResourceHandle();
PlaySound(MAKEINTRESOURCE(IDR_BTN_OVER),
hInstance,
SND_RESOURCE);
hInstance is 400000 which is the exe (should be 100000 for the dll)
can u help again?
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Ummm... I'm shooting in the dark here. Try replacing your hInstance stuff with
HINSTANCE hInstance = AfxGetAppModuleState()->m_hCurrentInstanceHandle;
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
still not working.....
any other suggestions??
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Here I go again OK, I have not tried this, but I'm more or less confident it'll work. In your generated xxx.cpp where the DllMain function is defined, there is a static AFX_EXTENSION_MODULE object. Remove the static bit and declare it as extern in some header file, so that you can use it elsewhere. The hResource member of this AFX_EXTENSION_MODULE is what you need to pass to AfxSetResourceHandle . Remove the AFX_MANAGE_STATE stuff, it's not needed. Don't forget to restore the original resource handle upon exiting. Shake well and serve chilled. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanks for the help...
i did that, and got compilation error regarding the extern AFX_EXTENSION_MODULE already defined????
can u help?
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Can you show the relevant code regarding the AFX_EXTENSION_MODULE both in the header and the .cpp file? Thanx
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
code taken from stdafx.h:
extern AFX_EXTENSION_MODULE GUILibDLL = { NULL, NULL };
code that uses in the cpp:
void CMyBtn::OnLButtonDown(UINT nFlags, CPoint point)
{
CButton::OnLButtonDown(nFlags, point);
AfxSetResourceHandle(GUILibDLL.hResource);
HINSTANCE hInstance = AfxGetResourceHandle();
PlaySound(MAKEINTRESOURCE(IDR_BTN_OVER),
hInstance,
SND_RESOURCE);
}
error in compilation:
Generating Code...
Linking...
GUILib.obj : error LNK2005: "struct AFX_EXTENSION_MODULE GUILibDLL" (?GUILibDLL@@3UAFX_EXTENSION_MODULE@@A) already defined in GUIBaseBtn.obj
StdAfx.obj : error LNK2005: "struct AFX_EXTENSION_MODULE GUILibDLL" (?GUILibDLL@@3UAFX_EXTENSION_MODULE@@A) already defined in GUIBaseBtn.obj
GUILib.obj : warning LNK4006: "struct AFX_EXTENSION_MODULE GUILibDLL" (?GUILibDLL@@3UAFX_EXTENSION_MODULE@@A) already defined in GUIBaseBtn.obj; second definition ignored
StdAfx.obj : warning LNK4006: "struct AFX_EXTENSION_MODULE GUILibDLL" (?GUILibDLL@@3UAFX_EXTENSION_MODULE@@A) already defined in GUIBaseBtn.obj; second definition ignored
Creating library Debug/GUILib.lib and object Debug/GUILib.exp
Debug/GUILib.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
can u help me???
thanks for all the effort man
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
In the header:
extern AFX_EXTENSION_MODULE GUILibDLL; In the .cpp where your DLLMain is:
AFX_EXTENSION_MODULE GUILibDLL = { NULL, NULL }; Please tell me if this works. If so, I'd feel a little guilty that you might have applied tihs blindly without clearly understanding what's going on. Please consult some C++ tutorial or book on the meaning and use of extern and static .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanks.
now the dll compiles ok, but the client that uses the dll show me error on the method (that i showed you before):
void CMyBtn::OnLButtonDown(UINT nFlags, CPoint point) <br />
{<br />
CButton::OnLButtonDown(nFlags, point);<br />
<br />
======> AfxSetResourceHandle(GUILibDLL.hResource);<br />
<br />
HINSTANCE hInstance = AfxGetResourceHandle();<br />
PlaySound(MAKEINTRESOURCE(IDR_BTN_OVER),<br />
hInstance,<br />
SND_RESOURCE);<br />
<br />
AfxSetResourceHandle(AfxGetResourceHandle());<br />
}
it says:
"error C2065: 'GUILibDLL' : undeclared identifier"
where else should i define it in the dll beside dllmain file????
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I don't get it. How could the client fail in a function compiled inside the DLL?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín???
did u see my reply??
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
With regards to:
---> bReadible = !(nStatus == 0);
What does this mean? I have never seen code written like this before.
BOOL CRawPingDlg::IsSocketReadible(SOCKET socket, DWORD dwTimeout, BOOL& bReadible)
{
timeval timeout;
timeout.tv_sec = dwTimeout / 1000;
timeout.tv_usec = (dwTimeout % 1000) * 1000;
fd_set fds;
FD_ZERO(&fds);
FD_SET(socket, &fds);
int nStatus = select(0, &fds, NULL, NULL, &timeout);
if (nStatus == SOCKET_ERROR)
return FALSE;
else
{
bReadible = !(nStatus == 0);
return TRUE;
}
}
Thank you
|
|
|
|
|
The ! means NOT.
If you have a boolean value like true the operator ! will make it to false.
if nStatus has the value zero, the term wil be true. !(nStatus == 0) will make it false. It is the same if you write nStatus != 0.
sledge
|
|
|
|
|
esepich wrote:
bReadible = !(nStatus == 0);
What does this mean? I have never seen code written like this before.
The ! negates the statement. if (nStatus == 0) is TRUE, then the ! negates it and bReadible will be FALSE.
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|