VC sculptor small technology set (5)

zhaozj2021-02-16  45

VC sculptor small technology set (5)

He Zhidan

1. Right-click on the VC to click on a class or macro, you can look at his definition, but how to return to the initial place?

Install Visual Assist, And Use Alt Left Arrow

Press the back of the menu (<- turn 45 degrees) button

It seems that I opened a document and turned off it.

2, how to get the system menu, and pop up the system menu?

Void ctestsysmenudlg :: onok ()

{

// Click The Ok Button to Show System Menu (Masterz)

Point curpos;

GetCursorpos (& Curpos);

SetForegroundWindow ();

CMenu * pmenu = getSystemMenu (false);

INT nSelection = pmenu-> TRACKPOPUPMENU (TPM_LEFTBUTTON | TPM_LEFTALIGN |

TPM_BOTTOMALIGN | TPM_NONOTIFY | TPM_RETURNCMD, CURPOS.X, CURPOS.Y, THIS

DWORD DWPOS = Curpos.x (Curpos.Y << 16) & 0xffff0000);

SendMessage (WM_SYSCOMMAND, NSELECTION, DWPOS);

CSTRING MSG;

Msg.format ("x:% d, y:% d; cursor.x =% d, cursor.y =% d", loword (dwpos), Hiword (dwpos), curpos.x, curpos.y);

OutputDebugstring (MSG);

}

3, how to control the brightness of the three lamps above the keyboard (Num Lock, Caps Lock Srcoll Lock)

#include

Void SetNumlock (Bool BState)

{

Byte KeyState [256];

GetKeyboardState (LPBYTE) & keystate;

IF ((BState &&! (KeyState [vk_numlock] & 1) ||

(! BState && (KeyState [vk_numlock] & 1)))))))

{

// Simulate a Key Press

Keybd_Event (vk_numlock,

0x45,

KeyEventf_extendedKey | 0,

0);

// simulate a key release

Keybd_Event (vk_numlock,

0x45,

KeyEventf_extendedKey | KeyEventf_Keyup,

0);

}

}

void main ()

{

SetNUMLOCK (TRUE);

}

4. How to change it to English after the Chinese is selected in the appWizard of VC?

Open the resource file with a file editor, find "Language", find it after finding:

// Chinese (p.r.c) resources

#if! defined (AFX_RESOURCE_DLL) || Defined (AFX_TARG_CHS)

#ifdef _win32

Language lang_chinese, SUBLANG_CHINESE_SIMPLIFIED

#pragma code_page (936)

#ENDIF / / / WIN32

This code indicates that the currently used code page is 936. The language represented is Simplified Chinese, and the following code is replaced with the following code: // English (u.s) Resources

#if! defined (AFX_RESOURCE_DLL) || Defined (AFX_TARG_ENU)

#ifdef _win32

Language lang_english, sublang_english_us

#pragma code_page (1252)

#ENDIF / / / WIN32

5. How to effectively determine if the mouse point is in the rectangular area of ​​the control

DWORD DW = GetMessagePos ();

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

CRECT R;

Getdlgitem (idc_edit1) -> getClientRect (& R);

Getdlgitem (IDC_EDIT1) -> ClientToscreen (& R);

IF (r.ptinRect (PT))

AfxMessageBox ("in the control");

6, handle the right click of the control, no

Bool ccDialogdlg :: PretranslateMessage (MSG * PMSG)

{

IF (WM_Mousemove == PMSG-> Message)

IF (PMSG-> hwnd == getdlgitem (idc_button1) -> getsafehwnd ())

{

Uint nflag = pmsg-> wparam; // state, such as Ctrl is not pressed

INT XPOS = loword (pmsg-> lparam); // Horizontal Position of Cursor

INT YPOS = HiWord (PMSG-> lparam); // Vertical Position of Cursor

}

Return CDIALOG :: PretranslateMessage (PMSG);

}

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

New Post(0)