Sign in to follow this  
Followers 0
ds34

Resolved: Resize RichEditCtrl (using old UDF)

7 posts in this topic

#1 ·  Posted (edited)

I create a RichEdit field

$hEdit = RichText_Create($handle, 10, 30, 780, 630, $RichTextFont)']

using RichEdit.au3:

func RichText_Create(ByRef $h_Gui, $x, $y, $width, $height,$fontname='COURIER NEW', $v_styles = $DEFAULT_RICHTEXT_STYLE, $v_exstyles = $WS_EX_CLIENTEDGE)

Now my GUI $hMain is being resized and I need to trigger an resize of the RichEdit field.

$aSize = WinGetPos($hMain)
    $aPosbar = ControlGetPos("", "", $hInputField)
    If Not @error And ControlMove($hMain, "",$hEdit, 10, 32, $aSize[2] - 30, $aPosbar[1] - 35) = 0 Then MsgBox(0, "Failure", "Edit Resizing failed")

Any ideas how I could trigger an resizing of the $hEdit?

Up to now I was using AutoItv 3.3.0 and did not need to do anything, upon $GUI_EVENT_RESIZED (I am using my own message handler) I performed a

_WinAPI_RedrawWindow($hMain)

which seems not to be enough in v3.4.0.

AU3 WIndow Info returns:

[CLASS:RichEdit20A; INSTANCE:1]

Style: 0x54001104

ExStyle: 0x00000200

BTW: the other controls in the GUI dock properly, so it is something special about the RichEdit.

Edit: corrected typo $edit vs. $hEdit

Edited by ds34

Share this post


Link to post
Share on other sites



Your posted ControlMove() has "$Edit" vice "$hEdit".

:D

Thanks, this is a typo in the post, the project actually uses different variable names. Always the ControlMove returns @error...

I did some more searching in the forum and saw that this was posted for several versions of the early RichEdits.

So I tried to use the current built-in UDF and ControlMove works over there.

Starting to migrate my project to the current UDF I got stuck as well.

Iam generating a colorized log and it seems that attaching portions to the hRichEdit is colorizing the whole RichEdit.

I do attach the new text, select from the old text-end till the new and colorize. But this fails often, since the selection is not done properly...

Also the performance of the RichEdit seems to be less than in the old RichEdit.au3s.

So now I am stepping back to the old RichEdit - since it is such an old RichEdit2 object - any idea how to resize this object?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It must not be

ControlMove($hMain, "",$hEdit, ...

but

ControlMove($hEdit, "", "", ...

The "new" RichEdit is slower because someone thought it would be a good idea to add Image-support to each RichEdit and not leave it as parameter or extra function.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

I went through this problem recently. I ended up using _WinAPI_SetWindowPos() to resize richedit.

_WinAPI_SetWindowPos($hEdit, 0, 10, 32, $aSize[2] - 30, $aPosbar[1] - 35, $SWP_SHOWWINDOW)

Share this post


Link to post
Share on other sites

It must not be

ControlMove($hMain, "",$hEdit, ...

but

ControlMove($hEdit, "", "", ...

The "new" RichEdit is slower because someone thought it would be a good idea to add Image-support to each RichEdit and not leave it as parameter or extra function.

Thanks for the hint. I tried this as well, but it returns 0 as well.

I went through this problem recently. I ended up using _WinAPI_SetWindowPos() to resize richedit.

_WinAPI_SetWindowPos($hEdit, 0, 10, 32, $aSize[2] - 30, $aPosbar[1] - 35, $SWP_SHOWWINDOW)

Thanks, this worked perfectly! Saved my day and keeps me running ;-)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I know this is old and resolved, but I thought I might add to it for anyone else who's run into this issue and ended up here.

if you use WinGetClientSize() instead of WinGetPos() so it looks like:

$aSize = WinGetPos($hMain)
    $aPosbar = ControlGetPos("", "", $hInputField)
    If Not @error And ControlMove($hMain, "",$hEdit, 10, 32, $aSize[2] - 30, $aPosbar[1] - 35) = 0 Then MsgBox(0, "Failure", "Edit Resizing failed")

You'll get more consistant results when dealing with different OS' and themes/border widths etc. It'll behave like it did for size when you created the richedit.

#Include <WinAPI.au3>
#Include <GuiRichEdit.au3>
...
GUISetOnEvent($GUI_EVENT_RESIZED, "_resizeRichEdit")
...

Func _resizeRichEdit()
    $aSize = WinGetClientSize($hMain)
    $aPosbar = ControlGetPos("", "", $hInputField)
    _WinAPI_SetWindowPos($hEdit,$HWND_TOP, 10, 32, $aSize[2] - 30, $aPosbar[1] - 35)
EndFunc

I'd need to see rest of the $hMain gui code to verify, but I'm guessing the $aPosbar line might be able to be removed

Edited by C2i

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0