Toon posts:

[win32 mdi] waarom werkt dit niet?

Pagina: 1
Acties:
  • 45 views sinds 30-01-2008

Verwijderd

Topicstarter
#include <windows.h>

#define IDM_FIRSTCHILD 50000

LRESULT CALLBACK WndProc( HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam );
LRESULT CALLBACK child_proc( HWND window, UINT message, WPARAM wparam, LPARAM lparam );

HINSTANCE instance;

HWND frame_window;
HWND client_window;
HWND child_window;

char szProgName[] = "Hello Win32";
char client_name[] = "boe";
char child_name[] = "bleh";

int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPreInst, LPSTR lpszCmdLine, int nCmdShow )
{

MSG lpMsg;
WNDCLASSEX wc;

instance = hInst;

wc.cbSize = sizeof(WNDCLASSEX);
wc.lpszClassName = szProgName;
wc.hInstance = hInst;
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
wc.lpszMenuName = NULL;
wc.hbrBackground = GetStockObject( WHITE_BRUSH );
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;

RegisterClassEx( &wc );

wc.lpfnWndProc = child_proc;
wc.cbWndExtra = sizeof( HANDLE );
wc.lpszClassName = child_name;
wc.hbrBackground = (HBRUSH)( BLACK_BRUSH );

RegisterClassEx( &wc );

frame_window = CreateWindow( szProgName,
"CodeWarrior Win32 stationery",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
(HWND)NULL,
(HMENU)NULL,
instance,
(LPSTR)NULL );

ShowWindow(frame_window, nCmdShow );
UpdateWindow( frame_window );

while( GetMessage( &lpMsg, NULL, 0, 0 ) )
{
if (!TranslateMDISysAccel( client_window, &lpMsg))
{
TranslateMessage( &lpMsg );
DispatchMessage( &lpMsg );
}
}
return( lpMsg.wParam);
}


LRESULT CALLBACK WndProc( HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam )
{
switch(messg)
{
case WM_CREATE:
{
MDICREATESTRUCT mdi;
CLIENTCREATESTRUCT ccs;

ccs.hWindowMenu = NULL;
ccs.idFirstChild = IDM_FIRSTCHILD;

client_window = CreateWindowEx(WS_EX_CLIENTEDGE, "mdiclient",
NULL,
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
0,
0,
0,
0,
hWnd,
NULL,
instance,
(LPVOID)&ccs );

ShowWindow( client_window, SW_SHOW );
SetParent( client_window, frame_window );

mdi.szClass = child_name;
mdi.szTitle = "test";
mdi.hOwner = instance;
mdi.x = 0;
mdi.y = 0;
mdi.cx = 300;
mdi.cy = 300;
mdi.style = MDIS_ALLCHILDSTYLES;
mdi.lParam = 0;

child_window = (HWND)SendMessage( client_window,
WM_MDICREATE,
0,
(LONG)&mdi );
break;
}
case WM_DESTROY:
PostQuitMessage( 0 );
break;
}

return( DefFrameProc( hWnd, client_window, messg, wParam, lParam ) );
}

LRESULT CALLBACK child_proc( HWND window, UINT message, WPARAM wparam, LPARAM lparam )
{
switch( message )
{
case WM_CREATE:
child_window = CreateWindowEx( WS_EX_TOOLWINDOW,
child_name,
NULL,
WS_CHILD | WS_VISIBLE,
0,0,100,100,
client_window,
NULL,
instance,
NULL);

break;


}

return DefMDIChildProc( window, message, wparam, lparam );
}


ik probeer dus een child-Toolwindow te ceeeren maar dit wilt niet echt lukken. Iemand enig idee waarom?

  • whoami
  • Registratie: December 2000
  • Laatst online: 12:26

https://fgheysels.github.io/


Dit topic is gesloten.