Jump to content

Transparent checkbox


funkey
 Share

Recommended Posts

Here is an example:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <SliderConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>

Global Const $tagNMCUSTOMDRAW = 'hwnd hWndFrom;uint_ptr IDFrom;int Code;dword DrawStage;hwnd hDC;' & $tagRECT & ';dword_ptr ItemSpec;uint ItemState;lparam ItemlParam'
Global Const $STM_GETIMAGE = 0x0173

Global $hGui = GUICreate("Test transparent checkbox replacement", 400, 200)
GUICtrlCreatePic(StringReplace(@AutoItExe, "AutoIt3.exe", "") & "Examples\GUI\msoobe.jpg", 0, 0, 400, 200, 0)
Global $hPic = GUICtrlGetHandle(-1)


GUICtrlCreateCheckbox("Standard checkbox", 10, 10, 200, 20)

GUICtrlCreateCheckbox("Standard checkbox transparent", 10, 50, 200, 20)
GUICtrlSetBkColor(-1, -2)

GUICtrlCreateCheckbox("Standard checkbox workaround", 10, 90, 13, 13)
GUICtrlCreateLabel("Standard checkbox workaround", 26, 90, 200, 13)
GUICtrlSetBkColor(-1, -2)


Global $hCB1 = _GuiCtrlCreateTransparentCheckbox("TransparentCheckbox 1", 10, 130)
Global $hCB2 = _GuiCtrlCreateTransparentCheckbox("TransparentCheckbox 2", 10, 170)

GUIRegisterMsg(0x004E, '_WM_NOTIFY')

GUISetState()

Do
Until GUIGetMsg() = -3

Func _GuiCtrlCreateTransparentCheckbox($text, $left, $top, $width = Default, $height = 13, $style = -1, $exStyle = 0)
GUICtrlCreateCheckbox($text, $left, $top, $width, $height, $style, $exStyle)
Return GUICtrlGetHandle(-1)
EndFunc   ;==>_GuiCtrlCreateTransparentCheckbox

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam)
Local $hWndFrom = DllStructGetData($tNMCD, 'hWndFrom')
Local $Code = DllStructGetData($tNMCD, 'Code')
Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage')
Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec')
Local $hDC = DllStructGetData($tNMCD, 'hDC')
Local $hMemDC, $hBitmap, $hPrev
Local $aPos

Switch $hWndFrom
  Case $hCB1, $hCB2
   Switch $Code
    Case $NM_CUSTOMDRAW
     Switch $DrawStage
      Case $CDDS_PREPAINT, $CDDS_POSTPAINT
       $aPos = ControlGetPos($hWndFrom, '', '')
       Switch $DrawStage
        Case $CDDS_PREPAINT
;~          DllStructSetData($tNMCD, 'ItemState', BitXOR(DllStructGetData($tNMCD, 'ItemState'), $CDIS_FOCUS))
         $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
         $hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0)
         $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap)
         _WinAPI_BitBlt($hDC, 13, 0, $aPos[2], $aPos[3], $hMemDC, $aPos[0] + 13, $aPos[1], $SRCCOPY)
         _WinAPI_SelectObject($hMemDC, $hPrev)
         _WinAPI_DeleteDC($hMemDC)
         Return BitOR($CDRF_NOTIFYITEMDRAW, $CDRF_NOTIFYPOSTPAINT)
       EndSwitch
     EndSwitch
   EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Very good idea!

But here is the implementation that i would use for such idea:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global Enum _
    $i_Start_Row = -1, _
        $i_hGUI_Row, $i_hPic_Row, $i_hCB_Row, _
    $i_Total_Rows
Global $aTrnsChckBxs_DATA[1][$i_Total_Rows]

$hGUI = GUICreate("Test transparent checkbox replacement", 400, 200)
$nPic = GUICtrlCreatePic(@AutoItExe & "\..\Examples\GUI\msoobe.jpg", 0, 0, 400, 200, 0)

