02. 画笔画刷和弹出菜单

# 画笔和画刷
1. 相关API:
   1. CreatePen,CreatePenIndirect,CreateSolidBrush,CreateHatchBrush,CreatePatternBrush,CreateBrushIndirect,GetStockObject
    
# 弹出菜单
1. SDK写法:
static HMENU hMenu=nullptr;
    case WM_CREATE: {
        hMenu = LoadMenu(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDR_MENU1));
        hMenu = GetSubMenu(hMenu, 0);
        break;
    }
    case WM_RBUTTONUP: {
        int nX = GET_X_LPARAM(lParam);
        int nY = GET_Y_LPARAM(lParam);
        POINT pt = { nX,nY };
        ClientToScreen(hWnd, &pt);
        TrackPopupMenu(hMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hWnd, nullptr); 
        break;
    }

  

2. MFC写法:
        ClientToScreen(&point);
	CMenu menu;
	menu.LoadMenu(IDR_MENURIGHT);
	menu.GetSubMenu(0)->TrackPopupMenu(TPM_RIGHTBUTTON, point.x, point.y, this);     

  

posted @ 2020-07-09 15:09  八转达人  阅读(137)  评论(0编辑  收藏  举报