Sign in to follow this  
Aviscowboy1

Dialog Hell

Recommended Posts

Aviscowboy1    124
Okay someone may know something that I cannot find. I am trying to add a dialog to a window that I have created. This dialog will have editing features such as frames for animation etc. Also the dialogs in the other child windows will also serve as my main editors for the game. the simple question is how do you attach a dialog to the child window? I am coding in win32, c++ with no MFC. Thank ya thank ya avareh mushhhh Aviscowboy

Share this post


Link to post
Share on other sites
Anon Mike    1098
The question doesn't make sense. What have you tried? What errors are you getting?

To create a modal dialog box call DialogBox or one of it's kin. For a modeless dialog use CreateDialog.

Petzold or pretty much any other book on basic Win32 programming will devote a couple of chapters to this sort of stuff.

Share this post


Link to post
Share on other sites
anonuser    148
Give it the WM_CHILD attribute, which should be accessable in the dialog editor. Then when creating it give it a parent window, it'll be embedded as such. Remember coordinates follow the parent.

Hope this helps. You may wanna look into Win32 a bit more. If you're going to be doing a control the best way would probably be active x. just because that's the norm. Me I don't do it because I'm lazy, but hell the proper way to create new controls and such is with active x. That way you can take it to and from different languages.

Share this post


Link to post
Share on other sites
Evil Steve    2017
You mean like using property pages, like this:
DruinkIM

If so, then you want to just use the WM_CHILD style when you create the dialog resource, and CreateDialog[Param](), passing the parent window as the hWndParent parameter. Here's some source snippets from my code:

bool CSettingsPage::Create(CSettingsDlg* pParent)
{
// Do pre-init //
m_pParent = pParent;

// Create window //
m_hWnd = CreateDialogParam(m_hInstanceTemplate,m_szTemplateID,
pParent->GetWindow(),StaticDlgProc,(LPARAM)this);
if(!m_hWnd)
return false;

// Enable tab control //
LONG lOldStyle = GetWindowLong(m_hWnd,GWL_EXSTYLE);
SetWindowLong(m_hWnd,GWL_EXSTYLE,lOldStyle | WS_EX_CONTROLPARENT);
SetWindowPos (m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|
SWP_FRAMECHANGED);

// Load icon //
m_hIcon = LoadIcon(m_hInstanceIcon,m_szIconID);
return true;
}



The "Enable tab control" bit is so you can use the tab key to properly change controls on the child sheet.
And then to call CSettingsPage::Create():

void CSettingsDlg::OnInitDialog()
{
RECT rc;
POINT pt;
DWORD i;
LVITEM theItem;
STitleInfo theInfo;

// Get position of pages //
GetClientRect(m_hDlg,&rc);
pt.x = rc.left; pt.y = rc.top;
ClientToScreen(m_hDlg,&pt);
GetWindowRect(GetDlgItem(m_hDlg,IDC_POSITION),&rc);
rc.left -= pt.x; rc.right -= pt.x;
rc.top -= pt.y; rc.bottom -= pt.y;
ShowWindow(GetDlgItem(m_hDlg,IDC_POSITION),SW_HIDE);
m_bCreating = true;

// Create & move pages //
for(i=0; i<m_vPages.size(); ++i)
{
if(!m_vPages[i]->Create(this))
{
assert(false);
continue;
}

SetWindowPos(m_vPages[i]->GetWindow(),NULL,rc.left,rc.top,
rc.right-rc.left,rc.bottom-rc.top,SWP_NOZORDER);
}

// Snip
}


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this