GUICtrlCreateCheckbox("Standard checkbox", 10, 10, 200, 20)
GUICtrlCreateCheckbox("Standard checkbox transparent", 10, 50, 200, 20)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateCheckbox("Standard checkbox workaround", 10, 90, 13, 13)
GUICtrlCreateLabel("Standard checkbox workaround", 26, 90, 200, 13)
GUICtrlSetBkColor(-1, -2)

$nCB1 = _GUICtrlTransCheckbox_Create($hGUI, $nPic, "TransparentCheckbox 1", 10, 130)
$nCB2 = _GUICtrlTransCheckbox_Create($hGUI, $nPic, "TransparentCheckbox 2", 10, 170)

GUISetState(@SW_SHOW, $hGUI)

While 1
    $nGUIMsg = GUIGetMsg()
    
    Switch $nGUIMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nCB1, $nCB2
            ConsoleWrite("CheckBox [" & GUICtrlRead($nGUIMsg, 1) & "] checked = " & (GUICtrlRead($nGUIMsg) = $GUI_CHECKED) & @LF)
    EndSwitch
WEnd

Func _GUICtrlTransCheckbox_Create($hGUI, $nBackPic, $sText, $iLeft, $iTop, $iWidth = -1, $iHeight = 13, $iStyle = -1, $iExStyle = 0)
    Local $nCB = GUICtrlCreateCheckbox($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle)
    Local $hCB = GUICtrlGetHandle($nCB)
    Local $hPic = GUICtrlGetHandle($nBackPic)
    
    If $aTrnsChckBxs_DATA[0][0] = 0 Then
        GUIRegisterMsg($WM_NOTIFY, '_TrnsChckBx_WM_NOTIFY')
    EndIf
    
    $aTrnsChckBxs_DATA[0][0] += 1
    ReDim $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]+1][$i_Total_Rows]
    
    $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hGUI_Row] = $hGUI
    $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hPic_Row] = $hPic
    $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hCB_Row] = $hCB
    
    Return $nCB
EndFunc

Func _GUICtrlTransCheckbox_Delete($nChckBx)
    Local $hCB = GUICtrlGetHandle($nChckBx)
    Local $aTmp[$aTrnsChckBxs_DATA[0][0]][$i_Total_Rows]
    
    GUICtrlDelete($nChckBx)
    
    For $i = 1 To $aTrnsChckBxs_DATA[0][0]
        If $aTrnsChckBxs_DATA[$i][$i_hCB_Row] <> $hCB Then
            $aTmp[0][0] += 1
            
            $aTmp[$aTmp[0][0]][$i_hGUI_Row] = $aTrnsChckBxs_DATA[$i][$i_hGUI_Row]
            $aTmp[$aTmp[0][0]][$i_hPic_Row] = $aTrnsChckBxs_DATA[$i][$i_hPic_Row]
            $aTmp[$aTmp[0][0]][$i_hCB_Row] = $aTrnsChckBxs_DATA[$i][$i_hCB_Row]
        EndIf
    Next
    
    ReDim $aTmp[$aTmp[0][0]+1][$i_Total_Rows]
    $aTrnsChckBxs_DATA = $aTmp
    
    Return $aTmp[0][0]
EndFunc

