Windows程序设计复习
《Window程序设计》上册复习:
__stdcall __cdecl WideCharToMultiByte MultiByteToWideChar
多字节字符集与Unicode:IsTextUnicode
TCHAR.h _tcslen(wcslen and strlen)
TCHAR(wchar_t and char) _T,_TEXT,L
Unicode/Ansi : lstrlen lstrcpy lstrcpyn lstrcat lstrcmp lstrcmpi
vsprintf wsprintf wvsprintf _vsntprintf
va_list, va_start, va_arg, va_end
PlaySound ScrollWindow ScrollDC
InvalidateRect InvalidateRgb
GetTextMetrics(get text metrics from dc) GetTextFace(Set...)
GetClientDC GetWindowDC
SetScrollRange SetScrollPos SetScrollSizes SetScrollInfo
WM_PAINT:BeginPaint函数调用使dc区域变为有效
CreateCompatibleDC GetDeviceCaps SetTextAlign
图形绘制函数:SetPixel(GetPixel)
TextOut
LineTo Polyline(no fill)/Polygon(fill) PolylineTo PolyPolyline Arc
PolyBezier PolyBezierTo
ArcTo AngleArc PolyDraw
Ellipse Rectangle RoundRect Chord Pie
CreatePen CreatePenIndirect GetObject SelectObject DeleteObject(hPen)
SetBkColor SetTextColor SetBkMode SetROP2(GetROP2) SetPolyFillMode
CreateBrushIndirect CreateSolidBrush CreateHatchBrush
CreatePatternBrush CreateDIBPatternBrushPt(create brush base on bitmap)
SetMapMode(GetMapMode) SetWindowExtEx DPtoLP LPtoDP
GetClientRect
SetViewportOrgEx SetWindowOrgEx
区域和剪裁:
FillRect FrameRect InvertRect(矩形所有象素颜色翻转)
SetRect OffsetRect InflateRect SetRectEmpty CopyRect
IntersectRect(交集) UnionRect IsRectEmpty PtInRect
CreateRectRgn(创建一个区域时,取得该区域的句柄) CreateRectRgnIndirect
CreateEllipticRgn CreateEllipticRgnIndirect
CreatePolygonRgn CombineRgn
区域的句柄可用于下4个绘图函数:FillRgn FrameRgn InvertRgn PaintRgn
(you must use DeleteObject(hRgn) to delete after not use the region which you create)
键盘:GetKeyState GetAsyncKeyState GetKeyNameText
ScreenToClient ClientToScreen CreateCaret SetCaretPos ShowCaret
windowclass cs | = CS_DBLCLKS;
鼠标:WM_NCHITTEST ShowCursor GetCursorPos(SetCursorPos)
SetCapture ReleaseCapture
SetWindowLong(GetWindowLong) SetClassLong(GetClassLong)
SetFocus(GetFocus) GetDlgItem WM_SETFOCUS WM_KILLFOCUS
SystemParametersInfo DrawBoxOutline
计时器:SetTimer KillTimer WM_TIMECHANGE
GetLocalTime(SetLocalTime) GetSystemTime(SetSystemTime)
GetDateFormat GetLocaleInfo
GetParent GetDlgCtrlID IsWindowVisible
按钮:BS_OWNERDRAW
通知码:BN_SETFOCUS 发送消息:BM_SETCHECK BM_SETIMAGE
GetSysColors(SetSysColors) ScrollWindow
按钮绘制:WM_CTLCOLORBTN 自画风格:BS_OWNERDRAW WM_DRAWITEM消息
WM_CTLCOLORBTN:很少使用
WM_ERASEBKGND:return TRUE;
WM_PAINT:窗口不响应
WM_DRAWITEM:自画
SetClassLong (hWnd, GCL_HBRBACKGROUND, (LONG)CreateSolidBrush(...))
WM_CTLCOLORSCROLLBAR(返回背景颜色)
WM_CTLCOLORSTATIC(用SetTextColor和SetBkColor设置前景和背景颜色)
WM_SYSCOLORCHANGE
文本编辑框:通知码:EN_SETFOCUS EN_KILLFOCUS EN_CHANGE EN_UPDATE
消息:EM_GETSEL EM_SETSEL EM_GETLINECOUNT EM_LINEINDEX
EM_LINELENGTH EM_GETLINE
重画标志:WM_SETREDRAW(TRUE/FALSE)
列表框:LB_RESETCONTENT LB_DELETESTRING LB_ADDSTRING LB_INSERTSTRING etc
强大的消息:LB_DIR
通知码:LBN_SELCHANGE LBN_KILLFOCUS etc GetEnvironmentStrings
GetCurrentDirectory
菜单及资源:DrawIcon AnsiNext LockResource(LoadResource(FindResource))
CreateMenu AppendMenu DeleteMenu InsertMenu ModifyMenu RemoveMenu
EnableMenuItem IsClipboardFormatAvaliable
DrawMenuBar GetSubMenu GetMenuItemCount GetMenuItemID CheckMenuItem
GetMenuString GetMenuState DestroyMenu TrackPopupMenu LoadMenu SetMenu
加速键:LoadAccelerators RegisterHotKey TranslateAccelerator
模态对话框:DialogBox DialogBoxIndirect DialogBoxParam
处理WM_INITDIALOG消息,退出用EndDialog
SendDlgItemMessage CheckRadioButton CheckDlgButton IsDlgButtonChecked
非模态对话框:CreateDialog CreateDialogIndirect ShowWindow SetDlgItemText
消息处理,在主窗口消息循环中加入:IsDialogMessage
通用对话框:GetOpenFileName GetSaveFileName ChooseColor
FindText ReplaceText
MSDN Examples:Using Common Dialog Boxes
RegisterWindowMessage
内存分配:GlobalAlloc GlobalReAlloc GlobalSize GlobalFree(GlobalHandle(p));
GlobalLock GlobalUnlock CopyMemory
剪贴板:OpenClipboard EmptyClipboard SetClipboardData CloseClipboard
GetClipboardData IsClipboardFormatAvailable EnumClipboardFormats
CountClipboardFormats RegisterClipboardFormat GetClipboardFormatName
剪贴板Hook:SetClipboardViewer(hWnd)-->WM_DRAWCLIPBOARD)
UnHook: ChangeClipboardChain
GetClipboardViewer WM_CHANGECBCHAIN WM_DRAWCLIPBOARD
《Window程序设计》下册复习:
打印机:CreateDC PrintDlg StartDoc StartPage EndPage EndDoc
EnumPrinters GetVersion(Ex) WM_SETTINGCHANGE WM_INITMENUPOPUP
OpenPrinter PrinterProperties CreateIC GetPrinterDC
SetAbortProc(use callback to abort print task) WM_SETTINGCHANGE
设备有关位图:
CreateBitmap CreateBitmapIndirect
BitBlt StretchBlt SetStretchBltMode PatBlt
SetBitmapBits GetBitmapBits
CreatePatternBrush CreateBrush CreateBrushIndirect
WM_DISPLAYCHANGE CreateCompatibleDC(内存dc作图原理)
GetSystemBmenu AppendMenu:插入位图菜单 GetTextExtentPoint32
LockWindowUpdata(GetDesktopWindow Or Other Or NULL) GetDCEx
设备无关位图:
BITMAPFILEHEADER BITMAPCOREHEADER SetFilePointer SetEndOfFile
CreateFile GetFileSize CloseHandle SetCursor ShowCursor
SetDIBitsToDevice StretchDIBits 掌握dib格式及显示方法
CreateDIBitmap(create ) SetDIBits(init pixels)这两个函数从dib到ddb
GetDIBits 从ddb到dib
DIB: 文件或内存块
DDB:gdi位图对象,并由位图句柄表示
CreateDIBSection :create a DIB,reture a handle of dib data section,not gdi
(windows重要函数:指向设备无关位图,但是返回的句柄又可用设备有关函数的操作)
显示dib的三种方法
①用SetDIBitsToDevice或StretchDIBits将dib直接显示在屏幕,速度慢
②用CreateDIBitmap和SetDIBits把DIB转换成DDB,然后用BitBlt或StretchBlt显示
③用CreateDIBSection创建DIB部分,然后使用BitBlt或StretchBlt显示
GdiFlush
调色板:CreatePalette SelectPalette RealizePalette UpdateColors
本章不太感兴趣,以后在网络上看到相关文章时再去学习,:)
文本与字体:
TrueType:轮廓字体技术
TextOut TabbedTextOut ExtTextOut DrawText DrawTextEx
SetTextColor SetBKMode SetBkColor SetTextCharacterExtra
GDI 字体:点阵,笔画,TrueType
设备字体:硬件内置的设备字体(打印机)
CreateFont CreateFontIndirect(旋转字体)
SetGraphicsMode SetMapperFlags ModifyWorldTransform
EnumFontFamilies SetTextJustification
GetDialogBaseUnits GetTextExtentPoint32(get text width and height)
程序需仔细调试,特别是那个换行打印的程序
ExtCreatePen(use logical brush) BeginPath(这两个函数中间画轮廓字)EndPath
StrokePath StrokeAndFillPath
元文件:CreateMetaFile CloseMetaFile DeleteMetaFile/DeleteFile
PlayMetaFile SetMetaFileBitsEx
本章不太感兴趣,以后在网络上看到相关文章时再去学习,:)
多文档界面:
程序需要仔细调试,重要的咚咚
hClient=GetWindow(hFrame,GW_CHILD)
一个视窗类:MDICLIENT
五个函数:DefFrameProc DefMDIChildProc
TranslateMDISysAccel
两个结构体:CLIENTCREATESTRUCT(这个客户视窗覆盖框架视窗的显示区域 )
MDICREATESTRUCT(以一个指向此结构的指标为参数将讯息WM_MDICREATE发送给客户视窗,用来创建子视窗)
十二个消息:
WM_MDICREATE 创建子视窗的消息,返回这个子窗口句柄
WM_MDIGETACTIVE 取得活动的子窗口句柄
WM_MDIDESTROY 销毁MDI子窗口(句柄可通过上消息取得)
WM_MDITILE
WM_MDICASCADE
WM_MDIICONARRANGE
WM_MDIRESTORE 恢复子窗口状态
WM_MDISETMENU 设置框架菜单
线程:CreateThread _beginthread
CRITICAL_SECTION EnterCriticalSection LeaveCriticalSection
DeleteCriticalSection CreateEvent ResetEvent WaitForSingleObject
每个线程有自己的堆栈 TlsAlloc TlsSetValue() TlsGetValue TlsFree
__declspec(thread) extern "C"缘由(C要大写!)
DLL:
dll入/出口点: DLL_PROCESS_ATTACH,etc
DLL共享内存:为dll创建共享节。#pragma data_seg("shared")
/section:shared,RWS
LoadLibrary FreeLibrary GetProcAddress
声音与音乐:mciSendString waveOut...
领略Internet:...
2005.2.28 深圳南山科技园