|
[MASkinG] Nasty dummyDlg |
mail frank
Member #6,213
September 2005
|
I'm writing a simple desktop game which is a windowed application. I tried openlayer first. It's greate library but it lacks the basic GUI elements. So I shift to MASkinG which can support skin and GUI. Since it supports skin, the MAS::Window has it's own title bar, close button etc, so I mangaged to remove the title bar of Windows. Here is what I did: 1. Create window by Win32 api to set the style to POPUP Everything seems fine, I can move, resize and close window by MASkinG's title bar, except that there is nasty black box behind my window and I can't move around my MASkinG window on whole desktop. I can only move it inside the rectangle which occupied by my MASkinG window. I look into the source code of MASkinG, it seems that a DummyDlg will be created when I call Popup(NULL). This DummyDlg will be the same size of the window and its background is black. My question is that is there a way to move my window like a real windows application? Please refer to my souce code:
|
miran
Member #2,407
June 2002
|
I thought about trying that a while ago but never got round to it. The way I would go about it would be to make the Window occupy the whole screen and make it unmovable (clear some flag, D_MOVABLE or something, I don't remember, check the docs). Then in some way handle the mouse movement when the left mouse button is pressed and the title bar has focus and run the Win32 API code that moves your hwnd instead of the MASkinG window. I have close to zero experience with Win32 API, so I can't help you much there, but I did once make an Allegro app with a custom window with no title bar and all that. I didn't implement moving the window and the app didn't use MASkinG though... Another thing you should know about is that if the skin you use has transparent parts in the window bitmaps (like rounded corners), those won't actually be transparent, but black... EDIT:
-- |
mail frank
Member #6,213
September 2005
|
I've tried win32 api MoveWindow() to move the windows. But there are two problems. First, the black box behind my window doesn't move the same way as my window. Second, it's flickering. I'm just wondering why there are two windows created? Why there is a need to create a DummyDlg? |
miran
Member #2,407
June 2002
|
Quote: Why there is a need to create a DummyDlg? Because of the way MASkinG is made. The main loop is in the Dialog::Execute() method and a popup window needs a parent dialog that owns this main loop. So if you popup a Window without a parent dialog, a dummy one has to be created. See my edit above for a suggestion about how you could handle moving the hwnd window. Put MoveWindow() in place of where I print the move distance to a label in the example... EDIT: Quote: This DummyDlg will be the same size of the window and its background is black. Hmmm, this should at least have to be possible to turn off. Actually the dummy dialog's backround isn't black, it's a copy of the screen before you call your window's Popup(), which in your case is in fact black. This makes sure that if the window is smaller than the screen, it doesn't leave "droppings" behind when it's moved, but I can easily imagine situations where you'd want to update the background anyway, so the background would just be in the way... EDIT2:
Notice the WM_NCHITTEST case in the WndProc callback. All you need to do is return HTCAPTION caption on that message when you want to move the window. Also in the MASkinG window I check on every MouseMove if the mouse is over the title bar area and that's all there is to it. As far as I can see this works, but of course transparent areas in the window (like rounded corners in some skins) are black but I don't think you can fix that easily (let me know if you know how that can be done). Also MASkinG's mouse cursor and the system mouse cursor are not the same. This could probably be fixed by making MASkinG use the hardware cursor... -- |
mail frank
Member #6,213
September 2005
|
Great! I'll try it. I've tried your first source code. The window is still a bit flickering. So I modified your code. To notify my application when I detect mouse release. The flickering disapeared but I can only move the window a little bit even I mouse the mouse a lot. Here is my code:
Are you the one who wrote MASkinG? If yes, I have to say you've done a great job. But I'm very curious is it possible to integrate Openlayer with MASkinG? I tried but failed and I don't have enough time and knowledge to do so. Anyway I'll try your second code and thank you so much. |
miran
Member #2,407
June 2002
|
Quote: Are you the one who wrote MASkinG? Yes. Quote: If yes, I have to say you've done a great job. Thank you. Quote: But I'm very curious is it possible to integrate Openlayer with MASkinG? I don't know, I haven't tried. It probably won't be easy even if it is possible, but I am working on making it possible to do that. But you can already use MASkinG with AllegroGL Quote: Anyway I'll try your second code and thank you so much. Yeah, the first piece of code I posted doesn't really do much in the right direction. The second piece though works perfectly. And it's only a few lines of code too. -- |
mail frank
Member #6,213
September 2005
|
Thanks for your advice. You second edition is working perfectly. Now I can move the MASkinG window like a normal appliation without the window's title bar. I had another question. How can I resize the MASkinG window afterwards? For example, I set the resolution to 160x560, after I press a buttion, the window should become 800x560. If I call resize function of MAS::Window, the window size will be changed but I can only see part of it because the resolution is not changed. But if I call ChangeResolution, the whole window will become black and can't be used any more. My another option is to open another MAS::Window side by side with the first one after I press the button. I haven't tried this yet. But I don't know whether this is possible. |
miran
Member #2,407
June 2002
|
That's one of the bad things about Allegro. You're stuck with a fixed size window. I think there's a hack to make windows resizable somewhere around though. Search the forums or start a new thread asking "How to make Allegro window resizable" or something... -- |
mail frank
Member #6,213
September 2005
|
OK. I'll do that. Is it possible to make the DummyDlg's size equal to 0? Or in another word can I at least minimized window? |
miran
Member #2,407
June 2002
|
Minimizing the window is possible of course (through Win32 API I mean). But the MASkinG window doesn't have a minimize icon when it's not resizable (only exit). You could hack the window code to enable the icon (it's there, just disabled) or something... -- |
|