Page 1 of 1

Repeated call of userParentResize

Posted: 9 Sep 2013 12:46
by Ferenc Nagy
Hi,

I modified the userParentResize event handler of the message window.
I inteded to retain the position and the height/width ratio of it.

The following screenshot is showing that
1. the procedure has been executed twice for one resizing and
2. I have seen strange double frames.


The code is here:

Code: Select all

onUserParentResize(_Source, _Width, _Height) :-         % 2013.09.08. Retain position and shape,         PrevClientWidth=taskWindow::prevClientWidth,         PrevClientWidth>0,         PrevClientHeight=taskWindow::prevClientHeight,         PrevClientHeight>0,         A=getParent(),         A:getClientSize(CurrentClientWidth,CurrentClientHeight),         Plain=getVpiWindow(),         rct(OL,OT,OR,OB)=winGetOuterRect(Plain),         % stdio::writef("%\n % %\n",winGetText(Plain),"old outer", rct(OL,OT,OR,OB)),         HasMenu = b_false,         WsFlags = winGetState(Plain),         rct(CL,CT,CR,CB)= rectGetClient(WsFlags, HasMenu, rct(OL,OT,OR,OB)),         % stdio::writef("% %\n","old client", rct(CL,CT,CR,CB)),         WidthRatio=(CurrentClientWidth+0.0)/PrevClientWidth,         HeightRatio=(CurrentClientHeight+0.0)/PrevClientHeight, %        stdio::writef("%-12.12s = %9.2g\n","Width Ratio",WidthRatio), %        stdio::writef("%-12.12s = %9.2g\n","Height Ratio",HeightRatio),         NL=math::round(CL*WidthRatio),         NR=math::round(CR*WidthRatio),         NT=math::round(CT*HeightRatio),         NB=math::round(CB*HeightRatio),         stdio::writef("% %\n","new client",rct(NL,NT,NR,NB)),         winMove(Plain,rct(NL,NT,NR,NB)),         stdio::writef("% %\n","new outer", winGetOuterRect(Plain)),         !.    
Would you be so kind to explain the strange phenomena?

Re: Repeated call of userParentResize

Posted: 9 Sep 2013 16:40
by Thomas Linder Puls
Ferenc Nagy wrote:I modified the userParentResize event handler of the message window.
What is the userParentResize event handler?

It is the handler of the ParentResize event

Posted: 10 Sep 2013 10:22
by Ferenc Nagy
Hi Thomas,
It is the handler of the ParentResize event.
I think you recognize the modifications of the constructor of the message window class.

Code: Select all

newPlus(Parent,Decoration,CloseResponder,Title,FontName,FontSize) :-         formWindow::new(Parent),         formMessageControl := messageControl::new(This),         setText(Title),         setFont(vpi::fontCreateByName(FontName,FontSize)),         addUserListener(onUserParentResize),         setCloseResponder(CloseResponder),         setDecoration(Decoration),         addSizeListener(resizeListener),         addGetFocusListener(focusListener),
addUserListener(onUserParentResize),

Code: Select all

        addDestroyListener(onDestroy),         Parent:addSizeListener(onParentResize),         stdio::setOutputStream(formMessageControl:getOutputStream()),         onParentResize(Parent).
My other goals work fine why I have modified the message handling.
1) Passing a font to the constructor.
2) Prohibiting the close box.
3) Allowing the user to modify the offset from the task window.
(Why have you fixed to the high value of 10 pixels?)

I attach the whole context.

Posted: 16 Sep 2013 14:53
by Thomas Linder Puls
I have looked at the attached files.

You obtain a line count from vpiMessage, but that does not make sense. You should completely eliminate vpiMessage (and vpiEditor) from your project. They are not used for message windows anymore.

I do not get the repetitions you have, are you sure they come from that clause?

I suggest that you use postAction instead of user events:

Code: Select all

predicates     onParentResize : sizeListener. clauses     onParentResize(Window) :-         not(documentWindow::isMaximized()),         not(isMinimized()),         !,         Window:getClientSize(Width, Height),         postAction({ :- onUserParentResize(Width, Height) }).     onParentResize(_).   predicates     onUserParentResize : (integer Width, integer Height). clauses     onUserParentResize(Width, Height) :-         b_false = vpi::getAttrVal(vpiDomains::attr_win_mdi),         !,         resizeMessageForm(Width, Height).     onUserParentResize(_Width, _Height) :-         retain_mode=relative_height,         !,         ClientWnd = uncheckedConvert(vpiDomains::windowHandle,             vpi::getAttrNativeVal(vpiDomains::attr_win_mdi_client_hwnd)),         vpiDomains::rct(_,_,Width, Height) = vpi::winGetClientRect(ClientWnd),         resizeMessageForm(Width, Height).      onUserParentResize(_Width, _Height) :-         % 2013.09.08. Retain position and shape,         PrevClientWidth=taskWindow::prevClientWidth,         PrevClientWidth>0,         PrevClientHeight=taskWindow::prevClientHeight,         PrevClientHeight>0,         A=getParent(),         ...

Resize adventures

Posted: 17 Sep 2013 12:35
by Ferenc Nagy
Thank you Thomas, for your work and suggestions.
I could build in them into my program.
I had to comment out the

Code: Select all

%addUserListener(onUserParentResize),

calls because your

Code: Select all

predicates      onUserParentResize : (integer Width, integer Height).
is not an user listener. It has only two parameters.

I attach a picture what happens sometimes when I resize the task window by the mouse
from the lower right corner.

Code: Select all

 ClientWnd = uncheckedConvert(vpiDomains::windowHandle,             vpi::getAttrNativeVal(vpiDomains::attr_win_mdi_client_hwnd)),

Is there a less twisted mode to get the client window?

Changes acoording to your advices

Posted: 20 Sep 2013 10:38
by Ferenc Nagy
Hi Thomas,
Here are the changes according to your advice:
http://discuss.visual-prolog.com/viewto ... 8423#38423.

I added one more option, the script system code which is at offset 23 in the binary Font structure
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

The versions with a font are described in http://www.pinvoke.net/default.aspx/Str ... GFONT.html

Excerpt:

Code: Select all

            ANSI_CHARSET = 0,             DEFAULT_CHARSET = 1,             SYMBOL_CHARSET = 2,             SHIFTJIS_CHARSET = 128,             HANGEUL_CHARSET = 129,             HANGUL_CHARSET = 129,             GB2312_CHARSET = 134,             CHINESEBIG5_CHARSET = 136,             OEM_CHARSET = 255,             JOHAB_CHARSET = 130,             HEBREW_CHARSET = 177,             ARABIC_CHARSET = 178,             GREEK_CHARSET = 161,             TURKISH_CHARSET = 162,             VIETNAMESE_CHARSET = 163,             THAI_CHARSET = 222,             EASTEUROPE_CHARSET = 238,             RUSSIAN_CHARSET = 204,             MAC_CHARSET = 77,             BALTIC_CHARSET = 186,