Jump to content

Recommended Posts

Posted (edited)

Hiho,

I saw this GUI style in recent discussions and did some reading. After I implemented it in SMF's main GUI I thought it would be worth to write a little example around it :)...

  'MSDN said:

http://msdn.microsoft.com/en-us/library/ms632680%28VS.85%29.aspx

Windows XP: With WS_EX_COMPOSITED set, all descendants of a window get bottom-to-top painting order using double-buffering. Bottom-to-top painting order allows a descendent window to have translucency (alpha) and transparency (color-key) effects, but only if the descendent window also has the WS_EX_TRANSPARENT bit set. Double-buffering allows the window and its descendents to be painted without flicker.

Note that the "bottom-to-top painting order" requires you to draw overlapping controls in the opposite order as usually done, means with the $WS_EX_COMPOSITED style set you need to create the background control AFTER the foreground control. It makes GUI updates a little more sluggish, but I think that's fully acceptable.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         KaFu, Authenticity, Zedna

 Script Function:
    Double buffered GUI with $WS_EX_COMPOSITED
    See also http://msdn.microsoft.com/en-us/library/ms632680%28VS.85%29.aspx

#ce ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

HotKeySet("{ESC}", "_Exit")

; ===============
; Test #1 with double buffer
; ===============

Global Const $WS_EX_COMPOSITED = 0x2000000

$hGUI = GUICreate("Test #1 with double buffer", 300, 200, -1, -1, -1, $WS_EX_COMPOSITED)

$button = GUICtrlCreateButton("Double Buffer Test", 50, 45, 200, 20)

$label = GUICtrlCreateLabel("Double Buffer Test", 0, 115, 300, 20, $SS_CENTER)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

; Background control, create AFTER foreground control
GUICtrlCreateLabel("", 0, 0, 300, 200)
GUICtrlSetBkColor(-1, 0x21AB9A)

GUISetState()
Sleep(1000)

For $i = 0 To 3000
    GUICtrlSetData($label, "Double Buffer Test " & $i)
    GUICtrlSetData($button, "Double Buffer Test " & $i)
Next

GUIDelete($hGUI)

; ===============
; Test #2 without double buffer
; ===============
$hGUI = GUICreate("Test #2 without double buffer", 300, 200)

; Background control, create BEFORE foreground control
GUICtrlCreateLabel("", 0, 0, 300, 200)
GUICtrlSetBkColor(-1, 0x21AB9A)

$button = GUICtrlCreateButton("Double Buffer Test", 50, 45, 200, 20)

$label = GUICtrlCreateLabel("Double Buffer Test", 0, 115, 300, 20, $SS_CENTER)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUISetState()
Sleep(1000)

For $i = 0 To 10000
    GUICtrlSetData($label, "Double Buffer Test " & $i)
    GUICtrlSetData($button, "Double Buffer Test " & $i)
Next

GUIDelete($hGUI)

_Exit()

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Cheers ;)...

Edited by KaFu
Posted

Good trick.

P.S

I wonder why is this not documented, and/or why $WS_EX_COMPOSITED is not in the «WindowsConstants.au3» include?

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

Hm, i've noticed that with this style the data updated slower than usualy...

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  On 11/28/2009 at 4:22 PM, 'MrCreatoR said:

Hm, i've noticed that with this style the data updated slower than usualy...

Yeah, I think double buffering just takes some time for background processing. But it's still fast enough for my needs :)...
Posted

I too wonder why this isn't included in WindowsConstants.au3. I use this style in many of my guis that have controls that frequently change. Great example.

Posted (edited)

  On 11/28/2009 at 5:39 PM, 'Yashied said:

Nice stuff, but what if I want to use, for example, buttons?

Still works like a charm ;), updated example in first post. Btw, I'm using it in SMF now, and that one I think contains all available standard controls :)... Edited by KaFu
Posted

  On 11/28/2009 at 5:47 PM, 'KaFu said:

Still works like a charm ;), updated example in first post. Btw, I'm using it in SMF now, and that one I think contains all available standard controls :)...

Strange things happening with tree view controls (tooltips mostly) here.

♡♡♡

.

eMyvnE

Posted

  On 11/28/2009 at 6:07 PM, 'trancexx said:

Strange things happening with tree view controls (tooltips mostly) here.

Thinking about it... you're right :), after adding that style to the GUI I also added $TVS_NOTOOLTIPS to my TreeView controls.
Posted (edited)
  Quote

I'm using it in SMF now

It's not a good idea to use that abbreviature, well known Simple Machines Forum abbreviated as SMF :) Edited by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

Global Const $WS_EX_COMPOSITED = 0x2000000

GUICreate('MyGUI', 400, 400, -1, -1, -1, $WS_EX_COMPOSITED)
GUICtrlCreateListView('Test', 10, 10, 380, 353)
GUICtrlCreateButton('OK', 170, 370, 70, 23)
GUISetState()

Do
Until GUIGetMsg() = -3

???

Edited by Yashied
Posted (edited)

sandin already used $WS_EX_COMPOSITED in his game Bounce The Sun. It is unfortunatelly not working with Vista and probably not with Win7 - it is flickering! :)

The days with WinXP are numbered...

UEZ

Edited 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted
  Quote

The days with WinXP are numbered.

Can not agree on that one. Win XP still used on school's and offices's computers. Win Vista / Seven is very demanding on computer resources.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  On 11/28/2009 at 8:01 PM, 'MrCreatoR said:

Can not agree on that one. Win XP still used on school's and offices's computers. Win Vista / Seven is very demanding on computer resources.

Computers are also updating though. When XP was first released as a beta thats probably what everyone said ;), and in 20 years time, windows XP will be like what windows 2000 is today.

As to the topic, as shown in bounce the sun, this makes games very easy to make, :)

Mat

Posted

  On 11/28/2009 at 7:12 PM, 'UEZ said:

It is unfortunatelly not working with Vista and probably not with Win7. :)

Really? Can anybody confirm this? Ts, sorry, that renders the Style useless in my eyes...
Posted

As I mentioned in sandin's thread it flickers with my Vista x32. I don't know whether $WS_EX_COMPOSITED works for Vista and above.

I will try the game in my VM with Win7 x64 but VMs have sometimes not same behaviour as on real hardware.

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

  On 11/28/2009 at 8:01 PM, 'MrCreatoR said:

Can not agree on that one. Win XP still used on school's and offices's computers. Win Vista / Seven is very demanding on computer resources.

Yes, but old hardware will be replaced someday. WinXP is not sold anymore and like Win98SE it will became someday a rememberance. All new hardware will be installed with Win7+...

UEZ

Edited 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

  On 11/28/2009 at 6:33 PM, 'MrCreatoR said:

It's not a good idea to use that abbreviature, well known Simple Machines Forum abbreviated as SMF ;)

Yeah, learned that earlier and decided to ignore it...theirs is a forum software, mines a window application, theirs is for sale, mine for free, they're sitting in the US, I'm in Germany... and the official name of my tool is "SMF - Search my Files". If they'll ever complain (which I doubt), we'll see :)...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...