Ignore:
Timestamp:
Sep 4, 1999, 9:42:30 PM (26 years ago)
Author:
sandervl
Message:

Dialog changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/dialog.cpp

    r780 r821  
    1 /* $Id: dialog.cpp,v 1.7 1999-09-01 19:12:20 phaller Exp $ */
     1/* $Id: dialog.cpp,v 1.8 1999-09-04 19:42:27 sandervl Exp $ */
    22
    33/*
    44 * Win32 dialog API functions for OS/2
    55 *
    6  * Copyright 1998 Sander van Leeuwen
     6 * Copyright 1999 Sander van Leeuwen (Wine port & OS/2 adaption)
    77 *
     8 *
     9 * Based on Wine code (990815; windows\dialog.c)
     10 *
     11 * Copyright 1993, 1994, 1996 Alexandre Julliard
    812 *
    913 * Project Odin Software License can be found in LICENSE.TXT
     
    1115 */
    1216#include <os2win.h>
    13 #include <nameid.h>
    14 #include "user32.h"
    15 #include "wndproc.h"
    16 #include "wndclass.h"
     17#include "win32wbase.h"
     18#include "win32dlg.h"
    1719
    1820//******************************************************************************
    1921//******************************************************************************
    20 HWND WIN32API CreateDialogParamA(HINSTANCE hinst, LPCSTR lpszTemplate,
    21                                 HWND hwndOwner, DLGPROC dlgproc,
    22                                 LPARAM lParamInit)
     22HWND WIN32API CreateDialogParamA(HINSTANCE hInst, LPCSTR lpszTemplate,
     23                                HWND hwndOwner, DLGPROC dlgproc,
     24                                LPARAM lParamInit)
    2325{
    24  HWND rc;
     26  HANDLE hrsrc = FindResourceA( hInst, lpszTemplate, RT_DIALOGA );
    2527
    26     if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
    27 #ifdef DEBUG
    28          WriteLog("OS2CreateDialogParamA %s\n", lpszTemplate);
    29 #endif
    30          lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate);
    31     }
    32 #ifdef DEBUG
    33     else WriteLog("OS2CreateDialogParamA %d\n", (int)lpszTemplate);
    34 #endif
     28    if (!hrsrc)
     29        return 0;
    3530
    36     return(rc);
     31    return CreateDialogIndirectParamA(hInst, (DLGTEMPLATE*)LoadResource(hInst, hrsrc),
     32                                      hwndOwner, dlgproc, lParamInit);
    3733}
    3834//******************************************************************************
    3935//******************************************************************************
    40 HWND WIN32API CreateDialogParamW(HINSTANCE hinst, LPCWSTR lpszTemplate,
    41                                 HWND hwndOwner, DLGPROC dlgproc,
    42                                 LPARAM lParamInit)
     36HWND WIN32API CreateDialogParamW(HINSTANCE hInst, LPCWSTR lpszTemplate,
     37                HWND hwndOwner, DLGPROC dlgproc,
     38                LPARAM lParamInit)
    4339{
    44  HWND rc;
     40  HANDLE hrsrc = FindResourceW( hInst, lpszTemplate, RT_DIALOGW );
    4541
    46     if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
    47          char *astring = UnicodeToAsciiString((LPWSTR)lpszTemplate);
    48 #ifdef DEBUG
    49          WriteLog("OS2CreateDialogParamW %s\n", astring);
    50 #endif
    51          lpszTemplate = (LPWSTR)ConvertNameId(hinst, astring);
    52          FreeAsciiString(astring);
    53     }
    54 #ifdef DEBUG
    55     else WriteLog("OS2CreateDialogParamW %d\n", (int)lpszTemplate);
    56 #endif
     42    if (!hrsrc)
     43        return 0;
    5744
    58     return(rc);
     45    return CreateDialogIndirectParamW(hInst, (DLGTEMPLATE*)LoadResource(hInst, hrsrc),
     46                                      hwndOwner, dlgproc, lParamInit);
    5947}
    6048//******************************************************************************
    6149//******************************************************************************
    62 HWND WIN32API CreateDialogIndirectParamA(HINSTANCE hinst,
    63                                          DLGTEMPLATE *dlgtemplate,
    64                                          HWND hwndParent, DLGPROC dlgproc,
    65                                          LPARAM lParamInit)
     50HWND WIN32API CreateDialogIndirectParamA(HINSTANCE hInst,
     51                         DLGTEMPLATE *dlgtemplate,
     52                         HWND hwndParent, DLGPROC dlgproc,
     53                         LPARAM lParamInit)
    6654{
    67  HWND hwnd;
     55 Win32Dialog *dialog;
    6856
    69     return(0);
     57    dprintf(("CreateDialogIndirectParamA: %x %x %x %x %x", hInst, dlgtemplate, hwndParent, dlgproc, lParamInit));
     58
     59    if (!dlgtemplate) return 0;
     60
     61        dialog = new Win32Dialog(hInst, (LPCSTR)dlgtemplate, hwndParent, dlgproc, lParamInit, FALSE);
     62
     63    if(dialog == NULL)
     64    {
     65        dprintf(("Win32Dialog creation failed!!"));
     66        return 0;
     67    }
     68    if(GetLastError() != 0)
     69    {
     70        dprintf(("Win32Dialog error found!!"));
     71        delete dialog;
     72        return 0;
     73    }
     74    return dialog->getWindowHandle();
    7075}
    7176//******************************************************************************
    7277//******************************************************************************
    73 HWND WIN32API CreateDialogIndirectParamW(HINSTANCE hinst,
    74                                          DLGTEMPLATE *dlgtemplate,
    75                                          HWND hwndParent, DLGPROC dlgproc,
    76                                          LPARAM lParamInit)
     78HWND WIN32API CreateDialogIndirectParamW(HINSTANCE hInst,
     79                         DLGTEMPLATE *dlgtemplate,
     80                         HWND hwndParent, DLGPROC dlgproc,
     81                         LPARAM lParamInit)
    7782{
    78  HWND hwnd;
     83 Win32Dialog *dialog;
    7984
    80     return(0);
     85    dprintf(("CreateDialogIndirectParamW: %x %x %x %x %x", hInst, dlgtemplate, hwndParent, dlgproc, lParamInit));
     86
     87    if (!dlgtemplate) return 0;
     88
     89        dialog = new Win32Dialog(hInst, (LPCSTR)dlgtemplate, hwndParent, dlgproc, lParamInit, TRUE);
     90
     91    if(dialog == NULL)
     92    {
     93        dprintf(("Win32Dialog creation failed!!"));
     94        return 0;
     95    }
     96    if(GetLastError() != 0)
     97    {
     98        dprintf(("Win32Dialog error found!!"));
     99        delete dialog;
     100        return 0;
     101    }
     102    return dialog->getWindowHandle();
    81103}
    82104//******************************************************************************
    83105//******************************************************************************
    84 INT  WIN32API DialogBoxIndirectParamA(HINSTANCE hinst,
    85                                       DLGTEMPLATE *dlgtemplate,
    86                                       HWND hwndParent, DLGPROC dlgproc,
    87                                       LPARAM lParamInit)
     106INT  WIN32API DialogBoxIndirectParamA(HINSTANCE hInst,
     107                      DLGTEMPLATE *dlgtemplate,
     108                      HWND hwndParent, DLGPROC dlgproc,
     109                      LPARAM lParamInit)
    88110{
    89     return(0);
     111    HWND hwnd = CreateDialogIndirectParamA(hInst, dlgtemplate, hwndParent, dlgproc,
     112                                           lParamInit);
     113    //TODO:
     114    if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner );
     115    return -1;
    90116}
    91117//******************************************************************************
    92118//******************************************************************************
    93 INT  WIN32API DialogBoxIndirectParamW(HINSTANCE hinst,
    94                                       DLGTEMPLATE *dlgtemplate,
    95                                       HWND hwndParent, DLGPROC dlgproc,
    96                                       LPARAM lParamInit)
     119INT  WIN32API DialogBoxIndirectParamW(HINSTANCE hInst, DLGTEMPLATE *dlgtemplate,
     120                                      HWND hwndParent, DLGPROC dlgproc,
     121                                      LPARAM lParamInit)
    97122{
    98     return(0);
     123    HWND hwnd = CreateDialogIndirectParamW(hInst, dlgtemplate, hwndParent, dlgproc,
     124                                           lParamInit);
     125    //TODO:
     126    if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner );
     127    return -1;
    99128}
    100129//******************************************************************************
    101130//******************************************************************************
    102 int WIN32API DialogBoxParamA(HINSTANCE hinst, LPCSTR lpszTemplate, HWND hwndOwner,
    103                              DLGPROC dlgprc, LPARAM  lParamInit)
     131int WIN32API DialogBoxParamA(HINSTANCE hInst, LPCSTR lpszTemplate, HWND hwndOwner,
     132                     DLGPROC dlgproc, LPARAM  lParamInit)
    104133{
    105  int rc;
    106 
    107     if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
    108         dprintf(("DialogBoxParam %s\n", lpszTemplate));
    109         lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate);
    110     }
    111     else {     
    112         dprintf(("DialogBoxParam %d\n", (int)lpszTemplate));
    113     }
    114 
    115     return(0);
     134    HWND hwnd = CreateDialogParamA( hInst, lpszTemplate, hwndOwner, dlgproc, lParamInit);
     135    //TODO:
     136    if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner );
     137    return -1;
    116138}
    117139//******************************************************************************
    118140//******************************************************************************
    119 int WIN32API DialogBoxParamW(HINSTANCE arg1, LPCWSTR arg2, HWND arg3,
    120                              DLGPROC arg4, LPARAM arg5)
     141int WIN32API DialogBoxParamW(HINSTANCE hInst, LPCWSTR lpszTemplate, HWND hwndOwner,
     142                             DLGPROC dlgproc, LPARAM lParamInit)
    121143{
    122  int   rc;
    123  char *astring = NULL;
    124 
    125 
    126     if((int)arg2 >> 16 != 0) {
    127             astring = UnicodeToAsciiString((LPWSTR)arg2);
    128     }
    129     else    astring = (char *)arg2;
    130     dprintf(("OS2DialogBoxParamW\n"));
    131 
    132     if((int)astring >> 16 != 0) FreeAsciiString(astring);
    133 
    134     dprintf(("OS2DialogBoxIndirectParamA returned %d\n", rc));
    135 
    136     return(0);
     144    HWND hwnd = CreateDialogParamW( hInst, lpszTemplate, hwndOwner, dlgproc, lParamInit);
     145    //TODO:
     146    if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner );
     147    return -1;
    137148}
    138149//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.