Link to home
Start Free TrialLog in
Avatar of peterkuxhaus
peterkuxhaus

asked on

convert from win16 to win32

Hi i have a program that was written some 12 years ago for designing patterns on cloth. The program worked fine on an old win 3.11 pc (now dead) so we installed what we had of the program on a nt4 pc all ok except the save button would not work and on w2k or xp it does not work correctly i have looked at the code that i can fined and it tells me it was written with borland so i am thinking c++ but i am unable to work out how to reopen the program so that i can convert to another platform ie win32 either in c++ or another language such as vb.net or c#.net can any body help i have attached some code if this helps
Relocation table offset 0x0040
Overlay Number 0x0000
New EXE Offset 0x00000250


New EXE Header Info    (Main Menu)
Module LAPIT
Description Lapit weave pattern editing system
Data NONSHARED
Windows Version 3.10 (PMODE ONLY!)

Signature 0x454E
Linker Version 0x0006
Linker Revision 0x0001
Entry Table Offset 0x031B
Entry Table Length 0x0002
Checksum 0x00000000
Module Flags 0x030A
DGROUP seg 0x0006
Heap Size 0x8000
Stack Size 0x2000
Initial CS:IP seg 0x0001 offset 0x0000
Initial SS:SP seg 0x0006 offset 0x0000
Entries in Segment Table 0x0006
Entries in Module Table 0x0006
Non-Resident Name Table Size 0x0039
Segment Table Offset 0x0040
Resource Table Offset 0x0070
Resident Name Table Offset 0x02E0
Module Table Offset 0x02E9
Imported Name Table Offset 0x02F5
Non-Resident Name Table Offset 0x0000056D
Moveable entries 0x0000
Alignment Shift Count 0x0009
Resource Segments 0x0000
Executable Type 0x0002
Additional Flags 0x0008
Fast Load Offset 0x0003
Fast Load Length 0x00D6
Avatar of PaulCaswell
PaulCaswell
Flag of United Kingdom of Great Britain and Northern Ireland image

Peter,

This is the details for the executable. In almost all cases, an executable is built from a set of source files (usually collectively called 'source code') It will be almost impossible to reliably change this program without source code. I would strongly recommend you try to find the source to this program.

Another alternative might be to run this under an emulator. Microsoft have released a PC Emulator for just such a problem as you have. If this is a valid alternative, let us know and we'll make some suggestions. The downside of this will be that you will have to install and configure the emulator on every PC that wants to run the program and this is not a trivial process.

Paul
ASKER CERTIFIED SOLUTION
Avatar of Molando
Molando

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of peterkuxhaus
peterkuxhaus

ASKER

Hi
I have been trying to locate the source code for the program and i hope to have it available on monday when i do i will post it so you can see if you can help
Thanks peter
Hi
I have now found what i think is the source code and have attached a sample if this is no good i will have to use the emulator option as it will only be needed on 2 pc's.
Thanks for any help
Peter

#include <stdio.h>
#include "windows.h"
#include "resource.h"
#include "lapit.h"

void
HandleSelectionState(LPDRAWITEMSTRUCT lpdis,int inflate);

void
HandleFocusState(LPDRAWITEMSTRUCT lpdis,int inflate);

void
DrawEntireItem(LPDRAWITEMSTRUCT lpdis,int inflate);

void
SetColours(HWND hDlg,int CtrlID,COLORREF IntlColr);
/* set up the colours in combo box */

/****************************************************************************
 *                                                                          *
 *  FUNCTION   : HandleSelectionState(LPDRAWITEMSTRUCT, int)                *
 *                                                                          *
 *  PURPOSE    : Handles a change in an item selection state. If an item is *
 *               selected, a black rectangular frame is drawn around that   *
 *               item; if an item is de-selected, the frame is removed.     *
 *                                                                          *
 *  COMMENT    : The black selection frame is slightly larger than the gray *
 *               focus frame so they won't paint over each other.           *
 *                                                                          *
 ****************************************************************************/

