Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Manipulating a Real Window - Can it be done in RPGXP?

Good day again everybody!

If anybody remembers, I started a serial script a long while back, which I got bored with and never finished. But there is one thing I've always wanted to do with the script, and that was use actual "Windows" windows for serial key prompt and all that fun stuff.

Y'know how when you use a 'p' or 'print' command, how it'll print your message with a real Window and not a game RGSS window? Or, even when you're editing the database, again how you're using a real window? That's actually what I'm talking about when referring to a "window".

Is there a way to manipulate a Window to have text fields for a player to fill information in? Just to keep it professional, this is what I want player to fill their activation codes in with, instead of a Game window.

Also, on an optional side note, is there a way to manipulate font type/size with the window as well as the demensions? That isn't as important as what I'm asking above, but it would definately be a plus. Thanks to anybody who can help me.

Lastly, I'm asking this for RPGXP if that is of any importance. Thanks to anybody who can help me.
 
I've already seen something like this on a Japanese site but don't remember where.
They were using a Win32API to do that and they had a couple of methods to get back the information on the user input. I don't think you'll be able to change the font though.

I'll try to find it again.
 
I highly doubt it will interfere with his script, I'm sure it won't.
I didn't exactly found what I was talking about but here's what I have.
Code:
# MultiByteToWideChar/WideCharToMultiByteã
 
I mean...

Code:
class Win32API
  GAME_INI_FILE = ".\\Game.ini"
  
  def Win32API.GetPrivateProfileString(section, key)
    val = "\0"*256
    gps = Win32API.new('kernel32', 'GetPrivateProfileString',%w(p p p p l p), 'l')
    gps.call(section, key, "", val, 256, GAME_INI_FILE)
    val.delete!("\0")
    return val
  end

  def Win32API.FindWindow(class_name, title)
    fw = Win32API.new('user32', 'FindWindow', %(p, p), 'i')
    hWnd = fw.call(class_name, title)
    return hWnd
  end

  HWND_TOP     = 0
  HWND_TOPMOST = -1
  SWP_NOMOVE   = 2
  
  def Win32API.SetWindowPos(hWnd, w, h)
    swp = Win32API.new('user32', 'SetWindowPos', %(l, l, i, i, i, i, i), 'i')
    ok = swp.call(hWnd, HWND_TOP, 0, 0, w, h, SWP_NOMOVE)
    # ‰º‚ÌÂ
 
There is a good API for making popups windows, like p, but with more options, like OK, Cancel, Yes, No buttons; or alert, warning and error icons; or changing the window title. The problem is that if it is for XP, the game will hang up if the window isn't closed within aprox. 8 sec., but in VX it works well because it doens't have the shitty hang up "protection" from XP.
Example of the API:
Code:
mb = Win32API.new('user32', 'MessageBox', 'ippi', 'i')
result = mb.call(0, "Are you sure?", 'Confirm', 36) != 7
This will bring up a window with Yes, No buttons, and store TRUE in result if the user press the yes button.

However, I know there are some APIs for creating windows, and objects in windows, but they are a bit complicated and I don't know if they work for RM.
 
rescue is a nice keyword :)
Code:
mb = Win32API.new('user32', 'MessageBox', 'ippi', 'i')
begin
  result = mb.call(0, "Are you sure?", 'Confirm', 36) != 7
  result
rescue Hangup
  result
end

With "pure" Ruby and Shoes (edit: http://shoooes.net/ ... not shoes :D), GTK, Fox or Tk it is possible but with the RGSS most of such Ruby extensions don't work so I think writing a program with another programming language is a better solution instead of using Win32API objects. You write some encrypted data in a file with the program and read and decrypt it with Ruby. But when vgvgf's known APIs work you can choose them.
 
Dargor":d46mcf0t said:
That's really nice and very good to know.
Maybe you can overcome the XP Hangup exception by using Zeriab's no hangup script?
ERZENGEL":d46mcf0t said:
rescue is a nice keyword :)
Code:
mb = Win32API.new('user32', 'MessageBox', 'ippi', 'i')
begin
  result = mb.call(0, "Are you sure?", 'Confirm', 36) != 7
  result
rescue Hangup
  result
end
Wow, I didn't know that, thanks! That will come in handy. I thought Hangup was an unavoidable error.
 
you can do pretty much any kind of window using the Win32API, but it's a little complicated using Ruby's limited dll capabilities. so if you want I could make you a dll that shows the window for you. :thumb:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top