Hey I still cant get BrowseForFolder working! i included the shell32.inc and shell32.lib files and qeditor still comes up with errors about it. I then searched the msdn cd and couldnt find that browseforfolder was a shell function..it was under SHBrowseForFolder..but im stuck at using this too..could someone please help me with getting something to work? all i want is a browse for folder dialog box thanx
Posted on 2001-04-25 02:46:00 by Kezza
kezza the BrowseForFolder function is defined in the masm32 lib which is a lib hutch made up and wont be found in the msdn. the msdn does contain SHBrowseForFolder so ive included some working code so you can cut,paste,assemble and study it. if you have any question just let me know.
.386
.model flat,stdcall
option casemap:none

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\shell32.lib      ;add this lib
include \masm32\include\shell32.inc     ;add this inc

.const
ButtonID equ 1                          ;button identifier

.data
ClassName db "SimpleButton",0
AppName  db "A Push Button",0
ButtonClassName db "button",0           ;class to make a button
ButtonText db "Press Me",0
BFF BROWSEINFO <>                       ;BFF is declared as the BROWSEINFO stuct
DisplayedText db "Browse",0             ;text that is displayed near the top of browse for folder dialog box
buffer db 512 dup (?)

.data?
hInstance HINSTANCE ?

.code
start:
	invoke GetModuleHandle, NULL
	mov    hInstance,eax
	invoke WinMain, hInstance,NULL,NULL, SW_SHOWDEFAULT
      invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
	LOCAL wc:WNDCLASSEX
	LOCAL msg:MSG
	LOCAL hwnd:HWND
	mov   wc.cbSize,SIZEOF WNDCLASSEX
	mov   wc.style, CS_HREDRAW or CS_VREDRAW
	mov   wc.lpfnWndProc, OFFSET WndProc
	mov   wc.cbClsExtra,NULL
	mov   wc.cbWndExtra,NULL
	push  hInst
	pop   wc.hInstance
	mov   wc.hbrBackground,COLOR_BTNFACE+1
	mov   wc.lpszMenuName,OFFSET NULL
	mov   wc.lpszClassName,OFFSET ClassName
	invoke LoadIcon,NULL,IDI_APPLICATION
	mov   wc.hIcon,eax
	mov   wc.hIconSm,eax
	invoke LoadCursor,NULL,IDC_ARROW
	mov   wc.hCursor,eax
	invoke RegisterClassEx, addr wc
	INVOKE CreateWindowEx,NULL,
	                      ADDR ClassName,
	                      ADDR AppName,
	                      WS_OVERLAPPEDWINDOW,
	                      CW_USEDEFAULT,
	                      CW_USEDEFAULT,
	                      300,
	                      200,
	                      NULL,
	                      NULL,
           hInst,NULL
	mov   hwnd,eax
	INVOKE ShowWindow, hwnd,SW_SHOWNORMAL
	INVOKE UpdateWindow, hwnd
	.WHILE TRUE
                INVOKE GetMessage, ADDR msg,NULL,0,0
                .BREAK .IF (!eax)
                INVOKE TranslateMessage, ADDR msg
                INVOKE DispatchMessage, ADDR msg
	.ENDW
	mov     eax,msg.wParam
	ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
	
    .IF uMsg==WM_DESTROY
		invoke PostQuitMessage,NULL
	.ELSEIF uMsg==WM_CREATE
		invoke CreateWindowEx,NULL,                                   ;create button
		                      ADDR ButtonClassName,
		                      ADDR ButtonText,
		                      WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,
                              75,
                              70,
                              140,
                              25,
                              hWnd,
                              ButtonID,
                              hInstance,
                              NULL
    .ELSEIF uMsg==WM_COMMAND
		mov eax,wParam
		   .if lParam==0
               .ELSE
		      .if ax==ButtonID
		         shr eax,16                                           ;BELOW THE STRUCT IS DEFINED BUT SOME ARENT NEEDED
			      .if ax==BN_CLICKED                                  ;SO YOU CAN CHANGE THE NULL'S TO WHATEVER YOU NEED TO
			      	push hWnd                                         ;start of BROWSEINFO struct
			      	pop BFF.hwndOwner
                  	mov BFF.pidlRoot,NULL 
                  	mov BFF.pszDisplayName,OFFSET buffer
                  	mov BFF.lpszTitle,OFFSET DisplayedText
                  	mov BFF.ulFlags,NULL
                  	mov BFF.lpfn,NULL
                  	mov BFF.lParam,NU
Posted on 2001-04-25 04:33:00 by smurf
Kezza, This is the from the current app I am working on that uses the library version from MASM32 for ther Shell Browse dialog. The code around it is very simple, it sets the 1st byte of szDropFileName to zero so that the result can be tested after the call, it uses the main app name for the title bar and bffMsg to set the sub title. As long as you have the correct include and library files in your app, it should work fine.

          szText bffMsg,"Set Current Directory"
          mov szDropFileName[0], 0
          invoke BrowseForFolder,hWin,ADDR szDropFileName,
                                 ADDR szDisplayName,ADDR bffMsg
          cmp szDropFileName[0], 0
          jne @F
          ret
          @@:
          invoke SetCurrentDirectory,ADDR szDropFileName
Regards, hutch@pbq.com.au
Posted on 2001-04-25 11:44:00 by hutch--