flat assembler
Message board for the users of flat assembler.
Index
> Tutorials and Examples > [fasm2] Common Controls (run-time) |
Author |
|
bitRAKE 22 Jun 2024, 22:38
In the past I've made examples for MRU, TaskDialog. Yet, there are many more controls ...
I've create these templates for all the common controls from a run-time perspective (i.e. the controls are created with code and not resource data structures). These examples are mostly less than 100 lines of code. Mainly, these are used as snippets to build other projects. The goal isn't to use every feature of a control. https://github.com/bitRAKE/fasm2-examples/tree/main/controls If someone else finds them useful that's great as well. In the future I'll create a set of from an assemble-time perspective (i.e. minimal code, for example SysAnimate requires no control specific code), maybe an advanced set of control uses, and perhaps some custom controls (I usually keep these to myself). _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
22 Jun 2024, 22:38 |
|
bitRAKE 12 Jul 2024, 05:28
I've put a little more work into this, one can kind of see the direction intended. The advanced version takes a control to it's limit (without subclassing or ownerdraw) - finding all the errors in documentation - what works and what is BS. SysLink is the first advanced category control. It's time consuming to run down all the documentation, and there are no examples of SysLink used in this way.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
12 Jul 2024, 05:28 |
|
bitRAKE 13 Jul 2024, 00:30
Thank you, comprehensive examples do help, but often they don't say what didn't work. For example, SysLink acts like CDDS_PREPAINT might work, but no further messages are sent. Or WM_NOTIFY doesn't populate the NMLINK structure completely. Just reading the documentation we get the impression things should work a particular way - perhaps they did at one time - the current reality is something else.
The other part is the relationship between features. Enabling modern theming in windows will often supersede all other customizations. |
|||
13 Jul 2024, 00:30 |
|
Ali.Z 14 Aug 2024, 17:07
Code: ; Template for program using standard Win32 headers ; syslnk demo by aliz, this is the default template supplied with fasm package format PE GUI 4.0 entry start ID_FASMBOARD = 0x0000f00f ID_FASMFAQ = 0x0000f1f3 include 'win32ax.inc' section '.text' code readable executable start: invoke GetModuleHandle,0 mov [wc.hInstance],eax invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax invoke RegisterClass,wc test eax,eax jz error invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,256,192,NULL,NULL,[wc.hInstance],NULL test eax,eax jz error msg_loop: invoke GetMessage,msg,NULL,0,0 cmp eax,1 jb end_loop jne msg_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop error: invoke MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK end_loop: invoke ExitProcess,[msg.wParam] proc WindowProc uses ebx esi edi, hwnd,wmsg,wparam,lparam cmp [wmsg],WM_MOUSEMOVE je .wmmousemove cmp [wmsg],WM_CTLCOLORSTATIC je .wmctlcolorstatic cmp [wmsg],WM_COMMAND je .wmcommand cmp [wmsg],WM_DESTROY je .wmdestroy cmp [wmsg],WM_CREATE je .wmcreate .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .finish .wmmousemove: cmp [hwnd_active],0 jz @f invoke InvalidateRect,[hwnd_board],0,0 invoke InvalidateRect,[hwnd_faq],0,0 @@: xor eax,eax mov [hwnd_active],eax not eax jmp .finish .wmctlcolorstatic: mov edi,[lparam] cmp edi,[hwnd_board] jz @f cmp edi,[hwnd_faq] jnz .defbrush @@: mov esi,[wparam] invoke SetBkMode,esi,TRANSPARENT cmp [hwnd_active],edi jnz @f ;not active invoke SetTextColor,esi,0x000000ff invoke SelectObject,esi,[hfont_selected] jmp .defbrush @@: ;not active invoke SelectObject,esi,[hfont_not_selected] invoke SetTextColor,esi,0x000ffff .defbrush: invoke GetSysColorBrush,1 jmp .finish .wmcommand: mov eax,[wparam] and eax,0xffff cmp eax,ID_FASMBOARD mov edx,_board jz .link cmp eax,ID_FASMFAQ jnz .finish mov edx,_faq .link: invoke ShellExecute,[hwnd],'open',edx,0,0,SW_SHOW invoke SendMessage,[hwnd],WM_MOUSEMOVE,0,0 xor eax,eax jmp .finish .wmcreate: invoke CreateWindowEx,0,'STATIC','fasm board',WS_CHILD+WS_VISIBLE+SS_NOTIFY,20,40,120,20,[hwnd],ID_FASMBOARD,[wc.hInstance],0 mov [hwnd_board],eax invoke CreateWindowEx,0,'STATIC','fasm faq',WS_CHILD+WS_VISIBLE+SS_NOTIFY,20,80,120,20,[hwnd],ID_FASMFAQ,[wc.hInstance],0 mov [hwnd_faq],eax invoke LoadCursor,0,IDC_NO invoke SetClassLong,[hwnd_board],GCL_HCURSOR,eax invoke CreateFontIndirect,lf mov [hfont_selected],eax mov [lf.lfUnderline],0 invoke CreateFontIndirect,lf mov [hfont_not_selected],eax invoke SetWindowLong,[hwnd_board],GWL_WNDPROC,LinkProc mov [old_link_proc],eax invoke SetWindowLong,[hwnd_faq],GWL_WNDPROC,LinkProc jmp .finish .wmdestroy: i dont trust ms invoke DeleteObject,[hfont_selected] invoke DeleteObject,[hfont_not_selected] invoke PostQuitMessage,0 xor eax,eax .finish: ret endp proc LinkProc uses ebx esi edi, hwnd,wmsg,wparam,lparam mov ebx,[hwnd] cmp [wmsg],WM_MOUSEMOVE jnz .def cmp [hwnd_active],ebx jz .def invoke InvalidateRect,ebx,0,1 mov [hwnd_active],ebx .def: invoke CallWindowProc,[old_link_proc],ebx,[wmsg],[wparam],[lparam] ret endp section '.data' data readable writeable _class db 'FASMWIN32',0 _title db 'Win32 program template',0 _error db 'Startup failed.',0 _board db 'https://board.flatassembler.net',0 _faq db 'https://flatassembler.net/docs.php?article=faq',0 wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class msg MSG lf LOGFONT 18,9,0,0,500,0,1,0,ANSI_CHARSET,OUT_TT_ONLY_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,FIXED_PITCH+FF_MODERN,'Courier New' db 0 hfont_selected dd ? hfont_not_selected dd ? hwnd_board dd ? hwnd_faq dd ? old_link_proc dd ? hwnd_active dd ? section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL',\ gdi32,'GDI32.DLL',\ shell32,'SHELL32.DLL' include 'api\kernel32.inc' include 'api\user32.inc' include 'api\gdi32.inc' include 'api\shell32.inc' _________________ Asm For Wise Humans Last edited by Ali.Z on 15 Aug 2024, 15:53; edited 1 time in total |
|||
14 Aug 2024, 17:07 |
|
Ali.Z 15 Aug 2024, 15:31
updated to include 2 links.
i know this is not strictly syslink control, but it is likely syslink implemented this way internally; this method works on all windows, while syslink wont work on older ones. _________________ Asm For Wise Humans |
|||
15 Aug 2024, 15:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.