flat assembler
Message board for the users of flat assembler.
Index
> Windows > Problems with special windows |
Author |
|
IronFelix 13 Feb 2009, 20:50
Hi flona!
As for static window - you should process WM_SIZE message of main window and change size/position of static window there as needed. |
|||
13 Feb 2009, 20:50 |
|
IronFelix 13 Feb 2009, 20:58
Tab control: ensure that in case of WM_NOTIFY message from tab control
with nmhdr.code = TCN_SELCHANGING main window procedure returns FALSE, as it allows selection to be changed in this case (see MSDN for details). |
|||
13 Feb 2009, 20:58 |
|
IronFelix 13 Feb 2009, 21:12
ListView control - looks like the same as in tab control, WM_NOTIFY from listview with nmhdr.code = LVN_ITEMCHANGING, ensure that main window procedure returns FALSE in this case.
TreeView - WM_NOTIFY from treeview with nmhdr.code = TVN_SELCHANGING, return not TRUE in order selection to be changed, and with nmhdr.code = TVN_ITEMEXPANDING return not TRUE also in order to treeview item to be collapsed/expanded. (see Win32SDK help or MSDN). Hope this will help you. Best regards. |
|||
13 Feb 2009, 21:12 |
|
flona 13 Feb 2009, 22:27
Thanks for your reply. I've first tried to fix the tab control, but the following code doesn't work.
Code: format PE GUI 4.0 entry start include '........\ASSEMBLER\INCLUDE\win32a.inc' section '.data' data readable writeable hInstance dd 0 msg MSG 0 wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_WINDOW,NULL,WindowClass _Window db "Window",0 _IText db "Test",0 WindowClass db "WindowClass",0 SysTabControl32 db "SysTabControl32",0 tci dd TCIF_TEXT,0,0,_IText,0,0,0 section '.code' code readable executable start: invoke GetModuleHandle,0 mov dword [hInstance],eax mov dword [wc.hInstance],eax invoke LoadIcon,0,IDI_APPLICATION mov dword [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov dword [wc.hCursor],eax invoke RegisterClass,wc call WinMain proc WinMain local hTab:DWORD call [GetDesktopWindow] invoke CreateWindowEx,0,WindowClass,_Window,\ WS_VISIBLE+WS_CLIPSIBLINGS+WS_CLIPCHILDREN+WS_TABSTOP+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX,\ 50,50,600,500,eax,0,dword [hInstance],0 invoke CreateWindowEx,0,SysTabControl32,0,WS_VISIBLE+WS_CHILD,10,10,200,200,eax,0,dword [hInstance],0 mov [hTab],eax invoke SendMessage,[hTab],TCM_INSERTITEM,0,tci invoke SendMessage,[hTab],TCM_INSERTITEM,1,tci msg_loop: invoke GetMessage,msg,0,0,0 cmp eax,1 jb end_loop jne msg_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop end_loop: ret endp proc WindowProc hwnd,Message,wparam,lparam push eax ebx esi edi cmp [Message],WM_NOTIFY je notify cmp [Message],WM_CLOSE je close cmp [Message],WM_DESTROY je destroy jmp default notify: mov ecx,[lparam] cmp dword [ecx+8],TCN_SELCHANGING jne default mov eax,FALSE jmp ende close: invoke ExitProcess,0 jmp ende destroy: invoke PostQuitMessage,0 jmp ende default: push [lparam] push [wparam] push [Message] push [hwnd] call [DefWindowProc] ende: pop edi esi ebx eax ret endp section '.idata' import data readable writeable library user32,'user32.dll',\ kernel32,'kernel32.dll' import user32,\ CreateWindowEx,'CreateWindowExA',\ UpdateWindow,'UpdateWindow',\ SendMessage,'SendMessageA',\ GetDesktopWindow,'GetDesktopWindow',\ DefWindowProc,'DefWindowProcA',\ PostQuitMessage,'PostQuitMessage',\ GetMessage,'GetMessageA',\ TranslateMessage,'TranslateMessage',\ DispatchMessage,'DispatchMessageA',\ LoadIcon,'LoadIconA',\ LoadCursor,'LoadCursorA',\ RegisterClass,'RegisterClassA' import kernel32,\ ExitProcess,'ExitProcess',\ GetModuleHandle,'GetModuleHandleA' _________________ My english is not very well. Pardon. |
|||
13 Feb 2009, 22:27 |
|
IronFelix 14 Feb 2009, 02:30
Try this code, flona:
Code: format PE GUI 4.0 entry Main include '........\ASSEMBLER\INCLUDE\win32a.inc' section '.data' data readable writeable hInstance dd 0 msg MSG 0 wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_WINDOW + 1,NULL,WindowClass _Window db "Window",0 _IText db "Test",0 WindowClass db "WindowClass",0 SysTabControl32 db "SysTabControl32",0 tci dd TCIF_TEXT,0,0,_IText,0,0,0 section '.code' code readable executable proc Main local hTab : DWORD invoke GetModuleHandle,0 mov dword [hInstance],eax mov dword [wc.hInstance],eax invoke LoadIcon,0,IDI_APPLICATION mov dword [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov dword [wc.hCursor],eax invoke RegisterClass,wc invoke CreateWindowEx,0,WindowClass,_Window,\ WS_VISIBLE+WS_CLIPSIBLINGS+WS_CLIPCHILDREN+WS_TABSTOP+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX,\ 50,50,600,500,NULL,0,[hInstance],0 invoke CreateWindowEx,0,SysTabControl32,0,WS_VISIBLE+WS_CHILD,10,10,200,200,eax,0,[hInstance],0 mov [hTab],eax invoke SendMessage,[hTab],TCM_INSERTITEM,0,tci invoke SendMessage,[hTab],TCM_INSERTITEM,1,tci msg_loop: invoke GetMessage,msg,0,0,0 cmp eax,1 jb end_loop jne msg_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop end_loop: invoke ExitProcess,0 endp proc WindowProc hwnd,Message,wparam,lparam mov eax,[Message] cmp eax,WM_NOTIFY je notify cmp eax,WM_CLOSE je close cmp eax,WM_DESTROY je destroy jmp default notify: mov ecx,[lparam] cmp dword [ecx+8],TCN_SELCHANGING jne default mov eax,FALSE jmp ende close: invoke DestroyWindow,[hwnd] jmp ende destroy: invoke PostQuitMessage,0 jmp ende default: invoke DefWindowProc,[hwnd],eax,[wparam],[lparam] ende: ret endp invoke InitCommonControls section '.idata' import data readable writeable library user32,'user32.dll',\ kernel32,'kernel32.dll',\ comctl32, 'comctl32.dll' include "........\ASSEMBLER\INCLUDE\apia\kernel32.inc" include "........\ASSEMBLER\INCLUDE\apia\user32.inc" include "........\ASSEMBLER\INCLUDE\apia\comctl32.inc" Some words about changes i have made. First, there is no need in "push eax ebx esi edi" / "pop edi esi ebx eax" in WindowProc - none of registers that must be saved/restored is used here. And after "pop eax" your return value will be changed. Second, it is better to use register for [Message] comparison, as it is less in size and little faster. Third, you should load "comctl32.dll" dynamically (via LoadLibrary) or via import table, because tab, listview and treeview controls implemented there and their classes are registering when this DLL is loading. That's why "InitCommonControls" call is put in code, but not executed - just for "comctl32.dll" to be loaded. Forth, it is better IMHO to use fasm standard imports includes (apia\kernel32.inc and others) - there is no need in this case to correct "import" macro parameters when new function from DLL is used. And if function from DLL is not used - it will not be in import table. And fifth - there is no need in "call WinMain", as this call is just unnecessary, it is better just to continue execution after "RegisterClass". Maybe it's enough ... Regards. |
|||
14 Feb 2009, 02:30 |
|
flona 14 Feb 2009, 10:34
It works
Thank you!! I'm now trying get the other controls work. _________________ My english is not very well. Pardon. |
|||
14 Feb 2009, 10:34 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.