flat assembler
Message board for the users of flat assembler.
Index
> Windows > Snippets... |
Author |
|
bitRAKE 26 Jun 2008, 21:19
http://support.microsoft.com/kb/131462
Code: ; Preventing FNERR_BUFFERTOOSMALL with multiple file selection in Open File ; common dialog. http://support.microsoft.com/kb/131462 ; ; Although it is doubtful that a single application would have concurrent ; multiple Open File dialogs selecting multiple files; multiple instances of ; the same application could be open and using the same code. So, Microsoft ; advises the use of a control property to preserve the OPENFILENAME pointer. ; ; Microsoft indicates to attach property to parent control, but no reason it ; can't be attached to this default or custom child control (simplifying the ; code slightly). Logically, the structure belongs to the parent, and so does ; the child control. OFNHookProc: label .hWnd dword at esp+4*1 label .uMsg dword at esp+4*2 label .wParam dword at esp+4*3 label .lParam dword at esp+4*4 cmp [.uMsg],WM_NOTIFY je .WM_NOTIFY cmp [.uMsg],WM_DESTROY je .WM_DESTROY cmp [.uMsg],WM_INITDIALOG je .WM_INITDIALOG xor eax,eax retn 16 .WM_INITDIALOG: invoke SetProp,[.hWnd+8],.T_OFN,[.lParam] xor eax,eax retn 16 .WM_DESTROY: invoke RemoveProp,[.hWnd+4],.T_OFN .WM_0: xor eax,eax retn 16 .WM_NOTIFY: mov eax,[.lParam] cmp [eax+NMHDR.code],CDN_SELCHANGE jne .WM_0 invoke GetParent,[.hWnd] ; returns characters needed (undocumented?) 1+ invoke SendMessage,eax,CDM_GETSPEC,0,0 add eax,MAX_PATH push eax invoke GetProp,[.hWnd+8],.T_OFN pop edx test eax,eax je .WM_0 cmp [eax+OPENFILENAME.nMaxFile],edx jnc .WM_0 pushad xchg eax,edi mov esi,edx invoke GetProcessHeap xchg eax,ebx ; this really isn't needed as HeapFree error is ignored and passing a NULL ; pointer goes right through. ; cmp [eax+OPENFILENAME.lpstrFile],0 ; je @F invoke HeapFree,ebx,0,[edi+OPENFILENAME.lpstrFile] @@: lea ebp,[esi*2] ; UNICODE: characters to bytes needed invoke HeapAlloc,ebx,HEAP_ZERO_MEMORY,ebp test eax,eax je @F mov [edi+OPENFILENAME.lpstrFile],eax mov [edi+OPENFILENAME.nMaxFile],esi @@: popad xor eax,eax retn 16 .T_OFN TCHAR "OFN",0 _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
26 Jun 2008, 21:19 |
|
bitRAKE 10 Sep 2008, 06:32
Unique file name:
Code: FILE.TEMPLATE TCHAR "%07u%07u%07u.log",0 push esp push esp invoke GetSystemTimeAsFileTime,esp mov eax,[esp+4] xor edx,edx mov ecx,10000000 div ecx xchg eax,[esp] div ecx xchg edx,[esp] div ecx push edx push eax invoke wsprintf,FILE.PATHNAME,FILE.TEMPLATE add esp,24 _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
10 Sep 2008, 06:32 |
|
f0dder 10 Sep 2008, 08:27
Are you sure it's a good idea to blindly remove windows properties?
IMHO you should only use one prop per windowclass anyway, and make it a pointer to a struct - that way you only have one property to worry about yourself, and you don't risk messing up anything |
|||
10 Sep 2008, 08:27 |
|
bitRAKE 10 Sep 2008, 13:31
I use it when the window is being destroyed per MS.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
10 Sep 2008, 13:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.