|
|
we can insert the user menuitem on the right click of the mouse in the browser(in the registry,i.e;MenuExt).I want the further code for adding the submenu to this usermenu item
|
|
|
|
|
Well, one way to do it is with a Browser Helper Object (BHO). You can find one such example here:
http://www.codeproject.com/useritems/PopupBlocker.asp[^]
Take a look at the screen shot, it's showing a popup menu off the context menu.
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|
|
How do i get it to were when someone clicks on the help menu, it opens a help file?
i used this code and it didn't work
<br />
case CM_HELP:<br />
WinHelp(NULL,"HELPFILE.HLP",HELP_HELPONHELP, 0L );<br />
|
|
|
|
|
Try this:
CString szHelpFile = "helpfile.hlp";
::WinHelp( m_hWnd, szHelpFile, HELP_FINDER, NULL );
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Saying something "doesn't work" is vague at best. What doesn't work? Is it a compiler/linker error? Is an exception thrown? Does it start the help engine but not find the HLP file? Does it open the HLP file but fail to find the right topic?
|
|
|
|
|
I you have allocated an linked-list in the CView class, i want to know how to pass a pointer to it to the CDocument class, so you don't have to copy/transmit everything.
Please help me, this is driving me crazy. I have no clue of how doing the serialization. Each node in the list has only two CPoint members.
Sincerely,
Fernando
Fernando Jose Martinez Mendoza
Bucaramanga - Colombia
|
|
|
|
|
fermar84 wrote:
I you have allocated an linked-list in the CView class, i want to know how to pass a pointer to it to the CDocument class, so you don't have to copy/transmit everything.
Use: CDocument::GetFirstViewPosition() - GetNextView(pos) to iterate the views to get the one you need and then access you list. eg.
POSITION pos = GetFirstViewPosition();
while (pos != NULL)
{
CView* pView = GetNextView(pos);
pLL = pView->GetPtrToLinkedList();
...
}
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Hi all,
How to broadcast a message within a LAN using Winsock? Meaning how to send a message to every machine in a local network without knowing their IP addresses, of course you do know the port you’re using. Like when games find all servers in a network without knowing they are there.
Aidman » over and out
|
|
|
|
|
You need to read up on Winsock. There are some articles here. As far as discovering other servers for a game environment etc. It depends on how each server is set up. For example, if the server is always listening for a connection on a particular port, it may be as simple as broadcasting a message to all IPs on that port and see which ones respond. Of course, there should already be an established protocol on how a game running on a client computer would do this.
But, sending a broadcast message is a connectionless datagram protocol such as UDP. Usually, you would send the message to IP broadcast address of 255.255.255.255 or your IP's subnet as xxx.xxx.xxx.255. If you read up on how to send a UDP network message, its simply a matter of putting the broadcast address as your destination address (the PC you're sending the message to).
|
|
|
|
|
If I use UDP to broadcast, Do I need to use the "setsockopt" function to set the "SO_BROADCAST" flag?
Aidman » over and out
|
|
|
|
|
Yes, you do. Here is a sample program I wrote to perform broadcast. It works on both Linux, Posix (for our embedded system), and Windows. For Windows, you need to #define WINMACHINE:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#ifdef WINMACHINE // for Windows
#include <windows.h>
#include <winsock.h>
#include <wincon.h>
#include <conio.h>
#else // for unix/POSIX
#include <machine/mpc823.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/errno.h>
#include <netinet/in.h>
#include <pthread.h>
#include <netinet/udp.h>
#endif
#define TXOUTBUFSZ 10000 // Output buffer size
#define RADAR_PORT 44068 // IP/UDP Port number for trans/rcv
#ifdef WINMACHINE // for Windows
WSADATA wsaData;
SOCKET sock;
SOCKADDR_IN dst_addr, src_addr;
int dst_addr_len = sizeof(dst_addr);
#else // for unix/POSIX
int sock;
struct sockaddr_in dst_addr, src_addr;
#endif
int rc;
int main()
{
char sampleMsg[132];
int optval = 1;
int optlen = sizeof(int);
dst_addr.sin_family = AF_INET;
dst_addr.sin_port = htons(RADAR_PORT);
dst_addr.sin_addr.s_addr = INADDR_BROADCAST;
strcpy(sampleMsg, "This is a test sample msg from the box. ");
#ifdef WINMACHINE // for Windows
rc = WSAStartup (MAKEWORD (1, 0), &wsaData);
if(rc != 0)
{
printf("Error starting WinSock\n");
goto error;
}
sock = socket(AF_INET,SOCK_DGRAM, 0);
if(sock == INVALID_SOCKET)
{
printf("Error creating receive socket\n");
goto error;
}
rc = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)&optval, optlen);
if(rc == SOCKET_ERROR)
{
printf("Error setting up receive buffer\n");
goto error;
}
while(!kbhit())
{
printf("Sending data: %s Any key to quit.\n", sampleMsg);
rc = sendto(sock, sampleMsg, strlen(sampleMsg) + 1, 0, (struct sockaddr*) &dst_addr, sizeof(dst_addr));
if(rc == SOCKET_ERROR)
{
printf("Couldn't send data.\n");
goto error;
}
Sleep(1000);
}
closesocket(sock);
goto finish;
#else // for unix/POSIX
sysInit();
startNetwork();
if (setuid(0)== -1)
printf("setuid not eq root");
if ((sock = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
{
printf("Network socket initialization failed.\n");
fflush(stdout);
goto error;
}
rc = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)&optval, optlen);
if(rc)
{
printf("Error setting up receive buffer\n");
goto error;
}
src_addr.sin_family = AF_INET;
src_addr.sin_port = htons(RADAR_PORT);
src_addr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(sock,(struct sockaddr*) &src_addr,sizeof (src_addr)) == -1)
printf("bind failed \n");
while(1)
{
printf("Sending data: %s Any key to quit.\n", sampleMsg);
if(sendto(sock, sampleMsg, strlen(sampleMsg) + 1, 0, (struct sockaddr*) &dst_addr, sizeof(dst_addr)) < 0)
{
printf("Error: could not send data. \n");
fflush(stdout);
goto error;
}
sleep(1);
}
goto finish;
#endif
finish:
printf("Done.\n");
return 0;
error:
#ifdef WINMACHINE
printf("\nsock Error in main(): %ld Hit any key\n", WSAGetLastError());
#else
printf("\nsock Error in main(): %ld Hit any key\n", errno);
#endif
getchar();
return 1;
}
|
|
|
|
|
GREAT THANKS!!!
really cool code =)
Aidman » over and out
|
|
|
|
|
Sorry, just one more question...
Can I use the same socket to receive broadcast messages?
Aidman » over and out
|
|
|
|
|
Yep. Set up a in_addr structure and a receive buffer to receive data from the specified port and set the IP address you're receiving from to INADDR_ANY. When you do a receive you have to do a bind() first (during the initialization). Should be plenty of examples around.
|
|
|
|
|
Ok thanks very much!
I am very sorry, could I ask a last another question?
How do you create a no blocking/waiting socket for recveiving?
So that if there is no incoming data available for the socket at the receiving function "recvfrom" it would continue instead of waiting for incoming data. Can you make the socket nonblocking or must you make the recievning function nonblocking? Is it possible to do this without having multithreads or network events?
Aidman » over and out
|
|
|
|
|
The short answer: Yes, you can make a socket blocking or non-blocking. Better answer: Get this book, "Network Programming for Microsoft Windows", Second Edition, Anthony Jones & Jim Ohlund. I got it off of half.com for $15 or $20 bucks. Well worth it especially since it retails for $59.00
Or, read up more on Winsock and sockets.
|
|
|
|
|
Is it possible to change the image size (higth/width) the the Image Class?
If so what is the best way to do so?
|
|
|
|
|
where did you find this "Image Class" ?
|
|
|
|
|
This is the link to where i found the Image class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/GDIPlusReference/Classes/ImageClass/ImageConstructors/Image_28stream_useEmbeddedColorManagement.asp
|
|
|
|
|
It is possible using CImage class in MFC !!!!
|
|
|
|
|
Dear all,
The only reason I posted the whole code was to give one the chance to run the program and see in practice the problem.
But I guess that is too much.
Anyway,
The implementation of the two functions is:
[code]
//It returns the member.
Member* AssociationList<book,member>::get_member(Book* book)
{
Member* member=0;
bool searching=true;
int index=0;
while(searching)
{
if (this->association_list[index])
if (this->association_list[index]->linked_book()==book)
{
member=this->association_list[index]->linked_member();
searching=false;
}
else
index++;
else
index++;
if (searching && (index == LIST_SIZE))
{
searching=false;
}
}
return member;
}
[/code]
[code]
//it returns the book
template<class book,class="" member="">
Book* AssociationList<book,member>::get_book(Member* member)
{
Book* book=0;
bool searching=true;
int index=0;
while(searching)
{
if (this->association_list[index])
if (this->association_list[index]->linked_member()==member)
{
book=this->association_list[index]->linked_book();
searching=false;
}
else
index++;
else
index++;
if (searching && (index == LIST_SIZE))
{
searching = false;
}
}
return book;
}
[/code]
The template file that I use to display the books is:
[code]
template<class object="">
void List<object>::displayElement(char* type)
{
if (num_elements == 0)
cout<<"No "<<type<<" is="" found="" in="" the="" "<<type<<"="" array.\n";
="" else
="" for(int="" element="0;" element<this-="">num_elements; element++)
{
cout<<'\n';
this->element_list[element]->display(association_list.get_member(element_list[element]));
}
}
[/code]
But it does not work for Members. I've tried to use the recommendations you've told me but it seems not to work.
The program works ok, when I call the functions:
book1.addElement("Books"); and book1.displayElement("Books");
to add a book and to display them respectively.
But when I use the :
member1.addElement("Member"); and member1.displayElement("Member"); it dispalys the problem:
The compiler complains at the point:
this->element_list[element]->display(association_list.get_member(element_list[element])); saying that : get_member: cannot convert parameter one from Class Member* to class Book*.
Can you correct any mistakes or suggest any solutions?
Please if you make any suggestion adjust them to my code, if possible.
Best Regards,
grscot
|
|
|
|
|
Below the message editing area you will see a Formatting bar. You need to select all of your code and then click on "pre" and "code" to make it readable. Untill you start doing that your code examples are useless.
Also short to the point snippets of code are far better than long winded examples.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
...however, you will have to turn your less than and greater than into HTML escapes, and avoid any smiley combination...
unless things changed since I last tried to post code
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
peterchen wrote:
...however, you will have to turn your less than and greater than into HTML escapes, and avoid any smiley combination...
unless things changed since I last tried to post code
Yes you're right. The Formatting bar has options for this too. ie. < and >
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|