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)
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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_CLOS E,0,0)
else if LOWORD(wParam) = ID_ModalBut then
ShowModal
else if LOWORD(wParam) = ID_OkBut then
PostMessage(hModal,WM_CLOS E,0,0);
end;
Result := DefWindowProc(hWnd,Msg,wPa ram,lParam );
end;
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_CLOS
else if LOWORD(wParam) = ID_ModalBut then
ShowModal
else if LOWORD(wParam) = ID_OkBut then
PostMessage(hModal,WM_CLOS
end;
Result := DefWindowProc(hWnd,Msg,wPa
end;
ASKER