Jump to content
  • Advertisement
Sign in to follow this  
Haggdahl

Create MDI child from dll

This topic is 4278 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been developing a control which combines a MDI Client and a Tab Control, one similar to the one VS uses. After writing it as a regular project I decided to write it as a dll to make it easier to use in future projects. The dll creates a MDI Client and a Tab Control in the parent window, but when I'm calling CreateMDIWindow the HWND is NULL and GetLastError returns 8 (ERROR_NOT_ENOUGH_MEMORY). The call for CreateMDIWindow is made within the dll. What's wrong?! Appreciate any comments! / Olle Häggdahl

Share this post


Link to post
Share on other sites
Advertisement
Here's the whole Add function!
Hope it'll help.
Thanks!


void CMDITabControl::AddItem(LPSTR lpWndTitle)
{
HWND hWndChild;
TCITEM ti;
CWnd *wnd = NULL;

wnd = new CWnd;

hWndChild = CreateMDIWindow(
g_strChildWndClass,
lpWndTitle,
WS_MAXIMIZE,
0, 0, 0, 0,
m_hWndMDIClient,
m_hInstWorkspace,
NULL
);

if(!hWndChild)
{
MessageBox(m_hWndWorkspace, "Child window creation failed!", "MDITabControl Error!", MB_ERROR);
SAFE_DELETE(wnd);
return;
}

// Show the tab control if it was previously hidden
if(m_nSize == 0)
{
ShowWindow(m_hWndTab, SW_SHOW);
ShowWindow(m_CloseBtn.m_hWnd, SW_SHOW);
}

// Add to our tab control
ti.mask = TCIF_TEXT;
ti.pszText = lpWndTitle;

SendMessage(m_hWndTab, TCM_INSERTITEM, 0, (LPARAM)(LPTCITEM)&ti);
SendMessage(m_hWndTab, TCM_SETCURSEL, 0, 0);

// Insert in our window list and increase size
wnd->m_hWnd = hWndChild;
wnd->m_pNext = m_pFirst;
m_pFirst = wnd;
m_nSize++;
}



[Edited by - Haggdahl on October 22, 2006 2:10:39 PM]

Share this post


Link to post
Share on other sites
Edit your post to use [ source ] [ /source ] tags.

Are you sure that the parameters to CreateMDIWindow() are correct? Where are you getting m_hInstWorkspace?

Also, for style and clarity, I recommend you use CW_USEDEFAULT rather than zeros if you want the default size and position.

Share this post


Link to post
Share on other sites
Thanks for the advice with tags!

As you can see the window is maximized and will stay maximized as long as it's visible, so the zeros doesn't matter.
The m_hInstWorkspace is defined in Init(), which is given the HINSTANCE from the parent when called. But I recently discovered that the HINSTANCES shouldn't matter
because their value is, almost always, 0x00400000. (some standard in Win32, see "http://blogs.msdn.com/oldnewthing/archive/2006/05/05/590749.aspx" which says some concerning Win32 and HINSTANCES)
And the rest of the parameters should be all right. This is very confusing.

/ Olle

Share this post


Link to post
Share on other sites
I've got it now. Skipped registering the class in the dll and now it works. Don't really know what was wrong. Thanks anyway!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!