void
HandleSelectionState(LPDRAWITEMSTRUCT lpdis,int inflate)
{
      RECT      rc;
      HBRUSH      hbr;

      /* Resize rectangle to place selection frame outside of the focus
       * frame and the item.
       */
      CopyRect ((LPRECT)&rc, (LPRECT)&lpdis->rcItem);
      InflateRect ((LPRECT)&rc, inflate, inflate);

      if (lpdis->itemState & ODS_SELECTED)
      {
            /* selecting item -- paint a black frame */
            hbr = GetStockObject(BLACK_BRUSH);
      }
      else
      {
            /* de-selecting item -- remove frame */
            hbr = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
      }
      FrameRect(lpdis->hDC, (LPRECT)&rc, hbr);
      DeleteObject (hbr);
}

/****************************************************************************
 *                                                                          *
 *  FUNCTION   : HandleFocusState(LPDRAWITEMSTRUCT, int)                    *
 *                                                                          *
 *  PURPOSE    : Handle a change in item focus state. If an item gains the  *
 *               input focus, a gray rectangular frame is drawn around that *
 *               item; if an item loses the input focus, the gray frame is  *
 *               removed.                                                   *
 *                                                                          *
 *  COMMENT    : The gray focus frame is slightly smaller than the black    *
 *               selection frame so they won't paint over each other.       *
 *                                                                          *
 ****************************************************************************/

void
HandleFocusState(LPDRAWITEMSTRUCT lpdis,int inflate)
{
      RECT      rc;
      HBRUSH      hbr;

      /* Resize rectangle to place focus frame between the selection
       * frame and the item.
       */
      CopyRect ((LPRECT)&rc, (LPRECT)&lpdis->rcItem);
      InflateRect ((LPRECT)&rc, inflate, inflate);

      if (lpdis->itemState & ODS_FOCUS)
      {
            /* gaining input focus -- paint a gray frame */
            hbr = GetStockObject(GRAY_BRUSH);
      }
      else
      {
            /* losing input focus -- remove (paint over) frame */
            hbr = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
      }
      FrameRect(lpdis->hDC, (LPRECT)&rc, hbr);
      DeleteObject (hbr);
}

/****************************************************************************
 *                                                                          *
 *  FUNCTION   : DrawEntireItem(LPDRAWITEMSTRUCT, int)                      *
 *                                                                          *
 *  PURPOSE    : Draws an item and frames it with a selection frame and/or  *
 *               a focus frame when appropriate.                            *
 *                                                                          *
 ****************************************************************************/

void
DrawEntireItem(LPDRAWITEMSTRUCT lpdis,int inflate)
{
      RECT      rc;
      HBRUSH      hbr;

      /* Resize rectangle to leave space for frames */
      CopyRect ((LPRECT)&rc, (LPRECT)&lpdis->rcItem);
      InflateRect ((LPRECT)&rc, inflate, inflate);

      /* Create a brush using the value in the item data field (this value
       * was initialized when we added the item to the list/combo box using
       * LB_ADDSTRING/CB_ADDSTRING) and draw the color in the list/combo box.
       */
      hbr = CreateSolidBrush (lpdis->itemData);
      FillRect (lpdis->hDC, (LPRECT)&rc, hbr);
      DeleteObject (hbr);

      /* Draw or erase appropriate frames */
      HandleSelectionState(lpdis, inflate + 4);
      HandleFocusState(lpdis, inflate + 2);
}


BOOL FAR PASCAL AlterColours(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{
LPDRAWITEMSTRUCT      lpdis;
LPMEASUREITEMSTRUCT lpmis;
/* Variables for WM_DRAWITEM */
RECT rc;
HBRUSH hbr;
int Item;
static PattData *Pat;
static HLOCAL hMem;

      switch (message)
      {
      case WM_INITDIALOG:
        /* get colours from pattern data */
        hMem=(HLOCAL) lParam;
        Pat=(PattData *) LocalLock(hMem);
        /* set up the colours */
        SetColours(hDlg,IDC_NRMTRVB,Pat->ClrScrTrvB);
        SetColours(hDlg,IDC_NRMTRVC,Pat->ClrScrTrvC);
        SetColours(hDlg,IDC_NRMOVRLAP,Pat->ClrScrTrvMix);
        SetColours(hDlg,IDC_PRTTRVB,Pat->ClrPrtTrvB);
        SetColours(hDlg,IDC_PRTTRVC,Pat->ClrPrtTrvC);
        SetColours(hDlg,IDC_PRTOVRLAP,Pat->ClrPrtTrvMix);
        break;
      case WM_COMMAND:
            switch (wParam)
            {
              case IDOK:
                   /* overwrite the current colours with selections */
                   Item=SendMessage(GetDlgItem(hDlg, IDC_NRMTRVB),CB_GETCURSEL,0,0L);
                   Pat->ClrScrTrvB=SendMessage(GetDlgItem(hDlg, IDC_NRMTRVB),CB_GETITEMDATA,Item,0L);

                   Item=SendMessage(GetDlgItem(hDlg, IDC_NRMTRVC),CB_GETCURSEL,0,0L);
                   Pat->ClrScrTrvC=SendMessage(GetDlgItem(hDlg, IDC_NRMTRVC),CB_GETITEMDATA,Item,0L);

                   Item=SendMessage(GetDlgItem(hDlg, IDC_NRMOVRLAP),CB_GETCURSEL,0,0L);
                   Pat->ClrScrTrvMix=SendMessage(GetDlgItem(hDlg, IDC_NRMOVRLAP),CB_GETITEMDATA,Item,0L);

                   Item=SendMessage(GetDlgItem(hDlg, IDC_PRTTRVB),CB_GETCURSEL,0,0L);
                   Pat->ClrPrtTrvB=SendMessage(GetDlgItem(hDlg, IDC_PRTTRVB),CB_GETITEMDATA,Item,0L);

                   Item=SendMessage(GetDlgItem(hDlg, IDC_PRTTRVC),CB_GETCURSEL,0,0L);
                   Pat->ClrPrtTrvC=SendMessage(GetDlgItem(hDlg, IDC_PRTTRVC),CB_GETITEMDATA,Item,0L);

                   Item=SendMessage(GetDlgItem(hDlg, IDC_PRTOVRLAP),CB_GETCURSEL,0,0L);
                   Pat->ClrPrtTrvMix=SendMessage(GetDlgItem(hDlg, IDC_PRTOVRLAP),CB_GETITEMDATA,Item,0L);
              case IDCANCEL:
                   LocalUnlock(hMem);
                   EndDialog (hDlg, wParam);
                   return(TRUE);
              default:
                   return(TRUE);
             }
      case WM_DRAWITEM:
             /* Get pointer to the DRAWITEMSTRUCT */
        lpdis = (LPDRAWITEMSTRUCT)lParam;
        switch (lpdis->itemAction)
        {
                  case ODA_DRAWENTIRE:
                        DrawEntireItem(lpdis, -4);
                        break;

                  case ODA_SELECT:
                        HandleSelectionState(lpdis, 0);
                        break;

                  case ODA_FOCUS:
                        HandleFocusState(lpdis, -2);
                        break;
        }
        /* Return TRUE meaning that we processed this message. */
        return(TRUE);

      case WM_MEASUREITEM:
        lpmis = (LPMEASUREITEMSTRUCT)lParam;

        /* All the items are the same height since the combo box is
        * CBS_OWNERDRAWFIXED
        */
        if ((int)lpmis->itemID == -1)
        {
             /* If -1 for item, then we are setting the height of the
             * always visible static item part of the dropdown combo box.
             */
             lpmis->itemHeight = 25;
             return(TRUE);
        }
             lpmis->itemHeight = 30;
             break;

      case WM_CLOSE:
             LocalUnlock(hMem);
             EndDialog(hDlg, IDOK);
             return(TRUE);

      default:
             return(FALSE);
       }
       return(TRUE);
}

void
SetColours(HWND hDlg,int CtrlID,COLORREF IntlColr)
/* set up the colours in combo box */
{
int i;
COLORREF ColourSet[]={
RGB(0,0,0),
RGB(0,0,255),
RGB(255,0,0),
RGB(255,0,255),
RGB(0,255,0),
RGB(0,255,255),
RGB(255,255,0),
RGB(255,255,255),
RGB(0,0,128),
RGB(128,0,0),
RGB(128,0,128),
RGB(0,128,0),
RGB(0,128,128),
RGB(128,128,0),
RGB(128,128,128)};

      for (i=0; i<15; i++)
      {
        SendMessage (GetDlgItem(hDlg, CtrlID),CB_ADDSTRING,0,ColourSet[i]);
        /* if this colour default colour select it */
        if (IntlColr==ColourSet[i])
             SendMessage (GetDlgItem(hDlg, CtrlID),CB_SETCURSEL,i,0L);
      }
}


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Paul,
I will have a look and try filemon, I may have to come back as i know very little about c++ writing
Peter