Jump to content
Sign in to follow this  
AoRaToS

Is this GUI thing possible?

Recommended Posts

AoRaToS

I am working on a GUI, I found out that with $WS_EX_LAYERED it works very well and as I want it except for 1 thing, the letters become transparent, for that not to happen I have to put an image to show behind, is that right?

Is it possible for me to just draw something behind instead of having to fileinstall a picture in my script?

I've tried this:

$hWnd = WinGetHandle("Options")

_GDIPlus_Startup()

$Graphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)

_GDIPlus_GraphicsFillRect($Graphic, 0, 0, 190, 300)

GUICtrlCreatePic($Graphic, 0, 0, 100, 200)

with no luck, if I change the $Graphic in the createpic with a black picture I have it works...

Do I have to create a jpg file with GDI and use it everytime? (Possible solution?)

Any other way to do it, fast so that the GUI doesn't take long to appear..

So acdtually what I need is a $WS_EX_LAYERED GUI but instead of transparent I want black or any other color I choose

Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
GEOSoft

GUISetBkColor()???


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
CodyBarrett

and technically your supposed to wait 24 hours before you bump.... but yeah whats wrong with guisetbkcolor?

Share this post


Link to post
Share on other sites
AoRaToS

and technically your supposed to wait 24 hours before you bump.... but yeah whats wrong with guisetbkcolor?

Sorry, I'll wait next time..

I tried that, it doesn't seem to work, the text is still transparent and I can see what's behind the letters (the desktop, another window etc)

And the Help file says:

The background is always set to transparent. GUICtrlSetBkColor() has not effect on pic control.

So I'm probably looking for some other way to do it..


s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
SmOke_N

Sorry, I'll wait next time..

I tried that, it doesn't seem to work, the text is still transparent and I can see what's behind the letters (the desktop, another window etc)

And the Help file says:

The background is always set to transparent. GUICtrlSetBkColor() has not effect on pic control.

So I'm probably looking for some other way to do it..

Post a re-creation script (that people can actually run) that demonstrates the issue you are having.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
AoRaToS

Try this, it looks allot like my GUI so I have left a few controls so you can see what happens:

What to do:

Press More

See how it looks

Then drag the right window by pressing and holding on it's top

It drags really well and the second window follows as wanted

But the letters are transparent so you can see what's behind through them, I want them black

Adding the GUICtrlSetBkColor() does nothing..

Then try removing the $WS_EX_LAYERED style from the Options GUI and see how it looks (as I want it to look) but try dragging the right one, the left doesn't follow and it get's painted over :/

So I want the black letters as they are without the $WS_EX_LAYERED style and the dragging I get with the style...

#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)

$MainGUI = GUICreate("TEST", 205, 362, @DesktopWidth - 210, Default, BitOR($WS_POPUP, $WS_DLGFRAME), $WS_EX_TOOLWINDOW)
GUICtrlCreatePic("", 1, 0, 205, 50, Default, $GUI_WS_EX_PARENTDRAG)
$More = GUICtrlCreateButton("More", 82, 300, 40, 30)
GUICtrlSetOnEvent($More, "Options")
GUISetState(@SW_SHOW)

While 1
 Sleep(100)
WEnd

