| 
 
| 赞 | 0 |  
| VIP | 0 |  
| 好人卡 | 15 |  
| 积分 | 1 |  
| 经验 | 5333 |  
| 最后登录 | 2022-5-25 |  
| 在线时间 | 66 小时 |  
 Lv1.梦旅人 
	梦石0 星屑60 在线时间66 小时注册时间2011-5-25帖子73 | 
| 
本帖最后由 shoed 于 2011-8-30 22:25 编辑
x
加入我们,或者,欢迎回来。您需要 登录 才可以下载或查看,没有帐号?注册会员  
 我们见过的窗体一般是一个四四方方的,很有规矩的。
 现在网游以及很多软件的窗口外观都不是规规矩矩的,让人感觉很有个性,
 如果我们也能将RMXP中的窗口做成富有个性的外观,那不是一件很有趣的事吗,
 其实这个窗体就是--图片窗体,可能大家还不太明白我说的是什么,那先上张图吧:
 
 这是一款网游的登陆界面
 
   
 这种窗体看上去多有趣啊,因此本人也仿造这个窗口,给我们的RMXP的窗口也加点料吧
 这是我做好的效果图:
 
   注意到上面的3个数字吗
 你可以用鼠标试着点点,本人改变的是scene_title
 
 主要的核心脚本:
 复制代码
