Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enabling a Child Window with a Disabled Parent......

Status
Not open for further replies.

bodhi

Programmer
Jan 3, 2002
67
0
0
GB
Hi all,

I am writing a utility app which has a parent window and a child editbox window.

For educational purposes I have written the whole thing from ground up.

I have something like :

class myparentclass
{ public:
blah blah....
private:
class EDITBOX *myeditbox;
blah blah....
};

as my parent class header.

My editbox is created as follows :

edithwnd = CreateWindowEx ( WS_EX_CLIENTEDGE,"edit",text,
WS_CHILD|WS_DISABLED|WS_BORDER,
x, y, w, h,parent,
(HMENU)ID_EDITBOX,dllinstance,
NULL
);
(Initially created disabled and invisible)
This all works as planned until I realised that I didn't want the user messing around with the app. while the editbox
was active.

I first of all tried EnableWindow(parenthwnd,FALSE);
only to discover that this also disables the editbox window
(because it's a child ??).

Next, I tried to hook the WM_ENABLE message sent following the EnableWindow() call in order to force the editbox to be enabled but this didn't work either.

Finally, I tried changing the editbox type to WS_POPUP but this caused a UAE (probably because of some difference in the window styles that I am unaware of).

I feel that I'm missing the obvious here - can anyone shed some light on how to make an editbox modal ?

Thanks.
 
As an addendum to the above :

I have managed to achieve the desired effect by capturing the mouse to the Edit Window when active and throwing away the mouse messages.

This works but I would still be interested to know if there is a 'correct' way of acheiving the same ends ?
 

I think you MIGHT be able to emulate DialogBox(). From what little I've read, DialogBox first calls CreateDialog, then enters a message polling loop within itself. It throws away any messages addressed to the parent window, but dispatches messages to the dialog box. Perhaps after creating the edit box you can make another message polling loop which first checks msg.hwnd if it is the edit box window, then dispatches the message if so. Can't really be sure of course, better back up your hard drive first. :) :) :)

Or better yet disassemble windows and look at the DialogBox procedure so you can be much more sure of what to do. ;-) ;-) ;-) "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top