Sign in to follow this  
Followers 0
PhoenixXL

after using WM_PAINT graphic dissapears upon minimizing

4 posts in this topic

#1 ·  Posted (edited)

Hey Everyone

the Title suggests the total problem

I searched the forum and Found exactly the same problem

But the according to the discussion in that Topic it seems as if resolved but it didnt work for me :)

Since it was created very long ago therefore i started the same topic here

Here is my code which i use in replacement for InputBox

InputBoxEx:

#include <GDIPlus.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>

Local $GUI[3]=['_GetInput || Phoenix XL',0x80000000,BITOR(0x00000080,0x00000008)]
Local $Input_Text[3][5]=[['Your Old Password','Password','This Field is Blank',20,0x2000], _
['********','New Password','This Field is Blank',20,0x2000], _
['','Confirm New Password','This Field is Blank',20,0x2000]]

Local $sButton[2][2]=[['Okay'], _
['Cancel']]

$sLong=_InputBoxEx($GUI,$Input_Text,$sButton)
$Control_ID_Array=BitShift($sLong,16)
ConsoleWrite('   '&IsArray($Control_ID_Array)&@CRLF)
$sGui=HWnd(BitAND($sLong,0xFFFF))
For $I = 207 To 0 Step -0.02
WinSetTrans($sGui, "", $I)
Next
GUIDelete($sGui)
;ConsoleWrite('GUI:'&$sGui&@CRLF)

Func _InputBoxEx($GUI=-1,$sInput_Text=-1,$sButton=-1)
If $sButton=-1 Then
Local $sx[2][2]=[  ['Okay'], _
['Cancel']  ]
$sButton=$sx
EndIf
If $sInput_Text=-1 Then

Local $sx[1][5]=[  ['Your Password', _
'Password', _
'Please Enter The Password', _
20, _
0x0020]   ]
$sInput_Text=$sx
EndIf
If $GUI=-1 Then
Local $sx[3]=['InputBoxEx || Phoenix XL',0x80000000,BITOR(0x00000080,0x00000008)]
$GUI=$sx
EndIf


Global $Notify=0,$__NotifyDone[1]=[0]
Local $sPrevious=Opt('GUIOnEventMode',0),$sReturn=-1
Local $vMargin=20,$__Loop=0
Local $sSpacing=28,$sButton_Height=15,$tRectF
Local $hOffset=0,$sButton_Width=50
For $n=0 To UBound($Input_Text,1)-1
$hOffset+=$Input_Text[$n][3]
Next
;ConsoleWrite('Offset:'&$hOffset&@CRLF)
Global $gHeight=$hOffset+((UBound($sInput_Text)-1)*$sSpacing)+(2*$vMargin)+(UBound($sInput_Text)*15)+($sButton_Height),$gWidth=350,$hMargin=30
$hOffset=0
;ConsoleWrite('Height:'&$gHeight&@CRLF)
Global $hGui= GUICreate($GUI[0], $gWidth, $gHeight, -1, -1  , $GUI[1], $GUI[2]) ;0x80000000 ;BITOR(0x00000080,0x00000008)
Local $sGui=GUISwitch($hGui)


GUISetBkColor(0)


Local $s_Button[UBound($sButton,1)]
For $n=0 To UBound($sButton,1)-1
;$s_Button[$n]=_GUICtrlCreateLabel($hGui,$sButton[$n][0],150+$hOffset,$gHeight-30,$sButton_Width,15)
ConsoleWrite($sButton[$n][1]&@CRLF)
$s_Button[$n]=GUICtrlCreateButton($sButton[$n][0],150+$hOffset,$gHeight-($sButton_Height+$vMargin),$sButton_Width,$sButton_Height,0x0001)
GUICtrlSetBkColor(-1,0)
GUICtrlSetColor(-1,0xFFD700)
$hOffset+=$sButton_Width+10
Next

Local $sInput[UBound($sInput_Text,1)]
Local $sLabel[UBound($sInput_Text,1)]
;For $n=0 To UBound($sInput_Text,1)-1
;ConsoleWrite('n:'&$n&$sInput_Text[0][0]&@CRLF)
;$sInput[$n]=GUICtrlCreateEdit($sInput_Text[$n][0],20,30,260,$sInput_Text[$n][2],$sInput_Text[$n][1]);$ES_WANTRETURN+$ES_MULTILINE+$WS_VSCROLL+$WS_HSCROLL
;$sLabel[$n]=_GUICtrlCreateLabel($hGui,$sInput_Text[$n][3],20,10,-1,15)
;Next

