Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/05/2012 in all areas

  1. You set row height by capturing the WM_MEASUREITEM message Search forum or read msdn.microsoft.com WM_MEASUREITEM and MEASUREITEMSTRUCT Structure #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global Const $ODT_LISTVIEW = 102 Global Const $ODA_DRAWENTIRE = 0x1 Global Const $ODA_SELECT = 0x2 Global Const $ODA_FOCUS = 0x4 Global Const $ODS_SELECTED = 0x0001 Global $default_font = "Arial" Global $default_font_size = 9 Global $GUI_main = GUICreate("", 300, 300, -1, -1, -1, $WS_EX_ACCEPTFILES) Global $hGUI_tab_listview[2][10] GUIRegisterMsg($WM_MEASUREITEM, "WM_MEASUREITEM") ;place before listview creation - message sent once for each ownerdrawn control created $hGUI_tab_listview[0][0] = GUICtrlCreateListView("", 15, 68, 250, 90, _ BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS, $LVS_OWNERDRAWFIXED), _ BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) ; + $LVS_EX_CHECKBOXES + $LVS_SINGLESEL GUICtrlSetFont(-1, $default_font_size + 8, 400, 0, $default_font, 5) _GUICtrlListView_AddColumn(-1, "Name") _GUICtrlListView_SetColumnWidth(-1, 0, 155) _GUICtrlListView_AddColumn(-1, "Count") _GUICtrlListView_SetColumnWidth(-1, 1, 72) For $i = 0 To 10 ; populate the listview for testing purposes _GUICtrlListView_AddItem(-1, "test " & $i) _GUICtrlListView_AddSubItem(-1, $i, $i, 1) Next GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM") GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Exit Func WM_MEASUREITEM($hWnd, $Msg, $wParam, $lParam) Local $tMEASUREITEMS = DllStructCreate("uint cType;uint cID;uint itmID;uint itmW;uint itmH;ulong_ptr itmData", $lParam) If DllStructGetData($tMEASUREITEMS, "cType") <> $ODT_LISTVIEW Then Return $GUI_RUNDEFMSG DllStructSetData($tMEASUREITEMS, "itmH", 20);row height ;GUIRegisterMsg($WM_MEASUREITEM, "") ;call this after last ownerdrawn listview created Return 1 EndFunc ;==>WM_MEASUREITEM Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) Local $tagDRAWITEMSTRUCT, $iBrushColor, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC, $bSelected $tagDRAWITEMSTRUCT = DllStructCreate( _ "uint cType;" & _ "uint cID;" & _ "uint itmID;" & _ "uint itmAction;" & _ "uint itmState;" & _ "hwnd hItm;" & _ "handle hDC;" & _ "long itmRect[4];" & _ "ulong_ptr itmData" _ , $lParam) If DllStructGetData($tagDRAWITEMSTRUCT, "cType") <> $ODT_LISTVIEW Then Return $GUI_RUNDEFMSG $cID = DllStructGetData($tagDRAWITEMSTRUCT, "cID") $itmID = DllStructGetData($tagDRAWITEMSTRUCT, "itmID") $itmAction = DllStructGetData($tagDRAWITEMSTRUCT, "itmAction") $itmState = DllStructGetData($tagDRAWITEMSTRUCT, "itmState") $hItm = DllStructGetData($tagDRAWITEMSTRUCT, "hItm") $hDC = DllStructGetData($tagDRAWITEMSTRUCT, "hDC") $bSelected = BitAND($itmState, $ODS_SELECTED) Switch $cID ; will look for ControlID, not window handle. Case $hGUI_tab_listview[0][0] Switch $itmAction Case $ODA_DRAWENTIRE ; don't forget, this is BGR, not RGB If $itmState = $bSelected Then ; item is not selected $iBrushColor = 0xCCEECC Else ; item is selected $iBrushColor = 0xEEDDBB EndIf Local $aBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $iBrushColor) Local $aBrushOld = _WinAPI_SelectObject($hDC, $aBrush[0]) Local $iLeft = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) DllStructSetData($tagDRAWITEMSTRUCT, "itmRect", $iLeft + 1, 1) ; rectangle coordinates for coloring ; +1 is the left margin _WinAPI_FillRect($hDC, DllStructGetPtr($tagDRAWITEMSTRUCT, "itmRect"), $aBrush[0]) _WinAPI_SelectObject($hDC, $aBrushOld) _WinAPI_DeleteObject($aBrush[0]) ; for all columns of the row: $local_alignment = $DT_LEFT For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_tab_listview[0][0]) - 1 ; 1. get subitem text: Local $iSubItmText = _GUICtrlListView_GetItemText($hGUI_tab_listview[0][0], $itmID, $i) ; 2. get subitem coordinates for drawing its respective text Local $aSubItmRect = _GUICtrlListView_GetSubItemRect($hGUI_tab_listview[0][0], $itmID, $i) ; the function above accepts not only subitems (one-based index), but also main item (index=0) ; 3. pass the coordinates to a DLL struct Local $iSubItmRect = DllStructCreate("long[4]") DllStructSetData($iSubItmRect, 1, $aSubItmRect[0] + 6, 1) ; +6 is left margin (X) DllStructSetData($iSubItmRect, 1, $aSubItmRect[1] + (-2), 2) ; + (-2) is upper margin (Y) DllStructSetData($iSubItmRect, 1, $aSubItmRect[2], 3) DllStructSetData($iSubItmRect, 1, $aSubItmRect[3], 4) DllCall("user32.dll", "int", "DrawTextW", "hwnd", $hDC, "wstr", $iSubItmText, "int", StringLen($iSubItmText), _ "ptr", DllStructGetPtr($iSubItmRect), "int", $local_alignment) Next ;#ce EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_DRAWITEM
    2 points
  2. You are incredibly stupid and your ideas are appalling.
    1 point
  3. UEZ

    PNG Form and Progress bar

    Try this: Main.au3 #include <GuiSkin.au3> Global $MY_GUIIMAGE = "gui.png" _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($MY_GUIIMAGE) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $GUI = GUICreate("", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($GUI, $hImage, 0) Global Const $IMAGE_BITMAP = 0 Global Const $STM_SETIMAGE = 0x0172 $GUI_Child = GUICreate("", $width, $height, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $GUI) GUICtrlCreateProgress(30,30,100,20) GUICtrlSetData(-1, 50) $idButton = GUICtrlCreateButton("Exit", $width - 120, $height - 100, 80, 80) GUISetControlsVisible($GUI_Child) $GUI_Child2 = GUICreate("", 193, 184, 50, 100, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED, $GUI) GUISetBkColor(0xD6E9F2, $GUI_Child2) $idPic = GUICtrlCreatePic("", 0, 0, 193, 184) $hBitmap = _GDIPlus_BitmapCreateFromFile(StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUITorus.png")) $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) _WinAPI_SetLayeredWindowAttributes($GUI_Child2, 0xD6E9F2) GUISetState(@SW_SHOW, $GUI) GUISetState(@SW_SHOW, $GUI_Child2) GUISetState(@SW_SHOW, $GUI_Child) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") For $i = 0 To 255 Step 10 ;fade SetBitmap($GUI, $hImage, $i) Next While 1 $msg = GUIGetMsg() Switch $msg Case -3, $idButton ExitLoop EndSwitch WEnd _WinAPI_DeleteObject($hHBitmap) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() GUIDelete($GUI_Child) GUIDelete($GUI) Exit Func GUISetControlsVisible($hWnd) Local $aM_Mask, $aCtrlPos, $aMask $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) $aLastID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", GUICtrlGetHandle(-1)) For $i = 3 To $aLastID[0] $aCtrlPos = ControlGetPos($hWnd, '', $i) If Not IsArray($aCtrlPos) Then ContinueLoop $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", _ "long", $aCtrlPos[0], _ "long", $aCtrlPos[1], _ "long", $aCtrlPos[0] + $aCtrlPos[2], _ "long", $aCtrlPos[1] + $aCtrlPos[3]) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2) Next DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1) EndFunc Edit: added 2nd child GUI for PNG image. Br, UEZ
    1 point
  4. JRSmile

    Irrlicht enviroment

    YES!
    1 point
×
×
  • Create New...