Extremely Active Member
Group: Admins
Posts: 2314
Member No.: 160
Joined: 22-June 04
|
adding file/folder browsing button to edit. use separate b_data structs for different edits at same time since they holds original window proc pointer.
CODE | ;======================================================================= ; v 3.5 (with independent buffer) ;======================================================================= ; b_data: <original winproc>,<0/1: file/folder>,<title>,<filter> ; ; b_data dd ?,0,MyTitle,MyFilter ;-----------------------------------------------------------------------
proc add_browser hWnd,b_data local .rect:RECT lea ecx,[.rect] invoke GetClientRect,[hWnd],ecx invoke SetWindowLong,[hWnd],GWL_USERDATA,[b_data] invoke SetWindowLong,[hWnd],GWL_WNDPROC,f4_browse mov ecx,[b_data] mov [ecx],eax invoke CreateWindowEx,0,_button,dots,\ WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\ 0,0,0,0,[hWnd],100,[hInstance],0 mov edx,[.rect + RECT.bottom] mov ecx,[.rect + RECT.right] sub ecx,edx invoke MoveWindow,eax,ecx,0,edx,edx,TRUE ret endp
;=======================================================================
proc f4_browse, hWnd, uMsg, wParam, lParam invoke GetWindowLong,[hWnd],GWL_USERDATA cmp [uMsg],WM_COMMAND jne .chk_key cmp [wParam],100 je .chk_op .chk_key: cmp [uMsg],WM_KEYUP jne .skip cmp [wParam],VK_F4 je .chk_op .skip: leave mov eax,[eax] push dword ptr esp mov dword ptr esp + 4,eax jmp [CallWindowProc] ;----------------------------------------------------------------------- .chk_op: push ebx push edi mov ebx,eax invoke GetProcessHeap invoke HeapAlloc,eax,0,520 mov edi,eax invoke GetWindowText,[hWnd],edi cmp dword ptr ebx + 4,0 mov edx,edi jne .b_dir ;----------------------------------------------------------------------- mov ecx,sizeof.OPENFILENAME sub esp,ecx mov edi,esp xor eax,eax rep stosb mov edi,esp m2m [edi + OPENFILENAME.hwndOwner],[hWnd] mov [edi + OPENFILENAME.lStructSize],sizeof.OPENFILENAME mov [edi + OPENFILENAME.nMaxFile],256 mov [edi + OPENFILENAME.Flags],\ OFN_FILEMUSTEXIST or OFN_HIDEREADONLY m2m [edi + OPENFILENAME.lpstrTitle],dword ptr ebx + 8 m2m [edi + OPENFILENAME.lpstrFilter],dword ptr ebx + 12 mov [edi + OPENFILENAME.lpstrFile],edx invoke GetOpenFileName,edi mov edi,[edi + OPENFILENAME.lpstrFile] add esp,sizeof.OPENFILENAME test eax,eax jz .ready invoke SetWindowText,[hWnd],edi jmp .ready ;----------------------------------------------------------------------- .b_dir: mov ecx,sizeof.BROWSEINFO sub esp,ecx mov edi,esp xor eax,eax rep stosb mov edi,esp mov [edi + BROWSEINFO.lpfn],get_dir_bk m2m [edi + BROWSEINFO.hwndOwner],[hWnd] mov [edi + BROWSEINFO.lParam],edx m2m [edi + BROWSEINFO.lpszTitle],dword ptr ebx + 8 invoke CoInitialize,0 invoke SHBrowseForFolder,edi mov edi,[edi + BROWSEINFO.lParam] add esp,sizeof.BROWSEINFO test eax,eax push edi jz .ready push eax invoke SHGetPathFromIDList,eax,edi invoke CoTaskMemFree invoke SetWindowText,[hWnd],edi ;----------------------------------------------------------------------- .ready: invoke SetFocus,[hWnd] invoke GetProcessHeap invoke HeapFree,eax,0,edi mov eax,TRUE pop edi pop ebx ret endp
;=======================================================================
proc get_dir_bk, hWnd, uMsg, lParam, lpData cmp [uMsg],BFFM_INITIALIZED jne @F invoke SendMessage,[hWnd],BFFM_SETSELECTION,TRUE,[lpData] @@: xor eax,eax ret endp
;======================================================================= |
|