qwert Posted January 30, 2012 Share Posted January 30, 2012 This script represents my attempt to place a rich text field on a PNG graphic. It almost works ... but I can't get the text field to display on the top. Only when entering text into the field does the field come to the top level. The few (style) settings I've experimented with don't change anything and end up adding a layer of confusion. So this example is stripped to the minimum ... and most of it is adapted from the Help file scripts. But obviously I've missed something.expandcollapse popup; ************ Test of Rich Text on PNG ************* #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> #Include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> ; ==================== GUI PART =============== ; (adapted from example 3 PNG work around by Zedna from Help file) Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI=GUICreate("Rich Text On PNG",800,140) ; Load PNG image _GDIPlus_Startup() ;$hImage = _GDIPlus_ImageLoadFromFile("..\GUI\Torus.png") << original stmt $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\GraphicBox.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;============ Rich Text Part ==================== $MainRich = _GUICtrlRichEdit_Create($hGUI, "", 60, 30, 720, 60, BitOR($ES_MULTILINE, $WS_VSCROLL)) _GUICtrlRichEdit_SetBkColor(-1,0xFFFFFF) _GUICtrlRichEdit_SetFont($MainRich, 14, "Franklin Gothic Medium") _GUIScrollBars_ShowScrollBar($MainRich, $SB_VERT, True) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState() ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() _GUICtrlRichEdit_Destroy($MainRich) ;============== Function ================== ; Draw PNG image Func MY_WM_PAINT($hWnd, $msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_PAINTI will greatly appreciate any help. Thanks in advance. Link to comment Share on other sites More sharing options...
Guest Posted January 30, 2012 Share Posted January 30, 2012 The Fixed code and you will require this ; ************ Test of Rich Text on PNG ************* #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> #Include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <Icons.au3> ; ==================== GUI PART =============== ; (adapted from example 3 PNG work around by Zedna from Help file) Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI=GUICreate("Rich Text On PNG",800,140) ;============ Rich Text Part ==================== $I_AmPic = GUICtrlCreatePic("",0,10,400,100) _SetImage($I_AmPic, @ScriptDir&"\i.png");################################ Your Png file GUICtrlSetState($I_AmPic, $GUI_DISABLE) $MainRich = _GUICtrlRichEdit_Create($hGUI, "", 20, 10, 720, 60, BitOR($ES_MULTILINE, $WS_VSCROLL)) _GUICtrlRichEdit_SetBkColor(-1,0xFFFFFF) _GUICtrlRichEdit_SetFont($MainRich, 14, "Franklin Gothic Medium") _GUIScrollBars_ShowScrollBar($MainRich, $SB_VERT, True) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState() ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() _GUICtrlRichEdit_Destroy($MainRich) ;============== Function ================== Link to comment Share on other sites More sharing options...
UEZ Posted January 30, 2012 Share Posted January 30, 2012 Try this: expandcollapse popup; ************ Test of Rich Text on PNG ************* #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> #Include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> ; ==================== GUI PART =============== ; (adapted from example 3 PNG work around by Zedna from Help file) Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $width = 800 $height = 140 $hGUI=GUICreate("Rich Text On PNG",$width,$height) ; Load PNG image _GDIPlus_Startup() ;============ Rich Text Part ==================== $MainRich = _GUICtrlRichEdit_Create($hGUI, "", 60, 30, 720, 60, BitOR($ES_MULTILINE, $WS_VSCROLL)) _GUICtrlRichEdit_SetBkColor(-1,0xFFFFFF) _GUICtrlRichEdit_SetFont($MainRich, 14, "Franklin Gothic Medium") _GUIScrollBars_ShowScrollBar($MainRich, $SB_VERT, True) ;~ $hImage = _GDIPlus_ImageLoadFromFile("..GUITorus.png") ;<< original stmt $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "GraphicBox.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $GW_CHILD = 5 Global Const $GW_HWNDNEXT = 2 Global $hRegion = _GDIPlus_RegionCreateFromRect(_GDIPlus_RectFCreate(0, 0, $width, $height)) Global $hChild = _WinAPI_GetWindow($hGUI, $GW_CHILD) Global $aRect Do $aRect = ControlGetPos($hChild, "", 0) _GDIPlus_RegionCombineRect($hRegion, _GDIPlus_RectFCreate($aRect[0], $aRect[1], $aRect[2], $aRect[3]), 3) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) Until Not $hChild _GDIPlus_GraphicsSetClipRegion($hGraphic, $hRegion) _GDIPlus_RegionDispose($hRegion) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState() ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() _GUICtrlRichEdit_Destroy($MainRich) ;============== Function ================== ; Draw PNG image Func MY_WM_PAINT($hWnd, $msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_PAINT Func _GDIPlus_GraphicsSetClipRegion($hGraphics, $hRegion, $iCombineMode = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetClipRegion", "hwnd", $hGraphics, "hwnd", $hRegion, "int", $iCombineMode) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc Func _GDIPlus_RegionCreateFromRect($tRectF) Local $pRectF, $aResult $pRectF = DllStructGetPtr($tRectF) $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateRegionRect", "ptr", $pRectF, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[2] EndFunc Func _GDIPlus_RegionCombineRect($hRegion, $tRectF, $iCombineMode = 2) Local $pRectF, $aResult $pRectF = DllStructGetPtr($tRectF) $aResult = DllCall($ghGDIPDll, "uint", "GdipCombineRegionRect", "hwnd", $hRegion, "ptr", $pRectF, "int", $iCombineMode) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc Func _GDIPlus_RegionDispose($hRegion) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeleteRegion", "hwnd", $hRegion) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
qwert Posted January 30, 2012 Author Share Posted January 30, 2012 UEZ, that's an excellent solution ... and the RichEdit performs perfectly on the image when scrolled. This will send me to the documentation and posts to learn about Regions. (I didn't try Aipion's icon approach due to requiring multiple UDFs, but it may well have use, too.)So, thanks very much. BTW, what I'm after as my final result is a floating popup to display rich text. I can remove the window frame with $WS_POPUP. But I need to make the tan background transparent? My simple approach of using $WS_EX_LAYERED doesn't seem to work with regions. Would you happen to know of a setting? Link to comment Share on other sites More sharing options...
rover Posted January 31, 2012 Share Posted January 31, 2012 So, you wait for the right people to respond to your questions?Modify drag&drop behavior for RichEdit text? I see fascists... Link to comment Share on other sites More sharing options...
Mikeman27294 Posted January 31, 2012 Share Posted January 31, 2012 Can you set the PNG to be disabled? I know that works with GUICtrlCreatePic. I know it's not the same function, and it might not work, but if it doesn't, nothing lost, right? Link to comment Share on other sites More sharing options...
qwert Posted January 31, 2012 Author Share Posted January 31, 2012 @Mikeman. Thanks for the response. I just found the answer on post #113040 from two years ago ... transparent gui background. All it took was adding $WS_EX_LAYERED back in ... and then setting attributes on the main window with _WinAPI_SetLayeredWindowAttributes($hGUI, 0xECE9D8, 255) 0xECE9D8 is the default background color in WinXP. Setting it as $Transparent=255 takes it away. I'm not certain I won't get tripped up later by Vista or Win7, but for now it gives the right result so I can continue working on my idea. @rover: that's a lot a good detail on my other thread. I'll work this week to implement and evaluate the techniques you've provided. Thanks very much. 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