Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » multiple windows

This thread is locked; no one can reply to it. rss feed Print
multiple windows
superstar4410
Member #926
January 2001
avatar

Ok, I am making a program that runs in 2 windows, When the main window is executed it calls(using the spawn function) the second program in another window.

The 2 programs actings as one interact through sending data through a file, now the heres the problem. Think of how winamp or music match jukebox works, the have like 2 windows running at once, but both are active at the same time, with me I have to click between windows to activate each one. Is there a solution to that (so both windows can be active at the same time)

thankss

Don't take yourself too seriously, but do take your responsibilities very seriously.

mEmO
Member #1,124
March 2001
avatar

Win32 or allegro? I don't think that there is a way to make two windows active in Win32 at the same time (If what you mean is that both of them should be "blue" at the same time). However, they will receive their messages nevertheless, so I don't really see the problem.

---------------------------------------------
There is only one God, and Connor is his son!
http://www.memocomputers.com
Happy birthday!

superstar4410
Member #926
January 2001
avatar

I mean allegro,

with the whole message thing, I'm NOT using win32 api message system. I'm using my own method through allegro to send data to a file, and both windows read from that file and communicate.

but heres the thing,i'm making my own video player to play special video files that I make(that are really datafiles with pictures in them).
One window is the video window(that plays the movie flie) and the second window has the controls, like play, stop, pause, etc.

When I run the video window is calls the control window and they both are on showing, but when I click on the control window the movie stops because that window becomes inactive and resume only after I click on it again.

you said that you didn't think it was possible? so how does winamp do it, like they have they playlist window, and the window that shows that file is playing (NO win32 api please).

Thanks

Don't take yourself too seriously, but do take your responsibilities very seriously.

KaBlammyman
Member #455
June 2000
avatar

When any program has more than 1 window at once, only 1 is active in any given point in time. They are just all showing at the same time. They dont stop showing their contents. However, they arnt "active". If winamp used a normal a "windows" window, only one window will be blue at the top. If you look at winamp with its base skin, you can see this, the top of the player will change color when you anrnt using the player window. Since they are always up, they both seem to active.

[edit] I was replying when you were, so I still thought you ment in windows...my fault.

->Insert clever quote here<-
http:my website

Ciro Duran
Member #3,011
December 2002
avatar

I don't know much of GUI programming... But you could give the "impression" that when you click of the windows both show up. When you click one window, bring the other window on the top first and then the one you clicked on. :P

---
El Ciro

In the beginning, God said "light_source { <0, 0, 0> color White }" and light was created.

superstar4410
Member #926
January 2001
avatar

Ok, I understand that, but how about the programs that have 2 windows up and both are only represented by one window on the task bar.

Its like the one program is separating itself into 2 windows. This example that i'm taking about is a program that isn't running in the default windows window, but its own custom window that usually dosent have the default (minimize, expand, and close) buttons at the top right corner

Don't take yourself too seriously, but do take your responsibilities very seriously.

Korval
Member #1,538
September 2001
avatar

Quote:

NO win32 api please

Then you don't get an answer.

Allegro is, primarily, a game library. It's interface to the GUI is precisely enough to get a game up and running, and nothing more than that.

If you want to do something like what you're wanting to do, you're going to have to talk to the GUI directly. That's simply the nature of the beast.

superstar4410
Member #926
January 2001
avatar

can that be done with

including winalleg
and not having to do all that

windows handling, hwnd.blahh

code

thanks

Don't take yourself too seriously, but do take your responsibilities very seriously.

Thomas Fjellstrom
Member #476
June 2000
avatar

Well, you can still use allegro to create your main window etc.. but for changing window properties etc.. you'll still need to use some Win32 code.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Dexter Tad-y
Member #2,930
November 2002
avatar

just a suggestion: Why not deal with only ONE(1) window instead of having to deal with multiple windows. Split your main window (in allegro) into several parts as you wish. Although you will lose the flexibility of multiple windows here (movable, etc).

___________________________________
Always listen to experts. They'll tell you what can't be done, and why. Then do it.
- Murphy's Laws

superstar4410
Member #926
January 2001
avatar

are there any good tutorials out their for integrating Win32 with allegro.

Like having the advantages of the win32 windows
but the ease of allegro graphic functions, like blitting, and datafiles,

Thankss

Don't take yourself too seriously, but do take your responsibilities very seriously.

mEmO
Member #1,124
March 2001
avatar

Quote:

Ok, I understand that, but how about the programs that have 2 windows up and both are only represented by one window on the task bar.

They make use of child windows and dialogs. You should really read up on Win32. The forgers win32 programming tutorial is really good, and should get you started. Eventually, I recommend you to buy Programming Windows fifth edition by Charlez Petzholds. The best Win32 programming book! (Well, I have only read that one, but everyone else says so ;D)

---------------------------------------------
There is only one God, and Connor is his son!
http://www.memocomputers.com
Happy birthday!

Catalin
Member #1,485
August 2001
avatar

your problem has to do with set_display_switch_mode. AFAIK when a windowed allegro program looses focus, it pauses. You cannot change the display switch mode for windowed programs (at least not on my computer). I think it's a directx issue, but i'm not sure.
You could change focus really fast between your windows, but that's not really a solution.

spellcaster
Member #1,493
September 2001
avatar

superstar, in order to get two windows, you need to manage two windows.
At the moment, allegro supports only one window. That means if you want a 2nd one, you have to manage it yourself.

That means you'll need to use the in32 API in one way, or the other. There's no "easy way" to avoid that.

If you don't want to learn / use the win32 API, you're out of luck and can't use a 2nd window, then.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