#--------------------------------------------------------------------------
# ● 特效窗体
# 制作者  小飞侠_shoed
#---------------------------------------------------------------------------
module Screen
  #背景图,与窗口的大小相同
  MASK_WIDTH = 459
  MASK_HEIGHT = 329
  
  IMAGE_BITMAP = 0
  LR_LOADFROMFILE = 0x0010
  LR_CREATEDIBSECTION = 0x2000
  VBBLACK = 0x0
  VBWHITE = 0xffffff
  RGN_AND = 1
  RGN_OR = 2
  RGN_XOR = 3
  
  GWL_STYLE      = (-16)             #窗口样式
  GWL_WNDPROC    = (-4)
  WS_POPUP       = 0x80000000   #弹出式窗口
  WS_MAXIMIZEBOX = 0x00010000
  WS_MINIMIZEBOX = 0x00020000
  WS_CAPTION     = 0x00C00000
  WS_BORDER      = 0x00800000
  WS_DLGFRAME    = 0x00400000
  
  WM_SYSCOMMAND = 0x0112
  SC_MINIMIZE = 0xF020
  WM_CLOSE = 0x0010
  
  @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
  @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l' 
  @getWindowRect=Win32API.new 'user32', 'GetWindowRect', %w(l p), 'l'
  @loadImage=Win32API.new 'user32', 'LoadImageA', %w(l p l l l l), 'l'
  
  
  @createCompatibleDC=Win32API.new 'gdi32', 'CreateCompatibleDC', %w(l), 'l'
  
  #@createCompatibleBitmap=Win32API.new 'gdi32', 'CreateCompatibleBitmap', %w(l l l), 'l'
  #@stretchBlt=Win32API.new 'gdi32', 'StretchBlt', %w(l l l l l l l l l l l), 'l'
 
  @selectObject=Win32API.new 'gdi32', 'SelectObject', %w(l l), 'l'
  @getPixel=Win32API.new 'gdi32', 'GetPixel', %w(l l l), 'l'
  
  @createRectRgn=Win32API.new 'gdi32', 'CreateRectRgn', %w(l l l l), 'l'
  @setWindowRgn=Win32API.new 'user32', 'SetWindowRgn', %w(l l i), 'l'
  @combineRgn=Win32API.new 'gdi32', 'CombineRgn', %w(l l l l), 'l'
  
  @deleteDC=Win32API.new 'gdi32', 'DeleteDC', %w(l), 'l'
  @deleteObject=Win32API.new 'gdi32', 'DeleteObject', %w(l), 'l'
  @getWindowLong=Win32API.new 'user32', 'GetWindowLongA', %w(l l), 'l'
  @setWindowLong=Win32API.new 'user32', 'SetWindowLongA', %w(l l l), 'l'
  @moveWindow=Win32API.new 'user32', 'MoveWindow', %w(l l l l l l), 'l'
 
  #@defWindowProc=Win32API.new 'user32', 'DefWindowProcA', %w(l l l l), 'l'
  #@callWindowProc=Win32API.new 'user32', 'CallWindowProcA', %w(l l l l l), 'l'
  
  @getCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  @screenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  @getKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  
  @sendMessage = Win32API.new("user32", "SendMessageA", 'l l l l', 'l')
  
  module_function
  
  def shape_window
    @hwnd=handel
    
    #原始窗口
    rect=" "*16
    @getWindowRect.call(@hwnd,rect)
    left,top,right,bottom=rect.unpack("llll")
    @x=left
    @y=top
    @width=right-left
    @height=bottom-top
    
    
    lStyle = @getWindowLong.call(@hwnd, GWL_STYLE)
    lStyle = lStyle & ~WS_CAPTION
    
    #@setWindowLong.call(@hwnd, GWL_WNDPROC, WindowProc)
    @setWindowLong.call(@hwnd, GWL_STYLE, lStyle)
    
    
    @moveWindow.call(@hwnd, @x,@y,MASK_WIDTH,MASK_HEIGHT,1);
    
    
    hBitmap = @loadImage.call(0, ".\\Graphics\\Pictures\\window.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
    backDC = @createCompatibleDC.call(0)
    @selectObject.call(backDC, hBitmap)
    
    hRgn  = @createRectRgn.call(0, 0, MASK_WIDTH, MASK_HEIGHT)
   
    for j in 0...MASK_HEIGHT
      for i in 0...MASK_WIDTH
        #主要是加快程序的速度,图片不是白色的大概区域
        if j>=80 and j<=300 and i>=15 and i<=400
          next
        end
        tcolor = @getPixel.call(backDC, i, j)
        if tcolor==VBWHITE then
          hTempRgn = @createRectRgn.call(i, j, i + 1, j + 1)
          @combineRgn.call(hRgn,hRgn,hTempRgn,RGN_XOR)
          @deleteObject.call(hTempRgn)
        end
      end
    end
    
    @setWindowRgn.call(@hwnd, hRgn, 1)
    
    @deleteObject.call(hBitmap)
    @deleteDC.call(backDC)
    #@deleteObject.call(hRgn)
    
  end
  def recovery_window
    lStyle = @getWindowLong.call(@hwnd, GWL_STYLE)
    lStyle = lStyle | WS_CAPTION
    @setWindowLong.call(@hwnd, GWL_STYLE, lStyle)
    @moveWindow.call(@hwnd, @x,@y,@width,@height,1);
  end
  def get_mouse_pos
   point_var = [0, 0].pack('ll')
   if @getCursorPos.call(point_var) != 0
     if @screenToClient.call(@hwnd, point_var) != 0
       x, y = point_var.unpack('ll')
       if (x < 0) or (x > 10000) then x = 0 end
       if (y < 0) or (y > 10000) then y = 0 end
       if x > 640 then x = 640 end
       if y > 480 then y = 480 end
       return x, y
     else
       return 0, 0
     end
   else
     return 0, 0
   end
 end
 
  def mouse_press?
    left_down = @getKeyState.call(0x01)
    return left_down[7]
  end
  
  def min_window
    @sendMessage.call(@hwnd,WM_SYSCOMMAND,SC_MINIMIZE,0)
  end
  
  def close_window
    @sendMessage.call(@hwnd,WM_CLOSE,0,0)
  end
  
   # find the game window...
  def handel
    game_name = "\0" * 256
    @readini.call('Game','Title','',game_name,255,".\\Game.ini")
    game_name.delete!("\0")
    return @findwindow.call('RGSS Player',game_name)
  end
  
  #def WindowProc
  #
  #end
 
end
  
 我的图片都存在pictures中
 
 工程:
 
  特效窗体外观.rar
(545.85 KB, 下载次数: 1128) 
 | 
 评分
查看全部评分
 |