Tragedy ~~~ The blog post I just wrote was inexplicably lost at the time of release ~~ Is it because of chrome ??? Ah, ah, ah ~~~ I wrote it again with Firefox 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'src ="/neweditor/editor/images/smiley/22.gif" alt = ""/>
March 18
Two days after the last update, I did a little bit today. In general, the device information is displayed.
Let's take a look at the results.
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I2422939-0.png "/>
I encountered several problems.
1. How to dynamically change the caption attribute of the dialog box
Solution: Use setwindowtext
My code
- BOOL CDevStatus: OnInitDialog (void)
- {
- CDialog: OnInitDialog ();
- This-> SetWindowTextA (LPCTSTR (CPublic: DevName ));
- // The following content is omitted
Creates a class for the pop-up window on the right, overrides the OnInitDialog method in CDialog, and uses the this pointer and a global variable CPublic: DevName to change the caption.
2. Global variables. What should I do if some variables need to be shared between the two dialogs? The easiest thing to think of is to use global variables for transmission. But how does one define global variables in MFC? I checked some information and found a method to define a PUBLIC class, which is specially used to place global variables. When used, it is referenced by scope. In fact, there are some problems in this process, I haven't solved it yet, and I don't think the method of using global variables is too good. Now, the processing is just a matter of expediency ~~
Code:
- # Pragma once
-
- # Include "pcap. h"
- // CPublic is used to define global variables/functions
-
- Class CPublic: public CWnd
- {
- DECLARE_DYNAMIC (CPublic)
-
- Public:
- CPublic ();
- Virtual ~ CPublic ();
- Static CString DevName; // Save the selected device name
- Protected:
- DECLARE_MESSAGE_MAP ()
- };
3. About the forced conversion of LPTCSTR. In the following code, d-> description is char *, and DevName is CString. We wanted to convert it to the same one for comparison. However, after conversion, the if statement is always false, leading to NULL pointer
- For (d = alldevs; d! = NULL; d = d-> next ){
- If (d-> description = CPublic: DevName) // Why is there a problem after the forced conversion of DevName using the LPCTSTR ??
- Break;
- }
If you do not perform forced conversion, there is no problem. I checked some information and still did not understand it...
4. About running programs on other computers.
This is because the graduation project will always have a day to answer the question. Maybe there will be no way to use your own computer at that time, so the running problems in different situations should also be solved. I have prepared a pure xp Virtual Machine dedicated for testing. In the previous console program, you can change the compilation option to/MT. However, MFC does not seem to be able to do this. It only needs to be compiled using a static library.
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I242GL-1.png "/>
However, this process is much larger ~~
5. for some functions, when using functions such as setwindowsText, I found a problem. In VS2008, the Code prompts a function such as setwindowtextw or setwindowtexta, so what are the differences between these users ???
I found this on the Internet.
"I have seen A saying on the Internet that there are two sets of code for functions in VC ++, one for ANSI and the other for UNICODE, and the other for ANSI ends with, functions in UNICODE end with W. At the same time, the function name after removing the ending character can refer to two functions at the same time, when the compiler explains it, it depends on whether your project is defined in UNICODE"
Later, I tried to change the character set, as though it was.
Due to the loss of the previously written blog post, I am very depressed. If I write it again, I am not so serious. Sorry.
As a matter of fact, there are a lot of problems that have not been solved today. While catching up with the progress, we still have to understand these things.
Graduation Project simple network protocol analyzer) Compilation course 3) completed
This article from "learning is a pleasure" blog, please be sure to keep this source http://eaglexhh.blog.51cto.com/1345400/519049