How do I create columns?
I have created a listcontrol using toolbox and have chosen the property to be of report view and then created a variable called m_recd for it. and then now what message function do i add and what do i do to create columns and then items.
I want to have 2 columns. How do I add title to it?
Can u send some code snippets if possible.
I am doing secondary programming on a CAD software with its API, and need to execute the command in the context menu of the CAD software programmatically, just like I manully right click a item and select a command.
I don't have any clue to do that now, and if it takes too many words to explain, could you please recommend me some material to read.
If the API doesn'tprovide such a functionality, then it is impossible for a user code to inject into another applications binary ( though it is possible to some extent through api hooking and ijecting code, its not that practical).
I'm currently working on an embedded system which has an ethernet port and a TCP/IP stack running. I'm having some problems with a telnet TCP connection. I find that sometimes if I really hammer the TCP session with very regular commands the TCP connection seems to lock up because the PC fails to recieve an ACK packet thus halting data flow. Currently I'm using Etherial (a network packet sniffer application) to look at the packets the PC is sending and recieving, and it claims that my embedded system is failing to send an ACK packet occasionally, but I can't find any evidence of this in the embedded system. Is it possible that a packet that has been corrupted on the data layer, would be discarded before even showing up in ethereal?
Simple things first - try changing the network cable.
This could be caused by a poor connection affecting the magnetics - remember there is no such thing as ditigal electronics merely badly distorted analogue!
I think the simplest way to start with visual program building is to create a new project with VC6. VC7 and VC8 complicate matters a little, but the steps are basically the same. The following description is for VC6.
Start by creating a new MFC application (exe) project named "MFCTest" and select a dialog based application. Leave all the defaults if you are unsure what they mean. After VC6 has created your project build it. You should see 0 errors and 0 warnings. Run it and you should see a simple dialog.
Start by going to the resource view and display the "IDD_MFCTEST_DIALOG" dialog. Add an edit bot to it by selecting it in the tool bar ("ab|") and draw it inside the dialog. A box with the word "Edit" appears. Open its properties (RMB->properties or ALT+ENTER) and change the ID from "IDC_EDIT1" to "IDC_NAME". Add another one and change its ID from "IDC_EDIT2" to "IDC_ADDRESS". We will now setup these boxes when the dialog opens.
The definition of the dialog is in the file "MFCTestDlg.cpp". In line 91 you find the function "BOOL CMFCTestDlg::OnInitDialog()" which is the function called during the creation of the dialog and where you may setup items, like values in edit boxes and populate lists. This function starts by setting up the menu and the icons and then has a "TODO:" section where you add your code.
Add the line "CEdit* np=(CEdit*)GetDlgItem(IDC_NAME);" after the "TODO:" to tell the program to find the edit box with the identifier IDC_NAME and put its address in "np". Then add the line "np->SetWindowText("Abracadabra");" to set the text in the edit box. Do the same to the address box by adding the lines "CEdit* ap=(CEdit*)GetDlgItem(IDC_ADDRESS);" and "ap->SetWindowText("Mars");".
Now compile and run the program and you will have the edit controls setup by the time the dialog opens. Now, to get text when the user types it, we have to add a handler to be called when the text changes.
Go to the resource view and select the "IDD_MFCTEST_DIALOG" dialog. Then select the IDC_NAME box. Press CTRL+W (to invoke the wizard) and verify that the project is "MFCTest", the class name is "MFCTestDlg", and that the selected object ID is "IDC_NAME". Then select "EN_CHANGE" in the "messages:" box. The "Add Function" button will become available and you may select it and accept the proposed function name. The "EN_CHANGE" becomes bold, and the "Edit Code" becomes the default button. Click it and you will go to line 177 of "MFCTestDlg.cpp".
The created function "void CMFCTestDlg::OnChangeName()" will be called when the text in the IDC_NAME box changes. For this example we will get whatever text the user types here and put a reversed version in the IDC_ADDRESS box. insert the following lines in the function:
First the edit boxes are found. Then a new string is created and filled with the contents of the name edit box. Then we reverse it and put the result in the address box. Note that setting the text in the address box would invoke its EN_CHANGE message, and so if you did the same in the handler for the address (if we had any) as we are doing in the name you would end up with an infinite loop of one handler invoking the other indefinitely.
If you want to add variables to the dialog class you can have the wizard do that for you or you can go to the "MFCTestDlg.h" file and add them yourself. The "main()" equivalent is found in "MFCTest.cpp" - the dialog creation is found in line 57 and it's invocation (open) is done with "int nResponse = dlg.DoModal();". Note that this call only returns when the dialog is closed.
I hope this quick start guide helps you. This is how I started it and works for me. The rest of the variations (like diferent controls and such) you can learn as you go along. MFC functions will always respond to the F1 key for help.