Func Options()
 Local $Check[2]
 $OptionsGUI = GUICreate("Options", 190, 297, -195, +35, BitOR($WS_POPUP, $WS_OVERLAPPED), BitOR($WS_EX_TOOLWINDOW, $WS_EX_MDICHILD, $WS_EX_CLIENTEDGE, $WS_EX_LAYERED), $MainGUI)
 $okbutton = GUICtrlCreateButton("OK", 30, 277, 60, 17, $BS_DEFPUSHBUTTON)
 $cancelbutton = GUICtrlCreateButton("Cancel", 100, 277, 60, 17)
 GUICtrlSetOnEvent($cancelbutton, "onExit")
 $Tab = GUICtrlCreateTab(2, 5, 187, 270)
 $Tab1 = GUICtrlCreateTabItem("TEST")
 $ChangeUserNameLabel = GUICtrlCreateLabel("TEST", 5, 33, 55, 20)
 $ChangeUserNameInput = GUICtrlCreateInput("", 70, 30, 115, 20)
 GUICtrlSetLimit(-1, 15)
 $ChangeRefreshLabel = GUICtrlCreateLabel("Auto-Refresh", 5, 58, 70, 20)
 $ChangeRefreshInput = GUICtrlCreateInput("", 70, 55, 30, 20)
 GUICtrlSetLimit(-1, 2)
 $Combo = GUICtrlCreateCombo("", 105, 55, 80, 20)
 GUICtrlSetData(-1, "seconds|minutes|hours")
 $Check[0] = GUICtrlCreateCheckbox("TEST1", 5, 80, 115, 20)
 $Check[1] = GUICtrlCreateCheckbox("TEST2", 5, 140, 115, 20)
 $Tab2 = GUICtrlCreateTabItem("TEST")
 GUICtrlCreateLabel("ZZZZZZZZZZZZZZ", 20, 33, 150, 20)
 $CheckUpdate = GUICtrlCreateButton("No limit", 45, 80, 100, 20)
 GUICtrlCreatePic("", 0, 0, 190, 300)
 GUICtrlSetState(-1, $GUI_DISABLE)
 GUISetState(@SW_SHOW)
EndFunc   ;==>Options

Func onExit()
 Exit
EndFunc
Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
CodyBarrett

haven't looked into your code.. but i found setting the hex color to 0x020202 instead of 0x000000 works fine... (for black) you can just find a different shade of the color you want that is invisible... idk try it out if that works it works for me because in my scripts i always change the colors of controls except for buttons...

Share this post


Link to post
Share on other sites
CodyBarrett

try putting the pic infront of everything else but after the GUIcreate

Share this post


Link to post
Share on other sites
AoRaToS

the letters still stay transparent and it's all black behind the tab, is there any other way I can make the drag work nice without the layered style?


s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
reb

I have added GUICtrlSetColor in 2 places. Run this code and see if it is what you want.

REB


MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites
AoRaToS

Thanks Reb, I think that's a good step forward, but still not all controls work with it, Instead of changind every controls color using the black shade 0x020202 that CodyBarrett gave me above, I used GUICtrlSetDefColor(0x020202, $OptionsGUI) and it works for most controls. the ones it doesn't work on I tried one their own but still stay the same, the resistant ones are the checkboxes and tabnames, their text color doesn't seem to change ^_^

Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
CodyBarrett

well.. dont change button txt colors for some reason it makes the cpu load very high

edit

try using a label overtop of the txt of the radio

Edited by CodyBarrett

Share this post


Link to post
Share on other sites
AoRaToS

Well what I want is the drag to work as intended, if it's in any way possible I would be glad...It's weird that it works with the layered style, and with the composited style (no controls though) and without them it doesn't ^_^


s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
MrMitchell

Thanks Reb, I think that's a good step forward, but still not all controls work with it, Instead of changind every controls color using the black shade 0x020202 that CodyBarrett gave me above, I used GUICtrlSetDefColor(0x020202, $OptionsGUI) and it works for most controls. the ones it doesn't work on I tried one their own but still stay the same, the resistant ones are the checkboxes and tabnames, their text color doesn't seem to change ;)

After you use GUICtrlSetDefColor, You might be having trouble with the checkboxes because of the default Windows Theme. Per the help file "Checkbox, Radio or Progress controls cannot be painted if the "Windows XP style" is used." So I changed to Classic Windows and the window looks pretty good except for the tabs still. Help file also says that tabs can't be colored so I don't know how you are going to get around that one!...yet ^_^ I'm sure someone will find a way, though.

Edit: Added screenshot, that's a shot of the GUI and child after displaying the child then dragging it around the screen.

post-46937-1241377417_thumb.jpg

Edited by MrMitchell

Share this post


Link to post
Share on other sites
AoRaToS

I've read that, most computers I run the program on have the old Windows theme so it would be mostly ok as you said, but I want a way that works well no matter what the theme is, If I could make a black picture behind the child it would be ok, if I could make the GUI drag WITH the child as expected without using the LAYERED style it would be even better cause the whole thing with the letters would be avoided...Any one else having ideas??I'm loosing my hope that it's possible...


s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
ResNullius

I've read that, most computers I run the program on have the old Windows theme so it would be mostly ok as you said, but I want a way that works well no matter what the theme is

