Jump to content

Recommended Posts

Posted

I have the following commands:

Func TomorrowMY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($TomorrowGUI, 0, 0, $RDW_UPDATENOW)
    $hImage   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "/Images/Image4.png")
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($TomorrowGUI)
    GUIRegisterMsg($WM_PAINT, "TomorrowMY_WM_PAINT")
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 45, 25)
    _WinAPI_RedrawWindow($TomorrowGUI, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
EndFunc

And I'm not too savvy with GDI. SO, how could I set the width/height of the image being used through my progrram?

MCR.jpg?t=1286371579

  Reveal hidden contents

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Posted (edited)

I also stumbled across this:

Which works.. oddly, but not on my GUI.

#include <GDIplus.au3>
#include <GuiConstantsEx.au3>
Opt('MustDeclareVars', 1)
Global $file, $msg
Do
    $file = FileOpenDialog("Select image to load", @ScriptDir, "Images (*.jpg;*.png; *.bmp;*.gif)")
    If @error Then
    $msg = MsgBox(20, "Error", "Please select an image!")
    If $msg = 7 Then
    Exit
    Else
    SetError(1)
    EndIf
    EndIf
Until Not @error
_GDIPlus_Startup()
Global $hImage = _GDIPlus_BitmapCreateFromFile($file)
Global $hwnd = GUICreate("GDI+: image resized to ",200,200)
GUISetState(@SW_SHOW)
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hwnd)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, 300,300)
While Sleep(30)
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    Exit
    EndSwitch
WEnd

Code posted by UEZ @

Here is a snippet of my code, containing the problem area.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#Include <WinAPI.au3>
Global $ZipCode, $GUI, $hgraphic, $himage, $RightNowGui, $TodayGui, $TonightGui, $TomorrowGui
Global $h_Desktop_SysListView32
_GetDesktopHandle()
$Width = @DesktopWidth
$Height = @DesktopHeight
_RightNowGUI()
Func _RightNowGUI()
    $RightNowGUI = GUICreate("", 150, 300, $Width-151, $Height-600, BitOR($WS_POPUP,$WS_BORDER), Default, WinGetHandle(AutoItWinGetTitle()))
    GuiSetFont(13)
    GUICtrlSetDefColor(0xFFFFFF)
    GUISetBkColor(0x000000)
    WinSetTrans($RightNowGUI,"",200)
    _GDIPlus_StartUp()
$file = FileOpenDialog("Select image to load", @ScriptDir, "Images (*.jpg;*.png; *.bmp;*.gif)")
    $hImage   = _GDIPlus_ImageLoadFromFile($file)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($RightNowGUI)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 13, 25, 300,300)
    DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $RightNowGUI, "hwnd", $h_Desktop_SysListView32)
    GuiSetState()
EndFunc
Func _GetDesktopHandle()
    $h_Desktop_SysListView32 = 0
    Local Const $hDwmApiDll = DllOpen("dwmapi.dll")
    Local $sChkAero = DllStructCreate("int;")
    DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero))
    Local $aero_on = DllStructGetData($sChkAero, 1)
    If Not $aero_on Then
        $h_Desktop_SysListView32 = WinGetHandle("Program Manager")
        Return 1
    Else
        Local $hCBReg = DllCallbackRegister("_GetDesktopHandle_EnumChildWinProc", "hwnd", "hwnd;lparam")
        If $hCBReg = 0 Then Return SetError(2)
        DllCall("user32.dll", "int", "EnumChildWindows", "hwnd", _WinAPI_GetDesktopWindow(), "ptr", DllCallbackGetPtr($hCBReg), "lparam", 101)
        Local $iErr = @error
        DllCallbackFree($hCBReg)
        If $iErr Then
            Return SetError(3, $iErr, "")
        EndIf
        Return 2
    EndIf
EndFunc
While 1
    Sleep(10)
WEnd
Edited by Damein

MCR.jpg?t=1286371579

  Reveal hidden contents

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Posted

It's always best to link to where you found the code.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

I have determined it is this bit:

DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $RightNowGUI, "hwnd", $h_Desktop_SysListView32)

That is making it not work. Anyone know why?

MCR.jpg?t=1286371579

  Reveal hidden contents

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Posted (edited)

Try this:

Func _RightNowGUI()
    GuiDelete($RightNowGUI)
    GuiDelete($TodayGUI)
    GuiDelete($TonightGUI)
    GuiDelete($TomorrowGUI)
    $RightNowGUI = GUICreate("", 150, 300, $Width-151, $Height-600, BitOR($WS_POPUP,$WS_BORDER), Default, WinGetHandle(AutoItWinGetTitle()))
    GuiSetFont(13)
    GUICtrlSetDefColor(0xFFFFFF)
    GUISetBkColor(0x000000)
    WinSetTrans($RightNowGUI,"",200)
    GuiSetState()
    GuiCtrlCreateLabel($OverViewTime[1],38,10,200,50)
    GuiCtrlCreateLabel($OverViewStatus[1],55,128,200,40)
    GuiCtrlCreateLabel("Temperature",38,160,200,40)
    GuiCtrlCreateLabel($OverViewTemp[1] & "°F",64,185,200,40)
    GuiCtrlCreateLabel("Precipitation",34,220,200,40)
    GuiCtrlCreateLabel($OverViewPrecip[1],60,245,200,40)
    $ContextMenu = GuiCtrlCreateContextMenu()
    $RightNowItem = GuiCtrlCreateMenuItem($OverViewTime[1], $ContextMenu)
    GUICtrlSetOnEvent($RightNowItem, "_RightNowGUI")
    $TodayItem = GuiCtrlCreateMenuItem($OverViewTime[2], $ContextMenu)
    GUICtrlSetOnEvent($TodayItem, "_TodayGUI")
    $TonightItem = GuiCtrlCreateMenuItem($OverViewTime[3], $ContextMenu)
    GUICtrlSetOnEvent($TonightItem, "_TonightGUI")
    $TomorrowItem = GuiCtrlCreateMenuItem($OverViewTime[4], $ContextMenu)
    GUICtrlSetOnEvent($TomorrowItem, "_TomorrowGUI")
    $RefreshItem = GuiCtrlCreateMenuItem("Refresh", $ContextMenu)
    GUICtrlSetOnEvent($RefreshItem, "_Refresh")
    $ExitItem = GuiCtrlCreateMenuItem("Close", $ContextMenu)
    GUICtrlSetOnEvent($ExitItem, "_Exit")
    DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $RightNowGUI, "hwnd", $h_Desktop_SysListView32)

    _GDIPlus_StartUp()
    $hImage   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "/Images/Image1.png")
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($RightNowGUI)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 13, 25, 300,300)
EndFunc

To avoid any erasing of the background pic I would suggest to use picture controls where you can load any image and send it to the pic control.

Btw, when you post only a fragment of your code we cannot test it properly because of missing variables, functions, etc.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
  • Recently Browsing   0 members

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