Jump to content

Recommended Posts

Posted (edited)
I created a very eye-catching graphical interface for use as a starter game.
However, I need that this program is written in C or C + +.
But I do not know where to start to call the gdiplus.
 
Do you know help me?
 
Source:
;~ #RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;~ file check

dim $file[12] = ["gamestart.png","gamestart2.png","Gameoption.png","Gameoption2.png","UpdateClient.PNG","UpdateClient2.PNG","EXIT.PNG","EXIT2.PNG","Nathan_Whitehead_-_Infiltrate.mp3","Main.png","Logo.PNG"]
dim $url = "http://albumangelus.altervista.org/skins/"

DirCreate("skins")

ProgressOn("file downloading","wait plis...")
For $down = 0 to  UBound($file)-1


    if not FileExists(@ScriptDir&"\skins\"&$file[$down]) Then

        $Download = inetget($url&$file[$down], @ScriptDir&"\skins\"&$file[$down],1,1)
        $SizeLink = InetGetSize($url&$file[$down],0)

        Do
            $Dow = InetGetInfo($Download, 0)
            $PerCento = Round($Dow*100/$SizeLink)
            ProgressSet( $PerCento, $PerCento & "%","-> "&$file[$down])
            Until InetGetInfo($Download, 2) = True


    EndIf
    ProgressSet(100 , "End", "well!")

Next
ProgressOff()

#include "WinMovButton.au3"
#include <GDIPlus.au3>
#include <GuiConstantsex.au3>
#include <WindowsConstants.au3>

Dim $Image_OneButton = @ScriptDir&"\skins\gamestart.png"
Dim $Image_TwoButton = @ScriptDir&"\skins\gamestart2.png"

Dim $Image_OneButton2 = @ScriptDir&"\skins\Gameoption.png"
Dim $Image_TwoButton2 = @ScriptDir&"\skins\Gameoption2.png"

Dim $Image_OneButton3 = @ScriptDir&"\skins\UpdateClient.png"
Dim $Image_TwoButton3 = @ScriptDir&"\skins\UpdateClient2.png"

Dim $Image_OneButton4 = @ScriptDir&"\skins\EXIT.png"
Dim $Image_TwoButton4 = @ScriptDir&"\skins\EXIT2.png"


_GDIPlus_Startup()


$MainLogo = GUICreate("DRAGON SLAYER - THE CHALENG",400,185,-1,-1,$WS_POPUP) ;Create Gui
$ShowLogo = _GuiCtrlCreatePNG(@ScriptDir&"\skins\logo.png",0 , 0, $MainLogo)

Sleep(4000)
SoundPlay(@ScriptDir&"\skins\Nathan_Whitehead_-_Infiltrate.mp3")
GUIDelete($MainLogo)
Sleep(1500)

$hWNDMain = GUICreate("DRAGON SLAYER - THE CHALENG",985,648,-1,-1,$WS_POPUP) ;Create Gui
GUISetState()
WinSettrans($hWNDMain,"",0)

$Button1 = _GuiCtrlCreatePNG(@ScriptDir&"\skins\main.png",0 , 0, $hWNDMain)

$Button = _GuiCtrlCreateButton($Image_OneButton,$Image_TwoButton,150,150,300,100, $Button1[0])
$Button2 = _GuiCtrlCreateButton($Image_OneButton2,$Image_TwoButton2,150,250,300,100, $Button1[0])
$Button3 = _GuiCtrlCreateButton($Image_OneButton3,$Image_TwoButton3,150,350,300,100, $Button1[0])
$Button4 = _GuiCtrlCreateButton($Image_OneButton4,$Image_TwoButton4,500,425,200,35, $Button1[0])

Dim $GO = False
while 1
_BMove($hWNDMain)
    Switch GUIGetMsg()
        case $Button
;~          Run(@ScriptDir&"\DSTA.exe")
            Exit
        case $Button2
;~          Run(@ScriptDir&"\config.exe")
        case $Button3
;~          Run(@ScriptDir&"\update.exe")
            exit
        case $Button4
            _GDIPlus_Shutdown()
            exit
        case -3 ; $GUI_EVENT_CLOSE
               _GDIPlus_Shutdown()
            exit
    EndSwitch
WEnd



Func _SetGraphicToControl($hControl,$sImage)
    Local $hImage

    If NOT FileExists($sImage) then Return 0
    $hImage = _GDIPlus_ImageLoadFromFile($sImage)
    SetBitmap($hControl,$hImage)
    _GDIPlus_ImageDispose($hImage)

    Return $sImage

EndFunc

Func _GuiCtrlCreatePNG($sImage,$iPosX, $iPosY, $hMainGUI)
    Local $hImage, $iw,$iH, $ret[3],$retto

    $hImage = _GDIPlus_ImageLoadFromFile($sImage)
    $iW = _GDIPlus_ImageGetWidth($hImage)
    $iH = _GDIPlus_ImageGetHeight($hImage)
    ConsoleWrite($iPosX)
    $Ret[0] = GUICreate("", $iW-60,$iH-60, $iPosX, $iPosY,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$hMainGUI)
    $Ret[1] = GUICtrlCreateLabel("",0,0,$iW,$iH)
    $Ret[2] = SetBitmap($Ret[0],$hImage)
    GUISetState(@SW_SHOW,$Ret[0])
    _GDIPlus_ImageDispose($hImage)

    Return $Ret

EndFunc

Func SetBitmap($hGUI, $hImage, $iOpacity = 255)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)

Return $hGUI

EndFunc

Source WinMovButton.au3:

#include <GDIPlus.au3>
Dim $Numero = 0
dim $Block[2]
Global $d[9][1]
Func _Button($hImage1,$hImage2,$x,$y,$w,$h,$SDOs)

if $Numero > 0 Then
    ReDim $Block[$Numero+1]
ReDim $d[9][$Numero+1]
EndIf
$Block[$Numero] = False
$b = _GuiCtrlCreatePNG($hImage1,$x,$y, $SDOs)
$d[0][$Numero] = $x
$d[1][$Numero] = $y
$d[2][$Numero] = $w
$d[3][$Numero] = $h
$d[4][$Numero] = $b[0]
$d[5][$Numero] = $hImage2
$d[6][$Numero] = $hImage1
$d[7][$Numero] = $b[1]

$Numero = $Numero +1
Return $d
EndFunc
Dim $Mouse_DK[2]
dim $Timer

Func _MouseDR($HD_GUI)
$Mouse_GI = MouseGetPos()
$Gui_Pos = WinGetPos($HD_GUI)
$Mouse_DK[0] = $Mouse_GI[0]-$Gui_Pos[0]
$Mouse_DK[1] = $Mouse_GI[1]-$Gui_Pos[1]
Return $Mouse_DK
EndFunc
Dim $style = True
Func _BMove($H_GUI)
if $style = True Then
if GUIGetStyle($H_GUI) <> 0x80000000 Then GUISetStyle(0x80000000,-1,$H_GUI)
$style = False
EndIf
$Mouse_DO = _MouseDR($H_GUI)
for $i = 0 to $Numero-1
if $Mouse_DO[0] > $d[0][$i] AND $Mouse_DO[0] < $d[0][$i]+$d[2][$i] AND $Mouse_DO[1] > $d[1][$i] AND  $Mouse_DO[1] < $d[1][$i]+$d[3][$i] Then
if $Block[$i] = False then
;########################################################;########################################################

_SetGraphicToControl($d[4][$i],$d[5][$i])

$Block[$i] = True
EndIf ;########################################################

Else
if $Block[$i] = True then
;~ _SetBitmapToCtrl($d[4][$i],$d[6][$i])
_SetGraphicToControl($d[4][$i],$d[6][$i])

$Block[$i] = False
EndIf
EndIf
Next
EndFunc
Func _BSEL($D_Sel)
    Return $D_Sel[7][UBound($D_Sel,2)-1]
EndFunc
Func _GuiCtrlCreateButton($hImage1,$hImage2,$x,$y,$w,$h,$SDOs)
    Return _BSEL(_Button($hImage1,$hImage2,$x,$y,$w,$h,$SDOs))
EndFunc

Func _SetBitmapToCtrl($CtrlId, $hBitmap)
GUICtrlSendMsg($CtrlId, 0x0172, 0, $hBitmap)
GUICtrlSetState($CtrlId, 16)
EndFunc

Func _IMGL($Image)
dim $LoadIMG,$iW,$iH,$hImage,$CloneIMG
$LoadIMG = _GDIPlus_ImageLoadFromFile($Image)
$iW = _GDIPlus_ImageGetWidth($LoadIMG)
$iH = _GDIPlus_ImageGetHeight($LoadIMG)
$CloneIMG = _GDIPlus_BitmapCloneArea($LoadIMG, 0, 0, $iW, $iH, $GDIP_PXF32ARGB)
$hImage = _GDIPlus_BitmapCreateHBITMAPFromBitmap($LoadIMG)
_GDIPlus_BitmapDispose($LoadIMG)
_GDIPlus_ImageDispose($CloneIMG)
Return $hImage
    EndFunc

sorry for my English. I'm Italian.

 

DSTC.au3

WinMovButton.au3

Edited by bub
Posted

Hello, User4574 here (the name is from a tv series, Stargate SG-1) :P anyways I can't really help you but I was wondering if you could show me where to find the GDIPlus au3 file

Posted

User4574, GDIPlus.au3 will be located in C:Program FilesAutoItIncludeGDIPlus.au3.  All the #include files are in that Include folder.

Bub, very nice!  I checked out the code, and you indeed have created a nice GUI.  I don't understand your question, though - you seem to be calling the GDIPlus events properly.  Do you mean you want to translate it into C/C++?

Posted

wow. respect for your gui. but i don't know anything about c(+).

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

  • Moderators
Posted

Have you thought about doing some reading, and thus learning about c or c++, so you can translate yourself?

This is A: an autoit forum, not a c/c++ forum and

B: the forum is dedicated to helping members improve their autoit scripts. Generally if someone says "code this for me" we direct them here:

http://www.vworker.com/

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted
I apologize for the misunderstanding.
 
I do not ask a source already done.
 
I only ask for help. Maybe some site where they explain the use of gdiplus.
 
excuse me, but I'm Italian.

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...