$hOffset=0
For $n=0 To UBound($sInput_Text,1)-1
$sLabel[$n]=_GUICtrlCreateLabel($hGui,$sInput_Text[$n][1],$hMargin,$vMargin+$hOffset,-1,15,2)
$sInput[$n]=GUICtrlCreateEdit($sInput_Text[$n][0],$hMargin,$vMargin+$hOffset+17,$gWidth-(2*$hMargin),$sInput_Text[$n][3],$sInput_Text[$n][4])
GUICtrlSetBkColor(-1,0xE8E8E8)
GUICtrlSetColor(-1,0x484848  )
$hOffset+=$sInput_Text[$n][3]+$sSpacing
Next

;ConsoleWrite('X:'&$sPos[0]&@TAB&'Y:'&$sPos[1]&@TAB&'Width:'&$sPos[2]&@TAB&'Height:'&$sPos[3]&@CRLF)
;_ScrollBar_Create($hGui,$sInput)
WinSetTrans($hGui, "", 0)
GUISetBkColor(0)
GUIRegisterMsg(0x0111,'WM_COMMAND')
GUIRegisterMsg(0x0100,'WM_KEYDOWN')
GUIRegisterMsg(0x000F,'WM_PAINT')
GUISetState(@SW_SHOW, $hGui)
GUICtrlCreatePic('',0,0,350,$gHeight,-1,0x00100000)
For $I = 0 To 207 Step 0.02
WinSetTrans($hGui, "", $I)
Next

Local $sMsg
While $sMsg<>-3
$sMsg=GUIGetMsg()
Switch $sMsg
Case $s_Button[0]
For $n=0 To UBound($sInput)-1
Switch GUICtrlRead($sInput[$n])
Case '',$sInput_Text[$n][2],$sInput_Text[$n][0]
Local $asSize = CalcRectangle($sInput_Text[$n][2])
ConsoleWrite($asSize[0]&'-'& $asSize[1]&@CRLF)
ControlMove($hGui, "", $sLabel[$n], Default, Default, $asSize[0], $asSize[1])
GUICtrlSetData($sLabel[$n],$sInput_Text[$n][2])
GUICtrlSetData($sInput[$n],'')
GUICtrlSetState($sLabel[$n],256)
ExitLoop
Case Else
If $n==UBound($sInput)-1 Then
$sReturn=$sInput
ExitLoop 2
EndIf
EndSwitch
Next
Case $s_Button[1]
$sReturn=-1
ExitLoop
EndSwitch
If $Notify<>0 Then
For $_=1 To $__NotifyDone[0]
If $__NotifyDone[$_]<>$Notify Then ContinueLoop
GUICtrlSetData($Notify,'')
GUICtrlSetState($Notify,256)
$__NotifyDone[0]+=1
ReDim $__NotifyDone[$__NotifyDone[0]+1]
$__NotifyDone[$__NotifyDone[0]]=$Notify
Next
EndIf
WEnd
;For $I = 207 To 0 Step -0.02
; WinSetTrans($hGui, "", $I)
;Next
ConsoleWrite('GUI:'&$hGui&@CRLF)
Opt('GUIOnEventMode',$sPrevious)
GUISwitch($sGui)
;Local $sHandle
Return _MakeLong($hGui,$sReturn)
EndFunc

