home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 2001 January
/
VPR0101A.BIN
/
OLS
/
TAR32053
/
tar32053.exe
/
SRC
/
DFLTWIN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1999-05-23
|
6KB
|
209 lines
/*
DfltWin.c
Tar32.DLLがデフォルトで用意する窓
*/
/*#include <process.h> for _beginthread() */
#include "dfltwin.h"
#include "dllmain.h"
#include "resource.h"
#include "defconf.h"
#include "tar32.h"
#include "tarmsg.h"
#include <windows.h>
#include <winbase.h>
extern HWND api_hwnd;
static volatile HWND dialog_hwnd;
static volatile int button_cancel;
static volatile HANDLE thread;
static DWORD thread_id;
static volatile int CreateDialog_flag;
static BOOL CALLBACK archiver_proc(HWND _hwnd,UINT _uMsg,UINT _nState,EXTRACTINGINFOEX *_pInfo)
{
return 1;
}
static BOOL CALLBACK dialog_func(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
/*if(dialog_hwnd!=hwnd){
return DefWindowProc(hwnd,message,wParam,lParam);
}*/
switch(message){
/*case WM_PAINT:
return DefWindowProc(hwnd,message,wParam,lParam);
*/
case WM_COMMAND:
switch(LOWORD(wParam)){
case IDCANCEL:
button_cancel=1;
return 1;
break;
}
return 0;
break;
case WM_INITDIALOG:
//MessageBox(NULL,"init dialog","tar32.dll",0);
button_cancel=0;
dialog_hwnd = hwnd;
CreateDialog_flag=1;
return 1;
break;
case WM_DESTROY:
//MessageBox(api_hwnd,"PostQuit(pre)","tar32.dll debug",0);
//PostQuitMessage(0);
//DestroyWindow(hwnd);
//EndDialog(hwnd,0);
return 0;
//MessageBox(api_hwnd,"PostQuit(post)","tar32.dll debug",0);
break;
default:
/* WM_ARCEXTRACT_UINTは定数でないので case部に書けない。。*/
if(message == WM_ARCEXTRACT_UINT){
int nMode=(int)wParam;
EXTRACTINGINFOEX *pInfo = (EXTRACTINGINFOEX *)lParam;
char textstr[100];
switch(nMode){
case ARCEXTRACT_BEGIN:/* それぞれの書庫内ファイルの処理開始 */
case ARCEXTRACT_INPROCESS:/* それぞれの書庫内ファイルを展開中 */
SetDlgItemText(hwnd,IDC_EDIT_FILENAME,pInfo->exinfo.szSourceFileName);
sprintf(textstr,"%8d / %8d",pInfo->exinfo.dwWriteSize,pInfo->exinfo.dwFileSize);
SetDlgItemText(hwnd,IDC_EDIT_SIZE,textstr);
if(button_cancel){
if(MessageBox(NULL,"TAR32.DLLを中断しますか?\n"
"(注:中断するとその後の動作が不安定になる場合があります)","TAR32.DLL",MB_OKCANCEL) == IDOK){
ReplyMessage(1);
return 0;
}else{
button_cancel=0;
}
}
//MessageBox(hwnd,"aaaa","tar32.dll",0);
break;
case ARCEXTRACT_END:/*処理終了*/
EndDialog(hwnd,0);
/*DestroyWindow(hwnd);
PostQuitMessage(0);*/
//PostQuitMessage(0);
/*MessageBox(api_hwnd,"ARCEXTRACT_END(pre)","tar32.dll debug",0);
PostMessage(hwnd,WM_DESTROY,0,0);
MessageBox(api_hwnd,"ARCEXTRACT_END(post)","tar32.dll debug",0);
break;*/
break;
case ARCEXTRACT_OPEN:/* 処理開始 */
break;
case ARCEXTRACT_COPY:/*ワークファイルの書き戻し*/
break;
}
return 1;
}else{
/* 真のデフォルト処理 */
//return DefWindowProc(hwnd,message,wParam,lParam);
return 0;
}
break;
}
return 1;
}
static DWORD WINAPI thread_func(LPVOID param)
{
button_cancel=0;
if (DialogBox(application_instance,
MAKEINTRESOURCE(IDD_DIALOG_EXECUTING),
NULL,dialog_func) == -1){
MessageBox(NULL,"CreateDialog Failed!","TAR32.DLL",MB_ICONWARNING);
}
return 0;
#if 0
MSG msg;
/*
MessageBox(NULL,"Start DialogBox","TAR32",0);
DialogBox(application_instance,MAKEINTRESOURCE(IDD_DIALOG_EXECUTING),api_hwnd,(DLGPROC)dialog_func);
MessageBox(NULL,"End DialogBox","TAR32",0);
*/
button_cancel=0;
//dialog_hwnd = CreateDialog(application_instance,MAKEINTRESOURCE(IDD_DIALOG_EXECUTING),api_hwnd,(DLGPROC)dialog_func);
//dialog_hwnd = CreateDialog(NULL,MAKEINTRESOURCE(IDD_DIALOG_EXECUTING),api_hwnd,(DLGPROC)dialog_func);
dialog_hwnd = CreateDialog(application_instance,MAKEINTRESOURCE(IDD_DIALOG_EXECUTING),NULL,dialog_func);
/* api_hwndを指定するとうまくいかない。。何故。。*/
//dialog_hwnd = CreateDialog(application_instance,MAKEINTRESOURCE(IDD_DIALOG_EXECUTING),api_hwnd,(DLGPROC)dialog_func);
//CreateDialog_flag=1;
if(dialog_hwnd==NULL){
MessageBox(NULL,"CreateDialog Failed!","TAR32.DLL",MB_ICONWARNING);
return 0;
}
ShowWindow(dialog_hwnd,SW_SHOW);
UpdateWindow(dialog_hwnd);
/*ShowWindow(api_hwnd,SW_SHOW);
UpdateWindow(api_hwnd);*/
while(GetMessage(&msg,dialog_hwnd,0,0)){
//while(GetMessage(&msg,NULL,0,0)){
//if(!IsDialogMessage(dialog_hwnd,&msg)){
TranslateMessage(&msg);
DispatchMessage(&msg);
//}
}
//MessageBox(api_hwnd,"thread_func exitting...","tar32.dll debug",0);
#endif
return 0;
}
/* TAR32.DLLデフォルトウインドウ(ダイアログ)の作成 */
/* 作成したウインドウのハンドルを返す */
int DefaultWindowInit(HWND *_pHwnd,ARCHIVERPROC **_pProc)
{
//MessageBox(NULL,"Start DialogBox","TAR32",0);
CreateDialog_flag=0;
/* CreateThreadでは標準Cランタイムライブラリ(memcpyなど)が使えないらしい。*/
//thread = CreateThread(NULL,0,thread_func,NULL,0,&thread_id);
thread = _beginthread(thread_func,0,NULL);
//thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)thread_func,NULL,0,&thread_id);
//SetThreadPriority(thread,THREAD_PRIORITY_HIGHEST);
//MessageBox(api_hwnd,"Post CreateThread","",0);
if(thread == NULL || thread == -1){
MessageBox(NULL,"Dialog thread execute failed!","TAR32.DLL",MB_ICONWARNING);
}
while(CreateDialog_flag==0){
Sleep(100);
}
*_pHwnd=dialog_hwnd;
*_pProc=archiver_proc;
//return dialog_hwnd;
return 0;
}
/* デフォルトウインドウが閉じるのを待つ */
void WaitDefaultWindowEnd(void)
{
/*
DWORD exitcode;
while(GetExitCodeThread(thread,&exitcode)!=0 && exitcode==STILL_ACTIVE){
Sleep(100);
}
*/
/*HANDLE hthisthread;
hthisthread = GetCurrentThread();
SetThreadPriority(hthisthread,THREAD_PRIORITY_LOWEST);
while(WaitForSingleObject(thread, 100)==WAIT_TIMEOUT){
;
}*/
WaitForSingleObject(thread, INFINITE);
}