home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2000 February / VPR0002A.BIN / VPR_DATA / PROGRAM / CW / main.c < prev    next >
C/C++ Source or Header  |  1999-11-29  |  4KB  |  145 lines

  1.                /******************************************************************************
  2. Module name: Clock.c
  3. Written by: Jeffrey Richter
  4. Notices: Copyright (c) 1995 Jeffrey Richter
  5. Purpose: Demonstrates using a dialog box for an application's main window.
  6. ******************************************************************************/
  7.  
  8. //#define _X86_
  9.  
  10. #include "Win95ADG.h"          /* See Appendix A for details */
  11. #include <windows.h>
  12. #include <windowsx.h>
  13. #include <shellapi.h>
  14.  
  15. #pragma warning(disable: 4001)    /* Single line comment */
  16. #include "resource.h"
  17.  
  18. #include <commdlg.h>
  19. #include <string.h>
  20. #include <stdio.h>
  21. #define MAXSIZE 250000
  22. FILE *fp;
  23. char buf[MAXSIZE];
  24. char buf_2[MAXSIZE];
  25.  
  26.  
  27.  
  28. void MakeHTML (HWND hwnd) {
  29.     HANDLE    hFile;
  30.     int i;
  31.     
  32.     hFile = CreateFile( "index.html", GENERIC_READ | GENERIC_WRITE,
  33.          FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
  34.     if (hFile != INVALID_HANDLE_VALUE )
  35.     {
  36.         DWORD dwActBytes;
  37.         ReadFile( hFile, buf, GetFileSize(hFile, NULL) - 14,
  38.              &dwActBytes, NULL );
  39.         WriteFile(hFile ,"<P><B>",6 , &dwActBytes, NULL );
  40.         GetDlgItemText(hwnd, IDC_EDIT1, buf_2, MAXSIZE);
  41.         WriteFile(hFile ,buf_2, strlen(buf_2), &dwActBytes, NULL );
  42.         WriteFile(hFile ,"</B><BR>",8 , &dwActBytes, NULL );
  43.  
  44.         GetDlgItemText(hwnd, IDC_EDIT2, buf_2, MAXSIZE);
  45.         for (i=0; i<strlen(buf_2); i++) {
  46.             if (buf_2[i]=='\r') {
  47.                 WriteFile(hFile ,"<BR>", 4, &dwActBytes, NULL );
  48.                 i++;
  49.             } else {
  50.                 WriteFile(hFile ,&buf_2[i], 1, &dwActBytes, NULL );
  51.             }
  52.         }
  53.         WriteFile(hFile ,"<BR></P>",8 , &dwActBytes, NULL );
  54.         WriteFile(hFile ,"<BR></BODY></HTML>",18 , &dwActBytes, NULL );
  55.         CloseHandle(hFile);
  56.         ShellExecute(hwnd, "open", "index.html",
  57.             NULL, NULL, SW_SHOWNORMAL);
  58.     }else{
  59.          MessageBox( hwnd, "開発中です。","おっと!",
  60.             MB_OK | MB_ICONINFORMATION );
  61.     }
  62. }
  63.  
  64.  
  65. ////////////////ドロップされたファイルを処理////////////////////////
  66. VOID Get_Drop_File(HWND hwnd , HDROP hDrop) {
  67.     int intFN_Long;
  68.     char fn[256];
  69.     
  70.     //ドロップされたファイル情報からファイル名を取得
  71.     intFN_Long = DragQueryFile(hDrop,0,fn,256);
  72.     DragFinish(hDrop);
  73.     fn[intFN_Long] = '\0'; //変数に終端文字を付ける。
  74.     
  75.     SetDlgItemText(hwnd, IDC_EDIT3, fn);
  76. }
  77. //////////////  99/11/28  ///////////////
  78.  
  79.  
  80. ///////////////////////////////////////////////////////////////////////////////
  81. BOOL WINAPI Main_DlgProc (HWND hwnd, UINT uMsg, 
  82.    WPARAM wParam, LPARAM lParam) {
  83.     
  84.     HDROP hDrop = NULL;
  85.     
  86.     switch (uMsg) {
  87.     
  88. //****この画面が表示されたときの処理 99/11/28 ***
  89.     case WM_INITDIALOG:
  90.         DragAcceptFiles( hwnd, TRUE);
  91. //        DragAcceptFiles( GetDlgItem(hwnd,IDC_EDIT2), TRUE);
  92.         break;        
  93. //*********************  99/11/28  *************
  94.  
  95. //*****ファイルドロップを感知する************
  96.     case WM_DROPFILES:
  97.         hDrop = (HANDLE)wParam;
  98.         Get_Drop_File(hwnd, (HANDLE)wParam);
  99.         return 0;        
  100. //*********************  99/11/28  *************
  101.  
  102.  
  103.     case WM_COMMAND:
  104.         switch(LOWORD(wParam))  {
  105.         case IDC_BUTTON1:
  106.             MakeHTML(hwnd);
  107.             return 1;
  108.             
  109.         case IDC_BUTTON2:
  110.             MessageBox( hwnd, "開発中です。\n","おっと!",
  111.                 MB_OK | MB_ICONINFORMATION );
  112.             return 1;
  113.  
  114. /*以下の3つのボタン(メニュー)は、
  115.     すべてEndDialog(hwnd, 0)で処理する。*/
  116.         case IDC_BUTTON3:
  117.         case ID_Quit:
  118.         case IDCANCEL:
  119.             EndDialog(hwnd, 0);
  120.               return 1;
  121.         }  
  122.     }
  123.     return(FALSE);                 // We didn't process the message.
  124. }
  125.  
  126.  
  127. ///////////////////////////////////////////////////////////////////////////////
  128.  
  129.  
  130. int WINAPI WinMain (HINSTANCE hinstExe, HINSTANCE hinstPrev, 
  131.    LPSTR lpszCmdLine, int nCmdShow) {
  132.  
  133.     //HANDLE hwnd;
  134.     
  135.    adgWARNIFUNICODEUNDERWIN95();
  136.    adgVERIFY(-1 != DialogBox(hinstExe, MAKEINTRESOURCE(IDD_HomePager),
  137.       NULL, Main_DlgProc));
  138. //    DragAcceptFiles( GetDlgItem(NULL,IDD_HomePager), TRUE);
  139.  
  140.    return(0);
  141. }
  142.  
  143.  
  144. //////////////////////////////// End of File //////////////////////////////////
  145.