Link to home
Start Free TrialLog in
Avatar of GroundFloor
GroundFloor

asked on

Make Window Modal....

Hi

I have created a program using code from http://www.angelfire.com/hi5/delphizeus/index.html using CreateWindow, etc. (simple form with one button on it)

I also have a second window (with different class, message handler, etc) which is created when i click on a button on the main form.

It shows as expected except it is not modal to the main form.

Anyone know how to make it modal? (i know i could use DIALOG as the method - just want to know if it can be done the way i have gone)
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GroundFloor
GroundFloor

ASKER

thanks, i was able to work out what i needed from your example
I was hoping that you would notice that I placed the

EnableWindow(hForm1, True);

in the wrong place, it would be better if it was like this -


function WindowFunc(hWnd, Msg, wParam, lParam: Integer): Integer; stdcall;
begin
case Msg of
  WM_CLOSE: if hWnd = hModal then EnableWindow(hForm1, True);// better place
  WM_DESTROY: if hWnd = hForm1 then PostQuitMessage(0);
   
  WM_COMMAND: if lParam = hButton1 then PostMessage(hForm1,WM_CLOSE,0,0)
    else if LOWORD(wParam) = ID_ModalBut then
     ShowModal
     else if LOWORD(wParam) = ID_OkBut then
     PostMessage(hModal,WM_CLOSE,0,0);
  end;
Result := DefWindowProc(hWnd,Msg,wParam,lParam);
end;