home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 2000 February
/
VPR0002A.BIN
/
VPR_DATA
/
PROGRAM
/
CW
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-11-29
|
4KB
|
145 lines
/******************************************************************************
Module name: Clock.c
Written by: Jeffrey Richter
Notices: Copyright (c) 1995 Jeffrey Richter
Purpose: Demonstrates using a dialog box for an application's main window.
******************************************************************************/
//#define _X86_
#include "Win95ADG.h" /* See Appendix A for details */
#include <windows.h>
#include <windowsx.h>
#include <shellapi.h>
#pragma warning(disable: 4001) /* Single line comment */
#include "resource.h"
#include <commdlg.h>
#include <string.h>
#include <stdio.h>
#define MAXSIZE 250000
FILE *fp;
char buf[MAXSIZE];
char buf_2[MAXSIZE];
void MakeHTML (HWND hwnd) {
HANDLE hFile;
int i;
hFile = CreateFile( "index.html", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if (hFile != INVALID_HANDLE_VALUE )
{
DWORD dwActBytes;
ReadFile( hFile, buf, GetFileSize(hFile, NULL) - 14,
&dwActBytes, NULL );
WriteFile(hFile ,"<P><B>",6 , &dwActBytes, NULL );
GetDlgItemText(hwnd, IDC_EDIT1, buf_2, MAXSIZE);
WriteFile(hFile ,buf_2, strlen(buf_2), &dwActBytes, NULL );
WriteFile(hFile ,"</B><BR>",8 , &dwActBytes, NULL );
GetDlgItemText(hwnd, IDC_EDIT2, buf_2, MAXSIZE);
for (i=0; i<strlen(buf_2); i++) {
if (buf_2[i]=='\r') {
WriteFile(hFile ,"<BR>", 4, &dwActBytes, NULL );
i++;
} else {
WriteFile(hFile ,&buf_2[i], 1, &dwActBytes, NULL );
}
}
WriteFile(hFile ,"<BR></P>",8 , &dwActBytes, NULL );
WriteFile(hFile ,"<BR></BODY></HTML>",18 , &dwActBytes, NULL );
CloseHandle(hFile);
ShellExecute(hwnd, "open", "index.html",
NULL, NULL, SW_SHOWNORMAL);
}else{
MessageBox( hwnd, "開発中です。","おっと!",
MB_OK | MB_ICONINFORMATION );
}
}
////////////////ドロップされたファイルを処理////////////////////////
VOID Get_Drop_File(HWND hwnd , HDROP hDrop) {
int intFN_Long;
char fn[256];
//ドロップされたファイル情報からファイル名を取得
intFN_Long = DragQueryFile(hDrop,0,fn,256);
DragFinish(hDrop);
fn[intFN_Long] = '\0'; //変数に終端文字を付ける。
SetDlgItemText(hwnd, IDC_EDIT3, fn);
}
////////////// 99/11/28 ///////////////
///////////////////////////////////////////////////////////////////////////////
BOOL WINAPI Main_DlgProc (HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam) {
HDROP hDrop = NULL;
switch (uMsg) {
//****この画面が表示されたときの処理 99/11/28 ***
case WM_INITDIALOG:
DragAcceptFiles( hwnd, TRUE);
// DragAcceptFiles( GetDlgItem(hwnd,IDC_EDIT2), TRUE);
break;
//********************* 99/11/28 *************
//*****ファイルドロップを感知する************
case WM_DROPFILES:
hDrop = (HANDLE)wParam;
Get_Drop_File(hwnd, (HANDLE)wParam);
return 0;
//********************* 99/11/28 *************
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_BUTTON1:
MakeHTML(hwnd);
return 1;
case IDC_BUTTON2:
MessageBox( hwnd, "開発中です。\n","おっと!",
MB_OK | MB_ICONINFORMATION );
return 1;
/*以下の3つのボタン(メニュー)は、
すべてEndDialog(hwnd, 0)で処理する。*/
case IDC_BUTTON3:
case ID_Quit:
case IDCANCEL:
EndDialog(hwnd, 0);
return 1;
}
}
return(FALSE); // We didn't process the message.
}
///////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain (HINSTANCE hinstExe, HINSTANCE hinstPrev,
LPSTR lpszCmdLine, int nCmdShow) {
//HANDLE hwnd;
adgWARNIFUNICODEUNDERWIN95();
adgVERIFY(-1 != DialogBox(hinstExe, MAKEINTRESOURCE(IDD_HomePager),
NULL, Main_DlgProc));
// DragAcceptFiles( GetDlgItem(NULL,IDD_HomePager), TRUE);
return(0);
}
//////////////////////////////// End of File //////////////////////////////////