VC programming experience Summary (c)
1. Display and hide the title bar
Method 1: Use API Implementation
/ / Hide TitleBar
LONG lStyle =:: GetWindowLong (this-> m_hWnd, GWL_STYLE);
:: SetWindowLong (this-> m_hWnd, GWL_STYLE, lStyle & ~ WS_CAPTION);
:: SetWindowPos (this-> m_hWnd, NULL, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
/ / Display TitleBar
:: SetWindowLong (this-> m_hWnd, GWL_STYLE, lStyle | WS_CAPTION);
:: SetWindowPos (this-> m_hWnd, NULL, 0, 0, 0, 0,? SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
Method 2: Use CWnd function ModifyStyle members realize
/ / Hide TitleBar
ModifyStyle (WS_CAPTION, 0, SWP_FRAMECHANGED);
/ / Display TitleBar
ModifyStyle (0, WS_CAPTION, SWP_FRAMECHANGED);
2. How with SendMessage () to send information to empty its contents? ?
HWND hEditWnd = GetDlgItem (IDC_EDIT1) -> GetSafeHwnd ();
:: SendMessage (hEditWnd, WM_SETTEXT, (WPARAM) 0, (LPARAM )"");
3. Pop-up document properties window
SHELLEXECUTEINFO ShExecInfo = (0);
ShExecInfo.cbSize = sizeof (SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_INVOKEIDLIST;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = "properties";
ShExecInfo.lpFile = "c: \" / / it could be a document
ShExecInfo.lpParameters = "";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx (& ShExecInfo);
4. Delete a directory of all documents
BOOL DeleteDirectory (LPCTSTR DirName)
(
CFileFind tempFind; / / CFileFind a statement of variables used to search
Char tempFileFind [200]; / / search for the definition format
Sprintf (tempFileFind, "% s \ \ *.*", DirName);
/ / *.* Match format, the directory of all documents
BOOL IsFinded = (BOOL) tempFind.FindFile (tempFileFind);
/ / Find the first document
While (IsFinded)
(
IsFinded = (BOOL) tempFind.FindNextFile (); / / recursive search other documents
If (! TempFind.IsDots ()) / / if it is not "." Directory
(
Char foundFileName [200];
Strcpy (foundFileName, tempFind.GetFileName (). GetBuffer (200));
If (tempFind.IsDirectory ()) / / If the directory, the recursive call
(/ / DeleteDirectory
Char tempDir [200];
Sprintf (tempDir, "% s \ \% s", DirName, foundFileName);
DeleteDirectory (tempDir);
)
Else
(/ / If it is deleted files directly
Char tempFileName [200];
Sprintf (tempFileName, "% s \ \% s", DirName, foundFileName);
DeleteFile (tempFileName);
)
)
)
TempFind.Close ();
If (! RemoveDirectory (DirName)) / / delete directory
(
AfxMessageBox ( "delete directory failure!", MB_OK);
Return FALSE;
)
Return TRUE;
)
5.lib dll file and the differences and link
. Dll in your program runs only when connected to the document, it is a relatively small executable file format. Dll there are other file formats such as. Ocx, all. Dll files are executable.
. Lib is in the process of compiling your time on the links connecting the documents, so you have to tell the compiler connected lib files there. Generally speaking, and Dynamic Link documents relative ratio lib document also called a static library. When you compile the code into these types of files, in the future they would no longer be changes. If you want to use lib document, it must:
1 contains a corresponding document for the first compiler lib inform the specific content of documents inside
2 lib file settings allow the compiler to find compiled binary code
If you want to separate from your code a dll file by replacing static libraries, the paper still need a lib. This lib files will be connected to the procedures in the operation of the operating system to tell when you want to use what dll file, under normal circumstances, lib file a corresponding dll file and the name of a specified output function dll entrance of the order form. If you do not want to lib lib is no document or documents, can be used WIN32 API function LoadLibrary, GetProcAddress. In fact, we can be in Visual C + + IDE in a binary form of open lib documents, many cases will see the ASCII code format of the C + + function or a function of some heavy-duty operation names.
General lib our most important documents on the trouble is there unresolved symble such errors, and that is wrong or connected lib document did not contain. C,. Cpp files to the project, the key is that if the C + + works with the C language, writing lib files, so there must contain:
Extern "C"
(
# Include "myheader.h"
)
This is because the C language lib document does not write C + + must be the name of the destruction of C function can not be heavy-duty, it would be wrong connector.
Tags: experience, vc








0 Comments to “VC programming experience Summary (c)”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.