Post by Nicky Peter Hollyoake on Feb 9, 2009 16:25:21 GMT -5
Heres another tutorial which I'm gonna find interesting to see what people can make of it. Before you read this tutorial you might wanna read my other tutorials to understand the basics of creating plugins for Basic4GL.
* Beginners tutorial
* OpenGL plugin tutorial
Now if you're wondering what I'm on about by accessing Basic4GL window, I mean we can change stuff like the position of the window, change title, size, etc. Just carry on reading to learn how to!
Now first of all, include the "windows.h" at the top after where it says "#define WIN32_LEAN_AND_MEAN".
Just after the window include file put "HWND hWin;"
Now near the bottom where it says "bool DLLFUNC Plugin::Start() {" in there before the "return 1" put this ...
Now this is basicailly a hack to get through to Basic4GL's window. Now you can start creating functions to mess about with it! Heres a fully functional code.
Now if you learn the windows library enough you can even make a system tray icon to minimize the window into it.
Remember if you ain't read my last tutorials and have no idea what I'm talking about read them.
(tell me if any problems)
- Nicky
* Beginners tutorial
* OpenGL plugin tutorial
Now if you're wondering what I'm on about by accessing Basic4GL window, I mean we can change stuff like the position of the window, change title, size, etc. Just carry on reading to learn how to!
Now first of all, include the "windows.h" at the top after where it says "#define WIN32_LEAN_AND_MEAN".
Just after the window include file put "HWND hWin;"
Now near the bottom where it says "bool DLLFUNC Plugin::Start() {" in there before the "return 1" put this ...
hWin = FindWindow(NULL, "Basic4GL");
Now this is basicailly a hack to get through to Basic4GL's window. Now you can start creating functions to mess about with it! Heres a fully functional code.
/* Example DLL project.
Created by: Thomas Mulgrew (tmulgrew@slingshot.co.nz)
This project will build a simple DLL that can be plugged into Basic4GL.
It contains one library function for example purposes.
I recommend using this as a template for creating Basic4GL plugin DLLs.
*/
///////////////////////////////////////////////////////////////////////////////
// Includes
// At the very least, Basic4GLDLLInterface.h must be included.
// Add any other include files here.
#include "Basic4GLDLLInterface.h"
// This example uses the windows MessageBox function, so we include the windows
// header.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
HWND hWin;
///////////////////////////////////////////////////////////////////////////////
// Constants
//
// Update these to describe your DLL.
const char *DESCRIPTION = "Easy 3D Program"; // This is displayed in the "Plug-in Chooser" in Basic4GL
const int VERSION_MAJOR = 1; // Major version number
const int VERSION_MINOR = 0; // Minor version number
///////////////////////////////////////////////////////////////////////////////
// Plugin
//
/// Main object representing the plugin to Basic4GL.
/// Basic4GL will access this through the IDLL_Plugin interface.
class Plugin : public IDLL_Basic4GL_Plugin {
public:
Plugin() { ; }
virtual bool DLLFUNC Load(IDLL_Basic4GL_FunctionRegistry ®istry, bool isStandaloneExe);
virtual bool DLLFUNC Start();
virtual void DLLFUNC End();
virtual void DLLFUNC Unload();
virtual void DLLFUNC GetError(char *error);
virtual void DLLFUNC Pause();
virtual void DLLFUNC Resume();
virtual void DLLFUNC DelayedResume();
virtual void DLLFUNC ProcessMessages();
};
///////////////////////////////////////////////////////////////////////////////
// DLL exported functions
extern "C" {
/// Query function
DLLExport int DLLFUNC Basic4GL_Query(char *details, int *major, int *minor) {
int i;
for (i = 0; DESCRIPTION != 0; i++)
details = DESCRIPTION;
*major = VERSION_MAJOR;
*minor = VERSION_MINOR;
return BASIC4GL_DLL_VERSION;
}
/// Main initialisation function.
/// Here we will construct and return our plugin object
DLLExport IDLL_Basic4GL_Plugin *DLLFUNC Basic4GL_Init() {
// Construct and return our plugin object
return new Plugin();
}
}
///////////////////////////////////////////////////////////////////////////////
// Runtime functions
// These are the functions that Basic4GL calls
void DLLFUNC Func_HideWindow(IDLL_Basic4GL_Runtime &basic4gl)
{
ShowWindow(hWin, basic4gl.GetIntParam(1));
}
///////////////////////////////////////////////////////////////////////////////
// Plugin
bool DLLFUNC Plugin::Load(IDLL_Basic4GL_FunctionRegistry ®istry, bool isStandaloneExe) {
// Initialise DLL stuff
// Register shared interfaces
// Register runtime functions
registry.RegisterVoidFunction ("HideWindow", Func_HideWindow);
registry.AddParam (DLL_BASIC4GL_INT);
// Register constants
registry.RegisterIntConstant ("SW_HIDE", SW_HIDE);
registry.RegisterIntConstant ("SW_MAXIMIZE", SW_MAXIMIZE);
registry.RegisterIntConstant ("SW_MINIMIZE", SW_MINIMIZE);
return true;
}
void DLLFUNC Plugin::Unload() {
// DLL is about to unload.
// Any final cleanup code (closing files, releasing resources etc) would go here
// Delete this object. This is safe because Basic4GL will not access it again.
delete this;
}
bool DLLFUNC Plugin::Start() {
// Program is about to start.
// Any pre-start init code would go here.
hWin = FindWindow(NULL, "Basic4GL");
return true;
}
void DLLFUNC Plugin::End() {
// Program is about to end
// Any cleanup code would go here
}
void DLLFUNC Plugin::Pause() {
// Called when the program is paused (i.e. during debugging).
// A full screen window might hide itself here so that the user can see the
// Basic4GL edit window (and debug their program)
}
void DLLFUNC Plugin::Resume() {
// Called when the program is resumed (i.e. during debugging).
// This is also called when the user "steps"
}
void DLLFUNC Plugin::DelayedResume() {
// Called when the program is resumed for more than a short "step".
// This is where a fullscreen window would re-show itself (if it did so in ::Resume()
// we would get flickering when the user steps through the program)
}
void DLLFUNC Plugin::GetError(char *error) {
// We don't return errors, but if we did, we would strcpy them to *error here.
;
}
void DLLFUNC Plugin::ProcessMessages() {
// Called periodically (in practice, quite frequently).
// This would be a good place to process windows messages etc.
}
Now if you learn the windows library enough you can even make a system tray icon to minimize the window into it.
Remember if you ain't read my last tutorials and have no idea what I'm talking about read them.
(tell me if any problems)
- Nicky