您好,欢迎访问三七文档
WindowsWindowsWindowsVisualC++MFCWindowsVC++MFCCCprintfWindowsWindowsWindowsWindowsWindowsApplicationProgrammingInterfaceAPIWindowsAPIWindowsWindows.hWindows1000APIAPICreateWindowShowWindowLoadIconSendMessageMSDNMSDNMSDNMSDN12VC++uuuuuMSDNMSDNMSDNWin32SDKSDKSDKSoftwareDevelopmentKitSDKAPISDKWin32SDKWindows32APIAPISDKAPISDKAPISDKJavaAPIJavaSDKWindowsWindowsWindows1.11.1WS_OVERLAPPEDWINDOW1.1Windows1.131WindowstttttWindowsWindowsWindowsHWNDHANDLEWindowsWindowsHICONHCURSORHBRUSHCfopenWindowsAPIWindowsDOS1WindowsMSGMSGMSDNtypedefstructtagMSG{HWNDhwnd;UINTmessage;WPARAMwParam;LPARAMlParam;DWORDtime;POINTpt;}MSG;hwndWindowsHWND4VC++uuuuumessageWindowsWindowsWM_XXXWMWindowMessageXXXWM_LBUTTONDOWNWM_KEYDOWNWM_CHARWM_XXXWM_XXXVisualC++WM_XXXgotodefinitionwParamlParammessageWM_CHARwParamlParamwParamlParamMSDNVC++gotodefinitionWPARAMLPARAMunsignedintlong2WindowsWM_LBUTTONDOWNWindowsWindows3WindowsWindowsWinMainWindowsWinMainWinMainWindows51WindowstttttDOSmainWinMainWindowsWin32WinMain1.4.1WinMainWinMainintWINAPIWinMain(HINSTANCEhInstance,//handletocurrentinstanceHINSTANCEhPrevInstance,//handletopreviousinstanceLPSTRlpCmdLine,//commandlineintnCmdShow//showstate);WinMain4WinMainhInstanceWindowshInstanceWinMainhPrevInstanceMSDNWin32NULLWin32lpCmdLineDsunxin.txtnotepad.exeD:\sunxin.txtWinMainVC++ProjectSettingsDebugProgramargumentsnCmdShowWinMainWINAPI__stdcallgotodefinitionWINAPIWINAPI__stdcall6VC++uuuuu1.4.2Chapter1WinMain1A6A6WindowsWindowsWNDCLASSWNDCLASSMSDNtypedefstruct_WNDCLASS{UINTstyle;WNDPROClpfnWndProc;intcbClsExtra;intcbWndExtra;HANDLEhInstance;HICONhIcon;HCURSORhCursor;HBRUSHhbrBackground;LPCTSTRlpszMenuName;LPCTSTRlpszClassName;}WNDCLASS;stylenCS_HREDRAW71WindowstttttnCS_VREDRAWnCS_NOCLOSEClosenCS_DBLCLKSstyleMSDNWindows.hCS_ClassStyle1611VC++gotodefinitionCS_VREDRAW=0x0001CS_HREDRAW=0x0002CS_DBLCLKS=0x0008CS_NOCLOSE=0x0200162111CS_HREDRAWCS_VREDRAWstyle=CS_HREDRAW|CS_VREDRAW~&styleCS_VREDRAWstyle=style&~CS_VREDRAWWindowslpfnWndProc123Windows1lpfnWndProc2RegsiterClass(&wndclass)3DispatchMessage(&msg)Windows8VC++uuuuuWNDCLASSlpfnWndProclpfnWndProcWNDPROCVC++gotodefinitionWNDPROCtypedefLRESULT(CALLBACK*WNDPROC)(HWND,UINT,WPARAM,LPARAM);LRESULTCALLBACKgotodefinitionlong__stdcallWNDPROCWNDPROCWNDPROCWNDPROC__stdcall__cdeclMSDNprintf__cdeclWin32API__stdcallVC++__cdecl__stdcall__stdcallWindows__stdcallCALLBACKCALLBACK__stdcallWindows98Windows2000CALLBACKWindowsNT4.0WNDCLASScbClsExtraWindowsWNDCLASSWindowsWNDCLASSWindows00cbWndExtraWindowsWindowsWindows0WNDCLASSCLASSDLGWINDOWEXTRA0hInstancehIconNULLhIconLoadIcon91WindowstttttHICONLoadIcon(HINSTANCEhInstance,LPCTSTRlpIconName)LoadIconWindowsMSDNLoadIconNULLLoadIconLPCTSTRgotodefinitionCONSTCHAR*IDMAKEINTRESOURCEIDLPCTSTRVC++.rcVC++ResourceViewVC++IDIDIDresource.hIDIDIDM_XXXMMenuIDI_XXXIIconIDB_XXXBButtonIDWNDCLASShCursorNULLhCursorLoadCursorHCURSORLoadCursor(HINSTANCEhInstance,LPCTSTRlpCursorName);LoadCursorLoadIconhbrBackgroundhbrBackgroundhbrBackgroundMSDNGetStockObjectGetStockObjectHGDIOBJGetStockObject(intfnObject);fnObjectMSDN10VC++uuuuuGetStockObjectGetStockObjectHGDIOBJhbrBackgroundwndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);lpszMenuNameIDMAKEINTRESOURCElpszMenuNameNULLlpszClassNamesunxin20062WNDCLASSRegisterClassATOMRegisterClass(CONSTWNDCLASS*lpWndClass);33CreateWindowCreateWindowHWNDCreateWindow(LPCTSTRlpClassName,//pointertoregisteredclassnameLPCTSTRlpWindowName,//pointertowindownameDWORDdwStyle,//windowstyleintx,//horizontalpositionofwindowinty,//verticalpositionofwindowintnWidth,//windowwidthintnHeight,//windowheightHWNDhWndParent,//handletoparentorownerwindowHMENUhMenu,//handletomenuorchild-windowidentifierHANDLEhInstance,//handletoapplicationinstanceLPVOIDlpParam//pointertowindow-creationdata);lpClassName1WNDCLASS111WindowstttttlpszClassNamesunxin2006sunxin2006CreateWindowRegisterClasssunxin2006lpWindowNamedwStyleWNDCLASSstyleCreateWindowdwStyleWS_OVERLAPPEDWINDOW#defineWS_OVERLAPPEDWINDOW(WS_OVERLAPPED|\WS_CAPTION|\WS_SYSMENU|\WS_THICKFRAME|\WS_MINIMIZEBOX|\WS_MAXIMIZEBOX)WS_OVERLAPPEDWINDOWnWS_OVERLAPPEDnWS_CAPTIONnWS_SYSMENUWS_CAPTIONnWS_THICKFRAMEnWS_MINIMIZEBOXWS_SYSMENUnWS_MAXIMIZEBOXWS_SYSMENUWS_OVERLAPPEDWINDOW1.1CreateWindowxynWidthnHeightxyxCW_USEDEFAULTynWidthCW_USEDEFAULTnHeighthWndParent1.2WS_CHILD1.112VC++uuuuu1.1hMenuhInstancelpParamWM_CREATElParamlpParamCLIENTCREATESTRUCTNULLCreateWindowNULL41ShowWindowBOOLShowWindow(HWNDhWnd,//handletowindowintnCmdShow//showstate);ShowWindowhWndnCmdShownSW_HIDEnSW_SHOWnSW_SHOWMAXIMIZEDnSW_SHOWMINIMIZEDnSW_SHOWNORMALnCmdShowMSDN2ShowWindowUpdateWindowUpdateWindowBOOLUpdateWindow(HWNDhWnd//handletowindow131Windowsttttt);hWndUpdateWindowWM_PAINTUpdateWindowWM_PAINTWM_PAINT1.4.3GetMessage()BOOLGetMessage(LPMSGlpMsg,//addressofstructurewithmessageHWNDhWnd,//handleofwindowUINTwMsgFilterMin,//firstmessageUINTwMsgFilterMax//lastmessage);lpMsgMSGGetMessagehWndNULLwMsgFilterMin0wMsgFilterMaxwMsgFilterMinwMsgFilterMax0GetMessageWM_QUITWM_QUIT-1hWndlpMsgMSGmsg;while(GetMessage(&msg,NULL,0,0)){Trans
本文标题:VC++深入详解
链接地址:https://www.777doc.com/doc-2035076 .html