📄 winbase.c
字号:
pClipRect=pClipRect->pNext; } } if(!IsRectEmpty(&rcBottom)){ pClipRect=pWin->pClipRgn->pHead; while(pClipRect){ if(IsIntersect(&pClipRect->rect,&rcBottom)){ bFlag=true; goto okret; } pClipRect=pClipRect->pNext; } } if(!IsRectEmpty(&rcLeft)){ pClipRect=pWin->pClipRgn->pHead; while(pClipRect){ if(IsIntersect(&pClipRect->rect,&rcLeft)){ bFlag=true; goto okret; } pClipRect=pClipRect->pNext; } } if(!IsRectEmpty(&rcRight)){ pClipRect=pWin->pClipRgn->pHead; while(pClipRect){ if(IsIntersect(&pClipRect->rect,&rcRight)){ bFlag=true; goto okret; } pClipRect=pClipRect->pNext; } }okret: if(bFlag) SendMessage(hWnd,LMSG_NCPAINT,(WPARAM)hDC,(LPARAM)NULL);//hDC is window coordsys scrGetClientRect(hWnd,&rc); //If invalidate region is not intersect with clip area, then we shoudn't redraw client area. if(IsIntersect(&(pWin->pInvRgn->rcBound), &rc)){ //get a client dc, don't forget that we have drawn some thing in the no client area hDCClient = GetDC(hWnd); if(!(lpPaint->bPaintDirect)){ hDCClientMem=CreateCompatibleDC(hDCClient); if(!hDCClientMem) return NULL; ReleaseDC(hWnd,hDCClient); hDCClient = hDCClientMem; iWinWidth = pWin->rect.right - pWin->rect.left + 1; iWinHeight = pWin->rect.bottom - pWin->rect.top + 1; memcpy(hDCClient->pData, hDC->pData, iWinWidth * iWinHeight * _lGUI_iBytesDataType); ReleaseDC(hWnd,hDC); } lpPaint->hdc=hDCClient; return hDCClient; } else{ EndPaint(hWnd,lpPaint); return NULL; }}//called by BeginPaintvoid inline EraseRect2Memory( HDC hDCMem, PRECT pOrgRect, PRECT pOutRect, COLORREF crColor){ int iWidth; int x,y; PCOLORREF pData; iWidth=((PBITMAP)(hDCMem->hBitmap))->bmWidth; pData=(PCOLORREF)(hDCMem->pData); if(!pData) return; for(y=pOutRect->top;y<=pOutRect->bottom;y++){ for(x=pOutRect->left;x<=pOutRect->right;x++){ *(pData + (y - pOrgRect->top)*iWidth + (x -pOrgRect->left))=crColor; } }}BOOL GUIAPI EndPaint( const HWND hWnd, LPPAINTSTRUCT lpPaint){ HDC hDC; PWindowsTree pWin; int iWidth,iHeight; int iType; pWin=(PWindowsTree)hWnd; if(!lpPaint->hdc){ //printerror("hDC is null in the function EndPaint."); return false; } iType=lpPaint->hdc->iType; if((iType!=DC_TYPE_MEM)&&(iType!=DC_TYPE_WIN)){ //printerror("hdc type error int the function EndPaint."); return false; } //if DC is MemDC then we should output it if(lpPaint->hdc->iType==DC_TYPE_MEM){ iWidth=pWin->rect.right-pWin->rect.left+1; iHeight=pWin->rect.bottom-pWin->rect.top+1; hDC=GetWindowDC(hWnd); winBitBlt(hDC,0,0,iWidth,iHeight,lpPaint->hdc,0,0,SRCCOPY); ReleaseDC(hWnd,hDC); } //Release lpPaint->hDC ReleaseDC(hWnd,lpPaint->hdc); //restore clip region if(!IsEmptyClipRegion(pWin->pClipRgn)) EmptyClipRegion(pWin->pClipRgn); CopyClipRegion(pWin->pClipRgn,pWin->pBackClipRgn); //free clip region EmptyClipRegion(pWin->pBackClipRgn); //clear invalidate area EmptyInvalidRegion(pWin->pInvRgn); return true;}//coordinate convert////====================================================================void GUIAPI ScreenToWindow( const HWND hWnd, int* px, int* py){ PWindowsTree pWin; int x=0,y=0; pWin=(PWindowsTree)hWnd; x=pWin->rect.left; y=pWin->rect.top; *px -=x; *py -=y;}void GUIAPI ScreenToWindowRect( const HWND hWnd, LPRECT lprc){ PWindowsTree pWin; int x=0,y=0; pWin=(PWindowsTree)hWnd; x=pWin->rect.left; y=pWin->rect.top; OffsetRect(lprc,(-1)*x,(-1)*y);}void GUIAPI WindowToScreen( const HWND hWnd, int* px, int* py){ PWindowsTree pWin; int x=0,y=0; pWin=(PWindowsTree)hWnd; x=pWin->rect.left; y=pWin->rect.top; *px +=x; *py +=y;}void GUIAPI WindowToScreenRect( const HWND hWnd, LPRECT lprc){ PWindowsTree pWin; int x=0,y=0; pWin=(PWindowsTree)hWnd; x=pWin->rect.left; y=pWin->rect.top; OffsetRect(lprc,x,y);}void GUIAPI WindowToClient( const HWND hWnd, int* px, int* py){ int iBorder; int iCaption; iBorder=wndGetBorder(hWnd); if(IsCaption(hWnd)) iCaption = WIN_CAPTION_HEIGHT; else iCaption = 0; *px-=iBorder; *py-=(iBorder+iCaption);}void GUIAPI WindowToClientRect( const HWND hWnd, LPRECT lprc){ int iBorder; int iCaption; iBorder=wndGetBorder(hWnd); if(IsCaption(hWnd)) iCaption = WIN_CAPTION_HEIGHT; else iCaption = 0; OffsetRect(lprc,(-1)*iBorder,(-1)*(iBorder+iCaption)); }void GUIAPI ClientToWindow( const HWND hWnd, int* px, int* py){ int iBorder; int iCaption; iBorder=wndGetBorder(hWnd); if(IsCaption(hWnd)) iCaption = WIN_CAPTION_HEIGHT; else iCaption = 0; *px+=iBorder; *py+=(iBorder + iCaption);}void GUIAPI ClientToWindowRect( const HWND hWnd, LPRECT lprc){ int iBorder; int iCaption; iBorder=wndGetBorder(hWnd); if(IsCaption(hWnd)) iCaption = WIN_CAPTION_HEIGHT; else iCaption = 0; OffsetRect(lprc,iBorder,iBorder+iCaption);}void GUIAPI ScreenToClient( const HWND hWnd, int* px, int* py){ ScreenToWindow(hWnd,px,py); WindowToClient(hWnd,px,py);}void GUIAPI ScreenToClientRect( const HWND hWnd, LPRECT lprc){ ScreenToWindowRect(hWnd,lprc); WindowToClientRect(hWnd,lprc);}void GUIAPI ClientToScreen( const HWND hWnd, int* px, int* py){ ClientToWindow(hWnd,px,py); WindowToScreen(hWnd,px,py);}void GUIAPI ClientToScreenRect( const HWND hWnd, LPRECT lprc){ ClientToWindowRect(hWnd,lprc); WindowToScreenRect(hWnd,lprc);}int GetWinType( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; return pWin->dwStyle & WS_TYPEMASK;}BOOL IsHideWindow( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if((pWin->dwStyle & WS_VISIBLE)==WS_VISIBLE) return false; else return true;}BOOL IsDesktop( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if((pWin->dwStyle & WS_TYPEMASK)==WS_DESKTOP) return true; else return false;}BOOL IsMainWin( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if((pWin->dwStyle & WS_TYPEMASK)==WS_MAIN) return true; else return false;}BOOL IsChildWin( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if((pWin->dwStyle & WS_TYPEMASK)==WS_CHILD) return true; else return false;}BOOL IsControl( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if((pWin->dwStyle & WS_TYPEMASK)==WS_CONTROL) return true; else return false;}BOOL IsFocus( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if(!pWin) return false; if((pWin->dwStyle & WS_FOCUS)==WS_FOCUS) return true; else return false;}BOOL IsVisible( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if(!pWin) return false; if((pWin->dwStyle & WS_VISIBLE)==WS_VISIBLE) return true; else return false;}BOOL IsActive( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if(pWin==_lGUI_pActiveWin) return true; else return false;}BOOL IsEnable( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if(!pWin) return false; if((pWin->dwStyle & WS_DISABLE)==WS_DISABLE) return false; else return true;}BOOL IsBorder( const HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if((pWin->dwStyle & WS_BORDER)==WS_BORDER) return true; else return false;}BOOL IsTrans( HWND hWnd){ PWindowsTree pWin; pWin = (PWindowsTree)hWnd; if((pWin->dwStyle & WS_TRANS) == WS_TRANS) return true; else return false;}BOOL IsCaption( HWND hWnd){ PWindowsTree pWin; pWin = (PWindowsTree)hWnd; if((pWin->dwStyle & WS_CAPTION) == WS_CAPTION) return true; else return false;}BOOL IsOkButton( HWND hWnd){ PWindowsTree pWin; pWin = (PWindowsTree)hWnd; if((pWin->dwStyle & WS_OKBUTTON) == WS_OKBUTTON) return true; else return false;}BOOL IsCloseBox( HWND hWnd){ PWindowsTree pWin; pWin = (PWindowsTree)hWnd; if((pWin->dwStyle & WS_CLOSEBOX) == WS_CLOSEBOX) return true; else return false;}BOOL IsOkButtonPressed( HWND hWnd){ PWindowsTree pWin; pWin = (PWindowsTree)hWnd; if((pWin->dwStyle & WS_OKBUTTONPRESSED) == WS_OKBUTTONPRESSED) return true; else return false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -