Sign in to follow this  
Followers 0
AlmarM

GUICtrlCreatePic problem

5 posts in this topic

Hiya!

When im drawing a picture into my GUI my other controls just freeze.

*Its about the: "If FileExists($PicResized) Then GUICtrlCreatePic($PicResized, 0, 0, 320, 460)"*

This is what I have:

$MainGUI = GUICreate("", 320, 460)

    If FileExists($PicResized) Then GUICtrlCreatePic($PicResized, 0, 0, 320, 460)

    $Start = GUICtrlCreateMenu("Start")
    $ClearData = GUICtrlCreateMenuItem("Wis alle gegevens", $Start)
    $PCData = GUICtrlCreateMenuItem("Computer gegevens", $Start)
    $ChangePic = GUICtrlCreateMenuItem("Achtergrond plaatje", $Start)
    GUICtrlCreateMenuItem("", $Start)
    $Exit = GUICtrlCreateMenuItem("Afsluiten", $Start)
    $Notepad = GUICtrlCreateMenu("Kladblok")
    $Clear = GUICtrlCreateMenuItem("Wis tekst", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Open = GUICtrlCreateMenuItem("Openen", $Notepad)
    $Save = GUICtrlCreateMenuItem("Opslaan", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Count = GUICtrlCreateMenuItem("Woorden teller", $Notepad)
    $Settings = GUICtrlCreateMenuItem("Instellingen", $Notepad)

    $Edit = GUICtrlCreateEdit("", 10, 10, 300, 200)
    GUICtrlSetFont($Edit, 9, "", "", "Lucida Console")

    Local $Left = 35, $Top = 230
    For $i = 0 To UBound($Buttons) - 1
        $Buttons[$i] = GUICtrlCreateButton("< X >", $Left, $Top, 50, 50, 0x0040 +  0x1000)
        $Left += 100

        If $Left > 300 Then
            $Left = 35
            $Top += 70
        EndIf
    Next

This isnt working.

Eitherway, this will work, but I need to hover over my controls first:

$MainGUI = GUICreate("", 320, 460)

    $Start = GUICtrlCreateMenu("Start")
    $ClearData = GUICtrlCreateMenuItem("Wis alle gegevens", $Start)
    $PCData = GUICtrlCreateMenuItem("Computer gegevens", $Start)
    $ChangePic = GUICtrlCreateMenuItem("Achtergrond plaatje", $Start)
    GUICtrlCreateMenuItem("", $Start)
    $Exit = GUICtrlCreateMenuItem("Afsluiten", $Start)
    $Notepad = GUICtrlCreateMenu("Kladblok")
    $Clear = GUICtrlCreateMenuItem("Wis tekst", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Open = GUICtrlCreateMenuItem("Openen", $Notepad)
    $Save = GUICtrlCreateMenuItem("Opslaan", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Count = GUICtrlCreateMenuItem("Woorden teller", $Notepad)
    $Settings = GUICtrlCreateMenuItem("Instellingen", $Notepad)

    $Edit = GUICtrlCreateEdit("", 10, 10, 300, 200)
    GUICtrlSetFont($Edit, 9, "", "", "Lucida Console")

    Local $Left = 35, $Top = 230
    For $i = 0 To UBound($Buttons) - 1
        $Buttons[$i] = GUICtrlCreateButton("< X >", $Left, $Top, 50, 50, 0x0040 +  0x1000)
        $Left += 100

        If $Left > 300 Then
            $Left = 35
            $Top += 70
        EndIf
    Next

    If FileExists($PicResized) Then GUICtrlCreatePic($PicResized, 0, 0, 320, 460)

Whats a possible sollution?


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites



FileExists is a blocking function isn't it? :S i'm not sure how to get past that...

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

From help file under GUICtrlCreatePic.

"If a picture is set as a background picture, as the other controls will overlap, it's important to disable the pic control and create it after the others controls: GuiCtrlSetState(-1,$GUI_DISABLE)."

Edited by Malkey

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hiya!

When im drawing a picture into my GUI my other controls just freeze.

*Its about the: "If FileExists($PicResized) Then GUICtrlCreatePic($PicResized, 0, 0, 320, 460)"*

This is what I have:

$MainGUI = GUICreate("", 320, 460)

    If FileExists($PicResized) Then GUICtrlCreatePic($PicResized, 0, 0, 320, 460)

    $Start = GUICtrlCreateMenu("Start")
    $ClearData = GUICtrlCreateMenuItem("Wis alle gegevens", $Start)
    $PCData = GUICtrlCreateMenuItem("Computer gegevens", $Start)
    $ChangePic = GUICtrlCreateMenuItem("Achtergrond plaatje", $Start)
    GUICtrlCreateMenuItem("", $Start)
    $Exit = GUICtrlCreateMenuItem("Afsluiten", $Start)
    $Notepad = GUICtrlCreateMenu("Kladblok")
    $Clear = GUICtrlCreateMenuItem("Wis tekst", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Open = GUICtrlCreateMenuItem("Openen", $Notepad)
    $Save = GUICtrlCreateMenuItem("Opslaan", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Count = GUICtrlCreateMenuItem("Woorden teller", $Notepad)
    $Settings = GUICtrlCreateMenuItem("Instellingen", $Notepad)

    $Edit = GUICtrlCreateEdit("", 10, 10, 300, 200)
    GUICtrlSetFont($Edit, 9, "", "", "Lucida Console")

    Local $Left = 35, $Top = 230
    For $i = 0 To UBound($Buttons) - 1
        $Buttons[$i] = GUICtrlCreateButton("< X >", $Left, $Top, 50, 50, 0x0040 +  0x1000)
        $Left += 100

        If $Left > 300 Then
            $Left = 35
            $Top += 70
        EndIf
    Next

This isnt working.

Eitherway, this will work, but I need to hover over my controls first:

$MainGUI = GUICreate("", 320, 460)

    $Start = GUICtrlCreateMenu("Start")
    $ClearData = GUICtrlCreateMenuItem("Wis alle gegevens", $Start)
    $PCData = GUICtrlCreateMenuItem("Computer gegevens", $Start)
    $ChangePic = GUICtrlCreateMenuItem("Achtergrond plaatje", $Start)
    GUICtrlCreateMenuItem("", $Start)
    $Exit = GUICtrlCreateMenuItem("Afsluiten", $Start)
    $Notepad = GUICtrlCreateMenu("Kladblok")
    $Clear = GUICtrlCreateMenuItem("Wis tekst", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Open = GUICtrlCreateMenuItem("Openen", $Notepad)
    $Save = GUICtrlCreateMenuItem("Opslaan", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Count = GUICtrlCreateMenuItem("Woorden teller", $Notepad)
    $Settings = GUICtrlCreateMenuItem("Instellingen", $Notepad)

    $Edit = GUICtrlCreateEdit("", 10, 10, 300, 200)
    GUICtrlSetFont($Edit, 9, "", "", "Lucida Console")

    Local $Left = 35, $Top = 230
    For $i = 0 To UBound($Buttons) - 1
        $Buttons[$i] = GUICtrlCreateButton("< X >", $Left, $Top, 50, 50, 0x0040 +  0x1000)
        $Left += 100

        If $Left > 300 Then
            $Left = 35
            $Top += 70
        EndIf
    Next

    If FileExists($PicResized) Then GUICtrlCreatePic($PicResized, 0, 0, 320, 460)

Whats a possible sollution?

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


    $MainGUI = GUICreate("", 320, 460)
    $Start = GUICtrlCreateMenu("Start")
    $ClearData = GUICtrlCreateMenuItem("Wis alle gegevens", $Start)
    $PCData = GUICtrlCreateMenuItem("Computer gegevens", $Start)
    $ChangePic = GUICtrlCreateMenuItem("Achtergrond plaatje", $Start)
    GUICtrlCreateMenuItem("", $Start)
    $Exit = GUICtrlCreateMenuItem("Afsluiten", $Start)
    $Notepad = GUICtrlCreateMenu("Kladblok")
    $Clear = GUICtrlCreateMenuItem("Wis tekst", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Open = GUICtrlCreateMenuItem("Openen", $Notepad)
    $Save = GUICtrlCreateMenuItem("Opslaan", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Count = GUICtrlCreateMenuItem("Woorden teller", $Notepad)
    $Settings = GUICtrlCreateMenuItem("Instellingen", $Notepad)

    $Edit = GUICtrlCreateEdit("", 10, 10, 300, 200)
    GUICtrlSetFont($Edit, 9, "", "", "Lucida Console")
    Dim $Buttons[9]
    Local $Left = 35, $Top = 230
    For $i = 0 To UBound($Buttons) - 1
        $Buttons[$i] = GUICtrlCreateButton("< X >", $Left, $Top, 50, 50)
        GuiCtrlSetState(-1,$GUI_ONTOP)
        $Left += 100

        If $Left > 300 Then
            $Left = 35
            $Top += 70
        EndIf
    Next

GUISetState()
$PicResized = @ScriptDir & "\Untitled.gif"
If FileExists($PicResized) Then GUICtrlCreatePic($PicResized, 0, 0, 320, 460)
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

Or

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
Const $Style_Stretch = 1 , $Style_Tile = 2 , $Style_Center = 3
Global $hBitmap , $ImageHeight , $ImageWidth , $Image_Style
    $MainGUI = GUICreate("", 320, 460)
    $PicResized = @ScriptDir & "\Untitled.bmp"
    LoadBitmap_FromFile($PicResized ,$Style_Stretch)
    $Start = GUICtrlCreateMenu("Start")
    $ClearData = GUICtrlCreateMenuItem("Wis alle gegevens", $Start)
    $PCData = GUICtrlCreateMenuItem("Computer gegevens", $Start)
    $ChangePic = GUICtrlCreateMenuItem("Achtergrond plaatje", $Start)
    GUICtrlCreateMenuItem("", $Start)
    $Exit = GUICtrlCreateMenuItem("Afsluiten", $Start)
    $Notepad = GUICtrlCreateMenu("Kladblok")
    $Clear = GUICtrlCreateMenuItem("Wis tekst", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Open = GUICtrlCreateMenuItem("Openen", $Notepad)
    $Save = GUICtrlCreateMenuItem("Opslaan", $Notepad)
    GUICtrlCreateMenuItem("", $Notepad)
    $Count = GUICtrlCreateMenuItem("Woorden teller", $Notepad)
    $Settings = GUICtrlCreateMenuItem("Instellingen", $Notepad)

    $Edit = GUICtrlCreateEdit("", 10, 10, 300, 200)
    GUICtrlSetFont($Edit, 9, "", "", "Lucida Console")
    Dim $Buttons[9]
    Local $Left = 35, $Top = 230
    For $i = 0 To UBound($Buttons) - 1
        $Buttons[$i] = GUICtrlCreateButton("< X >", $Left, $Top, 50, 50)
        GuiCtrlSetState(-1,$GUI_ONTOP)
        $Left += 100

        If $Left > 300 Then
            $Left = 35
            $Top += 70
        EndIf
    Next
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func WM_ERASEBKGND($hWnd, $Msg, $wParam, $lParam)
if $hBitmap Then
$D_C = _WinAPI_CreateCompatibleDC($wParam)
$Object = _WinAPI_SelectObject($D_C, $hBitmap)

Select
Case $Image_Style = 1
StretchBlt($wParam, 0, 0 , _WinAPI_GetClientWidth($hWnd), _WinAPI_GetClientHeight($hWnd), $D_C, 0, 0, _
$ImageWidth , $ImageHeight, $SRCCOPY)


Case $Image_Style = 2
For $i1 = 0 To (_WinAPI_GetClientHeight($hWnd) - 1) Step $ImageHeight
For $i2 = 0 To (_WinAPI_GetClientWidth($hWnd) - 1) Step $ImageWidth
_WinAPI_BitBlt($wParam,$i2,$i1, _WinAPI_GetClientWidth($hWnd), _WinAPI_GetClientHeight($hWnd), _
$D_C ,0,0,$SRCCOPY)
Next
Next

Case $Image_Style = 3
if ($ImageWidth < _WinAPI_GetClientWidth($hWnd)) Then
$i2 = ((_WinAPI_GetClientWidth($hWnd) - $ImageWidth) / 2)
Else
$i2 = 0
EndIf
if($ImageHeight < _WinAPI_GetClientHeight($hWnd)) Then
$i1 = ( (_WinAPI_GetClientHeight($hWnd) - $ImageHeight) / 2)
Else
$i1 = 0
EndIf
_WinAPI_BitBlt($wParam,$i2,$i1,_WinAPI_GetClientWidth($hWnd), _WinAPI_GetClientHeight($hWnd) , _
$D_C ,0,0,$SRCCOPY)
EndSelect

$Object = _WinAPI_SelectObject($D_C, $Object)

Return True
EndIf
EndFunc

Func StretchBlt($hdcDest,$nXOriginDest,$nYOriginDest,$nWidthDest,$nHeightDest,$hdcSrc,$nXOriginSrc, _
$nYOriginSrc,$nWidthSrc,$nHeightSrc,$dwRop)
$DllCall = DllCall("Gdi32.dll" ,"int","StretchBlt","hwnd",$hdcDest,"int",$nXOriginDest,"int",$nYOriginDest,"int",$nWidthDest , _
"int",$nHeightDest,"hwnd",$hdcSrc,"int",$nXOriginSrc,"int",$nYOriginSrc,"int",$nWidthSrc,"int",$nHeightSrc,"long",$dwRop)
Return $DllCall[0]
EndFunc


Func LoadBitmap_FromFile($sFileName ,$ImageStyle)
$IMAGE_BITMAP = 0
$LR_LOADFROMFILE = 0x0010
$hBitmap = _WinAPI_LoadImage(_WinAPI_GetModuleHandle(0),$sFileName,$IMAGE_BITMAP ,0,0,$LR_LOADFROMFILE)
_GDIPlus_Startup ()
$hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap)
$ImageWidth = _GDIPlus_ImageGetWidth ($hImage)
$ImageHeight = _GDIPlus_ImageGetHeight ($hImage)
$Image_Style = $ImageStyle
_GDIPlus_ShutDown ()
EndFunc

Func LoadBitmap_FromResources($resource_Name ,$ImageStyle)
$hBitmap = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(0), $resource_Name)
_GDIPlus_Startup ()
$hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap)
$ImageWidth = _GDIPlus_ImageGetWidth ($hImage)
$ImageHeight = _GDIPlus_ImageGetHeight ($hImage)
$Image_Style = $ImageStyle
_GDIPlus_ShutDown ()
EndFunc
Edited by wolf9228

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Works like a charm.

If FileExists($PicResized) Then GUICtrlCreatePic($PicResized, 0, 0, 320, 460)
    GUICtrlSetState(-1, 128)

Thanks Malkey :mellow:

And everbody else ofcourse :P

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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  
Followers 0