FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log inLog in 


Repeated call of userParentResize

Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog
View previous topic :: View next topic  
Author Message
Ferenc Nagy



Hungary
Joined: 24 Apr 2007
Posts: 378

PostPosted: 9 Sep 2013 12:46    Post subject: Repeated call of userParentResize Reply with quote

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:

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?



repeated resize.png
 Description:
Screen shot of the message window with marked strange phenomena.
 Filesize:  16.34 KB
 Viewed:  1652 Time(s)

repeated resize.png



_________________
TIA, Regards,
Frank Nagy
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3122

PostPosted: 9 Sep 2013 16:40    Post subject: Re: Repeated call of userParentResize Reply with quote

Ferenc Nagy wrote:
I modified the userParentResize event handler of the message window.

What is the userParentResize event handler?

_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Ferenc Nagy



Hungary
Joined: 24 Apr 2007
Posts: 378

PostPosted: 10 Sep 2013 10:22    Post subject: It is the handler of the ParentResize event Reply with quote

Hi Thomas,
It is the handler of the ParentResize event.
I think you recognize the modifications of the constructor of the message window class.

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),


        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.



modmessform.zip
 Description:
The full context of my modified message handling.

Download
 Filename:  modmessform.zip
 Filesize:  12.45 KB
 Downloaded:  211 Time(s)


_________________
TIA, Regards,
Frank Nagy
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3122

PostPosted: 16 Sep 2013 14:53    Post subject: Reply with quote

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:

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(),
        ...


_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Ferenc Nagy



Hungary
Joined: 24 Apr 2007
Posts: 378

PostPosted: 17 Sep 2013 12:35    Post subject: Resize adventures Reply with quote

Thank you Thomas, for your work and suggestions.
I could build in them into my program.
I had to comment out the

%addUserListener(onUserParentResize),

calls because your

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.

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

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



retaskwi.png
 Description:
Multiple borders of message window
 Filesize:  15.63 KB
 Viewed:  1550 Time(s)

retaskwi.png



_________________
TIA, Regards,
Frank Nagy


Last edited by Ferenc Nagy on 20 Sep 2013 10:38; edited 1 time in total
Back to top
View user's profile Send private message
Ferenc Nagy



Hungary
Joined: 24 Apr 2007
Posts: 378

PostPosted: 20 Sep 2013 10:38    Post subject: Changes acoording to your advices Reply with quote

Hi Thomas,
Here are the changes according to your advice:
http://discuss.visual-prolog.com/viewtopic.php?p=38423#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/windows/desktop/dd145037%28v=vs.85%29.aspx

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

Excerpt:

            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,




MessageFormChanges.zip
 Description:

Download
 Filename:  MessageFormChanges.zip
 Filesize:  17.2 KB
 Downloaded:  197 Time(s)


_________________
TIA, Regards,
Frank Nagy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum