HolmesShelock Posted May 2, 2011 Share Posted May 2, 2011 (edited) Hi All, I wrote this piece of code #include <GDIPlus.au3> #include <GUIConstants.au3> #Include <GuiButton.au3> #Include <WindowsConstants.au3> $hMainWindow = GUICreate('MAIN', 705, 369) GUISetState() _GDIPlus_Startup () $hMainGraphicObject = _GDIPlus_GraphicsCreateFromHWND ($hMainWindow) $HORIZONTAL_BAR_IMAGE = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Images\Horizontal Bar.png") _GDIPlus_GraphicsDrawImageRectRect($hMainGraphicObject, $HORIZONTAL_BAR_IMAGE, 0, 0, 490, 35, 190, 120, 490, 35) GUICtrlCreateCombo("Please Select", 358, 125, 320, 15) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd My intention was to place the ComboBox Control onto the Horizontal bar (Bar's width is greater than that of the control) But the result was http://yfrog.com/0gerrorobj The combobox control leaves a white patch below it. Again, when any other window comes over the horizontal bar's image, that part get erased. Please help me to resolve the issue. Edited May 2, 2011 by HolmesShelock [size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size] Link to comment Share on other sites More sharing options...
UEZ Posted May 2, 2011 Share Posted May 2, 2011 Try this: expandcollapse popup#include <GUIConstantsEx.au3> OnAutoItExitRegister("ExitApp") Opt("MustDeclareVars", 1) Global $hGUI, $PIC, $hBMP, $TXTID, $aPOS, $Msg, $Combo $hGUI = GUICreate("Gradient", 800, 480) $PIC = GUICtrlCreatePic("", 0, 115, 800, 40) GUICtrlSetState(-1, $GUI_DISABLE) $hBMP = _GUICtrlPic_GradientFill($PIC, "D05000", "FFE000", 2, 2, 1) $Combo = GUICtrlCreateCombo("Test1", 358, 125, 320, 15) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetData(-1, "Test2|Test3") GUICtrlSetBkColor(-1, -2) GUISetState() While True $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() Exit Func ExitApp() If $hBMP Then DllCall("Gdi32.dll", "Int", "DeleteObject", "Ptr", $hBMP) EndIf EndFunc ;==>ExitApp ; #FUNCTION# ==================================================================================================================== ; Name...........: _GUICtrlPic_GradientFill ; Description ...: Füllt ein Pic-Control mit einem zweifarbigen linearen Farbverlauf. ; Syntax.........: _GUICtrlPic_GradientFill($idCTRL, $C1, $C2[, $D = 1[, $3D = 3[, $GC = 0[, $BW = 0[, $BH = 0]]]]]) ; Parameters ....: $idCTRL - ID des Pic-Controls aus GUIStrlCreatePic() ; $C1 - Startfarbe als 6-stelliger RGB-Hexstring ("RRGGBB") ; $C2 - Zielfarbe als 6-stelliger RGB-Hexstring ("RRGGBB") ; $D - Verlaufsrichtung: ; |0 - horizontal ; |1 - vertikal ; |2 - diagonal (links oben -> rechts unten) ; |3 - diagonal (rechts oben -> links unten) ; |Default - 0 ; $3D - Verlaufsart: ; |1 - flacher Verlauf (Startfarbe -> Zielfarbe) ; |2 - "3D"-Verlauf (Startfarbe -> Zielfarbe -> Startfarbe) ; |3 - erhaben (wie 2, die Startfarbe bleibt aber im Randbereich) ; |Default - 1 ; $GC - Gammakorrektur: ; |0 - ohne ; |1 - mit ; |Default - 0 ; $BW - Breite des Verlaufs in Pixeln ; |Default - 0 (Breite des Controls) ; $BH - Höhe des Verlaufs in Pixeln ; |Default - 0 (Höhe des Controls) ; Return values .: Bei erfolgreicher Ausführung: Handle der erzeugten Bitmap (HBITMAP) ; Im Fehlerfall: False, @error wird auf 1 gesetzt ; Author ........: Großvater (www.autoit.de) ; Modified.......: ; Remarks .......: Das Control muss mit GUICtrlCreatePic() erzeugt worden sein, sonst geschieht nichts. ; Die Parameter $BW und $BH laden zum Experimentieren ein. ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _GUICtrlPic_GradientFill($idCTRL, $C1, $C2, $D = 1, $3D = 3, $GC = 0, $BW = 0, $BH = 0) Local Static $STM_SETIMAGE = 0x172 Local Static $IMAGE_BITMAP = 0x0 Local Static $BITSPIXEL = 0xC Local $hWnd If IsHWnd($idCTRL) Then $hWnd = $idCTRL Else $hWnd = GUICtrlGetHandle($idCTRL) EndIf Local $aResult = DllCall("User32.dll", "Int", "GetClassName", "Hwnd", $hWnd, _ "Str", "", "Int", 256) If $aResult[2] <> "Static" Then Return False EndIf Local $GDIPDll = DllOpen("GDIPlus.dll") If $GDIPDll = -1 Then Return SetError(1, 0, False) EndIf Local $SI = DllStructCreate("UInt Version;Ptr Callback;Bool NoThread;Bool NoCodecs") Local $Token = DllStructCreate("ulong_ptr Data") DllStructSetData($SI, "Version", 1) $aResult = DllCall($GDIPDll, "Int", "GdiplusStartup", _ "Ptr", DllStructGetPtr($Token), "Ptr", DllStructGetPtr($SI), "Ptr", 0) If @error Then DllClose($GDIPDll) Return SetError(1, 0, False) EndIf Local $GDIPToken = DllStructGetData($Token, "Data") Local $RECT = DllStructCreate("Long; Long; Long Right;Long Bottom") DllCall("User32.dll", "Bool", "GetClientRect", "Hwnd", $hWnd, _ "Ptr", DllStructGetPtr($RECT)) Local $W = DllStructGetData($RECT, "Right") Local $H = DllStructGetData($RECT, "Bottom") Switch $D Case 0, 1, 2, 3 Case Else $D = 0 EndSwitch Switch $3D Case 1, 2, 3 Case Else $3D = 1 EndSwitch Switch $GC Case 0, 1 Case Else $GC = 0 EndSwitch If $BW = 0 Then $BW = $W If $BH = 0 Then $BH = $H Local $pBITMAP = DllStructCreate("Ptr") DllCall($GDIPDll, "Int", "GdipCreateBitmapFromScan0", _ "Int", $W, "Int", $H, "Int", 0, "Int", 0x26200A, "Ptr", 0, _ "Ptr", DllStructGetPtr($pBITMAP)) $pBITMAP = DllStructGetData($pBITMAP, 1) Local $pGRAPHICS = DllStructCreate("Ptr") DllCall($GDIPDll, "Int", "GdipGetImageGraphicsContext", _ "Ptr", $pBITMAP, "Ptr", DllStructGetPtr($pGRAPHICS)) $pGRAPHICS = DllStructGetData($pGRAPHICS, 1) DllCall($GDIPDll, "Int", "GdipSetSmoothingMode", "Ptr", $pGRAPHICS, "Int", 0) Local $RECTF = DllStructCreate("Float L;Float T;Float R;Float B") DllStructSetData($RECTF, "R", $BW) DllStructSetData($RECTF, "B", $BH) Local $Color1 = "0xFF" & $C1 Local $Color2 = "0xFF" & $C2 Local $pBRUSH = DllStructCreate("Ptr") DllCall($GDIPDll, "Int", "GdipCreateLineBrushFromRect", _ "Ptr", DllStructGetPtr($RECTF), "Int", $Color1, "Int", $Color2, _ "Int", $D, "Int", 0, "Ptr", DllStructGetPtr($pBRUSH)) $pBRUSH = DllStructGetData($pBRUSH, 1) DllCall($GDIPDll, "Int", "GdipSetLineGammaCorrection", "Ptr", $pBRUSH, _ "Int", $GC) Local $RELINT = DllStructCreate("Float[5]") Switch $3D Case 1 DllStructSetData($RELINT, 1, 0.00, 1) DllStructSetData($RELINT, 1, 0.25, 2) DllStructSetData($RELINT, 1, 0.50, 3) DllStructSetData($RELINT, 1, 0.75, 4) DllStructSetData($RELINT, 1, 1.00, 5) Case 2 DllStructSetData($RELINT, 1, 0.0, 1) DllStructSetData($RELINT, 1, 0.5, 2) DllStructSetData($RELINT, 1, 1.0, 3) DllStructSetData($RELINT, 1, 0.5, 4) DllStructSetData($RELINT, 1, 0.0, 5) Case Else DllStructSetData($RELINT, 1, 0.0, 1) DllStructSetData($RELINT, 1, 1.0, 2) DllStructSetData($RELINT, 1, 1.0, 3) DllStructSetData($RELINT, 1, 1.0, 4) DllStructSetData($RELINT, 1, 0.0, 5) EndSwitch Local $RELPOS = DllStructCreate("Float[5]") DllStructSetData($RELPOS, 1, 0.0, 1) If $3D <> 3 Then DllStructSetData($RELPOS, 1, 0.25, 2) Else DllStructSetData($RELPOS, 1, 0.15, 2) EndIf DllStructSetData($RELPOS, 1, 0.5, 3) If $3D <> 3 Then DllStructSetData($RELPOS, 1, 0.75, 4) Else DllStructSetData($RELPOS, 1, 0.85, 4) EndIf DllStructSetData($RELPOS, 1, 1.0, 5) DllCall($GDIPDll, "Int", "GdipSetLineBlend", _ "Ptr", $pBRUSH, "Ptr", DllStructGetPtr($RELINT), _ "Ptr", DllStructGetPtr($RELPOS), "Int", 5) DllCall($GDIPDll, "Int", "GdipFillRectangle", "Ptr", $pGRAPHICS, _ "Ptr", $pBRUSH, "Float", 0, "Float", 0, "Float", $W, "Float", $H) Local $hBitmap = DllStructCreate("Ptr") DllCall($GDIPDll, "Int", "GdipCreateHBITMAPFromBitmap", _ "Ptr", $pBITMAP, "Ptr", DllStructGetPtr($hBitmap), "Int", 0XFFFFFFFF) $hBitmap = DllStructGetData($hBitmap, 1) DllCall($GDIPDll, "Int", "GdipDeleteBrush", "Ptr", $pBRUSH) DllCall($GDIPDll, "Int", "GdipDisposeImage", "Ptr", $pBITMAP) DllCall($GDIPDll, "Int", "GdipDeleteGraphics", "Ptr", $pGRAPHICS) DllCall($GDIPDll, "None", "GdiplusShutdown", "Ptr", $GDIPToken) DllClose($GDIPDll) GUICtrlSendMsg($idCTRL, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap) Return $hBitmap EndFunc ;==>_GUICtrlPic_GradientFill Thanks to Großvater for _GUICtrlPic_GradientFill() function! 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...
HolmesShelock Posted May 2, 2011 Author Share Posted May 2, 2011 Try this:Well, although it is no doubt nice, but so far I guess that with this example I can't load any custom image in PNG format & set it a background for any control. Am I right? [size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size] Link to comment Share on other sites More sharing options...
UEZ Posted May 2, 2011 Share Posted May 2, 2011 Well, although it is no doubt nice, but so far I guess that with this example I can't load any custom image in PNG format & set it a background for any control. Am I right?With this example you cannot. I thought this is also a good solution without loading an image.You can use GDI+ to load the png image and send it to the pic control.Can you provide the image?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...
HolmesShelock Posted May 2, 2011 Author Share Posted May 2, 2011 (edited) With this example you cannot. I thought this is also a good solution without loading an image.You can use GDI+ to load the png image and send it to the pic control.Can you provide the image?Br,UEZSure, I've attached the image below. Edited May 2, 2011 by HolmesShelock [size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size] Link to comment Share on other sites More sharing options...
UEZ Posted May 2, 2011 Share Posted May 2, 2011 (edited) I think this is one of the best way to do it: #include <GDIPlus.au3> #include <GUIConstants.au3> #Include <GuiButton.au3> #Include <WindowsConstants.au3> Global Const $STM_SETIMAGE = 0x0172 $hMainWindow = GUICreate('MAIN', 705, 369) $Pic = GUICtrlCreatePic("", 190, 120, 490, 35) GUICtrlSetState(-1, $GUI_DISABLE) _GDIPlus_Startup () $HORIZONTAL_BAR_IMAGE = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Images\Horizontal Bar.png") $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($HORIZONTAL_BAR_IMAGE) GUICtrlSendMsg($Pic, $STM_SETIMAGE, 0, $hBmp) GUICtrlCreateCombo("Please Select", 358, 125, 320, 15) GUICtrlSetData(-1, "Test2|Test3") _WinAPI_DeleteObject($hBmp) _GDIPlus_ImageDispose($HORIZONTAL_BAR_IMAGE) _GDIPlus_Shutdown() GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit EndSelect WEnd Br, UEZ Edited May 2, 2011 by 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...
HolmesShelock Posted May 2, 2011 Author Share Posted May 2, 2011 I think this is one of the best way to do it:Thanks a lot UEZ, it served my purpose. [size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size] Link to comment Share on other sites More sharing options...
HolmesShelock Posted May 3, 2011 Author Share Posted May 3, 2011 @ UEZ,Your example sends a message to Win32 Picture control. AutoIt's documentation for GUICtrlSendMsg() says that 'msg' parameter is "type of message to be send to the control as defined in the Windows control documentation". Can you or anyone give me links which contains a complete list of messages accepted by Windows controls? Because, earlier also in several examples I've found tricky uses of message sending to various control to achieve otherwise unachievable tasks. [size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size] Link to comment Share on other sites More sharing options...
UEZ Posted May 4, 2011 Share Posted May 4, 2011 Look at MSDN to get all kind of information: http://msdn.microsoft.com/en-us/library/ff486029(v=VS.85).aspx 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...
HolmesShelock Posted May 4, 2011 Author Share Posted May 4, 2011 Look at MSDN to get all kind of information: http://msdn.microsoft.com/en-us/library/ff486029(v=VS.85).aspxThank you UEZ for the link.BTW, your profile picture is horrifying. [size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size] Link to comment Share on other sites More sharing options...
UEZ Posted May 4, 2011 Share Posted May 4, 2011 (edited) Thank you UEZ for the link.BTW, your profile picture is horrifying. Horrifying? It is the crazy Salvadore Dali better than a rose, or? Br,UEZ Edited May 4, 2011 by 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...
HolmesShelock Posted May 4, 2011 Author Share Posted May 4, 2011 Horrifying? It is the crazy Salvadore Dali Learnt a non-tech new info from you. I didn't know that he was THAT famous. better than a rose, or? :shifty: Hey, it's also artistic,romantic, eternal sign of love................ [size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size] 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