Added win32 enhanced functionality to timer callbacks.
[wine/wine64.git] / dlls / shell32 / shell32_main.c
blob49753c520d2daec15a46c6d93468a680133b30d6
1 /*
2 * Shell basics
4 * 1998 Marcus Meissner
5 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
6 */
7 #include <assert.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <ctype.h>
12 #include "windows.h"
13 #include "winerror.h"
14 #include "file.h"
15 #include "shell.h"
16 #include "heap.h"
17 #include "module.h"
18 #include "neexe.h"
19 #include "resource.h"
20 #include "dlgs.h"
21 #include "win.h"
22 #include "graphics.h"
23 #include "cursoricon.h"
24 #include "interfaces.h"
25 #include "sysmetrics.h"
26 #include "shlobj.h"
27 #include "debug.h"
28 #include "winreg.h"
29 #include "imagelist.h"
30 #include "commctrl.h"
31 #include "authors.h"
33 #include "pidl.h"
34 #include "shell32_main.h"
36 /*************************************************************************
37 * CommandLineToArgvW [SHELL32.7]
39 LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
40 { LPWSTR *argv,s,t;
41 int i;
42 TRACE(shell,"\n");
44 /* to get writeable copy */
45 cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline);
46 s=cmdline;i=0;
47 while (*s)
48 { /* space */
49 if (*s==0x0020)
50 { i++;
51 s++;
52 while (*s && *s==0x0020)
53 s++;
54 continue;
56 s++;
58 argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
59 s=t=cmdline;
60 i=0;
61 while (*s)
62 { if (*s==0x0020)
63 { *s=0;
64 argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t );
65 *s=0x0020;
66 while (*s && *s==0x0020)
67 s++;
68 if (*s)
69 t=s+1;
70 else
71 t=s;
72 continue;
74 s++;
76 if (*t)
77 argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t );
78 HeapFree( GetProcessHeap(), 0, cmdline );
79 argv[i]=NULL;
80 *numargs=i;
81 return argv;
84 /*************************************************************************
85 * Control_RunDLL [SHELL32.12]
87 * Wild speculation in the following!
89 * http://premium.microsoft.com/msdn/library/techart/msdn193.htm
92 void WINAPI Control_RunDLL( HWND32 hwnd, LPCVOID code, LPCSTR cmd, DWORD arg4 )
94 FIXME(shell, "(0x%08x, %p, %s, 0x%08lx): stub\n", hwnd, code,
95 debugstr_a(cmd), arg4);
98 /*************************************************************************
99 * Shell_GetImageList [SHELL32.71]
101 * PARAMETERS
102 * imglist[1|2] [OUT] pointer which recive imagelist handles
104 * NOTES
105 * undocumented
106 * I don't know, which pointer is which. They may have to be
107 * exchanged. (jsch)
109 BOOL32 WINAPI Shell_GetImageList(HIMAGELIST * imglist1,HIMAGELIST * imglist2)
110 { WARN(shell,"(%p,%p):semi-stub.\n",imglist1,imglist2);
111 if (imglist1)
112 { *imglist1=ShellSmallIconList;
114 if (imglist2)
115 { *imglist2=ShellBigIconList;
118 return TRUE;
121 /*************************************************************************
122 * SHGetFileInfoA [SHELL32.218]
124 * FIXME
127 HIMAGELIST ShellSmallIconList = 0;
128 HIMAGELIST ShellBigIconList = 0;
130 DWORD WINAPI SHGetFileInfo32A(LPCSTR path,DWORD dwFileAttributes,
131 SHFILEINFO32A *psfi, UINT32 sizeofpsfi,
132 UINT32 flags )
133 { CHAR szTemp[MAX_PATH];
134 LPPIDLDATA pData;
135 DWORD ret=0;
137 TRACE(shell,"(%s,0x%lx,%p,0x%x,0x%x)\n",
138 path,dwFileAttributes,psfi,sizeofpsfi,flags);
140 /* translate the pidl to a path*/
141 if (flags & SHGFI_PIDL)
142 { SHGetPathFromIDList32A ((LPCITEMIDLIST)path,szTemp);
143 TRACE(shell,"pidl=%p is %s\n",path,szTemp);
145 else
146 { TRACE(shell,"path=%p\n",path);
149 if (flags & SHGFI_ATTRIBUTES)
150 { if (flags & SHGFI_PIDL)
151 { pData = _ILGetDataPointer((LPCITEMIDLIST)path);
152 psfi->dwAttributes = pData->u.generic.dwSFGAO; /* fixme: no direct access*/
153 ret=TRUE;
155 else
156 { psfi->dwAttributes=SFGAO_FILESYSTEM;
157 ret=TRUE;
159 FIXME(shell,"file attributes, stub\n");
162 if (flags & SHGFI_DISPLAYNAME)
163 { if (flags & SHGFI_PIDL)
164 { strcpy(psfi->szDisplayName,szTemp);
166 else
167 { strcpy(psfi->szDisplayName,path);
169 TRACE(shell,"displayname=%s\n", psfi->szDisplayName);
170 ret=TRUE;
173 if (flags & SHGFI_TYPENAME)
174 { FIXME(shell,"get the file type, stub\n");
175 strcpy(psfi->szTypeName,"FIXME: Type");
176 ret=TRUE;
179 if (flags & SHGFI_ICONLOCATION)
180 { FIXME(shell,"location of icon, stub\n");
181 strcpy(psfi->szDisplayName,"");
182 ret=TRUE;
185 if (flags & SHGFI_EXETYPE)
186 FIXME(shell,"type of executable, stub\n");
188 if (flags & SHGFI_LINKOVERLAY)
189 FIXME(shell,"set icon to link, stub\n");
191 if (flags & SHGFI_OPENICON)
192 FIXME(shell,"set to open icon, stub\n");
194 if (flags & SHGFI_SELECTED)
195 FIXME(shell,"set icon to selected, stub\n");
197 if (flags & SHGFI_SHELLICONSIZE)
198 FIXME(shell,"set icon to shell size, stub\n");
200 if (flags & SHGFI_USEFILEATTRIBUTES)
201 FIXME(shell,"use the dwFileAttributes, stub\n");
203 if (flags & SHGFI_ICON)
204 { FIXME(shell,"icon handle\n");
205 if (flags & SHGFI_SMALLICON)
206 { TRACE(shell,"set to small icon\n");
207 psfi->hIcon=pImageList_GetIcon(ShellSmallIconList,32,ILD_NORMAL);
208 ret = (DWORD) ShellSmallIconList;
210 else
211 { TRACE(shell,"set to big icon\n");
212 psfi->hIcon=pImageList_GetIcon(ShellBigIconList,32,ILD_NORMAL);
213 ret = (DWORD) ShellBigIconList;
217 if (flags & SHGFI_SYSICONINDEX)
218 { FIXME(shell,"get the SYSICONINDEX\n");
219 psfi->iIcon=32;
220 if (flags & SHGFI_SMALLICON)
221 { TRACE(shell,"set to small icon\n");
222 ret = (DWORD) ShellSmallIconList;
224 else
225 { TRACE(shell,"set to big icon\n");
226 ret = (DWORD) ShellBigIconList;
231 return ret;
234 /*************************************************************************
235 * ExtractIcon32A (SHELL32.133)
237 HICON32 WINAPI ExtractIcon32A( HINSTANCE32 hInstance, LPCSTR lpszExeFileName,
238 UINT32 nIconIndex )
239 { HGLOBAL16 handle = InternalExtractIcon(hInstance,lpszExeFileName,nIconIndex, 1);
240 TRACE(shell,"\n");
241 if( handle )
243 HICON16* ptr = (HICON16*)GlobalLock16(handle);
244 HICON16 hIcon = *ptr;
246 GlobalFree16(handle);
247 return hIcon;
249 return 0;
252 /*************************************************************************
253 * ExtractIcon32W (SHELL32.180)
255 HICON32 WINAPI ExtractIcon32W( HINSTANCE32 hInstance, LPCWSTR lpszExeFileName,
256 UINT32 nIconIndex )
257 { LPSTR exefn;
258 HICON32 ret;
259 TRACE(shell,"\n");
261 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
262 ret = ExtractIcon32A(hInstance,exefn,nIconIndex);
264 HeapFree(GetProcessHeap(),0,exefn);
265 return ret;
268 /*************************************************************************
269 * FindExecutable32A (SHELL32.184)
271 HINSTANCE32 WINAPI FindExecutable32A( LPCSTR lpFile, LPCSTR lpDirectory,
272 LPSTR lpResult )
273 { HINSTANCE32 retval=31; /* default - 'No association was found' */
274 char old_dir[1024];
276 TRACE(shell, "File %s, Dir %s\n",
277 (lpFile != NULL?lpFile:"-"),
278 (lpDirectory != NULL?lpDirectory:"-"));
280 lpResult[0]='\0'; /* Start off with an empty return string */
282 /* trap NULL parameters on entry */
283 if (( lpFile == NULL ) || ( lpResult == NULL ))
284 { /* FIXME - should throw a warning, perhaps! */
285 return 2; /* File not found. Close enough, I guess. */
288 if (lpDirectory)
289 { GetCurrentDirectory32A( sizeof(old_dir), old_dir );
290 SetCurrentDirectory32A( lpDirectory );
293 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
295 TRACE(shell, "returning %s\n", lpResult);
296 if (lpDirectory)
297 SetCurrentDirectory32A( old_dir );
298 return retval;
301 typedef struct
302 { LPCSTR szApp;
303 LPCSTR szOtherStuff;
304 HICON32 hIcon;
305 } ABOUT_INFO;
307 #define IDC_STATIC_TEXT 100
308 #define IDC_LISTBOX 99
309 #define IDC_WINE_TEXT 98
311 #define DROP_FIELD_TOP (-15)
312 #define DROP_FIELD_HEIGHT 15
314 extern HICON32 hIconTitleFont;
316 static BOOL32 __get_dropline( HWND32 hWnd, LPRECT32 lprect )
317 { HWND32 hWndCtl = GetDlgItem32(hWnd, IDC_WINE_TEXT);
318 if( hWndCtl )
319 { GetWindowRect32( hWndCtl, lprect );
320 MapWindowPoints32( 0, hWnd, (LPPOINT32)lprect, 2 );
321 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
322 return TRUE;
324 return FALSE;
327 /*************************************************************************
328 * SHAppBarMessage32 [SHELL32.207]
330 UINT32 WINAPI SHAppBarMessage32(DWORD msg, PAPPBARDATA data)
331 { FIXME(shell,"(0x%08lx,%p): stub\n", msg, data);
332 #if 0
333 switch (msg)
334 { case ABM_ACTIVATE:
335 case ABM_GETAUTOHIDEBAR:
336 case ABM_GETSTATE:
337 case ABM_GETTASKBARPOS:
338 case ABM_NEW:
339 case ABM_QUERYPOS:
340 case ABM_REMOVE:
341 case ABM_SETAUTOHIDEBAR:
342 case ABM_SETPOS:
343 case ABM_WINDOWPOSCHANGED:
346 #endif
347 return 0;
350 /*************************************************************************
351 * SHBrowseForFolderA [SHELL32.209]
354 LPITEMIDLIST WINAPI SHBrowseForFolder32A (LPBROWSEINFO32A lpbi)
355 { FIXME (shell, "(0x%lx,%s): stub\n", (DWORD)lpbi, debugstr_a(lpbi->lpszTitle));
356 return NULL;
359 /*************************************************************************
360 * SHGetDesktopFolder [SHELL32.216]
362 * SDK header win95/shlobj.h: This is equivalent to call CoCreateInstance with
363 * CLSID_ShellDesktop
364 * CoCreateInstance(CLSID_Desktop, NULL, CLSCTX_INPROC, IID_IShellFolder, &pshf);
366 * RETURNS
367 * the interface to the shell desktop folder.
369 * FIXME
370 * the pdesktopfolder has to be released at the end (at dll unloading???)
372 LPSHELLFOLDER pdesktopfolder=NULL;
374 DWORD WINAPI SHGetDesktopFolder(LPSHELLFOLDER *shellfolder)
375 { HRESULT hres = E_OUTOFMEMORY;
376 LPCLASSFACTORY lpclf;
377 TRACE(shell,"%p->(%p)\n",shellfolder,*shellfolder);
379 if (pdesktopfolder)
380 { hres = NOERROR;
382 else
383 { lpclf = IClassFactory_Constructor();
384 /* fixme: the buildin IClassFactory_Constructor is at the moment only
385 for rclsid=CLSID_ShellDesktop, so we get the right Interface (jsch)*/
386 if(lpclf)
387 { hres = lpclf->lpvtbl->fnCreateInstance(lpclf,NULL,(REFIID)&IID_IShellFolder, (void*)&pdesktopfolder);
388 lpclf->lpvtbl->fnRelease(lpclf);
392 if (pdesktopfolder)
393 { *shellfolder = pdesktopfolder;
394 pdesktopfolder->lpvtbl->fnAddRef(pdesktopfolder);
396 else
397 { *shellfolder=NULL;
400 TRACE(shell,"-- %p->(%p)\n",shellfolder, *shellfolder);
401 return hres;
403 /*************************************************************************
404 * SHGetPathFromIDList [SHELL32.221][NT 4.0: SHELL32.219]
406 BOOL32 WINAPI SHGetPathFromIDList32(LPCITEMIDLIST pidl,LPSTR pszPath)
407 { TRACE(shell,"(pidl=%p,%p)\n",pidl,pszPath);
408 return SHGetPathFromIDList32A(pidl,pszPath);
411 /*************************************************************************
412 * SHGetSpecialFolderLocation [SHELL32.223]
413 * gets the folder locations from the registry and creates a pidl
414 * creates missing reg keys and directorys
416 * PARAMS
417 * hwndOwner [I]
418 * nFolder [I] CSIDL_xxxxx
419 * ppidl [O] PIDL of a special folder
421 * RETURNS
422 * HResult
424 * FIXME
425 * - look for "User Shell Folder" first
428 HRESULT WINAPI SHGetSpecialFolderLocation(HWND32 hwndOwner, INT32 nFolder, LPITEMIDLIST * ppidl)
429 { LPSHELLFOLDER shellfolder;
430 DWORD pchEaten,tpathlen=MAX_PATH,type,dwdisp,res;
431 CHAR pszTemp[256],buffer[256],tpath[MAX_PATH],npath[MAX_PATH];
432 LPWSTR lpszDisplayName = (LPWSTR)&pszTemp[0];
433 HKEY key;
435 enum
436 { FT_UNKNOWN= 0x00000000,
437 FT_DIR= 0x00000001,
438 FT_DESKTOP= 0x00000002
439 } tFolder;
441 TRACE(shell,"(%04x,%d,%p)\n", hwndOwner,nFolder,ppidl);
443 strcpy(buffer,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\");
445 res=RegCreateKeyEx32A(HKEY_CURRENT_USER,buffer,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&key,&dwdisp);
446 if (res)
447 { ERR(shell,"Could not create key %s %08lx \n",buffer,res);
448 return E_OUTOFMEMORY;
451 tFolder=FT_DIR;
452 switch (nFolder)
453 { case CSIDL_BITBUCKET:
454 strcpy (buffer,"xxx"); /*not in the registry*/
455 TRACE (shell,"looking for Recycler\n");
456 tFolder=FT_UNKNOWN;
457 break;
458 case CSIDL_CONTROLS:
459 strcpy (buffer,"xxx"); /*virtual folder*/
460 TRACE (shell,"looking for Control\n");
461 tFolder=FT_UNKNOWN;
462 break;
463 case CSIDL_DESKTOP:
464 strcpy (buffer,"xxx"); /*virtual folder*/
465 TRACE (shell,"looking for Desktop\n");
466 tFolder=FT_DESKTOP;
467 break;
468 case CSIDL_DESKTOPDIRECTORY:
469 strcpy (buffer,"Desktop");
470 break;
471 case CSIDL_DRIVES:
472 strcpy (buffer,"xxx"); /*virtual folder*/
473 TRACE (shell,"looking for Drives\n");
474 tFolder=FT_UNKNOWN;
475 break;
476 case CSIDL_FONTS:
477 strcpy (buffer,"Fonts");
478 break;
479 case CSIDL_NETHOOD:
480 strcpy (buffer,"NetHood");
481 break;
482 case CSIDL_NETWORK:
483 strcpy (buffer,"xxx"); /*virtual folder*/
484 TRACE (shell,"looking for Network\n");
485 tFolder=FT_UNKNOWN;
486 break;
487 case CSIDL_PERSONAL:
488 strcpy (buffer,"Personal");
489 break;
490 case CSIDL_FAVORITES:
491 strcpy (buffer,"Favorites");
492 break;
493 case CSIDL_PRINTERS:
494 strcpy (buffer,"PrintHood");
495 break;
496 case CSIDL_PROGRAMS:
497 strcpy (buffer,"Programs");
498 break;
499 case CSIDL_RECENT:
500 strcpy (buffer,"Recent");
501 break;
502 case CSIDL_SENDTO:
503 strcpy (buffer,"SendTo");
504 break;
505 case CSIDL_STARTMENU:
506 strcpy (buffer,"Start Menu");
507 break;
508 case CSIDL_STARTUP:
509 strcpy (buffer,"Startup");
510 break;
511 case CSIDL_TEMPLATES:
512 strcpy (buffer,"Templates");
513 break;
514 default:
515 ERR (shell,"unknown CSIDL\n");
516 tFolder=FT_UNKNOWN;
517 break;
520 TRACE(shell,"Key=%s\n",buffer);
522 type=REG_SZ;
524 switch (tFolder)
525 { case FT_DIR:
526 /* Directory: get the value from the registry, if its not there
527 create it and the directory*/
528 if (RegQueryValueEx32A(key,buffer,NULL,&type,tpath,&tpathlen))
529 { GetWindowsDirectory32A(npath,MAX_PATH);
530 PathAddBackslash(npath);
531 switch (nFolder)
532 { case CSIDL_DESKTOPDIRECTORY:
533 strcat (npath,"Desktop");
534 break;
535 case CSIDL_FONTS:
536 strcat (npath,"Fonts");
537 break;
538 case CSIDL_NETHOOD:
539 strcat (npath,"NetHood");
540 break;
541 case CSIDL_PERSONAL:
542 strcpy (npath,"C:\\Personal");
543 break;
544 case CSIDL_FAVORITES:
545 strcat (npath,"Favorites");
546 break;
547 case CSIDL_PRINTERS:
548 strcat (npath,"PrintHood");
549 break;
550 case CSIDL_PROGRAMS:
551 strcat (npath,"Start Menu");
552 CreateDirectory32A(npath,NULL);
553 strcat (npath,"\\Programs");
554 break;
555 case CSIDL_RECENT:
556 strcat (npath,"Recent");
557 break;
558 case CSIDL_SENDTO:
559 strcat (npath,"SendTo");
560 break;
561 case CSIDL_STARTMENU:
562 strcat (npath,"Start Menu");
563 break;
564 case CSIDL_STARTUP:
565 strcat (npath,"Start Menu");
566 CreateDirectory32A(npath,NULL);
567 strcat (npath,"\\Startup");
568 break;
569 case CSIDL_TEMPLATES:
570 strcat (npath,"Templates");
571 break;
572 default:
573 RegCloseKey(key);
574 return E_OUTOFMEMORY;
576 if (RegSetValueEx32A(key,buffer,0,REG_SZ,npath,sizeof(npath)+1))
577 { ERR(shell,"could not create value %s\n",buffer);
578 RegCloseKey(key);
579 return E_OUTOFMEMORY;
581 TRACE(shell,"value %s=%s created\n",buffer,npath);
582 CreateDirectory32A(npath,NULL);
583 strcpy(tpath,npath);
585 break;
586 case FT_DESKTOP:
587 strcpy (tpath,"Desktop");
588 break;
589 default:
590 RegCloseKey(key);
591 return E_OUTOFMEMORY;
592 break;
595 RegCloseKey(key);
597 TRACE(shell,"Value=%s\n",tpath);
598 LocalToWideChar32(lpszDisplayName, tpath, 256);
600 if (SHGetDesktopFolder(&shellfolder)==S_OK)
601 { shellfolder->lpvtbl->fnParseDisplayName(shellfolder,hwndOwner, NULL,lpszDisplayName,&pchEaten,ppidl,NULL);
602 shellfolder->lpvtbl->fnRelease(shellfolder);
605 TRACE(shell, "-- (new pidl %p)\n",*ppidl);
606 return NOERROR;
608 /*************************************************************************
609 * SHHelpShortcuts_RunDLL [SHELL32.224]
612 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
613 { FIXME (exec, "(%lx, %lx, %lx, %lx) empty stub!\n",
614 dwArg1, dwArg2, dwArg3, dwArg4);
616 return 0;
619 /*************************************************************************
620 * SHLoadInProc [SHELL32.225]
624 DWORD WINAPI SHLoadInProc (DWORD dwArg1)
625 { FIXME (shell, "(%lx) empty stub!\n", dwArg1);
626 return 0;
629 /*************************************************************************
630 * ShellExecute32A (SHELL32.245)
632 HINSTANCE32 WINAPI ShellExecute32A( HWND32 hWnd, LPCSTR lpOperation,
633 LPCSTR lpFile, LPCSTR lpParameters,
634 LPCSTR lpDirectory, INT32 iShowCmd )
635 { TRACE(shell,"\n");
636 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
637 lpDirectory, iShowCmd );
641 /*************************************************************************
642 * AboutDlgProc32 (not an exported API function)
644 LRESULT WINAPI AboutDlgProc32( HWND32 hWnd, UINT32 msg, WPARAM32 wParam,
645 LPARAM lParam )
646 { HWND32 hWndCtl;
647 char Template[512], AppTitle[512];
649 TRACE(shell,"\n");
651 switch(msg)
652 { case WM_INITDIALOG:
653 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
654 if (info)
655 { const char* const *pstr = SHELL_People;
656 SendDlgItemMessage32A(hWnd, stc1, STM_SETICON32,info->hIcon, 0);
657 GetWindowText32A( hWnd, Template, sizeof(Template) );
658 sprintf( AppTitle, Template, info->szApp );
659 SetWindowText32A( hWnd, AppTitle );
660 SetWindowText32A( GetDlgItem32(hWnd, IDC_STATIC_TEXT),
661 info->szOtherStuff );
662 hWndCtl = GetDlgItem32(hWnd, IDC_LISTBOX);
663 SendMessage32A( hWndCtl, WM_SETREDRAW, 0, 0 );
664 SendMessage32A( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
665 while (*pstr)
666 { SendMessage32A( hWndCtl, LB_ADDSTRING32, (WPARAM32)-1, (LPARAM)*pstr );
667 pstr++;
669 SendMessage32A( hWndCtl, WM_SETREDRAW, 1, 0 );
672 return 1;
674 case WM_PAINT:
675 { RECT32 rect;
676 PAINTSTRUCT32 ps;
677 HDC32 hDC = BeginPaint32( hWnd, &ps );
679 if( __get_dropline( hWnd, &rect ) )
680 GRAPH_DrawLines( hDC, (LPPOINT32)&rect, 1, GetStockObject32( BLACK_PEN ) );
681 EndPaint32( hWnd, &ps );
683 break;
685 case WM_LBTRACKPOINT:
686 hWndCtl = GetDlgItem32(hWnd, IDC_LISTBOX);
687 if( (INT16)GetKeyState16( VK_CONTROL ) < 0 )
688 { if( DragDetect32( hWndCtl, *((LPPOINT32)&lParam) ) )
689 { INT32 idx = SendMessage32A( hWndCtl, LB_GETCURSEL32, 0, 0 );
690 if( idx != -1 )
691 { INT32 length = SendMessage32A( hWndCtl, LB_GETTEXTLEN32, (WPARAM32)idx, 0 );
692 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
693 char* pstr = (char*)GlobalLock16( hMemObj );
695 if( pstr )
696 { HCURSOR16 hCursor = LoadCursor16( 0, MAKEINTRESOURCE16(OCR_DRAGOBJECT) );
697 SendMessage32A( hWndCtl, LB_GETTEXT32, (WPARAM32)idx, (LPARAM)pstr );
698 SendMessage32A( hWndCtl, LB_DELETESTRING32, (WPARAM32)idx, 0 );
699 UpdateWindow32( hWndCtl );
700 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
701 SendMessage32A( hWndCtl, LB_ADDSTRING32, (WPARAM32)-1, (LPARAM)pstr );
703 if( hMemObj )
704 GlobalFree16( hMemObj );
708 break;
710 case WM_QUERYDROPOBJECT:
711 if( wParam == 0 )
712 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
713 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
714 { RECT32 rect;
715 if( __get_dropline( hWnd, &rect ) )
716 { POINT32 pt = { lpDragInfo->pt.x, lpDragInfo->pt.y };
717 rect.bottom += DROP_FIELD_HEIGHT;
718 if( PtInRect32( &rect, pt ) )
719 { SetWindowLong32A( hWnd, DWL_MSGRESULT, 1 );
720 return TRUE;
725 break;
727 case WM_DROPOBJECT:
728 if( wParam == hWnd )
729 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
730 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
731 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
732 if( pstr )
733 { static char __appendix_str[] = " with";
735 hWndCtl = GetDlgItem32( hWnd, IDC_WINE_TEXT );
736 SendMessage32A( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
737 if( !lstrncmp32A( Template, "WINE", 4 ) )
738 SetWindowText32A( GetDlgItem32(hWnd, IDC_STATIC_TEXT), Template );
739 else
740 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
741 *pch = '\0';
742 SendMessage32A( GetDlgItem32(hWnd, IDC_LISTBOX), LB_ADDSTRING32,
743 (WPARAM32)-1, (LPARAM)Template );
746 lstrcpy32A( Template, pstr );
747 lstrcat32A( Template, __appendix_str );
748 SetWindowText32A( hWndCtl, Template );
749 SetWindowLong32A( hWnd, DWL_MSGRESULT, 1 );
750 return TRUE;
754 break;
756 case WM_COMMAND:
757 if (wParam == IDOK)
758 { EndDialog32(hWnd, TRUE);
759 return TRUE;
761 break;
763 return 0;
767 /*************************************************************************
768 * ShellAbout32A (SHELL32.243)
770 BOOL32 WINAPI ShellAbout32A( HWND32 hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
771 HICON32 hIcon )
772 { ABOUT_INFO info;
773 TRACE(shell,"\n");
774 info.szApp = szApp;
775 info.szOtherStuff = szOtherStuff;
776 info.hIcon = hIcon;
777 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
778 return DialogBoxIndirectParam32A( WIN_GetWindowInstance( hWnd ),
779 SYSRES_GetResPtr( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX ),
780 hWnd, AboutDlgProc32, (LPARAM)&info );
784 /*************************************************************************
785 * ShellAbout32W (SHELL32.244)
787 BOOL32 WINAPI ShellAbout32W( HWND32 hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
788 HICON32 hIcon )
789 { BOOL32 ret;
790 ABOUT_INFO info;
792 TRACE(shell,"\n");
794 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
795 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
796 info.hIcon = hIcon;
797 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
798 ret = DialogBoxIndirectParam32A( WIN_GetWindowInstance( hWnd ),
799 SYSRES_GetResPtr( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX ),
800 hWnd, AboutDlgProc32, (LPARAM)&info );
801 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
802 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
803 return ret;
806 /*************************************************************************
807 * Shell_NotifyIcon [SHELL32.296]
808 * FIXME
809 * This function is supposed to deal with the systray.
810 * Any ideas on how this is to be implimented?
812 BOOL32 WINAPI Shell_NotifyIcon( DWORD dwMessage, PNOTIFYICONDATA pnid )
813 { TRACE(shell,"\n");
814 return FALSE;
817 /*************************************************************************
818 * Shell_NotifyIcon [SHELL32.297]
819 * FIXME
820 * This function is supposed to deal with the systray.
821 * Any ideas on how this is to be implimented?
823 BOOL32 WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATA pnid )
824 { TRACE(shell,"\n");
825 return FALSE;
828 /*************************************************************************
829 * FreeIconList
831 void WINAPI FreeIconList( DWORD dw )
832 { FIXME(shell, "(%lx): stub\n",dw);
835 /*************************************************************************
836 * SHGetPathFromIDList32A [SHELL32.261][NT 4.0: SHELL32.220]
838 * PARAMETERS
839 * pidl, [IN] pidl
840 * pszPath [OUT] path
842 * RETURNS
843 * path from a passed PIDL.
845 * NOTES
846 * exported by name
848 * FIXME
849 * fnGetDisplayNameOf can return different types of OLEString
851 DWORD WINAPI SHGetPathFromIDList32A (LPCITEMIDLIST pidl,LPSTR pszPath)
852 { STRRET lpName;
853 LPSHELLFOLDER shellfolder;
854 CHAR buffer[MAX_PATH],tpath[MAX_PATH];
855 DWORD type,tpathlen=MAX_PATH,dwdisp;
856 HKEY key;
858 TRACE(shell,"(pidl=%p,%p)\n",pidl,pszPath);
860 if (!pidl)
861 { strcpy(buffer,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\");
863 if (RegCreateKeyEx32A(HKEY_CURRENT_USER,buffer,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&key,&dwdisp))
864 { return E_OUTOFMEMORY;
866 type=REG_SZ;
867 strcpy (buffer,"Desktop"); /*registry name*/
868 if ( RegQueryValueEx32A(key,buffer,NULL,&type,tpath,&tpathlen))
869 { GetWindowsDirectory32A(tpath,MAX_PATH);
870 PathAddBackslash(tpath);
871 strcat (tpath,"Desktop"); /*folder name*/
872 RegSetValueEx32A(key,buffer,0,REG_SZ,tpath,tpathlen);
873 CreateDirectory32A(tpath,NULL);
875 RegCloseKey(key);
876 strcpy(pszPath,tpath);
878 else
879 { if (SHGetDesktopFolder(&shellfolder)==S_OK)
880 { shellfolder->lpvtbl->fnGetDisplayNameOf(shellfolder,pidl,SHGDN_FORPARSING,&lpName);
881 shellfolder->lpvtbl->fnRelease(shellfolder);
883 /*WideCharToLocal32(pszPath, lpName.u.pOleStr, MAX_PATH);*/
884 strcpy(pszPath,lpName.u.cStr);
885 /* fixme free the olestring*/
887 TRACE(shell,"-- (%s)\n",pszPath);
888 return NOERROR;
890 /*************************************************************************
891 * SHGetPathFromIDList32W [SHELL32.262]
893 DWORD WINAPI SHGetPathFromIDList32W (LPCITEMIDLIST pidl,LPWSTR pszPath)
894 { FIXME (shell,"(pidl=%p %s):stub.\n", pidl, debugstr_w(pszPath));
895 return 0;
899 void (CALLBACK* pDLLInitComctl)();
900 INT32 (CALLBACK* pImageList_AddIcon) (HIMAGELIST himl, HICON32 hIcon);
901 INT32(CALLBACK* pImageList_ReplaceIcon) (HIMAGELIST, INT32, HICON32);
902 HIMAGELIST (CALLBACK * pImageList_Create) (INT32,INT32,UINT32,INT32,INT32);
903 HICON32 (CALLBACK * pImageList_GetIcon) (HIMAGELIST, INT32, UINT32);
905 /*************************************************************************
906 * SHELL32 LibMain
908 * FIXME
909 * at the moment the icons are extracted from shell32.dll
910 * free the imagelists
912 HINSTANCE32 shell32_hInstance;
914 BOOL32 WINAPI Shell32LibMain(HINSTANCE32 hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
915 { HICON32 htmpIcon;
916 UINT32 iiconindex;
917 UINT32 index;
918 CHAR szShellPath[MAX_PATH];
919 HINSTANCE32 hComctl32;
922 TRACE(shell,"0x%x 0x%lx %p\n", hinstDLL, fdwReason, lpvReserved);
924 shell32_hInstance = hinstDLL;
926 GetWindowsDirectory32A(szShellPath,MAX_PATH);
927 PathAddBackslash(szShellPath);
928 strcat(szShellPath,"system\\shell32.dll");
930 if (fdwReason==DLL_PROCESS_ATTACH)
931 { hComctl32 = LoadLibrary32A("COMCTL32.DLL");
932 if (hComctl32)
933 { pDLLInitComctl=GetProcAddress32(hComctl32,"InitCommonControlsEx");
934 if (pDLLInitComctl)
935 { pDLLInitComctl();
937 pImageList_Create=GetProcAddress32(hComctl32,"ImageList_Create");
938 pImageList_AddIcon=GetProcAddress32(hComctl32,"ImageList_AddIcon");
939 pImageList_ReplaceIcon=GetProcAddress32(hComctl32,"ImageList_ReplaceIcon");
940 pImageList_GetIcon=GetProcAddress32(hComctl32,"ImageList_GetIcon");
941 FreeLibrary32(hComctl32);
943 else
944 { /* panic, imediately exit wine*/
945 ERR(shell,"P A N I C error getting functionpointers\n");
946 exit (1);
948 if ( ! ShellSmallIconList )
949 { if ( (ShellSmallIconList = pImageList_Create(sysMetrics[SM_CXSMICON],sysMetrics[SM_CYSMICON],ILC_COLORDDB | ILC_MASK,0,0x20)) )
950 { for (index=0;index < 40; index++)
951 { if ( ! ( htmpIcon = ExtractIcon32A(hinstDLL, szShellPath, index))
952 || ( -1 == (iiconindex = pImageList_AddIcon (ShellSmallIconList, htmpIcon))) )
953 { ERR(shell,"could not initialize iconlist (is shell32.dll in the system directory?)\n");
954 break;
959 if ( ! ShellBigIconList )
960 { if ( (ShellBigIconList = pImageList_Create(SYSMETRICS_CXSMICON, SYSMETRICS_CYSMICON,ILC_COLORDDB | ILC_MASK,0,0x20)) )
961 { for (index=0;index < 40; index++)
962 { if ( ! (htmpIcon = ExtractIcon32A( hinstDLL, szShellPath, index))
963 || (-1 == (iiconindex = pImageList_AddIcon (ShellBigIconList, htmpIcon))) )
964 { ERR(shell,"could not initialize iconlist (is shell32.dll in the system directory?)\n");
965 break;
970 TRACE(shell,"hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
972 return TRUE;