Window creation: Difference between revisions
Content deleted Content added
Line 5: | Line 5: | ||
Using SDL: |
Using SDL: |
||
/* |
|||
* Opens an 800x600 16bit color window. |
* Opens an 800x600 16bit color window. |
||
* Done here with ANSI C. |
* Done here with ANSI C. |
||
* |
*/ |
||
⚫ | |||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include "SDL/SDL.h" |
|||
⚫ | |||
main(){ |
|||
SDL_Surface *screen; |
|||
if (SDL_Init(SDL_INIT_VIDEO) != 0) { |
|||
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); |
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); |
||
return(1); |
return(1); |
||
} |
|||
atexit(SDL_Quit); |
|||
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE ); |
|||
} |
|||
==[[mIRC]]== |
==[[mIRC]]== |
Revision as of 20:41, 21 January 2007
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
ANSI C
Using SDL:
/* * Opens an 800x600 16bit color window. * Done here with ANSI C. */ #include <stdio.h> #include <stdlib.h> #include "SDL/SDL.h" main(){ SDL_Surface *screen; if (SDL_Init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); return(1); } atexit(SDL_Quit); screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE ); }
mIRC
Compiler: mIRC
Switches: C = Center Window p = Picture Window d = Desktop Window
alias CreateMyWindow { .window -Cp +d @WindowName 600 480 }
Python
Interpreter: Python 2.4, 2.5
Using Tkinter:
import tkinter w = tkinter.Tk() w.mainloop()
Using wxPython:
from wxPython.wx import * class MyApp(wxApp): def OnInit(self): frame = wxFrame(NULL, -1, "Hello from wxPython") frame.Show(true) self.SetTopWindow(frame) return true app = MyApp(0) app.MainLoop()
Using Pythonwin:
import win32ui from pywin.mfc.dialog import Dialog d = Dialog(win32ui.IDD_SIMPLE_INPUT) d.CreateWindow()
Using PyGTK:
import gtk window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.show() gtk.main()
Ruby
Interpreter: Ruby 1.8.5
Using Tk:
require 'tk' window = TkRoot::new() window::mainloop()
Using GTK:
require 'gtk2' window = Gtk::Window.new.show Gtk.main
RapidQ
create form as qform center width=500 height=400 end create form.showModal
VB.NET
Using .Net Framework:
Dim newForm as new Form newForm.Text = "It's a new windows" newForm.Show()