Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-16-2007, 08:56 AM
Member
 
Join Date: May 2007
Posts: 53
Default Problem with using winAPI from SWFKit

Hello!
I want to use winAPI funcs. For example:
Code:
struct {
    long left;
    long top;
    long right;
    long bottom;
} RECT;

dllimport "user32.dll" stdcall int GetWindowRect(long, RECT*) as user32_GetWindowRect;

var winID = getMainWnd().handle;

var myRect = new Struct(RECT);
var a = user32_GetWindowRect(winID, newRect);

trace('a='+a);
trace("myRect.left="+myRect.left);
trace("myRect.top="+myRect.top);
trace("myRect.right="+myRect.right);
trace("myRect.bottom="+myRect.left);
After this, 'a' equals 1 and the structure is filled with 0;

We tried many various vays: with StringStream, pointers, pointers-to-structure - cant make it work.

Thx in advance.
__________________
#define true false //happy debugging, friends
Reply With Quote
  #2 (permalink)  
Old 05-16-2007, 09:42 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Problem with using winAPI from SWFKit

Code:
struct {
    long left;
    long top;
    long right;
    long bottom;
} RECT;

dllimport "user32.dll" stdcall int GetWindowRect(long, RECT*) as user32_GetWindowRect;

var winID = getMainWnd().handle;

var myRect = new Struct(RECT);
var o = new Object;
o.value = myRect;
var a = user32_GetWindowRect(winID, o);
myRect = o.value;

trace('a='+a);
trace("myRect.left="+myRect.left);
trace("myRect.top="+myRect.top);
trace("myRect.right="+myRect.right);
trace("myRect.bottom="+myRect.left);
Because ffishscript cannot pass a parameter by reference, to receive out values of a function, you will have to use an object to pass a parameter. As you can see from the above code, we pass the object "o", instead of the struct "myRect", to the "user32_GetWindowRect" function. The object "o" contains a property "value", which points to the real data, the struct "myRect". When the "user32_GetWindowRect" function returns, the "value" property of the object "o" will contain the new data output by the function.

Whenever you want to receive output data of a parameter of a Dll function, please use an object that contains a "value" property, which will contain the input value and will receive the output value.
Reply With Quote
  #3 (permalink)  
Old 05-16-2007, 01:57 PM
Member
 
Join Date: May 2007
Posts: 53
Default Re:Problem with using winAPI from SWFKit

Thanks! Now works perfectly.
__________________
#define true false //happy debugging, friends
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:16 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.