当前位置:首页
开发技术指南» 文章正文
    引言:

 ·向高手们,dataset问题    »显示摘要«
    摘要: dataset的tables能不能作为关系数据表,使用复杂sql进行数据筛选?请高手指点 ......
 ·:局域网不能ping通某台xp机    »显示摘要«
    摘要: 在局域网中一台xp机能ping通其它计算机,但其它计算机不能ping通该机,也不能访问该机。 ......


关于透明form

建立一个form,再在form上面放一个image控件,image控件有一幅透明的图片,我怎么样让form和image控件透明而只显示那幅透明图片,最终结果是要透过透明的图片可以看见后面的窗体桌面等等,图片不会因为窗体的透明而模糊掉或者没有了

NO.1   作者: bbhere

Private   Declare   Function   CreateCompatibleBitmap   Lib   "gdi32"   (ByVal   hdc   As   Long,   ByVal   nWidth   As   Long,   ByVal   nHeight   As   Long)   As   Long  
  Private   Declare   Function   SelectObject   Lib   "gdi32"   (ByVal   hdc   As   Long,   ByVal   hObject   As   Long)   As   Long    
  Private   Sub   Form_Load()  
  Dim   hBitmap   As   Integer  
  Me.AutoRedraw   =   True  
  hBitmap   =   CreateCompatibleBitmap(Me.hdc,   0,   0)  
  SelectObject   Me.hdc,   hBitmap  
  Me.Refresh  
  End   Sub

NO.2   作者: IamDeane

这个代码粘过来来了  
  控件是Timer1,Picture1,还有两个图片Y5.bmp,\y4.bmp,还有个LABLE1,这下应该解决了吧  
  Option   Explicit  
  Private   Declare   Function   GetPixel   Lib   "gdi32"   (ByVal   hDC   As   Long,   ByVal   X   As   Long,   _  
          ByVal   Y   As   Long)   As   Long  
           
  Private   Declare   Function   SetWindowRgn   Lib   "user32"   (ByVal   hWnd   As   Long,   ByVal   hRgn   As   Long,   _  
          ByVal   bRedraw   As   Boolean)   As   Long  
           
  Private   Declare   Function   CreateRectRgn   Lib   "gdi32"   (ByVal   X1   As   Long,   ByVal   Y1   As   Long,   _  
          ByVal   X2   As   Long,   ByVal   Y2   As   Long)   As   Long  
           
  Private   Declare   Function   CombineRgn   Lib   "gdi32"   (ByVal   hDestRgn   As   Long,   ByVal   hSrcRgn1   As   Long,   _  
          ByVal   hSrcRgn2   As   Long,   ByVal   nCombineMode   As   Long)   As   Long  
  Private   Declare   Function   DeleteObject   Lib   "gdi32"   (ByVal   hObject   As   Long)   As   Long  
  Private   Const   RGN_OR   =   2  
  Private   Sub   Form_Load()  
      Picture1.ScaleMode   =   vbPixels                     设置度量单位为像素  
      Picture1.AutoRedraw   =   True                           自动重绘  
      Picture1.AutoSize   =   True  
      Picture1.BorderStyle   =   vbBSNone  
      Me.BorderStyle   =   vbBSNone  
      Set   Picture1.Picture   =   LoadPicture(App.Path   &   "\y4.bmp")  
      Dim   WindowRegion   As   Long  
      WindowRegion   =   getpic(Picture1)  
      SetWindowRgn   Me.hWnd,   WindowRegion,   True  
  End   Sub  
  Public   Function   getpic(pic   As   PictureBox)   As   Long  
      Dim   I   As   Long,   j   As   Long,   linex   As   Long  
      Dim   lineall,   myline,   mycolor   As   Long  
      Dim   mystart,   mybool   As   Boolean  
      Dim   hDC   As   Long,   PicWidth,   PicHeight   As   Long  
      hDC   =   pic.hDC  
      mystart   =   True  
      mybool   =   False  
      I   =   0  
      j   =   0  
      PicWidth   =   pic.ScaleWidth  
      PicHeight   =   pic.ScaleHeight  
      linex   =   0  
      mycolor   =   GetPixel(hDC,   0,   0)  
      For   j   =   0   To   PicHeight   -   1  
          For   I   =   0   To   PicWidth   -   1  
              If   GetPixel(hDC,   I,   j)   =   mycolor   Or   I   =   PicWidth   Then                   如果是透明像素  
                  If   mybool   Then  
                        mybool   =   False  
                        myline   =   CreateRectRgn(linex,   j   +   1,   I,   j)  
                        If   mystart   Then  
                              lineall   =   myline  
                              mystart   =   False  
                          Else  
                              CombineRgn   lineall,   lineall,   myline,   RGN_OR                     剪裁区域  
                        End   If  
                  End   If  
                Else  
                  If   Not   mybool   Then  
                        mybool   =   True  
                        linex   =   I   +   2  
                  End   If  
              End   If  
              Next  
          Next  
      getpic   =   lineall  
  End   Function  
   
  Private   Sub   Timer1_Timer()                       半透明动画  
      Me.   =   Me.   -   20  
      Dim   WindowRegion   As   Long  
      Set   Picture1.Picture   =   LoadPicture(App.Path   &   "\Y5.bmp")  
      Label1.Caption   =   "太阳出来了!"  
      WindowRegion   =   getpic(Picture1)  
      SetWindowRgn   Me.hWnd,   WindowRegion,   True  
  End   Sub  
   
  Private   Sub   Picture1_Click()  
      End  
  End   Sub  
 

