delphi - Can I get a non MDI form to act as a MDI child? -


i have application have mdi form main form , several mdi childforms opens supposed have none mdi child forms able show inside mdi area.

i have made unit inherites vcl.forms , has following code enables me control forms if try move them can't function work when form shown @ first. try move it jumps right place

procedure tform.wmmoving(var amessage: twmmoving); var   formsquare: ^trect;   worksquare: trect; begin   worksquare := getworksquare;   formsquare := pointer(amessage.dragrect);    if formsquare^.left < worksquare.left     begin       formsquare^.right := formsquare^.right - (formsquare^.left - worksquare.left);       formsquare^.left := worksquare.left;     end   else if formsquare^.right > worksquare.right     begin       formsquare^.left := formsquare^.left - (formsquare^.right - worksquare.right);       formsquare^.right := worksquare.right;     end;    if formsquare^.top < worksquare.top     begin       formsquare^.bottom := formsquare^.bottom - (formsquare^.top - worksquare.top);       formsquare^.top := worksquare.top;     end   else if formsquare^.bottom > worksquare.bottom     begin       formsquare^.top := formsquare^.top - (formsquare^.bottom - worksquare.bottom);       formsquare^.bottom := worksquare.bottom;     end; end; 

the getworksquare function gets working area of either mdi form or desktop. mintop value add form jump below ribbon menu use.

function getworksquare: trect; var   clientrect: trect; begin   if assigned(application.mainform)     begin       if application.mainform.formstyle = fsmdiform         begin           winapi.windows.getwindowrect(application.mainform.clienthandle, clientrect);           if clientrect.top < mintop             clientrect.top := mintop;         end       else         systemparametersinfo(spi_getworkarea, 0, @clientrect, 0);     end;   clientrect.top        := clientrect.top + 5;   clientrect.left       := clientrect.left + 5;   clientrect.right      := clientrect.right - 5;   clientrect.bottom     := clientrect.bottom - 5;   result                := clientrect; end; 

to clarify: shown code works on form has been shown if try move function getworksquare returns area on screen form allowed moved in - ether inside mdi container or if no mdi whole screen need when form opened has in same area getworksquare returns

as can hear saying need opening function check if main form mdi container , open form differntly have form open

function showusers: boolean; begin   tfrmusers.create(nil)     try       result := showmodal = mrok;           free;     end; end; 

any suggestions changes in code might me achieve this?

to answer question in title:

you have choose between mdi child , modal, mdi child cannot modal.

below 2 directions might want research.

the first decide upon app show them mdi child or modal form suggested david.

this works best if redesign bit when using mdi child, not have ok/cancel behaviour (you need think ui flow).

that warrants writing little framework big part of ui in frame, , surrounding bits (inherited) forms handle form style , modality.

another possibility @ user interaction flow in web , mobile applications. of environments don't support large modal forms, have different flows traditional windows applications.

an interesting answer in area in android: how modal dialog or similar modal behavior? , 1 in javascript ux area: ux: message boxes evil.

getting user experience right difficult many programmers , organizations many of them stuck in old modality mantra.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -