zoukankan      html  css  js  c++  java
  • 如何将方行的按纽改变为其他的形状

    下面的代码为如何生成一个圆形的按纽的方法 ,主要功能的实现为调用了一系列的API来实现的.

    [System.Runtime.InteropServices.DllImport("gdi32")]
      private static extern IntPtr BeginPath(IntPtr hdc);
      [System.Runtime.InteropServices.DllImport("gdi32")]
      private static extern int SetBkMode(IntPtr hdc,int nBkMode);  
      const int TRANSPARENT=1;
      [System.Runtime.InteropServices.DllImport("gdi32")]     
      private static extern IntPtr EndPath(IntPtr hdc);
      [System.Runtime.InteropServices.DllImport("gdi32")]
      private static extern IntPtr PathToRegion(IntPtr hdc);
      [System.Runtime.InteropServices.DllImport("gdi32")]
      private static extern int Ellipse(IntPtr hdc,int x1,int y1,int x2,int y2);
      [System.Runtime.InteropServices.DllImport("user32")]
      private static extern IntPtr SetWindowRgn(IntPtr hwnd,IntPtr hRgn,bool bRedraw);
      [System.Runtime.InteropServices.DllImport("user32")]
      private static extern IntPtr GetDC(IntPtr hwnd);
      public Class7()
      {   
      }
      public void MakeToPictureBoxsToCircle(PictureBox[] pb)
      {
       IntPtr dc;
       IntPtr region;
       for(int i=0;i
       {
        dc=GetDC(pb[i].Handle);
        BeginPath(dc);
        SetBkMode(dc,TRANSPARENT);
        Ellipse(dc,0,0,pb[i].Width-3,pb[i].Height-2);
        EndPath(dc);
        region=PathToRegion(dc);
        SetWindowRgn(pb[i].Handle,region,false);
       }  

  • 相关阅读:
    原创 ios绘制 圆形气泡
    ios 线程安全单例写法
    (转)ios中点击地图控件MKMapView的某点获取该点的经纬度
    使用正则提取url(iOS)
    MAC系统崩溃,使用命令行复制硬盘内容
    UISearchBar控件UI操作
    app发布流程详解
    App Store审核指南(中文版)2010版
    GCD详解
    iOS扫描二维码(系统方法)
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/1699873.html
Copyright © 2011-2022 走看看