flat assembler
Message board for the users of flat assembler.

Index > Windows > What's wrong with this?

Author
Thread Post new topic Reply to topic
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
[Sorry for bad title, couldn't think of anything better]
I have this code:
Code:
;in data section
title   du 'XM Player'
.len    = $-title
        dw 0
;...
class du 'PLAYERPLAYERPLAYERPLAYER',0
;...
wc      WNDCLASS CS_BYTEALIGNCLIENT+CS_BYTEALIGNWINDOW+CS_HREDRAW+CS_SAVEBITS+\
        CS_VREDRAW,WindowProc,0,0,0,0,0,0,0,class
;...
.orange = wc.hbrBackground

;and in code section:
invoke  GetModuleHandle,NULL
mov     [wc.hInstance],eax
;...
invoke  CreateSolidBrush,0045AEFFh
mov     [brushes.orange],eax
;...
invoke  LoadIcon,NULL,IDI_APPLICATION
mov     [wc.hIcon],eax
invoke  LoadCursor,NULL,IDC_ARROW
mov     [wc.hCursor],eax
invoke  RegisterClass,wc
test    eax,eax
jz      .error

invoke  MessageBox,NULL,'RegisterClass didn''t mess up','AAAAAAA',MB_ICONQUESTION

stdcall GetFirstArg,argc
invoke  CreateWindowEx,WS_EX_ACCEPTFILES+WS_EX_APPWINDOW,class,title,\
        WS_POPUP+WS_VISIBLE,CW_USEDEFAULT,CW_USEDEFAULT,137,80,NULL,\
        NULL,[wc.hInstance],eax
test    eax,eax
jz      .error
    

For some reason, CreateWindowEx fails, returning 0, yet the error code is ERROR_SUCCESS. Could someone find the fault with this code? (BTW, I have also tried redefining CW_USEDEFAULT to 0x80000000, which is what it is in WinUser.H, but it didn't help.
BTW, CreateWindowEx and RegisterClass are Unicode (CreateWindowExW etc.)

_________________
This calls for... Ultra CRUNCHY Man!
Ta da!! *crunch*
Post 21 Aug 2006, 20:46
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
are you sure GetFirstArg returns the correct value?
Post 22 Aug 2006, 00:18
View user's profile Send private message MSN Messenger Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
It wouldn't matter much, though, right? It doesn't crash there (I stepped through with debugger.) Besides, I've used that function in other applications, and it works.
Post 22 Aug 2006, 01:11
View user's profile Send private message Reply with quote
chris



Joined: 05 Jan 2006
Posts: 62
Location: China->US->China->?
chris
Hi, I didn't see your implementation of the window procedure, CreateWindowEx sends WM_CREATE to WindowProc before the window is visible, maybe something went wrong here?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowmessages/wm_create.asp
Post 23 Aug 2006, 03:03
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
Well, I have an interrupt (int3) at the beginning of my WindowProc, but it didn't trigger.
Post 23 Aug 2006, 14:03
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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.