Okay, i've written an example of how to do what you want. Make a new DGDK project and paste this into main.cpp:
#include "DarkGDK.h" //standard header
#include "windows.h" //windows header containing winapi functions
#include "globstruct.h" //DGDK globstruct header containing the global variable struct
void DarkGDK(void) {
/* Standard DGDK setup plus disable window layout */
dbSyncOn();
dbSyncRate(60);
dbSetDisplayMode(800, 600, 32);
dbSetWindowLayout(0, 0, 0);
/* RECT type variable to hold data about your game window */
RECT rWindowRect;
/* Four variables for storing data about the mouse cursor, slightly more accurate than DGDK's dbMouseMove functions */
float MouseMoveX = 0.0f;
float MouseMoveY = 0.0f;
POINT WinMousePos;
POINT OldWinMousePos;
/* Boolean variable to store wether or not the user is trying to drag the window */
bool bDraggingWindow = false;
while (LoopGDK()) {
/* Clear the screen a dark greyish colour and draw a rectangle at the top of the screen to be your "drag bar" */
dbCLS(dbRgb(100, 100, 100));
dbBox(0, 0, 800, 22, dbRgb(200, 200, 200), dbRgb(200, 200, 200), dbRgb(200, 200, 200), dbRgb(200, 200, 200));
/* If the mouse cursor is within the area of the drag bar.. */
if (dbMouseX() >= 0 && dbMouseX() <= 800 && dbMouseY() >= 0 && dbMouseY() <= 22) {
/* If the user clicks left mouse button then they are dragging the window, set the flag */
if (dbMouseClick() == 1) {
bDraggingWindow = true;
}
}
/* If the left mouse button isnt clicked then they cant be dragging the window, make sure the flag is false */
if (dbMouseClick() != 1) {
bDraggingWindow = false;
}
/* If they are dragging the window ... */
if (bDraggingWindow) {
/* Variables to store size of window to make calculation easier later */
int SizeX = 0;
int SizeY = 0;
/* Use GetWindowRect to get the position of the window - then calculate the sizes */
GetWindowRect(g_pGlob->hWnd, &rWindowRect);
SizeX = rWindowRect.right - rWindowRect.left;
SizeY = rWindowRect.bottom - rWindowRect.top;
/* Position the window at its current position plus whatever value the mouse has moved lately */
SetWindowPos(g_pGlob->hWnd, NULL, rWindowRect.left + MouseMoveX, rWindowRect.top + MouseMoveY, SizeX, SizeY, 0);
}
/* Code to get the distance the mouse moved in the last frame. Doing it with winapi seems to stop MOST (but not all) of the drag lag */
GetCursorPos(&WinMousePos);
if (WinMousePos.x != OldWinMousePos.x) {
MouseMoveX = WinMousePos.x - OldWinMousePos.x;
} else {
MouseMoveX = 0.0f;
}
if (WinMousePos.y != OldWinMousePos.y) {
MouseMoveY = WinMousePos.y - OldWinMousePos.y;
} else {
MouseMoveY = 0.0f;
}
GetCursorPos(&OldWinMousePos);
/* Output some stuff and update screen */
char szOutput[512];
sprintf_s(szOutput, 512, "MouseX: %d, MouseY: %d - MouseMove: %f - %f", dbMouseX(), dbMouseY(), MouseMoveX, MouseMoveY);
dbText(10, 550, szOutput);
dbSync ( );
}
return;
}
That is a fully working, fully commented example, tested here. Instead of sprites I have just drawn a box in the top of the screen - you can use a sprite if you like. I've also calculated if the mouse is over the box manually - you could just position another sprite at the mouse position and check for sprite hit I guess.
Whatever you like
Obviously in a real world situation you wouldnt hard code values like I have because it doesnt account for the user changing the window size etc.
The key to this is using the winapi functions to get and set the position of the window. We use the HWND stored in the dgdk globstruct to tell the winapi which window we're talking about. For detailed information about the functions i've used either google them or copy/paste them into msdn and it will explain each and every parameter
Hope this mini tutorial helps!