Solved

Simply question

Posted on 2003-12-02
7
230 Views
Last Modified: 2013-11-20
Okay i have a program that I wrote in visual basic which I have had trouble converting it into MFC can someone help me out on how i can convert the code to MFC?

This code as you can see connects to port 4443, listens for data, puts the received data on a list box and if the Option1 radio button is clicked it closes the port for listening.

Visual Basic Code:

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
List1.AddItem "Time: " & Time & " - " & Winsock1.RemoteHostIP & " - Direct Connect"
Winsock1.Close
Winsock1.LocalPort = 4443
Winsock1.Listen
End Sub
--------------------------
Private Sub Option1_Click()
If Option1.Value = True Then Winsock1.Close
End Sub
0
Comment
Question by:sdgaf
7 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9864112
you can use the WinSoct Control in VC using the "Project->Add To Project->Components and Controls" menu.
This will givee you a wrapper class of winsock, call the same functions with brackets....becoz vc uses set/get functions instead of properties.

Rosh :)
0
 

Author Comment

by:sdgaf
ID: 9868655
I used the following code and got errors saying Winsock1 undeclared. and LocalPort, Listen, and Close must point to a struct/class

Winsock1.LocalPort( 4443 );
Winsock1.Listen();
..
..
Winsock1.Close();
0
 

Expert Comment

by:Drew_Benton
ID: 9892065
Ok as in roshmon's post, add that component. But there is more stuff you need to do to use this control. Open up your main Dialog, drag the new component (Miscrosoft WinSock Control 6.0 ) onto the dialog. Now hold down "ctrl" and double click on the winsock control. A new dialog should pop up, "Add Member Variable" for the name make it "Winsock1". Now hit ok. Now your code will work. ( I hope =) )
- Drew
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Expert Comment

by:Drew_Benton
ID: 9892067
Clarification: "double click on the winsock control" thats on your dialog.
0
 

Author Comment

by:sdgaf
ID: 9893723
I do not see the winsock control in 6.0. I see every other control except for winsock. How do i get the winsock????
0
 

Expert Comment

by:Drew_Benton
ID: 9893854
ok do this:
Project ( at the top of the VC++ Window)->Add To Project (second item in the menu)->Components and Controls (the last item in that menu)
A new window will pop up, double click on the "Registered ActiveX Controls" folder to open it, then look for "Microsoft WinSock Control, version 6.0" (listed by alpha) so scroll midway into the 'M's'. When you find it double click on it. A confirmation will appear, hit Ok. A new dialog will popup, hit ok again, then close the "Components and Controls Gallery" window. Now try to do as I mentioned above. If you have any more ques feel free to ask.
0
 

Accepted Solution

by:
khaotiksociety earned 250 total points
ID: 9902399
Thanks, If you have any questions IM me
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question