Func _TrnsChckBx_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $hWndFrom, $iIDFrom, $tNMHDR
    Local Const $tagNMCUSTOMDRAW = 'hwnd hWndFrom;uint_ptr IDFrom;int Code;dword DrawStage;hwnd hDC;' & $tagRECT & ';dword_ptr ItemSpec;uint ItemState;lparam ItemlParam'
    Local Const $STM_GETIMAGE = 0x0173
    
    Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam)
    Local $hWndFrom = DllStructGetData($tNMCD, 'hWndFrom')
    Local $iCode = DllStructGetData($tNMCD, 'Code')
    Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage')
    Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec')
    Local $hDC = DllStructGetData($tNMCD, 'hDC')
    Local $hPic, $aPos, $hMemDC, $hBitmap, $hPrev
    
    For $i = 1 To $aTrnsChckBxs_DATA[0][0]
        If $hWndFrom = $aTrnsChckBxs_DATA[$i][$i_hCB_Row] Then
            Switch $iCode
                Case $NM_CUSTOMDRAW
                    Switch $DrawStage
                        Case $CDDS_PREPAINT, $CDDS_POSTPAINT
                            $hPic = $aTrnsChckBxs_DATA[$i][$i_hPic_Row]
                            $aPos = ControlGetPos($hWnd, '', $hWndFrom)
                            
                            If @error Then
                                ExitLoop
                            EndIf
                            
                            Switch $DrawStage
                                Case $CDDS_PREPAINT
                                    $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
                                    $hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0)
                                    $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap)
                                    _WinAPI_BitBlt($hDC, 13, 0, $aPos[2], $aPos[3], $hMemDC, $aPos[0] + 13, $aPos[1], $SRCCOPY)
                                    _WinAPI_SelectObject($hMemDC, $hPrev)
                                    _WinAPI_DeleteDC($hMemDC)
                                    Return BitOR($CDRF_NOTIFYITEMDRAW, $CDRF_NOTIFYPOSTPAINT)
                            EndSwitch
                    EndSwitch
            EndSwitch
            
            ExitLoop
        EndIf
    Next
    
    Return $GUI_RUNDEFMSG
EndFunc
Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

I love your implementation MrCreatoR. I was to lazy to do it that good way.

Here is the addition that the checkbox does not need to have a height of 13.

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global Enum _
  $i_Start_Row = -1, _
  $i_hGUI_Row, $i_hPic_Row, $i_hCB_Row, _
  $i_Total_Rows
Global $aTrnsChckBxs_DATA[1][$i_Total_Rows]

$hGUI = GUICreate("Test transparent checkbox replacement", 400, 200)
$nPic = GUICtrlCreatePic(@AutoItExe & "\..\Examples\GUI\msoobe.jpg", 0, 0, 400, 200, 0)

GUICtrlCreateCheckbox("Standard checkbox", 10, 10, 200, 20)
GUICtrlCreateCheckbox("Standard checkbox transparent", 10, 50, 200, 20)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateCheckbox("Standard checkbox workaround", 10, 90, 13, 13)
GUICtrlCreateLabel("Standard checkbox workaround", 26, 90, 200, 13)
GUICtrlSetBkColor(-1, -2)

$nCB1 = _GUICtrlTransCheckbox_Create($hGUI, $nPic, "TransparentCheckbox 1", 10, 130)
$nCB2 = _GUICtrlTransCheckbox_Create($hGUI, $nPic, "TransparentCheckbox 2", 10, 170)

GUISetState(@SW_SHOW, $hGUI)

While 1
 $nGUIMsg = GUIGetMsg()

 Switch $nGUIMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $nCB1, $nCB2
   ConsoleWrite("CheckBox [" & GUICtrlRead($nGUIMsg, 1) & "] checked = " & (GUICtrlRead($nGUIMsg) = $GUI_CHECKED) & @LF)
 EndSwitch
WEnd

Func _GUICtrlTransCheckbox_Create($hGUI, $nBackPic, $sText, $iLeft, $iAbove, $iWidth = -1, $iHeight = -1, $iStyle = -1, $iExStyle = 0)
 Local $nCB = GUICtrlCreateCheckbox($sText, $iLeft, $iAbove, $iWidth, $iHeight, $iStyle, $iExStyle)
 Local $hCB = GUICtrlGetHandle($nCB)
 Local $hPic = GUICtrlGetHandle($nBackPic)

 If $aTrnsChckBxs_DATA[0][0] = 0 Then
  GUIRegisterMsg($WM_NOTIFY, '_TrnsChckBx_WM_NOTIFY')
 EndIf

 $aTrnsChckBxs_DATA[0][0] += 1
 ReDim $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0] + 1][$i_Total_Rows]

 $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hGUI_Row] = $hGUI
 $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hPic_Row] = $hPic
 $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hCB_Row] = $hCB

 Return $nCB
