* Copyright 1996 Albrecht Kleine
*/
+#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "win.h"
/***********************************************************************
* FileDlg_Init [internal]
*/
-static BOOL32 FileDlg_Init()
+static BOOL32 FileDlg_Init(void)
{
static BOOL32 initialized = 0;
if (lpofn->Flags & OFN_WINE32) {
if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
{
- if (!(template = LockResource32( lpofn->hInstance )))
+ if (!(template = LockResource32( MapHModuleSL(lpofn->hInstance ))))
{
CommDlgLastError = CDERR_LOADRESFAILURE;
return FALSE;
}
else if (lpofn->Flags & OFN_ENABLETEMPLATE)
{
- if (!(hResInfo = FindResource32A(lpofn->hInstance,
+ if (!(hResInfo = FindResource32A(MapHModuleSL(lpofn->hInstance),
PTR_SEG_TO_LIN(lpofn->lpTemplateName), RT_DIALOG32A)))
{
CommDlgLastError = CDERR_FINDRESFAILURE;
return FALSE;
}
- if (!(hDlgTmpl = LoadResource32( lpofn->hInstance, hResInfo )) ||
+ if (!(hDlgTmpl = LoadResource32( MapHModuleSL(lpofn->hInstance),
+ hResInfo )) ||
!(template = LockResource32( hDlgTmpl )))
{
CommDlgLastError = CDERR_LOADRESFAILURE;
if (lpofn->Flags & OFN_WINE32) {
if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
{
- if (!(template = LockResource32( lpofn->hInstance )))
+ if (!(template = LockResource32( MapHModuleSL(lpofn->hInstance ))))
{
CommDlgLastError = CDERR_LOADRESFAILURE;
return FALSE;
else if (lpofn->Flags & OFN_ENABLETEMPLATE)
{
HANDLE32 hResInfo;
- if (!(hResInfo = FindResource32A(lpofn->hInstance,
+ if (!(hResInfo = FindResource32A(MapHModuleSL(lpofn->hInstance),
PTR_SEG_TO_LIN(lpofn->lpTemplateName),
RT_DIALOG32A)))
{
CommDlgLastError = CDERR_FINDRESFAILURE;
return FALSE;
}
- if (!(hDlgTmpl = LoadResource32(lpofn->hInstance,hResInfo)) ||
+ if (!(hDlgTmpl = LoadResource32(MapHModuleSL(lpofn->hInstance),
+ hResInfo)) ||
!(template = LockResource32(hDlgTmpl)))
{
CommDlgLastError = CDERR_LOADRESFAILURE;
*/
static BOOL32 FILEDLG_ScanDir(HWND16 hWnd, LPSTR newPath)
{
- int len;
- char str[512];
+ char buffer[512];
+ char* str = buffer;
+ int drive;
+ HWND32 hlb;
- lstrcpyn32A( str, newPath, 512 );
- len = strlen(str);
- GetDlgItemText32A( hWnd, edt1, str + len, sizeof(str) - len );
- if (!DlgDirList32A( hWnd, str, lst1, 0, 0x0000 )) return FALSE;
- strcpy( str, "*.*" );
- return DlgDirList32A( hWnd, str, lst2, stc1, 0x8010 );
+ lstrcpyn32A(buffer, newPath, sizeof(buffer));
+
+ if (str[0] && (str[1] == ':')) {
+ drive = toupper(str[0]) - 'A';
+ str += 2;
+ if (!DRIVE_SetCurrentDrive(drive))
+ return FALSE;
+ } else {
+ drive = DRIVE_GetCurrentDrive();
+ }
+
+ if (str[0] && !DRIVE_Chdir(drive, str)) {
+ return FALSE;
+ }
+
+ GetDlgItemText32A(hWnd, edt1, buffer, sizeof(buffer));
+ if ((hlb = GetDlgItem32(hWnd, lst1)) != 0) {
+ char* scptr; /* ptr on semi-colon */
+ char* filter = buffer;
+
+ TRACE(commdlg, "Using filter %s\n", filter);
+ SendMessage32A(hlb, LB_RESETCONTENT32, 0, 0);
+ while (filter) {
+ scptr = strchr(filter, ';');
+ if (scptr) *scptr = 0;
+ TRACE(commdlg, "Using file spec %s\n", filter);
+ if (SendMessage32A(hlb, LB_DIR32, 0, (LPARAM)filter) == LB_ERR)
+ return FALSE;
+ if (scptr) *scptr = ';';
+ filter = (scptr) ? (scptr + 1) : 0;
+ }
+ }
+
+ strcpy(buffer, "*.*");
+ return DlgDirList32A(hWnd, buffer, lst2, stc1, 0x8010);
}
/***********************************************************************
(LPARAM)SEGPTR_GET(str));
if (savedlg) /* use _gray_ text in FileSaveDlg */
+ {
if (!lpdis->itemState)
SetTextColor32(lpdis->hDC,GetSysColor32(COLOR_GRAYTEXT) );
else
SetTextColor32(lpdis->hDC,GetSysColor32(COLOR_WINDOWTEXT) );
/* inversion of gray would be bad readable */
+ }
TextOut16(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
str, strlen(str));
lpofn->nFileExtension = 0;
while(tmpstr2[lpofn->nFileExtension] != '.' && tmpstr2[lpofn->nFileExtension] != '\0')
lpofn->nFileExtension++;
- if (lpofn->nFileExtension == '\0')
+ if (tmpstr2[lpofn->nFileExtension] == '\0')
lpofn->nFileExtension = 0;
else
lpofn->nFileExtension++;
*/
BOOL32 WINAPI PrintDlg32A( LPPRINTDLG32A printdlg )
{
- FIXME(commdlg, "empty stub\n" );
- return FALSE;
+ FIXME(commdlg, "(%p): stub\n",printdlg);
+ /* Altough returning FALSE is theoricaly the right thing
+ * most programs check for a printer at startup, and if
+ * none is found popup PrintDlg32A(), if it fails the program
+ * terminates; by returning TRUE the programs can still run
+ * as long as no printer related stuff is used
+ */
+ return TRUE;
}
i++;
break;
}
+ if (i == -1)
+ i++;
TRACE(commdlg,"---> '%s' \n", &lpFile[i]);
len = strlen(lpFile+i)+1;
EnableWindow32(GetDlgItem32(hDlg,0x2c8),TRUE);
if (lprect)
- SetWindowPos32(hDlg,NULL,0,0,lprect->right-lprect->left,
+ SetWindowPos32(hDlg,0,0,0,lprect->right-lprect->left,
lprect->bottom-lprect->top, SWP_NOMOVE|SWP_NOZORDER);
ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_SHOW);
ScreenToClient16(hDlg,&point);
GetClientRect16(hDlg,&rect);
point.x+=GetSystemMetrics32(SM_CXDLGFRAME);
- SetWindowPos32(hDlg,NULL,0,0,point.x,res,SWP_NOMOVE|SWP_NOZORDER);
+ SetWindowPos32(hDlg,0,0,0,point.x,res,SWP_NOMOVE|SWP_NOZORDER);
ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_HIDE);
ShowWindow32(GetDlgItem32(hDlg,0x2c5),SW_HIDE);
FIXME(commdlg, "current logfont back to caller\n");
break;
}
- WINPROC_UnmapMsg16To32A(uMsg32, wParam32, lParam, res);
+ WINPROC_UnmapMsg16To32A(hDlg,uMsg32, wParam32, lParam, res);
return res;
}
}
-static BOOL32 Commdlg_GetFileName32A( BOOL16 (*dofunction)(),
+static BOOL32 Commdlg_GetFileName32A( BOOL16 (CALLBACK *dofunction)(SEGPTR x),
LPOPENFILENAME32A ofn )
{
BOOL16 ret;
memset(ofn16,'\0',sizeof(*ofn16));
ofn16->lStructSize = sizeof(*ofn16);
ofn16->hwndOwner = ofn->hwndOwner;
- /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */
- ofn16->hInstance = 0;
+ ofn16->hInstance = MapHModuleLS(ofn->hInstance);
if (ofn->lpstrFilter) {
LPSTR s,x;
s = (LPSTR)ofn->lpstrCustomFilter;
while (*s)
s = s+strlen(s)+1;
- x = SEGPTR_ALLOC(s-ofn->lpstrCustomFilter);
s++;
+ x = SEGPTR_ALLOC(s-ofn->lpstrCustomFilter);
memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);
ofn16->lpstrCustomFilter = SEGPTR_GET(x);
}
return ret;
}
-static BOOL32 Commdlg_GetFileName32W( BOOL16 (*dofunction)(),
+static BOOL32 Commdlg_GetFileName32W( BOOL16 (CALLBACK *dofunction)(SEGPTR x),
LPOPENFILENAME32W ofn )
{
BOOL16 ret;
memset(ofn16,'\0',sizeof(*ofn16));
ofn16->lStructSize = sizeof(*ofn16);
ofn16->hwndOwner = ofn->hwndOwner;
- /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */
- ofn16->hInstance = 0;
+ ofn16->hInstance = MapHModuleLS(ofn->hInstance);
if (ofn->lpstrFilter) {
LPWSTR s;
LPSTR x,y;
*/
BOOL32 WINAPI GetOpenFileName32A( LPOPENFILENAME32A ofn )
{
- BOOL16 (WINAPI * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
+ BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
return Commdlg_GetFileName32A(dofunction,ofn);
}
*/
BOOL32 WINAPI GetOpenFileName32W( LPOPENFILENAME32W ofn )
{
- BOOL16 (WINAPI * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
+ BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
return Commdlg_GetFileName32W(dofunction,ofn);
}
*/
BOOL32 WINAPI GetSaveFileName32A( LPOPENFILENAME32A ofn )
{
- BOOL16 (WINAPI * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
+ BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
return Commdlg_GetFileName32A(dofunction,ofn);
}
*/
BOOL32 WINAPI GetSaveFileName32W( LPOPENFILENAME32W ofn )
{
- BOOL16 (WINAPI * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
+ BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
return Commdlg_GetFileName32W(dofunction,ofn);
}
memset(lpcc16,'\0',sizeof(*lpcc16));
lpcc16->lStructSize=sizeof(*lpcc16);
lpcc16->hwndOwner=lpChCol->hwndOwner;
- lpcc16->hInstance=0; /* FIXME:MODULE_HANDLEtoHMODULE16(lpChCol->hInstance)*/
+ lpcc16->hInstance=MapHModuleLS(lpChCol->hInstance);
lpcc16->rgbResult=lpChCol->rgbResult;
memcpy(ccref,lpChCol->lpCustColors,64);
lpcc16->lpCustColors=(COLORREF*)SEGPTR_GET(ccref);
memset(lpcc16,'\0',sizeof(*lpcc16));
lpcc16->lStructSize=sizeof(*lpcc16);
lpcc16->hwndOwner=lpChCol->hwndOwner;
- lpcc16->hInstance=0; /*FIXME:MODULE_HANDLEtoHMODULE16(lpChCol->hInstance)*/
+ lpcc16->hInstance=MapHModuleLS(lpChCol->hInstance);
lpcc16->rgbResult=lpChCol->rgbResult;
memcpy(ccref,lpChCol->lpCustColors,64);
lpcc16->lpCustColors=(COLORREF*)SEGPTR_GET(ccref);