News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CreateWindowA

Started by Ratch, July 31, 2005, 08:12:37 PM

Previous topic - Next topic

Ratch

     Why doesn't MASM32 support CreateWindowA?  Everytime I do an assembly with that call, I get a "WINMAIN.INC(43) : error A2006: undefined symbol : CreateWindowA" message.  CreateWindowExA works fine.  An inquiring mind would like to know.  Ratch

hutch--

Ratch,

Un;less Microsoft have added it recently, win 32 does not have a function that same name as the 16 bit version of Windows. The old name can be used with some compilers because they either use an equate or a macro to handle the 2 parameter differences but it ends up a call to the 32 bit Ex version.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Ratch

hutch--
     The reason I asked was because CreateWindowA is documented in the WIN32 API help documentation.   It also shows up in the C code within  Petzold's Programming Windows , ("The definitive guide to the WIN32 API") as CreateWindow.  Seems to me that if that API is not viable, it should not be mentioned wherever WIN32 is spoken.  Ratch

Mark Jones

I just noticed this last week and almost posted a question about it, but then realized that there is a CreateWindowEx which does the same thing and more, so didn't bother. :) It should be easy enough to make CreateWindowA reference CreateWindowEx, but as Hutch says, the original CreateWindow is antequated.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Ratch

Mark Jones,

Quote
It should be easy enough to make CreateWindowA reference CreateWindowEx...
     If you do that, you will need to push another parameter.  You are right, no need for CreateWindowA, but it should be removed from the documentation if it is not supported.  Ratch

MichaelW

From WinUser.h in the February 2003 PSDK:

#define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
#define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)

eschew obfuscation

Ratch

MichaelW,

     You posted a snippet of a C file.  What does that mean, other than CreateWindowA has eleven parameters and CreateWindowExA has twelve parameters?  CreateWindowA is still undefined within MASM32, even though the documentation says it is a viable API. Obsolence is not an excuse.  Other APIs are considered obsolete too, but they are still available.  Ratch

Mark Jones

I think Michael's point was that the code was from the 2003 platform SDK, so MS is still supporting it. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Ratch

Mark Jones,
Quote
..., so MS is still supporting it

     Great! So why do I get a "undefined" when I reference it?  Ratch

GregL

In C, CreateWindow is a macro that calls CreateWindowA (or CreateWindowW). CreateWindowA is a macro that calls the CreateWindowExA WinAPI function. And likewise CreateWindowW is a macro that calls the CreateWindowExW WinAPI function. So to use CreateWindow in MASM you need similar macros, which are not included in MASM32.

Example macros (not tested):

CreateWindowA MACRO lpClassName, lpWindowNameD, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam
    invoke CreateWindowExA, 0, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam
ENDM   

CreateWindowW MACRO lpClassName, lpWindowNameD, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam
    invoke CreateWindowExW, 0, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam
ENDM   

IFDEF UNICODE
    CreateWindow EQU <CreateWindowW>
ELSE
    CreateWindow EQU <CreateWindowA>
ENDIF



Or as previously stated, just call CreateWindowEx instead of CreateWindow.


Ratch

Greg,
Quote
So to use CreateWindow in MASM you need similar macros, which are not included in MASM32.

     Thank you for your lucid explanation.  Ratch

MichaelW

I see no need for CreateWindows when you can just use CreateWindowsEx with a value of zero for dwExStyle. Example code from MSDN: Using Windows:

HINSTANCE hinst;
HWND hwndMain;

// Create the main window.

hwndMain = CreateWindowEx(
    0,                      // no extended styles
    "MainWClass",           // class name
    "Main Window",          // window name
    WS_OVERLAPPEDWINDOW |   // overlapped window
             WS_HSCROLL |   // horizontal scroll bar
             WS_VSCROLL,    // vertical scroll bar
    CW_USEDEFAULT,          // default horizontal position
    CW_USEDEFAULT,          // default vertical position
    CW_USEDEFAULT,          // default width
    CW_USEDEFAULT,          // default height
    (HWND) NULL,            // no parent or owner window
    (HMENU) NULL,           // class menu used
    hinstance,              // instance handle
    NULL);                  // no window creation data

if (!hwndMain)
    return FALSE;

// Show the window using the flag specified by the program
// that started the application, and send the application
// a WM_PAINT message.

ShowWindow(hwndMain, SW_SHOWDEFAULT);
UpdateWindow(hwndMain);

eschew obfuscation

Ratch

MichaelW,
Quote
Example code from MSDN: Using Windows: ....

     Yes, I know how to use CreateWindowEx, in fact, I have to use CreateWindowEx, unless I cook up a wrapper MACRO.  I was just wondering why CreateWindow was not supported in MASM32.  Ratch

MichaelW

Ratch,

I'm sure you do know how to use CreateWindowEx. I included the example code because it was the only indication I could find (other than the macros in the header file) that a value of zero for dwExStyle indicates no extended styles. The CreateWindowEx documentation just states that dwExStyle can be one or more of perhaps 20 WS_EX_ constants, none of which are zero.

eschew obfuscation

Ratch

MichaelW,
     OK, CreateWindowEx it is.  I think we have beaten this topic to death already.  Thanks to everyone for replying.  Ratch