Jump to content
Sign in to follow this  
PlayHD

[SOLVED]Child Window

Recommended Posts

PlayHD

Hey .

I have a little problem ..

I want to make a window with a child with _WinApi_SetParrent(..), it works fine.

But i have a little problem, when i try to make child of a pic is not working fine...

Pic : Link

Here is my project : Test.rar

ps. sorry for my english

Edited by PlayHD

Share this post


Link to post
Share on other sites
martin

I am unable to open your Test.rsr. 7zip fails and camunzip tells me that it the the first of more than one floppy.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
martin

Still no good.

ANyway,, if the zip is 126 k then the code is more than I want to deal with. Could you make a small example script and post that, then it will be a lot easier for us.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Melba23

martin,

I can download it - the original script is:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>
#include <Icons.au3>
$Form = GUICreate("Test", 600, 400)
Global $Pic = GUICtrlCreatePic("", 50, 40, 500, 300, -1, $WS_EX_CLIENTEDGE)
    _SetImage($Pic,"Bk.png")
GUISetState(@SW_SHOW,$Form)

$cForm = GUICreate("Test", 100, 100,1,1,$WS_SizeBox)
    _WinAPI_SetParent($cForm,GUICtrlGetHandle($Pic))
GUISetState(@SW_SHOW,$cForm)
;~ GUIRegisterMsg($WM_MOVE, "_WM_MOVE_SIZE")
GUIRegisterMsg($WM_SIZE, "_WM_MOVE_SIZE")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_MOVE_SIZE($hWnd, $Msg, $wParam, $lParam)
    _SetImage($Pic,"Bk.png")
EndFunc

plus Yashied's Icons UDF and a 3MB .png file.

But quite what the OP thinks he is doing in that script is beyond me - setting an image within a WM_SIZE handler? :wacko:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
UEZ

@martin:

Here the code runable:

#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>


Global Const $STM_SETIMAGE = 0x0172
_GDIPlus_Startup()

$hBitmap = _GDIPlus_ScaleImage2(@ScriptDir & "\Bk.png", 500, 300)
$hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)

_GDIPlus_BitmapDispose($hBitmap)

$Form = GUICreate("Test", 600, 400)
Global $Pic = GUICtrlCreatePic("", 50, 40, 500, 300, -1, $WS_EX_CLIENTEDGE)
$hB = GUICtrlSendMsg($Pic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)
If $hB Then _WinAPI_DeleteObject($hB)
GUISetState(@SW_SHOW,$Form)

$cForm = GUICreate("Test", 100, 100,1,1,$WS_SizeBox)
    _WinAPI_SetParent($cForm,GUICtrlGetHandle($Pic))
GUISetState(@SW_SHOW,$cForm)

;~ GUIRegisterMsg($WM_MOVE, "_WM_MOVE_SIZE")
;~ GUIRegisterMsg($WM_SIZE, "_WM_MOVE_SIZE")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _WinAPI_DeleteObject($hHBitmap)
            _GDIPlus_Shutdown()
            Exit

    EndSwitch
WEnd

Func _WM_MOVE_SIZE($hWnd, $Msg, $wParam, $lParam)
    $hB = GUICtrlSendMsg($Pic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hB = ' & $hB & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    If $hB Then _WinAPI_DeleteObject($hB)
EndFunc


Func _GDIPlus_ScaleImage2($sFile, $iNewWidth, $iNewHeight, $iBGColor = 0xFFF0F0F0, $bBGClear = True, $iInterpolationMode = 7) ;coded by UEZ 2012
    If Not FileExists($sFile) Then Return SetError(1, 0, 0)
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Then Return SetError(2, 0, 0)
    Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage)

    Local $iW, $iH, $f, $fRatio

    If $iWidth > $iHeight Then
        $f = $iWidth / $iNewWidth
    Else
        $f = $iHeight / $iNewHeight
    EndIf
    $iW = Int($iWidth / $f)
    $iH = Int($iHeight / $f)

    If $iW > $iNewWidth Then
        $fRatio = $iNewWidth / $iW
        $iW = Int($iW * $fRatio)
        $iH = Int($iH * $fRatio)
    ElseIf $iH > $iNewHeight Then
        $fRatio = $iNewHeight / $iH
        $iW = Int($iW * $fRatio)
        $iH = Int($iH * $fRatio)
    EndIf

    Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    If @error Then Return SetError(3, 0, 0)
    $hBitmap = $hBitmap[6]
    Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    If $bBGClear Then _GDIPlus_GraphicsClear($hBmpCtxt, $iBGColor)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBmpCtxt, "int", $iInterpolationMode)
    _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iW, $iH)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hBmpCtxt)
    Return $hBitmap
EndFunc

@PlayHD: the problem is the transparent image. If you convert it you must clear the background of the gdi+ image otherwise you will see the effect.

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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  

×