Solved

convert from win16 to win32

Posted on 2004-08-17
9
850 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:peterkuxhaus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
9 Comments
 
LVL 16

Expert Comment

by:PaulCaswell
ID: 11819363
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
0
 
LVL 2

Accepted Solution

by:
Molando earned 250 total points
ID: 11819369
Just an idea, but the save button may not be working because it can not open a directory that it wants.
make a c:\windows and c:\windows\system directory. You never know, could work.

You could also go to: http://www.sysinternals.com/ and pull down a copy of filemon. start your program, get to the point where you would press the save buoon, then run filemon. press the save button, then stop filemon.

look through the filemon logs for entries from your program, you will see what directories and files it tries to access. make sure those directories exist, and the files that it  iis looking for are there.
0
 

Author Comment

by:peterkuxhaus
ID: 11859869
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:peterkuxhaus
ID: 11910782
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);
      }
}


0
 
LVL 16

Assisted Solution

by:PaulCaswell
PaulCaswell earned 250 total points
ID: 11911084
Molando's ideas were good. Filemon is a tool that allows you to look at what a program is trying to do with files. You might just get away with making no code changes. You might find, for example, that the program is writing to a specific path that does not exist on the new system.

If that doesnt work, have a look in the source for what the program does when you hit the 'Save' button. You are looking for code called something like 'HandleButtonHit' or 'HandleButtonClick' or 'HandleSave' or 'SaveFile' or something. If you find the function behind the save button, try to see what it does. You could also look for file I/O functions such as 'CreateFile' and 'WriteFile'.

Paul
0
 

Author Comment

by:peterkuxhaus
ID: 11911295
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sumNumber challenge 16 140
notReplace  challenge 53 151
format the code in java 6 110
EvenOdd challenge 10 147
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question