flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > [fasm2] Common Controls (run-time)

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 22 Jun 2024, 22:38
In the past I've made examples for MRU, TaskDialog. Yet, there are many more controls ...
  • Animation
  • ComboBoxEx
  • Date and Time Picker
  • Header
  • IP Address
  • List View
  • Month Calendar
  • Progress Bar
  • Rebar
  • Status Bar
  • SysLink
  • Tab Control
  • Toolbar
  • Tooltip
  • Trackbar
  • Treeview
  • Up-Down

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
Post 22 Jun 2024, 22:38
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
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
Post 12 Jul 2024, 05:28
View user's profile Send private message Visit poster's website Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 727
Ali.Z 13 Jul 2024, 00:10
not sure if this will help, but lazarus (ide for delphi) have many controls implemented, although not sure how complex it is but if you can read pascal you might find how some of the controls work.

_________________
Asm For Wise Humans
Post 13 Jul 2024, 00:10
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
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.
Post 13 Jul 2024, 00:30
View user's profile Send private message Visit poster's website Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 727
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: Wink 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
Post 14 Aug 2024, 17:07
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 727
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
Post 15 Aug 2024, 15:31
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 10 Nov 2024, 01:52
I've added a minimal ribbon control example. Could act as a template to quickly get going with a very complex control.
Post 10 Nov 2024, 01:52
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 11 Nov 2024, 23:33
Part of a useful process of discovery in working with Ribbon controls is implementing event logging. Not just for useage metrics, but as the complexity increases it can help with debugging. Unfortunately, the documentation on the IUIEventLogger interface is incorrect and no examples exist - until now! Perhaps this might have helped with my previously failed attempt at implementing a useful Ribbon control ten years ago.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 11 Nov 2024, 23:33
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.