Don't know if this will help, but you can set individual controls in your GUIs to use the classic Windows theme.

See Siao's example here: http://www.autoitscript.com/forum/index.ph...st&p=402201

Share this post


Link to post
Share on other sites
martin

So there is no way for this to happen I guess...

If you want a window to maintain it's position relative to another window then it's not particulary difficult no matter what type of window and what controls you have.

Here is your code modified a bit.

#include <GuiConstantsEx.au3>
  #include <ButtonConstants.au3>
  #include <Constants.au3>
  #include <WindowsConstants.au3>
  #include <StaticConstants.au3>
  #include <Misc.au3>
  
  Opt("GUIOnEventMode", 1)
  Global $OptionsGUI = -1
  $MainGUI = GUICreate("TEST", 205, 362, @DesktopWidth - 210, Default, BitOR($WS_POPUP, $WS_DLGFRAME), $WS_EX_TOOLWINDOW)
  GUICtrlCreatePic("", 1, 0, 205, 50, Default, $GUI_WS_EX_PARENTDRAG)
  $More = GUICtrlCreateButton("More", 82, 300, 40, 30)
  GUICtrlSetOnEvent($More, "Options")
  GUISetState(@SW_SHOW)
  GUIRegisterMsg($WM_MOVE,"Follow")
  While 1
      Sleep(100)
  WEnd
  
  Func Options()
      if IsHWnd($OptionsGUI) then return
      Local $Check[2], $wp = wingetPos($MainGui)
      $OptionsGUI = GUICreate("Options", 190, 297, $wp[0] - 190,$wp[1], BitOR($WS_POPUP, $WS_OVERLAPPED), BitOR($WS_EX_TOOLWINDOW, $WS_EX_CLIENTEDGE));, BitOR($WS_POPUP, $WS_OVERLAPPED), BitOR($WS_EX_TOOLWINDOW, $WS_EX_MDICHILD, $WS_EX_CLIENTEDGE, $WS_EX_LAYERED), $MainGUI)
      $okbutton = GUICtrlCreateButton("OK", 30, 277, 60, 17, $BS_DEFPUSHBUTTON)
      $cancelbutton = GUICtrlCreateButton("Cancel", 100, 277, 60, 17)
      GUICtrlSetOnEvent($cancelbutton, "onExit")
      $Tab = GUICtrlCreateTab(2, 5, 187, 270)
      $Tab1 = GUICtrlCreateTabItem("TEST")
      $ChangeUserNameLabel = GUICtrlCreateLabel("TEST", 5, 33, 55, 20)
      $ChangeUserNameInput = GUICtrlCreateInput("", 70, 30, 115, 20)
      GUICtrlSetLimit(-1, 15)
      $ChangeRefreshLabel = GUICtrlCreateLabel("Auto-Refresh", 5, 58, 70, 20)
      $ChangeRefreshInput = GUICtrlCreateInput("", 70, 55, 30, 20)
      GUICtrlSetLimit(-1, 2)
      $Combo = GUICtrlCreateCombo("", 105, 55, 80, 20)
      GUICtrlSetData(-1, "seconds|minutes|hours")
      $Check[0] = GUICtrlCreateCheckbox("TEST1", 5, 80, 115, 20)
      $Check[1] = GUICtrlCreateCheckbox("TEST2", 5, 140, 115, 20)
      $Tab2 = GUICtrlCreateTabItem("TEST")
      GUICtrlCreateLabel("ZZZZZZZZZZZZZZ", 20, 33, 150, 20)
      $CheckUpdate = GUICtrlCreateButton("No limit", 45, 80, 100, 20)
      GUICtrlCreatePic("", 0, 0, 190, 300)
      GUICtrlSetState(-1, $GUI_DISABLE)
      GUISetState(@SW_SHOW)
  EndFunc;==>Options
  
  Func onExit()
      Exit
  EndFunc;==>onExit
  
  Func Follow($hWnd,$iMsg,$wParam,$lParam)
     Local $iX,$iY
     If $hWnd <> $MainGUI then return

     $iX = BitAnd($lParam,0xFFFF)
     $iY = BitAnd($lParam,0xffff0000)/0x10000
     
     winmove($OptionsGUI,"",$iX - 190,$iY)
     
 EndFunc
Edited 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.

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  

×