Skip to main content

Featured

Build docker image from multiple build contexts

Build docker image from multiple build contexts Building a docker image requires specifying a source of truth to include in the image from a local directory or a remote git repository. In the previous version, the docker BuildKit allows users to specify the build context from a single source of truth only. However, the engineers may need to have the context from different locations based on the type of files. For instance, icons, images or other resources that are not included in the same package, including the resource from other docker images. Fortunately, the Docker Buildx toolkit supports multiple build context flag for Docker 1.4. Let's learn how to use this new feature. The following list is a shortcut for jumping into a specific topic handy. What version of Docker is this tutorial targeting? How to specify the version of Dockerfile frontend? Ho

[TreeCtrl]CTreeCtrl取得目前滑鼠右鍵點選項目

這邊需使用到HitTest()來取得滑鼠點選的項目。

步驟如下:
1.使用GetCursorPos()來取得目前滑鼠座標。
2.使用CTreeCtrl::ScreenToClient()轉換滑鼠座標位置到CTreeCtrl的相對位置。
3.使用CTreeCtrl::HitTest()來取得此座標位置是否有Item存在。
4.判斷HitTest()回傳的Flag狀態是否為TVHT_ONITEM
5.如上述步驟都成立,則HitTest()回傳之HTREEITEM則為所要之Item。如此值為NULL,則代表此座標位置並無Tree Item存在。

程式碼如下:
 CPoint pt;  
 UINT unFlag = 0;  
 ::GetCursorPos(&pt);  
 pTree->ScreenToClient(&pt);  
   
 //When this function is called, the pt parameter specifies the coordinates of the point to test.   
 //The function returns the handle of the item at the specified point or NULL if no item occupies the point.   
 //In addition, the pFlags parameter contains a value that indicates the location of the specified point.  
 HTREEITEM htreeHitItem = pTree->HitTest(pt, &unFlag);  
   
 if ( htreeHitItem == NULL || !(unFlag&TVHT_ONITEM) )        //No hit item, and not on item  
 {  
     //Just show Create  
     return false;   
 }else if ( htreeHitItem && (unFlag & TVHT_ONITEM) ) {  
     //Just show edit and delete  
     pTree->Select(htreeHitItem, TVGN_CARET);        //Set this item be selected  
     //pTree->SelectItem(htreeHitItem);              //用這個也可以
 }else{        //Not allow  
     return false;  
 }    //End of if ( htreeHitItem == NULL || !(unFlag&TVHT_ONITEM) )  

如需再指定此Item被選擇,僅需使用CTreeCtrl::Select()或是CTreeCtrl::SelectItem()即可。

Comments

Popular Posts