WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
What is FASM G
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
Forum Rules Snippets forum rules

In this forum all the registered users may post their snippets of code they whish to share with the WinAsm Studio community following these basic rules:
* Only snippets of code are accepted in the topics of this forum.
* Discussions, suggestions, requests etc. must be posted in the "Discussions" topic.
* Do not post copyrighted material.
Administrators/moderators may edit, move or delete the entries that do not follow the preceding rules.

 

Add a button to an edit control, code snippet that adds a button (such as one for file or folder browsing) in an edit control.

shoorick
Quote Post


Extremely Active Member
******

Group: Admins
Posts: 2342
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

;=======================================================================

Sponsored Links
PMEmail PosterUsers Website
Top
DobryGron
Quote Post


New Member
*

Group: Members
Posts: 1
Member No.: 39302
Joined: 8-November 10


hello

Can you add " Add Sale" button on the top besides
PMEmail PosterIntegrity Messenger IMICQAOLYahooMSN
Top
shoorick
Quote Post


Extremely Active Member
******

Group: Admins
Posts: 2342
Member No.: 160
Joined: 22-June 04


sure. the only you will need to use another subclassing window procedure instead of f4_browse
PMEmail PosterUsers Website
Top
garnerdawson
Quote Post


New Member
*

Group: Members
Posts: 2
Member No.: 54438
Joined: 16-October 12


Why am i getting a code error while debugging it, did i missed some thing from the code.
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topic

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google