Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8459267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:17:23+00:00 2026-06-10T13:17:23+00:00

I am trying to create a window in x86 assembly with masm32 using the

  • 0

I am trying to create a window in x86 assembly with masm32 using the CreateWindowEx API. I have gotten my code to have no compile-time errors or anything of the sort- it compiles just fine. Yet when I run the exe, nothing happens. I don’t see any obvious errors, and I have practically copied the code out of Iczelion’s Win32 Tutorial (Part 3 – A Simple Window). What is wrong with it?

Here is my code:

.386 
.model flat, stdcall 
option casemap :none 
WinMain proto :DWORD,:DWORD, :DWORD,:DWORD

include \masm32\include\windows.inc 
include \masm32\include\user32.inc 
include \masm32\include\kernel32.inc 
include \masm32\include\gdi32.inc 
includelib \masm32\lib\user32.lib 
includelib \masm32\lib\kernel32.lib 
includelib \masm32\lib\gdi32.lib

.data 
ClassName db "Testwin", 0
AppName db "Testing Window", 0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
.code 
start: 

push NULL
call GetModuleHandle
mov  hInstance,eax
call GetCommandLine
mov CommandLine, eax
push SW_SHOWDEFAULT
push CommandLine
push NULL
push hInstance
call WinMain
push eax
call ExitProcess

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE, CmdLine:LPSTR,CmdShow:DWORD
; local vars:
LOCAL wc:WNDCLASSEX 
LOCAL msg:MSG 
LOCAL hwnd:HWND

; defining the window:
mov   wc.cbSize,SIZEOF WNDCLASSEX 
mov   wc.style, CS_HREDRAW or CS_VREDRAW 
mov   wc.lpfnWndProc, OFFSET WndProc 
mov   wc.cbClsExtra,NULL 
mov   wc.cbWndExtra,NULL 
push  hInst 
pop   wc.hInstance 
mov   wc.hbrBackground,COLOR_WINDOW+1 
mov   wc.lpszMenuName,NULL 
mov   wc.lpszClassName,OFFSET ClassName 
invoke LoadIcon,NULL,IDI_APPLICATION 
mov   wc.hIcon,eax 
mov   wc.hIconSm,eax 
invoke LoadCursor,NULL,IDC_ARROW 
mov   wc.hCursor,eax 
invoke RegisterClassEx, addr wc 
;create the window
invoke CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\ 
       WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\ 
       CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\ 
       hInst,NULL
invoke ShowWindow,hwnd,SW_SHOWNORMAL
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
cmp uMsg, WM_DESTROY
jne _next
invoke PostQuitMessage, NULL
_next:

WndProc endp
end start 

Where have I gone wrong? I suspect it has something to do with CreateWindowEx, considering it takes 12 parameters, most of which I don’t understand.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:17:25+00:00Added an answer on June 10, 2026 at 1:17 pm

    I believe you have not assigned the window handle returned by CreateWindowEx to the hwnd variable.

    So add the following line after invoke CreateWindowEx and before invoke ShowWindow –

    mov hwnd, eax
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a window (not a WinForm) using CreateWindowEx and RegisterClass.
I'm trying to create a preferences window. In it I have some checkbox style
I am trying to create a sleep/delay procedure in 16bit MASM Assembly x86 that
I am trying to create a simple window with C/C++ using the native Windows
I am trying to compile Boost 1.47 for x86 Windows CE using Visual Studio
I'm trying to programmatically create a window with my own custom OpenGL NSView as
I am trying to create a status window which content(textbox) should change in a
I am trying to create a child window in WPF.this child window should open
I am trying to create a sort of a window, formed by multiple divs.
I am trying to create a very simple chat window that simply has the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.