EndFunc   ;==>_GUICtrlTransCheckbox_Create

Func _GUICtrlTransCheckbox_Delete($nChckBx)
 Local $hCB = GUICtrlGetHandle($nChckBx)
 Local $aTmp[$aTrnsChckBxs_DATA[0][0]][$i_Total_Rows]

 GUICtrlDelete($nChckBx)

 For $i = 1 To $aTrnsChckBxs_DATA[0][0]
  If $aTrnsChckBxs_DATA[$i][$i_hCB_Row] <> $hCB Then
   $aTmp[0][0] += 1

   $aTmp[$aTmp[0][0]][$i_hGUI_Row] = $aTrnsChckBxs_DATA[$i][$i_hGUI_Row]
   $aTmp[$aTmp[0][0]][$i_hPic_Row] = $aTrnsChckBxs_DATA[$i][$i_hPic_Row]
   $aTmp[$aTmp[0][0]][$i_hCB_Row] = $aTrnsChckBxs_DATA[$i][$i_hCB_Row]
  EndIf
 Next

 ReDim $aTmp[$aTmp[0][0] + 1][$i_Total_Rows]
 $aTrnsChckBxs_DATA = $aTmp

 Return $aTmp[0][0]
EndFunc   ;==>_GUICtrlTransCheckbox_Delete

Func _TrnsChckBx_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
 Local $hWndFrom, $iIDFrom, $tNMHDR
 Local Const $tagNMCUSTOMDRAW = 'hwnd hWndFrom;uint_ptr IDFrom;int Code;dword DrawStage;hwnd hDC;' & $tagRECT & ';dword_ptr ItemSpec;uint ItemState;lparam ItemlParam'
 Local Const $STM_GETIMAGE = 0x0173

 Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam)
 Local $hWndFrom = DllStructGetData($tNMCD, 'hWndFrom')
 Local $iCode = DllStructGetData($tNMCD, 'Code')
 Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage')
 Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec')
 Local $hDC = DllStructGetData($tNMCD, 'hDC')
 Local $hPic, $aPos, $hMemDC, $hBitmap, $hPrev
 Local $iAbove, $iBeneath, $iBoxSize = 13
 For $i = 1 To $aTrnsChckBxs_DATA[0][0]
  If $hWndFrom = $aTrnsChckBxs_DATA[$i][$i_hCB_Row] Then
   Switch $iCode
    Case $NM_CUSTOMDRAW
     Switch $DrawStage
      Case $CDDS_PREPAINT
       $hPic = $aTrnsChckBxs_DATA[$i][$i_hPic_Row]
       $aPos = ControlGetPos($hWnd, '', $hWndFrom)

       If @error Then
        ExitLoop
       EndIf

       If $aPos[3] < $iBoxSize Then $iBoxSize = $aPos[3]
       $iAbove = Floor(($aPos[3] - $iBoxSize) / 2)
       $iBeneath = $iAbove + $iBoxSize

       $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
       $hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0)
       $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap)
       _WinAPI_BitBlt($hDC, 0, 0, $iBoxSize, $iAbove, $hMemDC, $aPos[0], $aPos[1], $SRCCOPY) ;field above checkbox
       _WinAPI_BitBlt($hDC, 0, $iBeneath, $iBoxSize, $iBeneath - $iAbove, $hMemDC, $aPos[0], $aPos[1] + $iBeneath, $SRCCOPY) ;field beneath checkbox
       _WinAPI_BitBlt($hDC, $iBoxSize, 0, $aPos[2] - $iBoxSize, $aPos[3], $hMemDC, $aPos[0] + $iBoxSize, $aPos[1], $SRCCOPY) ;checkbox text field
       _WinAPI_SelectObject($hMemDC, $hPrev)
       _WinAPI_DeleteDC($hMemDC)
       Return $CDRF_DODEFAULT
     EndSwitch
   EndSwitch

   ExitLoop
  EndIf
 Next

 Return $GUI_RUNDEFMSG
