Using Phoenix, a Windows.Forms problem

pseud0

Newcomer
Joined
Mar 16, 2004
Messages
2
First off: Wow! This is really cool. You the man Wyrd! Exactly what one need to just fire away with a new project.

Well, as an esteemed n00bie, I naturally ran my head in the wall.

Is it possible to utilize Phoenix in an application that has a Windows.Form as the main entrypoint?

I tried to change the "main" in your example into a constructor that takes the form as an argument. And then set the variables for that form. But on execution the application doesn't appear at all.

I want to use the Form application as the main entrypoint in order to utilize windows graphical components such as MessageBox and different dialogs.

My application basically has a map layer with objects bound to it. By clicking an object I want a windows gui dialog to appear with object information (house, intersection, water, blah blah). But I still want to use DirectDraw for drawing the map. (am I making any sense here???)

Code example:
Code:
public Form1 () {
[indent]InitializeComponent();
Map m = new Map(this);
[/indent]
}

... and in Map:
Map(Form window)  {
[indent]
window.WindowState = FormWindowState.Maximized;
window.FormBorderStyle = FormBorderStyle.None;
window.Show();

// Start the game.
this.Start(window);
//Cleanup.
this.Dispose();
[/indent]}

In the example above the application just fails.
And if I set the Game (ie: Map-class) as the startup project then for some reason I cant use MessageBox() since:
'System.Windows.Forms.MessageBox' denotes a 'class' which is not valid in the given context

I'm so sorry for all the trouble, I wish I wasn't such a newbie. :(
 
It looks like you're running the game from a constructor. That's bad, since the game is an infinite loop, thus the class is never fully created. What you need to do is rig the form so it shows some sort of splash screen, then when the user clicks it (or you can setup a timer), the game will begin to run.
 
BTW, if all you want to do is draw the map with DirectDraw, and nothing else, then you don't have to inherit the GameBase class. The GameBase is ment for actual games. Just create an instance of the Display class and pass in your form as the window. You can then access the Display's Backbuffer property and draw directly to it. When you're done drawing, call the Flip() method, and the graphics will appear on your form.

Unfortunately I don't have any sample code to show you this (other than what I already showed), and probably won't until I get the design somewhat finalized. I don't want to write up a bunch of samples only to have them not work in the next version. What you can do though, is look at the source for GameBase and see how it uses the Display class.
 
Back
Top