Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / [Example] Using DarkGDK in an MDI window

Author
Message
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 22nd Jun 2009 06:44 Edited at: 22nd Jun 2009 06:47
I have been playing around with the windows API recently with the intention of using it as the GUI for some tools that I am building for use with DarkGDK.

The thought struck me, that wouldnt it be cool, if we could put the DarkGDK window, in a child window of it's main window, kind of like a preview window or the "3d view" in application like 3ds max.

So I started looking around at tutorials and code examples of using the Multiple Document Interface and modal/modeless dialogs.
While I was able to find a heap of information about MDI's on their own, and creating the client and children etc, I couldnt find anything about how to use GDK in such a way.. so I had to experiment with various commands and functions until I figured it out.

Anyway, I went through both Sephnroth's and theForger's tutorials for the WinAPI, and most of this code is built ontop of theirs, and its also not optimized at all but thats not important for the purpose of an example.

The code contains 2 modal dialogs, 1 modeless dialog, an MDI client window and MDI child windows that are generated during run-time, and also windows forms controls that are generated at runtime.
(The difference between modal and modeless dialogs is that a modal dialog takes control away from the parent window while its open, much like an "About Box" window in something like Visual Studio, and all messages are handled by the dialog, which has its own built in handler, whereas a "Modeless" dialog box will not take away control from the main window, and also has no built in message handler.)

Usage of the EXE :
Double-click to open..
pressing <space> will open the "Test Dialog" - you can enter data and check the box in that dialog, it will remember what you have entered when it is opened and closed(although it wont remeber more than 10 digits in the lower box) and if its checkbox was ticked or not.
The menu across the top of the app is self-explanatory, File, Edit, Window, Dialog, Misc.

File : open, close, save and exit the app, all working
Edit : Copy, Paste, Cut - all working inside the edit windows
Window : Tile, Cascade - all working
Dialog - Hide, Show - all working
Misc - Ticked, About, Test Dialog - all working

Escape will exit the app if the main window has focus.

The attachment has everything you need to compile the code example, all resources are included as are the .RC and resource.h files.

To compile it, start a new "DarkGDK - Game" project inside Visual Studio. Copy the contents of the ZIP file to the project's folder, overwriting main.cpp.

add "main.h" to the project with by right clicking on the project name and selecting "Add Existing Item".

The resources should be found automatically as they are included in the headers.

Here is a copy/paste of the Main.cpp code - be warned, its long and procedural




Here are some screenies of the app running :

Normal Startup look :


Modal dialog open :


Modeless dialog open :


Multiple Document Interface - editor windows with GDK window :


The attachment is in ZIP format, about 560k packed

If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 22nd Jun 2009 12:25
Great contribution! Outstanding
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 22nd Jun 2009 17:07
These are the kind of things I wish were easier to find when we need them.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 22nd Jun 2009 19:28
The DarkShader editor uses this same technique, I believe.

prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 22nd Jun 2009 22:51
I wish I had seen this before. It is DAMN useful. Cheers


Your signature has been erased by a mod
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 26th Jun 2009 19:29
Very cool! I have one question though. I keep getting this error
Quote: "1>------ Build started: Project: GDK Level Editor, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>c:\program files\microsoft directx sdk (august 2007)\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
1>Linking...
1>LINK : Debug\GDK Level Editor.exe not found or not built by the last incremental link; performing full link
1>Main.obj : error LNK2019: unresolved external symbol __imp__InitCommonControls@0 referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
1>Debug\GDK Level Editor.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\GDK Level Editor\GDK Level Editor\Debug\BuildLog.htm"
1>GDK Level Editor - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========="

All I did was copy and paste the code


wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 26th Jun 2009 20:35
Woah, i can see this making your own little "WYSIWYG" game editor

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Jun 2009 04:14
@heyufool1 - you need to include comctl32.lib - its the library that contains the common controls for the toolbar and MDI stuff, cant generate some of the MDI controlls and runtime controls without that library included, just add it to linker->input->additional dependancies.

Also please note that the Example is only that, its not a stable debugged application, and I can crash it in about 3 secs if I try lol... Its only meant to demonstrate a concept, if you wanted to use this technique then it would need to be coded properly, with all events caught and any possible errors handled. As it is there is no limit to the things you can do, and no error catching except as the most basic level to get it running, there is a surface "under" the GDK surface that you can notice when resizing the GDK window - some of the re-draw of windows and the GDK window arent handled properly and the overlapping of some is quite ugly, little things like that would be removed in a real world app..

If it ain't broke.... DONT FIX IT !!!

Login to post a reply

Server time is: 2024-10-01 06:06:23
Your offset time is: 2024-10-01 06:06:23