flat assembler
Message board for the users of flat assembler.

Index > Windows > Two questions about WinAPI

Author
Thread Post new topic Reply to topic
denial



Joined: 12 Sep 2004
Posts: 98
denial
Hello,

I've got two questions refering to the usage of the Windows API. I hope you can help me, I'd be really glad. Smile

(1) I've been taking a look at the structure definitions in the include/equates/user32.inc file. The official helpfile of the API says, that the definition for the WNDCLASS structure for example is:

Code:
typedef struct _WNDCLASS {    // wc  
    UINT    style; 
    WNDPROC lpfnWndProc; 
    int     cbClsExtra; 
    int     cbWndExtra; 
    HANDLE  hInstance; 
    HICON   hIcon; 
    HCURSOR hCursor; 
    HBRUSH  hbrBackground; 
    LPCTSTR lpszMenuName; 
    LPCTSTR lpszClassName; 
} WNDCLASS; 
    


however, in FASM it is translated like this:

Code:
struct WNDCLASS
  .style         dd ?
  .lpfnWndProc  dd ?
  .cbClsExtra   dd ?
  .cbWndExtra   dd ?
  .hInstance    dd ?
  .hIcon        dd ?
  .hCursor      dd ?
  .hbrBackground dd ?
  .lpszMenuName  dd ?
  .lpszClassName dd ?
ends    


I was wondering why the offical defintion of the API uses so many types and why FASM just uses DWORDS. Doesn't that cause some kind of incompatiblity, or are these types really all 32-bits long? If yes, why did they use so many types?

(2) When I look at the RegisterClassEx function, the official helpfile says, that it returns an "ATOM"... What the hell is that Shocked
I've never heard of it, and I wanted to ask how I have to handle it in FASM. May I also use just DWORD here? Wink

Thank you
denial Smile
Post 20 Feb 2005, 15:50
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
denial wrote:
or are these types really all 32-bits long? If yes, why did they use so many types?


They are all 32bit dword type. Why? It is a HLL (C, C++) approach... what to say...

Quote:
(2) When I look at the RegisterClassEx function, the official helpfile says, that it returns an "ATOM"... What the hell is that Shocked
I've never heard of it, and I wanted to ask how I have to handle it in FASM. May I also use just DWORD here? Wink


Yes, you can. Also you simply can forget about this value, or use it in CreateWindowEx instead of string with the window class name. Actually ATOM is string value, stored somewhere inside the system, that is identified by Windows with its ATOM handle (that is integer). btw: Actually ATOM is 16bit value IIRC.

Regards.
Post 20 Feb 2005, 16:11
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
denial



Joined: 12 Sep 2004
Posts: 98
denial
Thank you very much for your help. Smile
Post 20 Feb 2005, 16:20
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
ATOMs are, as JohnFound said, pointers to strings that are used as unique identifiers for registered classes, messages, clipboard formats, event sources, service control handlers and hotkeys.

The ATOM handle (hAtom) returned by "Register..." functions can be used to check that the object has been created successfully before attempting continue processing, this is done by checking that hAtom is non zero.

HTH

cod3b453
Post 21 Feb 2005, 23:56
View user's profile Send private message Reply with quote
denial



Joined: 12 Sep 2004
Posts: 98
denial
Thank you for further explanation, it helped me alot. Smile
Post 22 Feb 2005, 13:10
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.