Ok here is a simple code snippet to register a windows class and then create a child window, inside the parent (GDK created) window.
#include "DarkGDK.h"
#include "globstruct.h"
#include "windows.h"
// need this to fix dx dll entry points when including globstruct
// fixes linker error with unreferenced calls.
class CFactoryTemplate
{
public :
CFactoryTemplate(){
};
};
CFactoryTemplate * g_Templates;
int g_cTemplates;
//message processing function declarations - dont do anything yet
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return 0;
}
// the main entry point for the application is this function
// all this does is try to register and open a window.
void DarkGDK ( void )
{
char class_name[16] ;
char text_buffer[64] ;
WNDCLASSEX wcx;
DWORD last_err = -1;
DWORD last_err2 = -1;
HWND awin;
int registration_status = -1;
int creation_status = -1;
sprintf(class_name, "MenuClass");
// populate the WNDCLASSEX struct to pass to registerclassex
// to register the window class type.
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.style = CS_HREDRAW | CS_VREDRAW;
wcx.lpfnWndProc = NULL,//WndProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = g_pGlob->hInstance;
wcx.hIcon = NULL;
wcx.hCursor = NULL;
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcx.lpszMenuName = NULL;
wcx.lpszClassName = class_name;
wcx.hIconSm = NULL;
//register the class - this works ok
if (!RegisterClassEx(&wcx))
registration_status = 0;
else
registration_status = 1;
last_err = GetLastError();
// if registration success then create the child window
if (registration_status)
{
awin = CreateWindowEx(
WS_EX_OVERLAPPEDWINDOW,
class_name,
class_name,
WS_OVERLAPPED ,
5,
5,
100,
100,
g_pGlob->hWnd,
NULL,
g_pGlob->hInstance,
NULL);
}
if (!awin)
creation_status = 0;
else
creation_status = 1;
last_err2 = GetLastError();
// write something to screen - showing the child window should hide this
sprintf(text_buffer,"Registration showed %s", (registration_status?"OK":"FAIL"));
dbText(10,10,text_buffer);
sprintf(text_buffer,"Creation showed %s", (creation_status?"OK":"FAIL"));
dbText(10,30,text_buffer);
// if the window creation was ok, shwo and update the window.
if (awin)
{
ShowWindow(awin, SW_SHOWNORMAL);
UpdateWindow(awin);
}
// let a human see the window for a few secs before
// destroying it
Sleep(2550);
if (awin)
DestroyWindow(awin);
// write some more stuff
sprintf(text_buffer,"Last Err %u", (last_err));
dbText(10,120,text_buffer);
sprintf(text_buffer,"Last Err2 %u", (last_err2));
dbText(10,150,text_buffer);
while ( LoopGDK ( ) )
{
if ( dbEscapeKey ( ) )
break;
dbSync ( );
}
return;
}
All I want to do is to create a child window and then destroty it.
This may create issues with the drawing functions, but Ill get to that later....