EndFunc   ;==>_TrnsChckBx_WM_NOTIFY

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Your $tNMCD structure is misaligned for x64. That means the code doesn't work as intended for 64bit Autoit.

This is because you simply concatenate tags of different structures to create one bigger structure. That is not correct because if some structure is made of few smaller structures then every smaller structure needs to be properly aligned before being made part of the concatenated.

This is not simple task in AutoIt because it misses syntax elements to do that properly. If something like this could be chewed by the interpreter then there wouldn't be need for different workarounds:

Local Const $tagNMCUSTOMDRAW = '{hwnd hWndFrom;uint_ptr IDFrom;int Code};dword DrawStage;hwnd hDC;{' & $tagRECT & '};dword_ptr ItemSpec;uint ItemState;lparam ItemlParam'

This works for your code on both versions of AutoIt:

Local Const $tagNMCUSTOMDRAW = 'hwnd hWndFrom;uint_ptr IDFrom;int_ptr Code;dword DrawStage;hwnd hDC;' & $tagRECT & ';dword_ptr ItemSpec;uint ItemState;lparam ItemlParam'
;...
Local $iCode = BitOR(DllStructGetData($tNMCD, 'Code'), 0)
Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Thank you very much tranceXX! I do not have a system with x64, so I could not test it. Now I'm glad that everything works fine.

But why do you need a BitOR with 0! to get the $iCode? I think we don't need this.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Thank you very much tranceXX! I do not have a system with x64, so I could not test it. Now I'm glad that everything works fine.

But why do you need a BitOR with 0! to get the $iCode? I think we don't need this.

BitOR is there to quickly get only 32 bits from 0x00000000FFFFFFF4 that would be read from the structure as "Code" on x64.

Otherwise it's interpreted as 4294967284 (you need -12).

"Bit operations are performed as 32-bit integers" <- help file line.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • 3 years later...
  • 1 month later...

is it possible to set the checkbox text characteristics? color, bold, underlined, font

 

sure:

GUICtrlCreateCheckbox("Standard checkbox workaround", 10, 90, 13, 13)
GUICtrlCreateLabel("Standard checkbox workaround", 26, 90, 200, 13)
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, $COLOR_YELLOW) ; ==> this requires #include <ColorConstants.au3>
GUICtrlSetFont(-1, 11, 300,  $GUI_FONTSTRIKE , "Arial")

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

  • 1 month later...

GreenCan

I am talking about the transparent checkbox created here by "funkey"

although, it is not realy transparent because i tried it, i added a background jpg, but the checkbox background still grey, you can't see the background image through them.

Edited by amd711
Link to comment
Share on other sites

What am i doing wrong?

Global Enum _
    $i_Start_Row = -1, _
        $i_hGUI_Row, $i_hPic_Row, $i_hCB_Row, _
    $i_Total_Rows
Global $aTrnsChckBxs_DATA[1][$i_Total_Rows]



#Region ### START Koda GUI section ### Form=c:\users\megasoft\desktop\afal_aio_3\front.kxf
Global $hGui = GUICreate("XXX",440, 357,-1,-1,-1,$WS_EX_TRANSPARENT)
GUISetIcon("icon.ico")
;GUISetBkColor(0x008080)

$nPic = GUICtrlCreatePic("wall9.jpg",0,0,550,380)
GUICtrlSetState(-1, $GUI_DISABLE)
;_ResourceSetImageToCtrl($nPic, "TEST_JPG_1") ; set JPG image to picture control from resource
;GUICtrlCreatePic(StringReplace(@AutoItExe, "AutoIt3.exe", "") & "Examples\GUI\msoobe.jpg", 0, 0, 400, 200, 0)
Global $nPic = GUICtrlGetHandle(-1)

Global $nCB1 = _GUICtrlTransCheckbox_Create($hGUI, $nPic,"CheckBox1", 60, 125)



