Datus Posted July 20, 2008 Share Posted July 20, 2008 (edited) Im opening a window and displaying text in an edit window which i read from a file. I use this rather than a label as i can use auto wrap. What im trying to do is display a picture in the backgroud. I believe this isnt possible so Im putting a picture on the window and trying to get the GUICtrlCreateEdit transparent. I dont really fully understand bitor & bitand but nothing i try and do seems to work. below is the code im using atm $LoadIsoPickedSynopsis = GUICreate("Films plot summary", $AdjustW, $AdjustH, (60 * $MultiW) + $AdjustW, 75 * $MultiH) GUICtrlCreatePic("Datus_Iso_backdrop.jpg", 0, 0, (60 * $MultiW) + $AdjustW, 75 * $MultiH) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetBkColor($LoadIsoPickedSynopsis, 0xeee9bf) $SynopsisText = GUICtrlCreateEdit("", 0, 0, $AdjustW, $AdjustH, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY , $WS_EX_TRANSPARENT) ive spent some time looking arround and using search but nothing ive tried seems to work. sorry if this is an easy fix but im stumped. cheers for anyhelp Edited July 20, 2008 by Datus We live as we dream alone! Link to comment Share on other sites More sharing options...
martin Posted July 20, 2008 Share Posted July 20, 2008 Im opening a window and displaying text in an edit window which i read from a file. I use this rather than a label as i can use auto wrap. What im trying to do is display a picture in the backgroud. I believe this isnt possible so Im putting a picture on the window and trying to get the GUICtrlCreateEdit transparent. I dont really fully understand bitor & bitand but nothing i try and do seems to work. below is the code im using atm $LoadIsoPickedSynopsis = GUICreate("Films plot summary", $AdjustW, $AdjustH, (60 * $MultiW) + $AdjustW, 75 * $MultiH) GUICtrlCreatePic("Datus_Iso_backdrop.jpg", 0, 0, (60 * $MultiW) + $AdjustW, 75 * $MultiH) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetBkColor($LoadIsoPickedSynopsis, 0xeee9bf) $SynopsisText = GUICtrlCreateEdit("", 0, 0, $AdjustW, $AdjustH, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY , $WS_EX_TRANSPARENT) ive spent some time looking arround and using search but nothing ive tried seems to work. sorry if this is an fix but im stumped. cheers for anyhelpWhy not use a label and set it to have a transparent background? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
tijiez Posted July 20, 2008 Share Posted July 20, 2008 I use this rather than a label as i can use auto wrap.I guess you didn't read. :/ Link to comment Share on other sites More sharing options...
ProgAndy Posted July 20, 2008 Share Posted July 20, 2008 Way to set a background image ( but no perfect drawing ) expandcollapse popup#include <WindowsConstants.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <WinAPI.au3> Global $hbmp,$hBrush $hBmp = _WinAPI_LoadImage(0, _ @SystemDir & "\oemlogo.bmp", _ $IMAGE_BITMAP , _ 0, _ 0, _ $LR_LOADFROMFILE ) $hBrush = _WINAPI_CreatePatternBrush( $hBmp ) #region - GUI Create GUICreate('dd') $edit = GUICtrlCreateEdit("hi",10,10) $hwnd = GUICtrlGetHandle($edit) GUIRegisterMsg($WM_CTLCOLOREDIT,"dDialogProc") GUISetState() #endregion #region - GUI SelectLoop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd #endregion Func OnAutoItExit() _WinAPI_DeleteObject($hBrush) _WinAPI_DeleteObject($hbmp) EndFunc Func dDialogProc( $hDlg, $uMsg, $wParam, $lParam) Switch $uMsg Case $WM_CTLCOLOREDIT _WINAPI_SetBkMode( $wParam, 1 ) Return $hBrush EndSwitch EndFunc Func _WINAPI_SetBkMode($hdc,$mode) Local $brush = DllCall("gdi32.dll","long","SetBkMode","long",$hdc,"int",$mode) EndFunc Func _WINAPI_CreatePatternBrush($hbmp) Local $brush = DllCall("gdi32.dll","long","CreatePatternBrush","long",$hbmp) If Not @error Then Return $brush[0] Return 0 EndFunc *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 Link to comment Share on other sites More sharing options...
martin Posted July 20, 2008 Share Posted July 20, 2008 (edited) I guess you didn't read. :/ I didn read but I guess you haven't tried using a label. expandcollapse popup#include <GUIConstants.au3> #include <windowsconstants.au3> #include <editconstants.au3> #include <sendmessage.au3> #region - GUI Create $gui1 = GUICreate("Parent GUI", 300, 400, 100, 100) GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 0, 0, 300, 400) GUISetState() $gui2 = GUICreate("child", 200, 398, 103, 130, $WS_POPUP, BitOR(0x2000000, $WS_EX_LAYERED), $gui1);$WS_EX_COMPOSITED $ed1 = GUICtrlCreateEdit("", -2, -2, 204, 402, BitOR($ES_READONLY, $ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetBkColor(-1, 0xABCDEF) GUICtrlSetColor(-1, 0xffff00) GUICtrlSetCursor(-1,2) $text = FileRead(@ScriptFullPath) GUICtrlSetData(-1, $text) _API_SetLayeredWindowAttributes($gui2, 0xABCDEF, 255) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMANDER") GUIRegisterMsg($WM_MOVE, "shift_child") #endregion _SendMessage($gui1, $WM_NCACTIVATE, 1) #region - GUI SelectLoop controlsend($gui2,"",$ed1,"^{HOME}") While 1 $extMsg = GUIGetMsg(1) $msg = $extMsg[0] Switch $extMsg[1] Case $gui1 Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect EndSwitch WEnd #endregion ;=============================================================================== ; ; Function Name: _API_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF-Strucure, else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ;=============================================================================== ; Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, 0, 0) Case Else Return 1 EndSelect EndFunc ;==>_API_SetLayeredWindowAttributes Func shift_child($hwnd, $msg, $wparam, $lparam) If $hwnd = $gui1 Then Local $wp = WinGetPos($gui1) WinMove($gui2, '', $wp[0] + 3, $wp[1] + 30) EndIf EndFunc ;==>shift_child Func WM_COMMANDER($hwnd, $msg, $wparam, $lparam) $nNotifyCode = BitShift($wparam, 16) $nID = BitAND($wparam, 0x0000FFFF) $hCtrl = $lparam If $nID = $ed1 Then If $nNotifyCode = $EN_SETFOCUS Then _SendMessage($gui1, $WM_NCACTIVATE, 1);, 0) Send("{HOME}") EndIf If $nNotifyCode = $EN_KILLFOCUS and _ wingettitle("") <> "Parent GUI" _ Then _SendMessage($gui1, $WM_NCACTIVATE, 0);, 0) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>setparentactive EDIT:improved example.(added shift_child function.) Edited August 2, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Datus Posted July 20, 2008 Author Share Posted July 20, 2008 (edited) Thanks for the replys. ive spent last few hours looking at posts with transparent in them. doesnt look like there is an easy way but wonder why there is an option for transparent if it doesnt work. Have found some nice code to do all sorts of things whilst browsing which is always fun. Dont really want to call api's, dlls etc as i dont under stand them too well and will probably find next updates etc will stop them from working. So anyone else have any ideas? As for using Label:I cant use this as i dont know the contents of what will be displayed as i read a file. I need wrap and vertical scroll bar etc. But any sugestion is not a bad one........ But it is excatly what im trying to achieve. Edited July 20, 2008 by Datus We live as we dream alone! Link to comment Share on other sites More sharing options...
Fzarada Posted August 1, 2008 Share Posted August 1, 2008 Another issue with using Label instead of Edit is you can't scroll the text Am I wrong on this assumption? I've tried many ideas on scrolling vertically a text in a label, all in vain. The most closer solution was using ControlMove, But as its name says it doesn't move only the text Link to comment Share on other sites More sharing options...
martin Posted August 2, 2008 Share Posted August 2, 2008 Another issue with using Label instead of Edit is you can't scroll the text Am I wrong on this assumption? I've tried many ideas on scrolling vertically a text in a label, all in vain. The most closer solution was using ControlMove, But as its name says it doesn't move only the text You can make a transparent edit with vertical scroll bars shown in the example below. It will no doubt need some changes to suit your needs. BE WARNED - if you do not set the window extended style to $WS_COMPOSITED (0x2000000) then Windows has a real problem redrawing the edit and you will get stuck with having to wait a long time while the computer appears to hang. With $WS_EX_COMPOSITED it seems to be fine; maybe there are other solutions. expandcollapse popup#include <GUIConstants.au3> #include <windowsconstants.au3> #region - GUI Create $gui1 = GUICreate("Parent GUI", 300, 400, 100, 100) GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 0, 0, 300, 400) GUISetState() $gui2 = GUICreate("child", 200, 250, 115,170, $WS_POPUP, BitOR(0x2000000, $WS_EX_LAYERED));$WS_EX_COMPOSITED GUICtrlCreateEdit("", 0, 0, 200, 250) GUICtrlSetBkColor(-1, 0xABCDEF) $text = FileRead(@ScriptFullPath) GUICtrlSetData(-1, $text) _API_SetLayeredWindowAttributes($gui2,0xABCDEF,255) GUISetState() winsetontop($gui2,'',1) #endregion #region - GUI SelectLoop While 1 $extMsg = GUIGetMsg(1) $msg = $extMsg[0] Switch $extMsg[1] Case $gui1 Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect EndSwitch WEnd #endregion ;=============================================================================== ; ; Function Name: _API_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF-Strucure, else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ;=============================================================================== ; Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, 0, 0) Case Else Return 1 EndSelect EndFunc ;==>_API_SetLayeredWindowAttributes Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Datus Posted August 6, 2008 Author Share Posted August 6, 2008 Thanks again for your sugestions. Martin ive had ago on your code and it works a treat. Couple of things for other people who are reading. Edit window had its text highlighted and i forgot how to stop this. Solution is to activate another window eg. WinActivate("Parent GUI") to make the edit window neater do this GUICtrlCreateEdit("", 0, 0, 200, 250,BitOR($ES_AUTOVSCROLL, $WS_VSCROLL,$ES_READONLY)) ONCE again THANKS MARTIN We live as we dream alone! Link to comment Share on other sites More sharing options...
martin Posted August 6, 2008 Share Posted August 6, 2008 ONCE again THANKS MARTINThat's ok, glad it did what you wanted. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Datus Posted August 6, 2008 Author Share Posted August 6, 2008 (edited) Ahh there is a little request, I would like to put a picture on the child window and see it through the edit window. Is there a way to do that? Edited August 6, 2008 by Datus We live as we dream alone! Link to comment Share on other sites More sharing options...
martin Posted August 6, 2008 Share Posted August 6, 2008 Ahh there is a little request, I would like to put a picture on the child window and see it through the edit window. Is there a way to do that?Not that I know of. Could you just put the picture on the parent? It would show the same. Here's an example (might not be obvious at first that there's a second picture.) This version also has some improvements. The child is locked to the parent and the parent is drawn as activated even when the child is active and a few other things maybe. expandcollapse popup#include <GUIConstants.au3> #include <windowsconstants.au3> #include <editconstants.au3> #include <sendmessage.au3> #include <guiedit.au3> #region - GUI Create $gui1 = GUICreate("Parent GUI", 300, 400, 100, 100) GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 0, 0, 300, 400);,$WS_CLIPSIBLINGS) GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 80,80,100,40) GUISetState() $gui2 = GUICreate("child", 200, 398, 103, 130, $WS_POPUP, BitOR(0x2000000, $WS_EX_LAYERED), $gui1);$WS_EX_COMPOSITED $ed1 = GUICtrlCreateEdit("", -2, -2, 204, 402, BitOR($ES_READONLY, $ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetBkColor(-1, 0xABCDEF) GUICtrlSetFont(-1,10,800) ;GUICtrlSetColor(-1, 0xdd4444) GUICtrlSetCursor(-1,2) $text = FileRead(@ScriptFullPath) GUICtrlSetData(-1, $text) _API_SetLayeredWindowAttributes($gui2, 0xABCDEF, 255) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMANDER") GUIRegisterMsg($WM_MOVE, "shift_child") #endregion _SendMessage($gui1, $WM_NCACTIVATE, 1) #region - GUI SelectLoop controlsend($gui2,"",$ed1,"^{HOME}");prevents selected text ;controlsend($gui2,"",$ed1,"^{END}") ;_GUICtrlEdit_AppendText($ed1,@CRLF & "the end") While 1 $extMsg = GUIGetMsg(1) $msg = $extMsg[0] Switch $extMsg[1] Case $gui1 Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect EndSwitch WEnd #endregion ;=============================================================================== ; ; Function Name: _API_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF-Strucure, else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ;=============================================================================== ; Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, 0, 0) Case Else Return 1 EndSelect EndFunc ;==>_API_SetLayeredWindowAttributes Func shift_child($hwnd, $msg, $wparam, $lparam) If $hwnd = $gui1 Then Local $wp = WinGetPos($gui1) WinMove($gui2, '', $wp[0] + 3, $wp[1] + 30) EndIf EndFunc ;==>shift_child Func WM_COMMANDER($hwnd, $msg, $wparam, $lparam) $nNotifyCode = BitShift($wparam, 16) $nID = BitAND($wparam, 0x0000FFFF) $hCtrl = $lparam If $nID = $ed1 Then If $nNotifyCode = $EN_SETFOCUS Then _SendMessage($gui1, $WM_NCACTIVATE, 1);, 0) Send("{HOME}") EndIf If $nNotifyCode = $EN_KILLFOCUS and _ wingettitle("") <> "Parent GUI" _ Then _SendMessage($gui1, $WM_NCACTIVATE, 0);, 0) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>setparentactive Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Datus Posted August 7, 2008 Author Share Posted August 7, 2008 (edited) Not sure what you doing with the latest version but i like the locking child to parent.I will need to look at that bit.For your edification ive included this link of my program without transparent window.and with transparentSo now ive place a picture on top of my thumbs same size as the window and then places your transparent code on top.Here it is in all its glory!What you think of that or do you have a better idea? Edited August 7, 2008 by Datus We live as we dream alone! Link to comment Share on other sites More sharing options...
martin Posted August 7, 2008 Share Posted August 7, 2008 Not sure what you doing with the latest version but i like the locking child to parent.I will need to look at that bit.For your edification ive included this link of my program without transparent window.and with transparentSo now ive place a picture on top of my thumbs same size as the window and then places your transparent code on top.Here it is in all its glory!What you think of that or do you have a better idea?It looks very good. No, I haven't got a better idea. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now