Func WM_COMMAND($hWnd,$iMsg,$wParam,$lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Local  $nID= BitAND($wParam, 0xFFFF)
Switch $nNotifyCode
Case 0x100
GUICtrlSetBKColor($nID,0xFFFFFF)
If IsDeclared($nID) Then Return
Assign($nID,True,2)
GUICtrlSetData($nID,'')
GUICtrlSetColor(-1,0)
Case 0x200
GUICtrlSetBKColor($nID,0xD8D8D8  )
EndSwitch
Return 'GUI_RUNDEFMSG'
EndFunc
Func WM_PAINT($hWnd,$iMsg,$wParam,$lParam)
_DrawLine($hGui,10, $gHeight-25,90,$gHeight-25)
_DrawLine($hGui,10, $gHeight-15,70, $gHeight-15)
_DrawLine($hGui,15, 10,15, $gHeight-10)
_DrawLine($hGui,$gWidth-($hMargin/2), 10,$gWidth-(($hMargin/2)+90), 10)
_DrawLine($hGui,$gWidth-($hMargin/2), 20,290, 20)
_DrawLine($hGui,$gWidth-(($hMargin/2)+5), 7,$gWidth-(($hMargin/2)+5), $gHeight-10)
;_WinAPI_UpdateWindow($hGui)
;ConsoleWrite('WM_PAINT'&@CRLF)
Return 'GUI_RUNDEFMSG'
EndFunc
Func WM_KEYDOWN($hWnd,$iMsg,$wParam,$lParam)
Switch $wParam
Case 0x0D
Assign('Enter_Pressed',True,2)
EndSwitch
Return 'GUI_RUNDEFMSG'
EndFunc

Func _GuiCtrlCreateLabel($sHwnd,$sText,$sLeft,$sTop,$sWidth,$sHeight,$sCursor=0,$sColor=0xFFD700,$sBkColor=-2,$sStyle=-1,$sExStyle=-1)
Local $sPrevious=GUISwitch($sHwnd)
Local $sLabel=GUICtrlCreateLabel($sText,$sLeft,$sTop,$sWidth,$sHeight,$sStyle,$sExStyle)
GUICtrlSetBkColor(-1,$sBkColor)
GUICtrlSetColor(-1,$sColor)
GUICtrlSetCursor(-1,$sCursor)
GUISwitch($sPrevious)
Return $sLabel
EndFunc


Func CalcRectangle($sString, $sFont='Arial',$fFontsize=8.5)
_GDIPlus_Startup()
    Local $aResult, $hFont, $i=0 ,$iLen = StringLen($sString),$tLayout
    Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(WinGetHandle(AutoItWinGetTitle()))
    Local $tRectF = DllStructCreate($tagGDIPRECTF)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFont = _GDIPlus_FontCreate( _GDIPlus_FontFamilyCreate($sFont), $fFontsize, 0)
    Do
$tLayout = _GDIPlus_RectFCreate(0, 0, $i, 0)
        $aResult = DllCall($ghGDIPDll, "int", "GdipMeasureString", _
  "handle", $hGfx, _
  "wstr", $sString, _
  "int", $iLen, _
  "handle", $hFont, _
  "struct*", $tLayout, _
  "handle", $hFormat, _
  "struct*", $tRectF, _
  "int*", 0, _
  "int*", 0)
If $aResult[8] >=  $iLen Then ExitLoop
        $i += 1
    Until False
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_GraphicsDispose($hGfx)
    $tLayout  = 0
Local $sReturn[2]=[DllStructGetData($aResult[7],'Width'),DllStructGetData($aResult[7],'Height')]
_GDIPlus_Shutdown()
    Return $sReturn
EndFunc

Func _DrawLine($Gui,$x1,$y1,$x2,$y2,$sChannel='80FFD700')
Local  $hGraphic, $hPen
; Draw line
_GDIPlus_Startup ()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($Gui)
$hPen = _GDIPlus_PenCreate ('0x'&$sChannel)
If Not _GDIPlus_GraphicsDrawLine ($hGraphic, $x1,$y1,$x2,$y2, $hPen) Then ConsoleWrite('Error from GDI+:'&@error&@CRLF)
; Clean up resources
_GDIPlus_PenDispose ($hPen)
_GDIPlus_GraphicsDispose ($hGraphic)
_GDIPlus_ShutDown ()
;Done.....
EndFunc   ;==>_Main

Func _MakeLong($iLo, $iHi)
Return BitOR(BitShift($iHi, -16), BitAND($iLo, 0xFFFF))
EndFunc   ;==>_WinAPI_MakeLong

The problem is the Golden Lines Dissapear when Minimizing or when i drag the pointer of Autoit Window Info Tool over it

i even noticed that onfocus i change the color of the Input which Triggers the WM_PAINT and Lines are again drawn due to which the Golden Lines get more and more Glowing

Please Help me out

Thanks for you Time ;)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites



works like a charm

Thnx Zedna


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

1 more doubt

In my Script

when the edit control receives focus the background color changes to White

and when it receives killfocus the background changes to grey

In both the above cases WM_PAINT is called and it PAINTS the golden lines over and over making it more yellowish

is there a way to avoid this


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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