memofield transparent without borders and scrollbar?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

memofield transparent without borders and scrollbar?

Post by migro » Tue Jul 21, 2009 2:15 am

Is it possible to configure a memofield with transparency and without borders and the scrollbar?

I like to provide a dialog with a changing tooltipsection depending on the selected action. Doing it with a label is possible, but formating all the different textsections with a whole bunch of %CRLF% are a little bit confusing :wink:
regards
migro

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Jul 23, 2009 5:11 am

Is it possible to configure a memofield with transparency and without borders and the scrollbar?
Using functions already on the forum I was able to make a memo field transparent and scrollbarless. I could not seem to eliminate the border. Applying the function that removes borders from dialogs to the memo object:

Code: Select all

LibFunc>user32,SetWindowLongA,sres,Dialog1.msMemo1.handle,-16,1
Causes catastrophic failure of the dialog.

The following is 2/3 of your request.

Code: Select all

Dialog>Dialog1
   Caption=Transparent Memo Field
   Width=752
   Height=581
   Top=CENTER
   Left=CENTER
   Memo=msMemo1,33,23,680,466,
   Button=Close,328,514,75,25,2
EndDialog>Dialog1

Show>dialog1

//constants
  Let>GWL_EXSTYLE=-20
  Let>WS_EX_LAYERED=524288
  Let>LWA_COLORKEY=1

//get style attributes of dialog1 window
  LibFunc>user32,GetWindowLongA,attribs,dialog1.handle,GWL_EXSTYLE
  Let>attribs={%attribs% OR %WS_EX_LAYERED%}
//make selected color transparent
  LibFunc>user32,SetWindowLongA,swl,dialog1.handle,GWL_EXSTYLE,attribs
  LibFunc>user32,SetLayeredWindowAttributes,res,dialog1.handle,16777215,0,LWA_COLORKEY
//Eliminate the scrollbars 
  LibFunc>user32,ShowScrollBar,sbres,dialog1.msMemo1.handle,3,0

Label>Loop
  GetDialogAction>Dialog1,res1
  If>res1=2
    Exit>0
  EndIf
Wait>0.01
Goto>Loop
I get why you want to use memo fields to avoid the need for CRLFs. Eliminating borders and scrollbars makes sense, but I'm not understanding the desire for transparency. Are you looking to float text with no field background? Similar to the last two examples HERE. I think if you're trying to make tool tips that are floating text, using a dialog and labels would be easier. I'm guessing that one of the RegEx experts can come up with a regex line to to replace a space with CRLF every X characters. That would give you word wrap on a label. Come to think of it, I could use that feature myself. I'll start a thread and ask.

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Tue Jul 28, 2009 12:47 am

Dear JRL,

thanks for the Answer.
but I'm not understanding the desire for transparency.
In my dialog the tooltipsection got another background color. So if I need to use a non transparent memofield it looks real awful ;-)

I agree with You that it might be easier and more stable to use labels ....
I'm not experienced with RegEx so I use normal CRLF.
regards
migro

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jul 28, 2009 4:06 am

We did come up with a RegEx solution here: http://www.mjtnet.com/forum/viewtopic.php?t=5626 Thanks to Dick (JRL) for asking about it.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Jul 30, 2009 5:22 am

Here's a working sample for tooltips using Bob's wordWrap RegEx.

Code: Select all

//A dialog to be the text showcase.
Dialog>Dialog1
Caption=D~L~o~g1
Top=-1000000
Label=,12,8,True
EndDialog>Dialog1

Show>Dialog1
LibFunc>user32,SetWindowLongA,sres,Dialog1.handle,-16,1
CloseDialog>Dialog1

//Visual aid separator for each tooltip block
////****************************************************************
//The text to be displayed in our dialog
Let>Text=Start with a borderless dialog. Give the dialog a color and a line of text to display.
//Bob Hansen's word wrap RegEx sequestered in a subroutine.
//Usage:
//GoSub>WordWrap,Wrap Length,String
GoSub>WordWrap,30,Text

//Usage:
//GoSub>ToolTip,Xpos,Ypos,Wide,Tall,Text[,Font,Size,Style,TextColor[,BackColor]]
GoSub>ToolTip,500,100,200,90,WordWrapResult,Arial,12,0,16646144,6881279

//Display the message for a moment then close the window
Wait>6
CloseDialog>Dialog1
////****************************************************************
Let>Text=Adjust the size of the dialog to make the dialog encompass the text but not be overly large.
GoSub>WordWrap,30,Text
GoSub>ToolTip,500,200,310,310,WordWrapResult,Arial,12,0,16646144,6881279
Wait>6
CloseDialog>Dialog1
////****************************************************************
Let>Text=Adjust the size of the dialog to make the dialog encompass the text but not be overly large.%CRLF%%CRLF%Hmmmm...
GoSub>WordWrap,30,Text
GoSub>ToolTip,500,200,310,310,WordWrapResult,Arial,12,0,16646144,6881279
Wait>3
CloseDialog>Dialog1
////****************************************************************
Let>Text=Adjust the position of the dialog on the screen, the size and color of the text and even the dialog background color.
GoSub>WordWrap,30,Text
GoSub>ToolTip,500,300,310,120,WordWrapResult,Arial,16,0,255,6881210
Wait>9
CloseDialog>Dialog1
////****************************************************************
Let>Text=Good luck
GoSub>WordWrap,30,Text
GoSub>ToolTip,500,100,190,60,WordWrapResult,Arial,25,0,255,6881279
Wait>3
////****************************************************************
Let>Text=Good luck, GoodBye...
GoSub>WordWrap,11,Text
GoSub>ToolTip,500,100,190,90,WordWrapResult,Arial,25,0,255,6881279
Wait>2
//Open Dialog4 script
Libfunc>user32.dll,AnimateWindow,Result,Dialog1.handle,1000,262160
//Close Dialog4 script
Libfunc>user32.dll,AnimateWindow,Result,Dialog1.handle,1000,327696
////****************************************************************


SRT>ToolTip
Let>Dialog1.mslabel1=ToolTip_var_5
ResetDialogAction>Dialog1
Show>Dialog1
SetDialogObjectColor>Dialog1,,ToolTip_var_10
SetDialogObjectFont>Dialog1,mslabel1,ToolTip_var_6,ToolTip_var_7,ToolTip_var_8,ToolTip_var_9
LibFunc>user32,ShowScrollBar,sbres,Dialog1.handle,3,0
MoveWindow>D~L~o~g1,ToolTip_var_1,ToolTip_var_2
ResizeWindow>D~L~o~g1,ToolTip_var_3,ToolTip_var_4
LibFunc>user32,ShowScrollBar,sbres,Dialog1.handle,3,0
END>ToolTip

SRT>WordWrap
Let>vNeedle=(.{1,%WordWrap_var_1%})(%SPACE%|$)
Let>vHaystack=%WordWrap_var_2%
RegEx>%vNeedle%,%vHaystack%,0,matches,matchnum,1,$1%CRLF%,WordWrapResult
END>WordWrap

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Sat Aug 01, 2009 11:09 am

Really nice sample Dick.

Next time I need to do something with tooltips, I try it this way.

I like the way formatting only the text in the label, without affecting other textparts of a dialog.

Thanks a lot to You and Bob for sharing it.
regards
migro

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts