home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vclassrc.zip / procs.c < prev    next >
Text File  |  1998-12-27  |  7KB  |  167 lines

  1. /*  <VClassed 1.6, a PM OS/2 WorkPlace Shell class manager>
  2.     Copyright (C) 1996, 1997, 1998  Daniele Vistalli
  3.  
  4.     This program is free software; you can redistribute it and/or modify
  5.     it under the terms of the GNU General Public License as published by
  6.     the Free Software Foundation; either version 2 of the License, or
  7.     (at your option) any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program; if not, write to the Free Software
  16.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19.     You can contact me :
  20.     Daniele Vistalli :
  21.             dvistalli@tin.it
  22.         virusface@usa.net
  23.  
  24. */
  25.  
  26. #define INCL_WIN
  27.  
  28. #include <os2.h>
  29. #include <string.h>
  30. #include <stdlib.h>
  31.  
  32. #include "vclassed.h"
  33.  
  34. MRESULT EXPENTRY RegisterDlgProc (HWND wnd,ULONG msg,MPARAM mp1,MPARAM mp2)
  35. {
  36.   switch (msg) {
  37.     case WM_INITDLG :
  38.        WinSendMsg(WinWindowFromID(wnd,IN_Class),EM_SETTEXTLIMIT,MPFROMSHORT(40),0);
  39.        WinSendMsg(WinWindowFromID(wnd,IN_Dll),EM_SETTEXTLIMIT,MPFROMSHORT(255),0);
  40.        return(0);
  41.     case WM_COMMAND :
  42.         switch (SHORT1FROMMP(mp1)) {
  43.          case DID_OK :
  44.            { char aclass[41], dll[256];
  45.              WinQueryDlgItemText(wnd,IN_Class,40,aclass);
  46.              WinQueryDlgItemText(wnd,IN_Dll,255,dll);
  47.              if (strlen(aclass) == 0) { WinMessageBox(HWND_DESKTOP,wnd,"You must provide a class name","Error",0,MB_OK | MB_MOVEABLE | MB_ICONHAND);
  48.                                        return(0); }
  49.              if (strlen(dll) == 0) { WinMessageBox(HWND_DESKTOP,wnd,"You must provide a dll file","Error",0,MB_OK | MB_MOVEABLE | MB_ICONHAND);
  50.                                        return(0); }
  51.              if (WinRegisterObjectClass(aclass,dll)) WinMessageBox(HWND_DESKTOP,wnd,"Class registered succesfully","Success",0, MB_OK | MB_MOVEABLE | MB_INFORMATION);
  52.              else WinMessageBox(HWND_DESKTOP,wnd,"Error registering new class","Error",0, MB_OK | MB_MOVEABLE | MB_ICONHAND);
  53.              WinDismissDlg(wnd,DID_OK);
  54.              return(0);
  55.            }
  56.          case BTN_Browse :
  57.           {
  58.             FILEDLG FileDlg;
  59.             char pszTitle[]="Select DLL";
  60.             char pszFullFile[]="*.dll";
  61.             HWND hwndFileDlg;
  62.  
  63.             memset(&FileDlg, 0, sizeof(FILEDLG));
  64.             FileDlg.cbSize=sizeof(FILEDLG);
  65.             FileDlg.fl = FDS_CENTER | FDS_OPEN_DIALOG;
  66.             FileDlg.pszTitle=pszTitle;
  67.             strcpy(FileDlg.szFullFile, pszFullFile);
  68.             FileDlg.pszOKButton = malloc(10);
  69.             strcpy(FileDlg.pszOKButton,"~Register");
  70.             hwndFileDlg = WinFileDlg(HWND_DESKTOP, wnd, &FileDlg);
  71.             if ( FileDlg.lReturn != DID_CANCEL & hwndFileDlg != NULLHANDLE ) WinSetDlgItemText(wnd,IN_Dll,FileDlg.szFullFile);
  72.             free(FileDlg.pszOKButton);
  73.             return(0);
  74.           }
  75.          default : return(WinDefDlgProc(wnd,msg,mp1,mp2));
  76.         }
  77.     default :
  78.      return(WinDefDlgProc(wnd,msg,mp1,mp2));
  79.     }
  80. }
  81.  
  82. MRESULT EXPENTRY CreateDlgProc (HWND wnd,ULONG msg,MPARAM mp1,MPARAM mp2)
  83. {
  84.   static char aclass[55];
  85.  
  86.   switch (msg) {
  87.    case WM_INITDLG :
  88.     { CRecord *Cl;
  89.       HWND Combo;
  90.       char tmp[255];
  91.       Cl = PVOIDFROMMP(mp2);
  92.       tmp[0] = 0;
  93.       strcat(tmp,"Create new object : ");
  94.       strcat(tmp,Cl->data);
  95.       WinSetWindowText(wnd,tmp);
  96.       strcpy(aclass,Cl->data);
  97.  
  98.       WinSendMsg(WinWindowFromID(wnd,DLGCRE_Title),EM_SETTEXTLIMIT,MPFROMSHORT(255),0);
  99.       Combo = WinWindowFromID(wnd,DLGCRE_Dest);
  100.       WinSendMsg(Combo,EM_SETTEXTLIMIT,MPFROMSHORT(255),0);
  101.       WinSendMsg(WinWindowFromID(wnd,DLGCRE_Parm),EM_SETTEXTLIMIT,MPFROMSHORT(255),0);
  102.  
  103.       strcpy(tmp,"<WP_DESKTOP>");
  104.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  105.       strcpy(tmp,"<WP_NOWHERE>");
  106.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  107.       strcpy(tmp,"<WP_OS2SYS>");
  108.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  109.       strcpy(tmp,"<WP_TEMPS>");
  110.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  111.       strcpy(tmp,"<WP_CONFIG>");
  112.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  113.       strcpy(tmp,"<WP_START>");
  114.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  115.       strcpy(tmp,"<WP_INFO>");
  116.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  117.       strcpy(tmp,"<WP_DRIVES>");
  118.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  119.       strcpy(tmp,"<WP_APPSFOLDER>");
  120.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  121.       strcpy(tmp,"<WP_CONNCETIONSFOLDER>");
  122.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  123.       strcpy(tmp,"<WP_GAMES>");
  124.       WinSendMsg(Combo,LM_INSERTITEM,MPFROMSHORT(LIT_END),tmp);
  125.  
  126.  
  127.  
  128.       WinCheckButton(wnd,DLGCRE_Check,1);
  129.       return(0);
  130.     }
  131.    case WM_COMMAND :
  132.     switch (SHORT1FROMMP(mp1)) {
  133.       case DID_OK :
  134.        {
  135.          char title[256], dest[256], parms[256];
  136.          ULONG mode=0;
  137.  
  138.          WinQueryDlgItemText(wnd,DLGCRE_Title,255,title);
  139.          if (strlen(title) == 0) { WinMessageBox(HWND_DESKTOP,wnd,"You must provide a title for the object","Error",0,MB_OK | MB_MOVEABLE | MB_ICONHAND);
  140.                                        return(0); }
  141.          WinQueryDlgItemText(wnd,DLGCRE_Dest,30,dest);
  142.          if (strlen(dest) == 0) { WinMessageBox(HWND_DESKTOP,wnd,"You must provide a destination folder for the object","Error",0,MB_OK | MB_MOVEABLE | MB_ICONHAND);
  143.                                        return(0); }
  144.          WinQueryDlgItemText(wnd,DLGCRE_Parm,255,parms);
  145.  
  146.          switch ( SHORT1FROMMP(WinSendDlgItemMsg(wnd,DLGCRE_Check,BM_QUERYCHECKINDEX,0,0)) ) {
  147.            case 0 : mode = CO_FAILIFEXISTS; break;
  148.            case 1 : mode = CO_REPLACEIFEXISTS; break;
  149.            case 2 : mode = CO_UPDATEIFEXISTS; break;
  150.            }
  151.  
  152.          if (WinCreateObject(aclass,title,parms,dest,mode) == NULLHANDLE) WinMessageBox(HWND_DESKTOP,wnd,"Error creating new object","Error",0,MB_OK | MB_MOVEABLE | MB_ICONHAND);
  153.          else WinMessageBox(HWND_DESKTOP,wnd,"Object created successfully","Success",0,MB_OK | MB_MOVEABLE | MB_INFORMATION);
  154.  
  155.         WinDismissDlg(wnd,DID_OK);
  156.         return(0);
  157.        }
  158.       default :
  159.        return(WinDefDlgProc(wnd,msg,mp1,mp2));
  160.       }
  161.    default:
  162.     return(WinDefDlgProc(wnd,msg,mp1,mp2));
  163.   }
  164. }
  165.  
  166.  
  167.