Jump to content

Custom ScrollBar


Recommended Posts

>Topic Solved

Hey Every1 !!

I'm a Very Novice Coder..........
and don't know how Everything does The Work.........
Therefore no Idea of making a custom Scrollbar for a Edit Control.........

Herez the Code of my Gui
 

Global $ghGDIPBrush = 0
Global $ghGDIPDll = 0
Global $ghGDIPPen = 0
Global $giGDIPRef = 0
Global $giGDIPToken = 0
Global Const $tagGDIPSTARTUPINPUT = "uint Version;ptr Callback;bool NoThread;bool NoCodecs"
Global $hGui
#region -GDI +
Func _GDIPlus_Startup()
$giGDIPRef += 1
If $giGDIPRef > 1 Then Return True
$ghGDIPDll = DllOpen("GDIPlus.dll")
If $ghGDIPDll = -1 Then Return SetError(1, 2, False)
Local $tInput = DllStructCreate($tagGDIPSTARTUPINPUT)
Local $pInput = DllStructGetPtr($tInput)
Local $tToken = DllStructCreate("ulong_ptr Data")
Local $pToken = DllStructGetPtr($tToken)
DllStructSetData($tInput, "Version", 1)
Local $aResult = DllCall($ghGDIPDll, "int", "GdiplusStartup", "ptr", $pToken, "ptr", $pInput, "ptr", 0)
If @error Then Return SetError(@error, @extended, False)
$giGDIPToken = DllStructGetData($tToken, "Data")
Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_Startup
Func _GDIPlus_GraphicsCreateFromHWND($hWnd)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateFromHWND", "hwnd", $hWnd, "ptr*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aResult[0], $aResult[2])
EndFunc   ;==>_GDIPlus_GraphicsCreateFromHWND
Func _GDIPlus_PenCreate($iARGB = 0xFF000000, $fWidth = 1, $iUnit = 2)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePen1", "dword", $iARGB, "float", $fWidth, "int", $iUnit, "ptr*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aResult[0], $aResult[4])
EndFunc   ;==>_GDIPlus_PenCreate
Func _GDIPlus_GraphicsDrawLine($hGraphics, $iX1, $iY1, $iX2, $iY2, $hPen = 0)
__GDIPlus_PenDefCreate($hPen)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawLineI", "handle", $hGraphics, "handle", $hPen, "int", $iX1, "int", $iY1, _
   "int", $iX2, "int", $iY2)
Local $tmpError = @error, $tmpExtended = @extended
__GDIPlus_PenDefDispose()
If $tmpError Then Return SetError($tmpError, $tmpExtended, False)
Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_GraphicsDrawLine
Func __GDIPlus_PenDefCreate(ByRef $hPen)
If $hPen = 0 Then
  $ghGDIPPen = _GDIPlus_PenCreate()
  $hPen = $ghGDIPPen
EndIf
EndFunc   ;==>__GDIPlus_PenDefCreate
Func __GDIPlus_PenDefDispose()
If $ghGDIPPen <> 0 Then
  _GDIPlus_PenDispose($ghGDIPPen)
  $ghGDIPPen = 0
EndIf
EndFunc   ;==>__GDIPlus_PenDefDispose
Func _GDIPlus_PenDispose($hPen)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipDeletePen", "handle", $hPen)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_PenDispose
Func _GDIPlus_Shutdown()
If $ghGDIPDll = 0 Then Return SetError(-1, -1, False)
$giGDIPRef -= 1
If $giGDIPRef = 0 Then
  DllCall($ghGDIPDll, "none", "GdiplusShutdown", "ptr", $giGDIPToken)
  DllClose($ghGDIPDll)
  $ghGDIPDll = 0
EndIf
Return True
EndFunc   ;==>_GDIPlus_Shutdown
Func _GDIPlus_GraphicsDispose($hGraphics)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipDeleteGraphics", "handle", $hGraphics)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_GraphicsDispose
#endregion -GDI +

_GetInput('heya',300)
Func _GetInput($sTitle,$sBig=100,$sText='PassWord',$sFirstButton='Ok',$sSecondButton='Cancel')
Local $sPrevious=Opt('GUIOnEventMode',0)
$hGui= GUICreate($sTitle, 300, $sBig, -1, -1  , 0x80000000, BITOR(0x00000008, 0x00000080))
GUISetBkColor(0)
GUIRegisterMsg(0x0084, "WM_NCHITTEST")
Local $sLabel[3]=[GUICtrlCreateLabel($sText,20,10,160,15),GUICtrlCreateLabel($sFirstButton,150,$sBig-30,50,12),GUICtrlCreateLabel($sSecondButton,200,$sBig-30,50,12)]
For $i=0 To 2
  GUICtrlSetColor($sLabel[$i],0xffffff)
  GUICtrlSetBkColor($sLabel[$i],-2)
  If $i=0 Then ContinueLoop
  GUICtrlSetCursor($sLabel[$i],0)
Next
Local $sInput=GUICtrlCreateEdit('',20,30,260,$sBig-65)
WinSetTrans($hGui, "", 0)
GUISetState(@SW_SHOW, $hGui)
_DrawLine($hGui,10, $sBig-25,90,$sBig-25)
_DrawLine($hGui,10, $sBig-15,70, $sBig-15)
_DrawLine($hGui,15, 10,15, $sBig-10)
_DrawLine($hGui,200, 10,290, 10)
_DrawLine($hGui,240, 20,290, 20)
_DrawLine($hGui,285, 7,285, $sBig-10)
For $I = 0 To 207 Step 0.02
  WinSetTrans($hGui, "", $I)
Next
Local $sMsg
While $sMsg<>-3
  $sMsg=GUIGetMsg()
  Switch $sMsg
   Case $sLabel[1]
    Switch GUICtrlRead($sInput)
     Case ''
      GUICtrlSetData($sLabel[0],'Please Enter The Password')
      ContinueLoop
    EndSwitch
    Return GUICtrlRead($sInput)
   Case $sLabel[2]
    ExitLoop
  EndSwitch
WEnd
For $I = 207 To 0 Step -0.02
  WinSetTrans($hGui, "", $I)
Next
GUIDelete($hGui)
Opt('GUIOnEventMode',$sPrevious)
Return -1
EndFunc

Func WM_NCHITTEST($HWND, $IMSG, $WPARAM, $LPARAM)
If $HWND = $hGui Then Return 2
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:'&@error&@CRLF)
; Clean up resources
_GDIPlus_PenDispose ($hPen)
_GDIPlus_GraphicsDispose ($hGraphic)
_GDIPlus_ShutDown ()
;Done.....
EndFunc   ;==>_Main

For the Windows basic ScrollBar that just Spoils the C00l GUI's Look...........
I just Wanted that i could use a BMP as the Scroll Bar for my GUI or i could just change the color of the Scroll Bar.........

If u have C++ knowledge this may do the work

Thanks for Any Help..........

Regards
Phoenix XL

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.

Link to comment
Share on other sites

You can start to learn details about ScrollBars here:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb787529%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/ms997557.aspx

EDIT:

My advice: If you are beginner then don't do such complicated things and stick to standard controls.

Edited by Zedna
Link to comment
Share on other sites

@Zedna,

Thnx For the Reply..
But No Luck with the Help either
Being a Beginner I shouldnt Try This.

When my School Summer Vacations Would Start..This Would Of Course be my First Project :)

On Successful Results I will obviously Share it.  ;)

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

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