#include "awswin.h"
#include
#include
#include
#include "bcwfind.h"
#include
#include "aws.ids"
#include "help.idh"
#define CM_ABOUT 101
#define CM_WORKSHOP SC_RESTORE
#define CM_HELP 103
void TAWSWindow::DoAFile(LPSTR filename) {
if(access(filename,0)!=0) {
char msg[256];
wsprintf(msg,"%s does not exist",filename);
MessageBox(HWindow,msg,NULL,MB_OK);
} else {
char command[256];
wsprintf(command,"workshop %s",filename);
if(WinExec(command,SW_SHOWMAXIMIZED)<32) {
char msg[256];
wsprintf(msg,"Could not execute:\n\'%s\'",command);
MessageBox(HWindow,msg,NULL,MB_OK);
}
}
}
void CombineNameAndLocation(const char *name, const char *location, char* buf) {
if(location[0]) {
lstrcpy(buf,location);
int i=lstrlen(location);
if(location[i-1]!='\\')
lstrcat(buf,"\\");
lstrcat(buf,name);
} else
lstrcpy(buf,name);
}
void TAWSWindow::AutoWorkshop() {
HWND hWndProject=GetBCWProjectWindow();
if(hWndProject) {
// find a .RC or a .RES file project item
BOOL Found=FALSE;
int ProjectItems=GetBCWProjectItems(hWndProject);
for(int i=0;iExecDialog(new TBLDialog(this,DIALOG_ABOUT));
break;
case CM_WORKSHOP:
AutoWorkshop();
break;
case CM_HELP:
WinHelp(HWindow,"autobcw.hlp",HELP_CONTEXT,IDH_AWS);
break;
default:
DefWndProc(Msg);
return;
}
Msg.Result=0;
}
void TAWSWindow::WMSize(RTMessage Msg) {
//refuse to change to any other state than minimized
if(Msg.WParam==SIZE_MAXIMIZED || Msg.WParam==SIZE_RESTORED)
Show(SW_MINIMIZE);
}
void TAWSWindow::WMDrop(RTMessage Msg) {
WORD cFiles=DragQueryFile((HDROP)Msg.WParam,0xFFFF,NULL,0);
if(cFiles!=1) {
MessageBox(HWindow,"Only one file accepted","auto-Implib: error",MB_OK);
} else {
char filename[128];
DragQueryFile((HDROP)Msg.WParam,0,(LPSTR)filename,128);
char drive[MAXDRIVE],
dir[MAXDIR],
name[MAXFILE],
ext[MAXEXT];
fnsplit(filename,drive,dir,name,ext);
if(lstrcmpi(ext,".RC")!=0 &&
lstrcmpi(ext,".RES")!=0 &&
lstrcmpi(ext,".BMP")!=0 &&
lstrcmpi(ext,".ICO")!=0 )
MessageBox(HWindow,"File must be a resource type file","auto-Workshop: error",MB_OK);
else {
DoAFile(filename);
}
}
DragFinish((HDROP)Msg.WParam);
Msg.Result=0;
}
void TAWSWindow::GetWindowClass(WNDCLASS& WndClass) {
inherited::GetWindowClass(WndClass);
WndClass.hIcon=LoadIcon(GetApplication()->hInstance,MAKEINTRESOURCE(ICON_AWS));
}
void TAWSWindow::SetupWindow() {
inherited::SetupWindow();
DragAcceptFiles(HWindow,TRUE);
HMENU hMenu=GetSystemMenu(HWindow,FALSE);
// delete some unused menu items in the system menu
DeleteMenu(hMenu,SC_RESTORE,MF_BYCOMMAND); // delete restore
DeleteMenu(hMenu,SC_SIZE,MF_BYCOMMAND); // delete size
DeleteMenu(hMenu,SC_MINIMIZE,MF_BYCOMMAND); // delete minimize (is always minimized)
DeleteMenu(hMenu,SC_MAXIMIZE,MF_BYCOMMAND); // delete maximized
AppendMenu(hMenu,MF_STRING,CM_ABOUT,"&About...");
InsertMenu(hMenu,0,MF_STRING|MF_BYPOSITION,CM_WORKSHOP,"Start &Workshop");
AppendMenu(hMenu,MF_STRING,CM_HELP,"&Help...");
}