home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best Internet Programs
/
BESTINTERNET.bin
/
internet
/
winftp
/
ws_child.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-11
|
29KB
|
795 lines
/***************************************************************************
Windows Sockets FTP Client Application Support Module
Written by:
Santanu Lahiri Internet: slahiri@magnus.acs.ohio-state.edu
Converted the Create Buttons calls to simulated buttons. Added necessary
WM_PAINT code to handle displaying the buttons in the appropriate mode
Added the ComboBox "History" feature.
Cleaned up WM_PAINT code that was eating resources - Deselected created
brushes and pens before the hdc was released.
*****************************************************************************/
/*
MODULE: WS_CHILD.C (child window functions)
*/
#include "ws_glob.h"
#include "winftp.H"
#include <dos.h>
#include <ctype.h>
#define WS_CHILDSTYLE WS_CHILD|WS_VISIBLE
#define LBS_STYLE LBS_STANDARD|WS_VSCROLL|WS_CHILDSTYLE|LBS_NOTIFY|LBS_NOINTEGRALHEIGHT
#define WS_TXTSTYLE WS_CHILDSTYLE|SS_LEFTNOWORDWRAP
#define WS_RADIOSTYLE WS_CHILDSTYLE|BS_RADIOBUTTON
#define CBS_STYLE WS_CHILDSTYLE|WS_VSCROLL|CBS_DROPDOWNLIST|CBS_HASSTRINGS|CBS_SORT
#define SBV_STYLE WS_CHILDSTYLE|SBS_VERT|WS_VISIBLE
#define EDT_STYLE WS_CHILDSTYLE|WS_BORDER|ES_AUTOHSCROLL
#define XSIZ(x) (x*nWndx)/4
#define YSIZ(x) (x*nWndy)/8
#ifdef WIN32
#define MAXLINES 150
#else
#define MAXLINES 100
#endif
#define STATLEN 151
char *lpStatusLines=NULL;
int nStatusPtr=0;
int nStatusScroll=1;
RECT rcMsg;
BOOL bCanMKD,bCanRMD,bCanREN,bCanDELE,bIsQVT,bIsNCSA,bIs5000,bIsDual;
BOOL bHELP=FALSE;
LPSTR lpListBox = "listbox";
LPSTR lpButton = "button";
LPSTR lpStatic = "static";
LPSTR lpEdit = "edit";
LPSTR lpComboBox= "combobox";
LPSTR lpScroll = "scrollbar";
LPSTR lpChgDir = "ChgDir";
LPSTR lpMkDir = "MkDir";
LPSTR lpRmDir = "RmDir";
LPSTR lpRefresh = "Refresh";
LPSTR lpDisplay = "Display";
LPSTR lpRename = "Rename";
LPSTR lpDelete = "Delete";
LPSTR lpConnect = "Connect";
LPSTR lpClose = "Close";
LPSTR lpLongDir = "LongDir";
LPSTR lpAbort = "Abort";
LPSTR lpOptions = "Options";
LPSTR lpAbout = "About";
LPSTR lpExit = "Exit";
LPSTR lpToRemote= "-->";
LPSTR lpToLocal = "<--";
typedef struct
{
LPSTR *lpBtnTxt;
RECT rcBtn;
int nBtnID, nStat;
int nTxtx, nTxty;
int nSendMsg;
RECT rcExt;
} BTNPOS;
static RECT rcLEdt, rcREdt, rcLLst, rcRLst, rcLDir, rcLFile, rcRDir, rcRFile;
#define BUTTONS 23
BOOL bEnabled[BUTTONS];
BTNPOS bpButton[BUTTONS] =
{
&lpChgDir, { 84, 32, 26, 13}, BTN_LCHANGE, 0, 0, 0, 0, {0, 0, 0, 0},
&lpMkDir, { 84, 46, 26, 13}, BTN_LMKDIR, 0, 0, 0, 0, {0, 0, 0, 0},
&lpRmDir, { 84, 60, 26, 13}, BTN_LRMDIR, 0, 0, 0, 0, {0, 0, 0, 0},
&lpRefresh, { 84, 84, 26, 13}, BTN_LREFRESH, 0, 0, 0, 0, {0, 0, 0, 0},
&lpDisplay, { 84, 107, 26, 13}, BTN_LDISPLAY, 0, 0, 0, 0, {0, 0, 0, 0},
&lpRename, { 84, 121, 26, 13}, BTN_LRENAME, 0, 0, 0, 0, {0, 0, 0, 0},
&lpDelete, { 84, 135, 26, 13}, BTN_LDELETE, 0, 0, 0, 0, {0, 0, 0, 0},
&lpChgDir, { 213, 32, 26, 13}, BTN_RCHANGE, 0, 0, 0, 0, {0, 0, 0, 0},
&lpMkDir, { 213, 46, 26, 13}, BTN_RMKDIR, 0, 0, 0, 0, {0, 0, 0, 0},
&lpRmDir, { 213, 60, 26, 13}, BTN_RRMDIR, 0, 0, 0, 0, {0, 0, 0, 0},
&lpRefresh, { 213, 84, 26, 13}, BTN_RREFRESH, 0, 0, 0, 0, {0, 0, 0, 0},
&lpDisplay, { 213, 107, 26, 13}, BTN_RDISPLAY, 0, 0, 0, 0, {0, 0, 0, 0},
&lpRename, { 213, 121, 26, 13}, BTN_RRENAME, 0, 0, 0, 0, {0, 0, 0, 0},
&lpDelete, { 213, 135, 26, 13}, BTN_RDELETE, 0, 0, 0, 0, {0, 0, 0, 0},
&lpToLocal, { 116, 101, 14, 13}, BTN_REMOTE_TO_LOCAL, 0, 0, 0, 0, {0, 0, 0, 0},
&lpToRemote,{ 116, 118, 14, 13}, BTN_LOCAL_TO_REMOTE, 0, 0, 0, 0, {0, 0, 0, 0},
&lpConnect, { 4, 185, 32, 9}, BTN_CONNECT, 0, 0, 0, 0, {0, 0, 0, 0},
&lpClose, { 38, 185, 32, 9}, BTN_CLOSE, 0, 0, 0, 0, {0, 0, 0, 0},
&lpLongDir, { 72, 185, 32, 9}, BTN_LONG, 0, 0, 0, 0, {0, 0, 0, 0},
&lpAbort, { 106, 185, 34, 9}, BTN_ABORT, 0, 0, 0, 1, {0, 0, 0, 0},
&lpOptions, { 142, 185, 32, 9}, BTN_OPTION, 0, 0, 0, 0, {0, 0, 0, 0},
&lpAbout, { 176, 185, 32, 9}, BTN_ABOUT, 0, 0, 0, 0, {0, 0, 0, 0},
&lpExit, { 210, 185, 32, 9}, BTN_EXIT, 0, 0, 0, 0, {0, 0, 0, 0}
};
//*********************************************************************
// Create the Button positions array. Compute the actual screen sizes
// and the screen text positions based on the initial button position
// and size. Use the actual screen size of text to locate it in a button.
//*********************************************************************
void CreateButtonPos (HWND hWnd)
{
HDC hdc;
DWORD dwExt;
RECT rc;
int nI, cExt, cHt;
#ifdef WIN32
SIZE sizeStr;
#endif
hdc = GetDC (hWnd);
SelectObject (hdc, GetStockObject (ANSI_VAR_FONT)); // This allows actual size calc.
for (nI=0; nI<sizeof (bpButton)/sizeof (BTNPOS); nI++)
{
bEnabled[nI] = TRUE;
#ifdef WIN32
dwExt = GetTextExtentPoint (hdc, *bpButton[nI].lpBtnTxt, lstrlen (*bpButton[nI].lpBtnTxt), &sizeStr);
cExt = sizeStr.cx; // Length of screen text
cHt = sizeStr.cy; // Height of screen text
#else
dwExt = GetTextExtent (hdc, *bpButton[nI].lpBtnTxt, lstrlen (*bpButton[nI].lpBtnTxt));
cExt = LOWORD (dwExt); // Length of screen text
cHt = HIWORD (dwExt); // Height of screen text
#endif
rc = bpButton[nI].rcExt = bpButton[nI].rcBtn; // Copy button size for later use
rc.right += rc.left; // Compute screen right bound
rc.bottom+= rc.top; // Compute screen lower bound
rc.left = (rc.left * nWndx) / 4; // Convert to MM_TEXT pixel count
rc.top = (rc.top * nWndy) / 8;
rc.right = (rc.right * nWndx) / 4;
rc.bottom = (rc.bottom * nWndy) / 8;
bpButton[nI].rcBtn = rc; // Save the computed sizes.
bpButton[nI].nTxtx = (rc.left+rc.right-cExt)/2; // Compute the text position
bpButton[nI].nTxty = (rc.top+rc.bottom-cHt)/2; // horizontal and vertical both.
}
rcMsg.top = YSIZ (164);
rcMsg.bottom = YSIZ (179);
rcMsg.left = XSIZ (8);
rcMsg.right = XSIZ (228);
ReleaseDC (hWnd, hdc); // Done here, release resources.
}
//*********************************************************************
//*********************************************************************
void CreateListRectPos (LPRECT rcLDir, int nX, int nY, int nExt, int nH)
{
rcLDir->left = nX;
rcLDir->top = nY;
rcLDir->right = nX+nExt-1;
rcLDir->bottom= nY+nH-1;
}
//*********************************************************************
//*********************************************************************
int GetChildWindowID (LPARAM lParam)
{
POINT pt;
BOOL bFlag = (pt.y > rcLLst.bottom);
pt.y = HIWORD (lParam);
pt.x = LOWORD (lParam);
if (PtInRect (&rcLFile, pt)) return LST_LFILES;
if (PtInRect (&rcRFile, pt)) return LST_RFILES;
if (PtInRect (&rcLDir, pt)) return LST_LDIRS;
if (PtInRect (&rcRDir, pt)) return LST_RDIRS;
if (PtInRect (&rcLLst, pt)) return LST_LDIRLST;
if (PtInRect (&rcRLst, pt)) return LST_RDIRLST;
if (PtInRect (&rcLEdt, pt)) return EDT_LFILETYPE;
if (PtInRect (&rcREdt, pt)) return EDT_RFILETYPE;
return 0;
}
//*********************************************************************
//*********************************************************************
int CreateSubWindows(HWND hParent,HWND hInst)
{
HFONT hFont = GetStockObject (ANSI_VAR_FONT);
int nX1, nX2, nY1, nY2, nH1, nH2, nExt;
CreateButtonPos (hParent); // Create the button screen positions.
nExt= XSIZ ( 28); // Editbox Extent
nX1 = XSIZ ( 81); // Local File Type position
nX2 = XSIZ (210); // Remote File Type position
nY1 = YSIZ ( 6); // EditBox Y position
nH1