VC sculptor small technology set (2)

zhaozj2021-02-16  42

VC sculptor small technology set (2)

He Zhidan

1. If you don't define _unicode, LPCTSTR represents const char *, so it can be used directly.

If the _unicode, lpctstr represents const wchar_t *, it cannot be used directly.

2, get the position of the mouse

DWORD DW = GetMessagePos ();

Cpoint PT (Loword (DW), HiWord (DW)); // Mouse screen coordinate

CWnd :: screenToclient ();

3, get the length of the file

Method 1: Handle Hhandle;

DWORD DWSIZE;

HHHANDE = :: Createfile ((lpctstr) strzipfile, generic_read,

File_share_read, null, open_existing, file_attribute_normal,

NULL);

IF (HHHANDLE == Invalid_Handle_Value)

Return False;

DWSIZE = :: getFileSize (HHANDE, NULL);

CloseHandle (HHANDLE);

Method 2: cstring szfile = "c: /aaa.txt";

INT nfilesize = 0;

CFILEFIND FINDER;

IF (Finder.findfile (SzFile) {

Finder.FindNextFile ();

nfilesize = finder.getLength (); // file size is here

Finder.Close ();

}

Method 3: cstdiofile sf;

.

sf.getlength ();

4, Carray is not "=", but there is copy.

CStringArray Arr1, Arr2; Arr1.Add ("0"); Arr2.Add ("a"); Arr1.copy (arr2);

5, how to get the handle of the VIEW class

Don't forget the # include file

CMYVIEW * PVIEW = (CMYVIEW *) (CMAINFRAME *) AFXGETMAINWND ()) -> getActiveView ();

PView-> m_hwnd is

6, custom message

Below is the step of adding custom messages:

Step 1: Define the message. When developing a Windows95 application, Microsoft recommends that user-defined messages are at least WM_USER 100 because many new controls should also use WM_USER messages.

Step 2: Implement the message processing function. This function uses WPRAM and LPARAM parameters and returns lpeSult.

LpeSult CMAINFRAME :: ONMYMESSAGE (WPARAM WPARAM, LPARAM LPARAM)

{

// TODO: Handle user custom message

...

Return 0;

}

Step 3: Describe the message processing function in the AFX_MSG block of the class header:

Class CMAINFRAME: PUBLIC CMDIFRAMEWND

{

...

// General message mapping function

protected:

// {{AFX_MSG (CMAINFRAME)

AFX_MSG Int Oncreate (LPCReatestruct LPCreateStruct);

AFX_MSG Void Ontimer (uint nidEvent);

AFX_MSG LRESULT ONMYMESSAGE (WPARAM WPARAM, LPARAM LPARAM);

//}} AFX_MSG

Declare_message_map ()

}

Step 4: In the user class message block, use the ON_MESSAGE macro to map the message to the message processing function.

Begin_MESSAGE_MAP (CMAINFRAME, CMDIFRAMEWND) / / {{AFX_MSG_MAP (CMAINFRAME)

ON_WM_CREATE ()

ON_WM_TIMER ()

ON_MESSAGE (WM_MY_MESSAGE, ONMYMESSAGE)

//}} AFX_MSG_MAP

END_MESSAGE_MAP ()

If the user needs a unique message throughout the system, you can call the SDK function REGISTERWINDOWMESAGE and use the on_register_message macro to replace the ON_MESSAGE macro, the rest is the same.

7, WSCANF is the wide character version of Scanf, the usage is the same as Scanf, used to read the STDIN stream, store information into the variable specified by its parameter list.

The CIN object is derived from the iStream class, mainly used to input data from the standard input device to the program, through the data input by CIN, must consist in the format of the word, CIN match ">>" symbol

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

New Post(0)