VC programming experience summary (3)

zhaozj2021-02-16  78

1. Display and hide the title bar

Method 1: Using API implementation

// Hide Titlebarlong 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 the CWND member function modifyStyle implement // Hide TitlebarmodifyStyle (WS_CAPTION, 0, SWP_FRAMECHANGED); // Display TitlebarmodifyStyle (0, WS_CAPTION, SWP_FRAMECHANGED);

2. How to use SendMessage () to send a message to clear its content? HWND HEDITWND = getdlgitem (idc_edit1) -> getsafehwnd (); :: SendMessage (HeditWnd, WM_SETTEXT, (WPARAM) 0, (LPARAM) "")

3. The file property window pop SHELLEXECUTEINFO ShExecInfo = {0}; ShExecInfo.cbSize = sizeof (SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_INVOKEIDLIST; ShExecInfo.hwnd = NULL; ShExecInfo.lpVerb = "properties"; ShExecInfo.lpFile = "c: / "; // can also be file shexecinfo.lpparameters =" "; shexecinfo.lpdirectory = null; shexecinfo.ns = sw_show; shexecinfo.hinstapp = null; shellexecuteex (& shexecInfo);" SHELLEXECUTEEX ";

4. Delete all files in a directory

Bool DeletedIRectory (LPCTSTR DIRNAME) {cfileFind Tempfind; // Declare a cfilefind class variable to search for Char TempFileFind [200]; // Used to define Sprintf (TempFileFind, "% S //*.*", DIRNAME ); // matching format address *. *, All files Bool isfile = (bool) tempfind.FindFile (TempFileFind); // finds the first file while (isfinded) {isfinded = (bool) TempFind. FindNextFile (); // Removable Search Other Files IF (! Tempfind.isdots ()) // If not "." Directory {Char FoundFileName [200]; strcpy (FoundFileName (). GetBuffer (200)) , if (TempFind.Indirectory ()) // If it is a directory, recursively call {// deletedirectory char Tempdir [200]; Sprintf (Tempdir, "% S / / /% S", DIRNAME, FOUNDFILENAME); DELETEDIRECTory (Tempdir );} else {// If it is a file, CHAR TEMPFILENAME [200]; Sprintf (TempFileName, "% S / /% S", DIRNAME, FOUNDFILENAME); deletefile (TempFileName);}}} tempfind.close ); if (! RemoveDirectory) // Delete Directory {AFXMessageBox ("Delete Directory Failed!", MB_OK; Return False;} Return True;} 5. • LIB and DLL File Differences and Contact

.dll is the file that is only connected when you run it, so it is a relatively small executable file format, and there are other file formats such as .ocx, all .dll files are executable. .

.lib is a file that is connected when your program is compiled, so you must inform the compiler to connect the lib file there. In general, the LIB file is also referred to as a static connection library than the dynamic connection file. When you compile the code into files in these formats, they can't be changed later. If you want to use the lib file, you must: 1? Contains a corresponding header file to inform the compiler lib file specific content 2? Set the lib file to allow the compiler to find the compiled binary code

If you want to isolate a DLL file from your code instead of a static connection library, you still need a lib file. This lib file will be connected to the program to tell the operating system When you run, what DLL file you want to use, in general, the name of the corresponding DLL file in the lib file and a sequence table indicating the DLL output function entry. If you don't want to use a lib file or there is no lib file, you can use Win32 API functions to LoadLibrary, getProcAddress. In fact, we can open the lib file in a binary form in Visual C IDE, most of the case of see the C function of the ASCII code or some of the overloaded functions.

转载请注明原文地址:https://www.9cbs.com/read-17373.html

New Post(0)