Func _GUICtrlTransCheckbox_Create($hGUI, $nBackPic, $sText, $iLeft, $iTop, $iWidth = -1, $iHeight = 13, $iStyle = -1, $iExStyle = 0)
    Local $nCB = GUICtrlCreateCheckbox($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle)
    Local $hCB = GUICtrlGetHandle($nCB)
    Local $hPic = GUICtrlGetHandle($nBackPic)

    If $aTrnsChckBxs_DATA[0][0] = 0 Then
        GUIRegisterMsg($WM_NOTIFY, '_TrnsChckBx_WM_NOTIFY')
    EndIf

    $aTrnsChckBxs_DATA[0][0] += 1
    ReDim $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]+1][$i_Total_Rows]

    $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hGUI_Row] = $hGUI
    $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hPic_Row] = $hPic
    $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hCB_Row] = $hCB

    Return $nCB
EndFunc

Func _GUICtrlTransCheckbox_Delete($nChckBx)
    Local $hCB = GUICtrlGetHandle($nChckBx)
    Local $aTmp[$aTrnsChckBxs_DATA[0][0]][$i_Total_Rows]

    GUICtrlDelete($nChckBx)

    For $i = 1 To $aTrnsChckBxs_DATA[0][0]
        If $aTrnsChckBxs_DATA[$i][$i_hCB_Row] <> $hCB Then
            $aTmp[0][0] += 1

            $aTmp[$aTmp[0][0]][$i_hGUI_Row] = $aTrnsChckBxs_DATA[$i][$i_hGUI_Row]
            $aTmp[$aTmp[0][0]][$i_hPic_Row] = $aTrnsChckBxs_DATA[$i][$i_hPic_Row]
            $aTmp[$aTmp[0][0]][$i_hCB_Row] = $aTrnsChckBxs_DATA[$i][$i_hCB_Row]
        EndIf
    Next

    ReDim $aTmp[$aTmp[0][0]+1][$i_Total_Rows]
    $aTrnsChckBxs_DATA = $aTmp

    Return $aTmp[0][0]
EndFunc

Func _TrnsChckBx_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $hWndFrom, $iIDFrom, $tNMHDR
    Local Const $tagNMCUSTOMDRAW = 'hwnd hWndFrom;uint_ptr IDFrom;int Code;dword DrawStage;hwnd hDC;' & $tagRECT & ';dword_ptr ItemSpec;uint ItemState;lparam ItemlParam'
    Local Const $STM_GETIMAGE = 0x0173

    Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam)
    Local $hWndFrom = DllStructGetData($tNMCD, 'hWndFrom')
    Local $iCode = DllStructGetData($tNMCD, 'Code')
    Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage')
    Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec')
    Local $hDC = DllStructGetData($tNMCD, 'hDC')
    Local $hPic, $aPos, $hMemDC, $hBitmap, $hPrev

    For $i = 1 To $aTrnsChckBxs_DATA[0][0]
        If $hWndFrom = $aTrnsChckBxs_DATA[$i][$i_hCB_Row] Then
            Switch $iCode
                Case $NM_CUSTOMDRAW
                    Switch $DrawStage
                        Case $CDDS_PREPAINT, $CDDS_POSTPAINT
                            $hPic = $aTrnsChckBxs_DATA[$i][$i_hPic_Row]
                            $aPos = ControlGetPos($hWnd, '', $hWndFrom)

                            If @error Then
                                ExitLoop
                            EndIf

                            Switch $DrawStage
                                Case $CDDS_PREPAINT
                                    $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
                                    $hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0)
                                    $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap)
                                    _WinAPI_BitBlt($hDC, 13, 0, $aPos[2], $aPos[3], $hMemDC, $aPos[0] + 13, $aPos[1], $SRCCOPY)
                                    _WinAPI_SelectObject($hMemDC, $hPrev)
                                    _WinAPI_DeleteDC($hMemDC)
                                    Return BitOR($CDRF_NOTIFYITEMDRAW, $CDRF_NOTIFYPOSTPAINT)
                            EndSwitch
                    EndSwitch
            EndSwitch

            ExitLoop
        EndIf
    Next

    Return $GUI_RUNDEFMSG
EndFunc
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...