Jump to content

Recommended Posts

Posted

Hello, My English is not good. :)

-->(The following picture)

sshot-11.png.28c2d9285061e41c102d456db74

#pragma compile(Out, example.exe)
#pragma compile(Icon, black.ico)

#include <GUIConstantsEx.au3>

$Gui = GUICreate("Gui", 150, 50)
$button = GUICtrlCreateButton("Help", 32, 13, 80, 24)
GUISetState(@SW_SHOW)

While True
   Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         GUIDelete($Gui)
         Exit
      Case $button
         MsgBox(4096, "Help", "Help!")
   EndSwitch
WEnd

Icon ---> black.ico

This problem stems from? I can not solve. Why so?
Posted

I dont know why it does happen. But I wrote a way to show correct icon.

 

#NoTrayIcon
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>
#include <SendMessage.au3>
#include <WinAPISys.au3>
#include <GUIConstantsEx.au3>


#pragma compile(Out, example.exe)
#pragma compile(Icon, black.ico)

#Region Globals
Global $hEventProc = 0
Global $hEventHook = 0
Global Const $ICON_BIG = 1
Global $hIcon=0
#EndRegion Globals

$hGUI = GUICreate("GUI", 150, 50)
$button = GUICtrlCreateButton("Help", 32, 13, 80, 24)
GUISetState(@SW_SHOW)
$hIcon = _GetClassLongPtr($hGUI, $GCL_HICONSM)


_RegisterOwnMessageHandler()

Func _GetClassLongPtr($hwindow, $nIndex) ;GetClassLongPtr 64
    Return DllCall("User32.dll", "ULONG_PTR", "GetClassLong", "handle", $hwindow, "int", $nIndex)[0]
EndFunc   ;==>_GetClassLongPtr

While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete($hGUI)
            _FreeHandles()
            Exit
        Case $button
            MsgBox(4096, "Help", "Help!")
    EndSwitch
WEnd

Func _FreeHandles()
    If $hEventHook Then _WinAPI_UnhookWinEvent($hEventHook)
    If $hEventProc Then DllCallbackFree($hEventProc)
    $hEventHook = 0
    $hEventProc = 0
EndFunc   ;==>_FreeHandles

Func _RegisterOwnMessageHandler()
    If $hEventProc Or $hEventProc Then
        _FreeHandles()
    EndIf
    $hEventProc = DllCallbackRegister('_EventProc', 'none', 'ptr;dword;hwnd;long;long;dword;dword')
    If $hEventProc = 0 Then Return False
    $iRegistered = OnAutoItExitRegister('_FreeHandles')
    If $iRegistered = 0 Then Return False
    $hEventHook = _WinAPI_SetWinEventHook($EVENT_SYSTEM_ALERT, $EVENT_SYSTEM_ALERT, DllCallbackGetPtr($hEventProc))
    If $hEventHook = 0 Then Return False
    Return True
EndFunc   ;==>_RegisterAutoitMsgErrorHandler

Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime)
    #forceref $hEventHook, $iObjectID, $iChildID, $iThreadId, $iEventTime

    If WinGetProcess($hWnd) = @AutoItPID Then
        _SendMessage($hWnd, $WM_SETICON, $ICON_BIG, $hIcon)
    EndIf

EndFunc   ;==>_EventProc

Saludos

Posted (edited)

 

@Danyfirex : Thank you so much.. :) Working. :) Why not an easier way? (Msgbox(Here adjust easily possible , "", ""))

   Thank you.. Thank you.. I am very happy.. :))

Edited by luger
Posted

Hi. I'm not sure if messagebox has an easy way for that. so the script I wrote avobe is the easier I found.

You're Welcome.

 

Saludos

 

Posted (edited)
4 hours ago, Danyfirex said:

Hi. I'm not sure if messagebox has an easy way for that. so the script I wrote avobe is the easier I found.

You're Welcome.

Saludos

 

I understand you.. Thanks again.. :)

Edited by luger
Posted

Hi

Not sure if this is the point. 

MsgBox comes predefined with limited icon options.

Gui's run as scripts inside AU3 will not show their icons. (this is what Danyfirex fixed...)

You already have a pragma setting, I use this at compile time :

#AutoIt3Wrapper_Icon=RosterGriffin.ico

And when compiled as an EXE then it shows the right icon.

Hope that helps.

Skysnake

Why is the snake in the sky?

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