flat assembler
Message board for the users of flat assembler.
Index
> Windows > Can't figure it out |
Author |
|
LocoDelAssembly 13 Jan 2007, 18:36
You are using ShowWindow and UpdateWindow with a never initialised variable. add "mov [hwnd], eax" after window creation. On the registration class add
Code: mov [wincls+WNDCLASS.cbClsExtra], 0 mov [wincls+WNDCLASS.cbWndExtra], 0 mov [wincls+WNDCLASS.lpszMenuName], NULL And NULL terminate the strings. Code: ClassName du "KOHLRAK",0 Note that your txt must be unicode and null terminated (probably not very common), but size you are using it to set the tittle bar text which need a single line of text better don't use an external TXT file and do something like Code: Title du 'KOHLRAK', 0 [edit]I forgot the most important part, replace all occurrencies of WNDCLASSEX with WNDCLASS[/edit] |
|||
13 Jan 2007, 18:36 |
|
kohlrak 13 Jan 2007, 19:11
LocoDelAssembly wrote: You are using ShowWindow and UpdateWindow with a never initialised variable. add "mov [hwnd], eax" after window creation. On the registration class add oops... And shouldn't the cbWndExtra and lpszMenuName be 0ed by default? Quote: And NULL terminate the strings. I can't beleive that i forgot to null terminate that thing, anyway... Quote: Note that your txt must be unicode and null terminated (probably not very common), but size you are using it to set the tittle bar text which need a single line of text better don't use an external TXT file and do something like I did null terminate the TXT file, i made sure that i did that. lol Quote: [edit]I forgot the most important part, replace all occurrencies of WNDCLASSEX with WNDCLASS[/edit] That deffinately threw me off... But why dosn't WNDCLASSEX work for that...? Last edited by kohlrak on 13 Jan 2007, 19:16; edited 1 time in total |
|||
13 Jan 2007, 19:11 |
|
LocoDelAssembly 13 Jan 2007, 19:16
Because you are calling RegisterClass instead of RegisterClassEx
|
|||
13 Jan 2007, 19:16 |
|
kohlrak 13 Jan 2007, 19:22
oooooooooooh... Well... after all that, my code is now
Code: use32 format PE gui 4.0 include '%fasminc%\win32ax.inc' entry main ;---------------------------------------------------------------------------------------- macro initapp Thandle { ;program initialization invoke GetModuleHandle, 0 ;Gets our program's location in memory mov [Thandle], eax ;puts it in Thandle } ;---------------------------------------------------------------------------------------- macro initwnd phandle, wincls, style, hwndfnc, wClsName { mov [wincls+WNDCLASSEX.hInstance],phandle mov [wincls+WNDCLASSEX.style],style mov [wincls+WNDCLASSEX.lpfnWndProc],hwndfnc mov [wincls+WNDCLASSEX.lpszClassName],wClsName mov [wincls+WNDCLASSEX.hbrBackground],COLOR_WINDOW+1 invoke LoadIcon,NULL,IDI_APPLICATION mov [wincls+WNDCLASSEX.hIcon],eax invoke LoadCursor,NULL,IDC_ARROW mov [wincls+WNDCLASSEX.hCursor],eax invoke RegisterClass,wincls mov [wincls+WNDCLASS.cbClsExtra], 0 mov [wincls+WNDCLASS.cbWndExtra], 0 mov [wincls+WNDCLASS.lpszMenuName], NULL} ;---------------------------------------------------------------------------------------- macro msgloop { .msgloop: invoke GetMessage, msg, 0, 0, 0 or eax, eax jz .endmsgloop invoke TranslateMessage, msg invoke DispatchMessage, msg jmp .msgloop .endmsgloop: } ;---------------------------------------------------------------------------------------- section '.code' readable writeable executable ;-----------------------START OF PROGRAM----------------------------- ;--------------------Window Variables-------------------- Title du "KOHLRAK", 0 ClassName du "KOHLRAK",0 ;Never actually seen, so i put that there for uniqueness. WindowClass WNDCLASS ;Our window class msg MSG ;Variable that holds information of what is to be done with the window. hwnd dd ? ;handle for our window ;Program Variables Thandle dd ? ;handle for our program ;--------------------START-------------------- main: initapp Thandle initwnd eax, WindowClass,CS_HREDRAW or CS_VREDRAW, Window_Handling_Func, ClassName invoke CreateWindowEx, NULL,\ ClassName,\ Title,\ WS_OVERLAPPEDWINDOW,\ CW_USEDEFAULT,\ CW_USEDEFAULT,\ CW_USEDEFAULT,\ CW_USEDEFAULT,\ NULL,\ NULL,\ Thandle,\ NULL mov [hwnd], eax invoke ShowWindow, [hwnd], SW_SHOW invoke UpdateWindow, [hwnd] msgloop invoke ExitProcess, 0 ;------------------WINDOW HANDLING FUNCTION------------------------ proc Window_Handling_Func, cWnd, cMsg, cWparam, cLparam push ebx esi edi ;Safety cmp [cMsg], WM_DESTROY jne .noclose invoke PostQuitMessage, 0 .noclose: invoke DefWindowProc, [cWnd], [cMsg], [cWparam], [cLparam] pop edi esi ebx ret endp ;------------------------------------------------------------------ section '.idata' readable writeable data import library kernel, 'kernel32.dll',\ user, 'user32.dll' import kernel, ExitProcess, 'ExitProcess',\ GetModuleHandle, 'GetModuleHandleW' import user, LoadIcon, 'LoadIconW',\ LoadCursor, 'LoadCursorW',\ RegisterClass, 'RegisterClassW',\ CreateWindowEx, 'CreateWindowExW',\ ShowWindow, 'ShowWindow',\ GetMessage, 'GetMessageW',\ TranslateMessage, 'TranslateMessage',\ DispatchMessage, 'DispatchMessageW',\ PostQuitMessage, 'PostQuitMessage',\ DefWindowProc, 'DefWindowProcW',\ UpdateWindow, 'UpdateWindow' Still dosn't show the window... |
|||
13 Jan 2007, 19:22 |
|
LocoDelAssembly 13 Jan 2007, 19:40
LocoDelAssembly wrote:
Quote: oops... And shouldn't the cbWndExtra and lpszMenuName be 0ed by default? I assumed you want a code that will work even when the structure resides in run-time allocated memory or in stack memory where you can't trust that the memory is zero initialised. |
|||
13 Jan 2007, 19:40 |
|
kohlrak 13 Jan 2007, 19:48
Oops... finally i get it runnin'. lol See, i'm looking at a tut by iczellion and some other guy's fasm rewrite of the tutorial, but some things are slightly different between the 2 tutorials, and i guess that's where my errors are comming from.
Thanks, bud. |
|||
13 Jan 2007, 19:48 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.