Jump to content

Dll never works


Recommended Posts

Hi,

As long as I use AutoIt I never got a DLL working.

Now I'm trying to use CreateWindow() from user32.dll (which is almost the same as CreateWindowEx() from WinAPI.au3)

MSDN: http://msdn.microsoft.com/en-us/library/ms632679(VS.85).aspx

Script I'm trying to get working:

#include <WindowsConstants.au3>
 #include <GUIConstantsEx.au3>
 #include <WinAPI.au3>
 
 
 $Gui = GUICreate("bla",400,400)
 GUISetState()
 
 $Gui = HWnd($Gui)
 $Class = _WinAPI_GetClassName($Gui)
 
 $Hwnd = _WinAPI_CreateWindow($Class, "Title", 0, 10, 10, 100, 100, $Gui)
 
 MsgBox(0,"sdsd",$Hwnd)
 
 _WinAPI_ShowWindow($Hwnd, @SW_SHOW)
 
 
 
 While 1
     
 WEnd
 
 
 #CS
 
     HWND CreateWindow(   
         LPCTSTR lpClassName,    str
         LPCTSTR lpWindowName,  str
         DWORD dwStyle,         int
         int x,                 int
         int y,                 int
         int nWidth,                int
         int nHeight,           int
         HWND hWndParent,       hwnd
         HMENU hMenu,           hwnd
         HINSTANCE hInstance,   hwnd
         LPVOID lpParam         ptr
     );
 
 #CE
 
 Func _WinAPI_CreateWindow($sClass, $sName, $iStyle, $iX, $iY, $iWidth, $iHeight, $hParent, $hMenu = 0, $hInstance = 0, $pParam = 0)
     Local $aResult
     
     If $hInstance = 0 Then $hInstance = _WinAPI_GetModuleHandle("")
     $aResult = DllCall("User32.dll", "hwnd", "CreateWindow", _
     "str", $sClass, _
     "str", $sName, _
     "int", $iStyle, _
     "int", $iX, _
     "int", $iY, _
     "int", $iWidth, _
     "int", $iHeight, _
     "hwnd", $hParent, _
     "hwnd", $hMenu, _
     "hwnd", $hInstance, _
     "ptr", $pParam)
     
     Return $aResult[0]
     
 EndFunc;==>_WinAPI_CreateWindowEx

@Error keeps saying that the function doesn't exist.

Does anyone know how I can get this working? Thanks.

Edited by Kip
Link to comment
Share on other sites

@Error keeps saying that the function doesn't exist.

Does anyone know how I can get this working?

If it says the function doesn't exist, it means the function doesn't exist. There's nothing to get working. Simple as that.

Examining user32.dll with any PE editor capable of showing DLL exports would confirm this.

Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

Just use CreateWindowEx and set ExStyle to 0 (zero) :)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

This is the same, the function does exist. But the return value is 0x00000000:

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


$Gui = GUICreate("bla",400,400,-1,-1,$WS_CLIPCHILDREN)
GUISetState()

$Gui = HWnd($Gui)
$Class = _WinAPI_GetClassName($Gui)

$Hwnd = CreateMDIWindow($Class, "Title", 0, 10, 10, 100, 100, $Gui)

MsgBox(0,"sdsd",$Hwnd)

_WinAPI_ShowWindow($Hwnd, @SW_SHOW)



While 1
    
WEnd


#CS

    HWND CreateMDIWindow(     
        LPCTSTR lpClassName,
        LPCTSTR lpWindowName,
        DWORD dwStyle,
        int X,
        int Y,
        int nWidth,
        int nHeight,
        HWND hWndParent,
        HINSTANCE hInstance,
        LPARAM lParam
    );

#CE

Func CreateMDIWindow($sClass, $sName, $iStyle, $iX, $iY, $iWidth, $iHeight, $hParent, $hInstance = 0, $pParam = 0)
     Local $aResult
    
     If $hInstance = 0 Then $hInstance = _WinAPI_GetModuleHandle("")
     $aResult = DllCall("User32.dll", "hwnd", "CreateMDIWindow", _
     "str", $sClass, _
     "str", $sName, _
     "int", $iStyle, _
     "int", $iX, _
     "int", $iY, _
     "int", $iWidth, _
     "int", $iHeight, _
     "hwnd", $hParent, _
     "hwnd", $hInstance, _
     "ptr", $pParam)
    
     Return $aResult[0]
    
EndFunc;==>_WinAPI_CreateWindowEx
Link to comment
Share on other sites

  • Moderators

Did you register the class before making the MDI (Or at least use a standard class)?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

I take the class from the standard gui. That also works with CreateWindowEx().

I'm familiar with how it works for standard windows... but I know whenever I do this in other languages, I register a class and an event function before I create it.

If you check kernel32's GetLastError after you call the dll, you may be able to help yourself there.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

then i get an error code... I don't know what that code means.

There's a link there on msdn System Error Codes that would show you what it means.

http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspx

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

It's not so easy to create MDI Child Windows in AutoIt ...

Please take a look at here -> http://msdn.microsoft.com/en-us/library/ms644909(VS.85).aspx

For an example how to create and register window classes in AutoIt take a look at here -> http://www.autoitscript.com/forum/index.ph...hl=window+class

http://www.autoit.de/index.php?page=Thread&threadID=6339

Greetz

Greenhorn

Link to comment
Share on other sites

I got a very simple function working :)

$Ret = _MessageBox("hi",0,0,4)
_MessageBox($Ret)

Func _MessageBox($Text, $Title="", $Hwnd=0, $Style=0)
    
    $iRet = DllCall("User32.dll","int","MessageBox","hwnd",$Hwnd,"str",$Text,"str",$Title,"uint",$Style)
    
    if not @error Then Return $iRet[0]
    
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

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