Sign in to follow this  
stevo86

Dialog box problems...

Recommended Posts

I've been having some trouble with a dialog box I've created and I was wondering if any of you have had a similar problem. Following is the original problem I had: Here I tried DialogBox and CreateDialog but aside from a few minor focus settings, there was no difference. Seeing as how that was clearly not working I tried out a method Carmack used on the Quake 2 Editor. He created a dialog box, looped through all the controls, saved them all into an HWND array and then created each one manually as a regular window. Now I have this: Here For this method I'm using just plain old CreateWindow and using the settings from the resource file to setup each control. Any help would be appreciated.

Share this post


Link to post
Share on other sites
No luck... I'm currently using WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CHILD, and it's not getting me anywhere. I tried switching to WS_POPUP, with no difference...

Originally I was creating the box like so:


case ID_TEXTURE_GENERATE:
{
DialogBox(glApp->GetInstance(), MAKEINTRESOURCE(IDD_TEXTUREGENERATOR), glApp->GetWindowHandle(), (DLGPROC)TextureProc);
} break;

But with the new code I tried out, I'm using this:


case ID_TEXTURE_GENERATE:
{
// initialized earlier on in the application
texWin->Init();
} break;

...

texwin.h - a window class for the texture dialog box

bool Init() {
HWND tempWindow;

OnCreate();

tempWindow = CreateDialog(mParentInstance, (char*)IDD_TEXGENERATION, mParent, (DLGPROC)NULL);
if (!tempWindow)
return false;

GetControls(tempWindow);
DestroyWindow(tempWindow);

ShowWindow(mWnd, SW_SHOW);
SetActiveWindow(mWnd);
SetForegroundWindow(mWnd);
UpdateWindow(mWnd);
RedrawWindow(mWnd, NULL, NULL, RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_ERASENOW);
}

bool OnCreate() {
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));

wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.style = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = 0;
wc.lpszMenuName = NULL;
wc.lpszClassName = TEXWINCLASS;
wc.lpfnWndProc = (WNDPROC)TextureProc;
wc.hInstance = mParentInstance;

if (!RegisterClass(&wc)) {
return false;
}

if (!(mWnd = CreateWindow(TEXWINCLASS, "Texture", WS_OVERLAPPED | WS_VISIBLE | WS_CAPTION | WS_CHILD,
20, 20, 300, 250, mParent, 0, mParentInstance, NULL))) {
return false;
}

if (!mWnd) {
return false;
}

return true;
}

CTextureWindow(HWND parent, HWND parentInstance) {
mParent = parent;
mParentInstance = parentInstance;
}


So, I don't know what I'm doing wrong... :\

Share this post


Link to post
Share on other sites
I'm pretty sure the problem is the WS_CHILD style. You won't get that going to have the controls embedded easily in your window if you're using 3d acceleration. I'm not sure if that's what you're actually trying.

Wouldn't you want a free floating dialog?

Share this post


Link to post
Share on other sites
I've tried it with and without WS_CHILD with no apparent difference. And I don't think the child setting has anything to do with a floating window or not.

Share this post


Link to post
Share on other sites
What exactly is it you're trying to do?

Your texwin class creates two windows, one modeless window (with WS_CHILD?) and a dialog which gets destroyed two lines later.
What does GetControls do? Is it supposed to copy/move the controls from the dialog to the window from texwin? Why not directly use CreateDialog but instead the copying of the controls?

With WS_CHILD your window gets embedded in the main application, without it can be free floating/dragged.

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