Skip to main content
gamedev.net
🔒 Locked

MDI Problem

Started by Metzler Jul 22, 2002 at 12:30 PM 1 replies 300+ views
Original Post
Metzler
Metzler
Hey Guys, I have a problem with MDI and Win32. Previously, it was an SDI application, which was/is running an Direct-Draw thing in the mainwindow. Now i need some aditional windows and so i switch the whole thing, so that it should be MDI compatible. But when i try, to create the window, it always fails. This is, that i do : int WINAPI WinMain (HINSTANCE hinst, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass; MSG message; const char szclassname[] = "Abinator"; //Main Window Class winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinst; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); winclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); winclass.lpszClassName = "Abinator MAP"; winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if (!RegisterClassEx(&winclass)) return(0); //Childclass Palette winclass.style = CS_HREDRAW | CS_VREDRAW ; winclass.lpfnWndProc = MDIChildWndProc; winclass.cbClsExtra = 0 ; winclass.cbWndExtra = NULL ; winclass.hInstance = hinst ; winclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; winclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; winclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH) ; winclass.lpszMenuName = NULL ; winclass.lpszClassName = "child_palette"; if (!RegisterClassEx(&winclass)) return(0); if (!(hwnd = CreateWindow ("Abinator MAP", TEXT ("Abinator Map Editor"), WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hinst, NULL))) return(0); CLIENTCREATESTRUCT ccs; ccs.hWindowMenu = NULL; ccs.idFirstChild = IDM_FIRSTCHILD; palette = CreateWindow("child_palette", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, 0,0,200,200, hwnd, NULL, hinst, (LPSTR)&ccs); //ShowWindow(palette, SW_SHOW); MDICREATESTRUCT mcs; mcs.szTitle = "Palette Abinator"; mcs.szClass = "mdiChild"; mcs.hOwner = hinst; mcs.x = 10; mcs.y = 10; mcs.cx = 100; mcs.cy = 100; mcs.style = NULL; mcs.lParam = NULL; HWND hchild = (HWND)SendMessage(palette, WM_MDICREATE, 0, (LPARAM) (LPMDICREATESTRUCT) &mcs); if(!hchild) { MessageBox(hwnd, "Could not create MDI Child", "Error", MB_ICONEXCLAMATION | MB_OK); } hdc = GetDC(hwnd); DX_Init_Display(); Init_Map(); load_map("karte.map"); ShowWindow (hwnd, ncmdshow) ; UpdateWindow (hwnd) ; while (GetMessage (&message, NULL, 0, 0)) { RECT rct; AdjustClient(hwnd, rct); int right = (rct.right-rct.left) / 40 + view_x; int bottom = (rct.bottom-rct.top) / 40 + view_y; render_map(view_x,view_y,right,bottom, rct); char buffer[150]; long length = sprintf(buffer, "Mouse X : %d, Mouse Y : %d, Bottom : %d",Mouse_Move.x, Mouse_Move.y, rct.bottom); // TextOut(hdc,0,0,buffer,length); TranslateMessage (&message) ; DispatchMessage (&message) ; } return message.wParam ; } I didnt post the callback functions, there is nothing special in it... Could it fail due to DirectDraw ? THX for answers
Metzler
Metzler
Hasn''t anybody in here done some DirectX and MDI programming ? I cant get this to work. I just experienced, that before it initialises DirectX, he draws a little window in the main window, then pops up my MessageBox "Could not create MDI Child"
and then normally draws the DirectX stuff.
Where is my problem ??
LessBread
LessBread
I''ve done a little MDI programming before, although not mixed with DX. I used the MDI sample from winprog.org as a base. I suggest taking a look at it. From what I recall, the WndProc''s are the source of most problems with MDI implementations. If there''s a problem with the WndProc, CreateWindow usually fails.

"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.