NO.3   作者: fishzone

这个是   把图片中白色部分变成透明。  
  把下面的过程放到标准模块中。  
  用的时候,在form中放一个和窗体一样大的   picturebox,在这个picturebox   中的picture属性  
  放一张部分白色的图片。  
  像这样调用就可以了:  
   
  Public   Sub   Form_Load()  
          FitToPicture   picMain,   Me  
  End   Sub  
   
   
   
  Option   Explicit  
             
  Public   Type   BITMAP  
          bmType   As   Long  
          bmWidth   As   Long  
          bmHeight   As   Long  
          bmWidthBytes   As   Long  
          bmPlanes   As   Integer  
          bmBitsPixel   As   Integer  
          bmBits   As   Long  
  End   Type  
     
  Public   Declare   Function   GetBitmapBits   Lib   "gdi32"   (ByVal   hBitmap   As   Long,   ByVal   dwCount   As   Long,   lpBits   As   Any)   As   Long  
  Public   Declare   Function   GetObject   Lib   "gdi32"   Alias   "GetObjectA"   (ByVal   hObject   As   Long,   ByVal   nCount   As   Long,   lpObject   As   Any)   As   Long  
  Public   Declare   Function   CreateRectRgn   Lib   "gdi32"   (ByVal   x1   As   Long,   ByVal   y1   As   Long,   ByVal   X2   As   Long,   ByVal   Y2   As   Long)   As   Long  
  Public   Declare   Function   CombineRgn   Lib   "gdi32"   (ByVal   hDestRgn   As   Long,   ByVal   hSrcRgn1   As   Long,   ByVal   hSrcRgn2   As   Long,   ByVal   nCombineMode   As   Long)   As   Long  
  Public   Declare   Function   SetWindowRgn   Lib   "user32"   (ByVal   hwnd   As   Long,   ByVal   hRgn   As   Long,   ByVal   bRedraw   As   Long)   As   Long  
  Public   Declare   Function   DeleteObject   Lib   "gdi32"   (ByVal   hObject   As   Long)   As   Long  
   
 


 ·求助: 啊, 在线等    »显示摘要«
    摘要: 公司有一台机子以前安装winxp,但是不能网报税.我就从光盘安装了win2000,问题就出现了:现在winxp不能启动.有什么办法让winxp启动. ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE