Sign in to follow this  
Followers 0
qwert

The Case of the Vanishing Gradient

3 posts in this topic

I’ve only worked with gradients for a few hours. But one of my very first test scripts has a big problem:

The contents of the GUI vanishes when any other window gains focus.

#Include <WinAPIEx.au3>
Global $aVertex[2][3] = [[0, 0, 0x81F70F], [200, 600, 0x002F2F]]

$hForm = GUICreate('MyGUI', 200, 600)
$hDC = _WinAPI_GetDC($hForm)
GUISetState()
_WinAPI_GradientFill($hDC, $aVertex, 0, 1)
_WinAPI_ReleaseDC($hForm, $hDC)

Do
Until GUIGetMsg() = -3

I've tried moving the ReleaseDC to the very bottom ... and a couple of variations of GUISetState.

How do I lock the gradient in place until the GUI is deleted?

Thanks in advance for any help.

Share this post


Link to post
Share on other sites



#Include <GUIConstantsEx.au3>
#Include <WinAPIEx.au3>

Global Const $STM_SETIMAGE = 0x0172

Dim $aVertex[2][3] = [[0, 0, 0x81F70F], [200, 600, 0x002F2F]]

$hDC = _WinAPI_CreateCompatibleDC(0)
$hBitmap = _WinAPI_CreateBitmap(200, 600, 1, 32)
$hSv = _WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_GradientFill($hDC, $aVertex, 0, 1)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteDC($hDC)

$hForm = GUICreate('MyGUI', 200, 600)
GUICtrlCreatePic('', 0, 0, 200, 600)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSendMsg(-1, $STM_SETIMAGE, 0, $hBitmap)
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites

Thank you for the quick response.  It gives exactly the result I'd hoped to get ... although I admit that I'm not far enough into working with gradient fills to understand exactly the differences.  But that's OK.

I'll take this as my new baseline example and look forward to learning more as I go.

I appreciate your help.

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  
Followers 0