A J
Member #3,025
December 2002
avatar

allrgro function set_display_switch_mode()
its in the docs.

___________________________
The more you talk, the more AJ is right. - ML

Dark
Member #749
November 2000
avatar

why not just use something like the spacebar to pop the controls up over the video, then press space again to hide them?

__________________________________
Posting from outside Spellcaster's window...

A J
Member #3,025
December 2002
avatar

have one window.
then spam the desktop using blit_to_hdc( ... );
use the hdc for the windows desktop.
use a win32 api function to get the windows desktops hdc.

or

launch another window that does nothing.
then get its hdc (use the win32 api function to get the hdc of that other window)
then blit_to_hdc()

or

write a win32 app.

or

use one window, make it full screen
then, just before the window is activated (using set_gfx_mode)
copy the windows hdc to a bitmap.
then go allegro full screen
blit that bitmap to the full screen.
it will look like the windows desktop.
then just draw your own windows on top of that !

___________________________
The more you talk, the more AJ is right. - ML

spellcaster
Member #1,493
September 2001
avatar

Hm... blitting directly to the screen is a nice idea. But... it won't do the trick. Same with hijacking another windows hdc. Reason for this is mainly the fact that he won't be able to process anything that's happening that area.
If he's blitting to the screen, he might click on something that is on the desktop (or on a control of another program at this position). I t will also lead to redraw problems.

Using a single fullscreen window will work. But it's a fake. If he wanted to run fullscreen, he would use a fullscreen app and use internal windows for that stuff.
Since he runs windowed, I guess there's a reason for this (like being able to run nicely together with other apps, or simulate a "normal" win32 app).

Quote:

use one window, make it full screen
then, just before the window is activated (using set_gfx_mode)

The idea is good, but he needs to grab the dektop before he calls allegro_init and set_gfx_mode().
Setting the mode will destroy the desktop content.

While that's not hard (check the lexEyes source for an example) it requires win32 API calls. Which he wants to avoid.

I'd guess he wants to simulate a normal win app, without learning the win32 API. That will not work properly, sincy he'd have to simulate a lot of windows behavior by hand. It might be better to go his own way, so the user doesn't expect windows functionality in the frist place.

But, in the long run, learning win32 wil be worth it.. so why not start today?

--
There are no stupid questions, but there are a lot of inquisitive idiots.

A J
Member #3,025
December 2002
avatar

seriously win32 api is not that hard.
the basics id say are easier than allegro.

gettings some data out of the system, or settings same stuff is often one function call.
and its as easy as just adding a header file to the top of the 'c' file that uses the win32 call.

try this:

int main(void)
{
allegro_init();
MessageBox(win_get_window(), "msg", "title", MB_OK );
}

there you have it, a win32 call... how easy !
if you dont want to use allegro in the above example...

try this:

int main(void)
{
MessageBox( NULL, "msg", "title", MB_OK );
}

___________________________
The more you talk, the more AJ is right. - ML

superstar4410
Member #926
January 2001
avatar

the problem with me and the winapi
is that its so confusing.

I tried to learn it and quit like 3 different times.

Plus it just seems like it has soo much extra overhead. With allegro I can do things so much easier and with way less lines of code.

With the winapi its like 70 lines just to get a window open, and the who resource bit, and having to declare menu items and all that, and all the classes.

I'll just use one window like the win media player on xp.

Plus I have heard that there are alternatives to the win 32api.

Well i'm a computer science Minor at college, and next semester i'm taking this really good computer course and I'll see if they teach the win32 api and talk with my professor about all the little details.

Thanks for all the suggestions.

Don't take yourself too seriously, but do take your responsibilities very seriously.

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

seriously win32 api is not that hard.
the basics id say are easier than allegro.

You, sir, are on crack :P

I wrote a little example of getting Allegro and Win32 to work together. So now all you need to do is learn a little Win32 to run a second window. See mEmO's last post; Petzold rocks 8-). Allegro will run slower in a window than fullscreen though; no question.

Though if one were very 1337, I would bet you could put the main game window into fullscreen using ChangeDisplaySettings() and then running a smaller window over that. But I've never tried that.

Win32 is not too hard, though it can be cumbersome. Never tried any alternatives though. Isn't this that "console" thing everyone loves so much? You could create a simple GUI window using Allegro or something, no?

Just rambling ...

EDIT: Hey, I just noticed

that ss4410 is using paragraphs! :o

When did he start
doing that?

;D

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Wer fu
Member #1,084
March 2001
avatar

Why not use 3 thread? One for each window (GUI operation and verification) and an other for the core of the program.

ICQ:71667703 or Email&MSN: werfu_dx@yahoo.fr
Werfu was here

A J
Member #3,025
December 2002
avatar

threads are not the issue...
the issue is about getting multi-windows..

heres another idea...

have 2 seperate programs... both use allegro for drawing etc... both are stand alone allegro programs.

BUT, one launches the other.
then communicate between them using
win32::SendMessage( WM_COPYDATA, ... );

sorted 8-)

___________________________
The more you talk, the more AJ is right. - ML

Thomas Fjellstrom
Member #476
June 2000
avatar

Or you could use shared memory... Or a pipe.. Or a socket... etc...

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

A J
Member #3,025
December 2002
avatar

i was trying to offer the simplest method, as someones afraid of win32, and needs to be shown the light :)

i would bet that win32::SendMessage(WM_COPYDATA,...) is the simplest, and yes i know its not portable, but really what (useful warez) is these days anyway.

___________________________
The more you talk, the more AJ is right. - ML

Go to: