home *** CD-ROM | disk | FTP | other *** search
/ Internet Publisher's Toolbox 2.0 / Internet Publisher's Toolbox.iso / html / rtf2html / wrtf2htm / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-21  |  3.6 KB  |  142 lines

  1. //*************************************************************
  2. //  File name: init.c
  3. //
  4. //  Description:
  5. //
  6. //      Routines which initialize the application and instance.
  7. //
  8. //  Development Team:
  9. //
  10. //      Mike Brehm
  11. //      Irfan Gowani
  12. //
  13. //  Written by Microsoft Product Support Services, Windows Developer Support
  14. //  Copyright (c) 1992 Microsoft Corporation. All rights reserved.
  15. //*************************************************************
  16.  
  17. #include "global.h"
  18.  
  19. //*************************************************************
  20. //
  21. //  InitApplication()
  22. //
  23. //  Purpose:
  24. //
  25. //        Initializes the application (window classes)
  26. //
  27. //
  28. //  Parameters:
  29. //
  30. //      HANDLE hInstance - Instance handle from WinMain.
  31. //      
  32. //
  33. //  Return: (BOOL)
  34. //
  35. //      TRUE  - Window class was initialized and registered.
  36. //      FALSE - Window class not initialized and registered.
  37. //
  38. //
  39. //  Comments:
  40. //
  41. //
  42. //  History:    Date       Author       Comment
  43. //              12/12/91   Mike Brehm   Created
  44. //
  45. //*************************************************************
  46.  
  47. BOOL InitApplication (HANDLE hInstance)
  48. {
  49.    WNDCLASS wc;    // Window class
  50.  
  51.    wc.style = CS_HREDRAW | CS_VREDRAW;;
  52.    wc.lpfnWndProc = (WNDPROC)MainWndProc;
  53.    wc.cbClsExtra = 0;
  54.    wc.cbWndExtra = 0;
  55.    wc.hInstance = hInstance;
  56.    wc.hIcon = LoadIcon(hInstance, "DRAGDROPICON");
  57.    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  58.    wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1); 
  59.    wc.lpszMenuName = szMainMenu;
  60.    wc.lpszClassName = szMainClass;
  61.  
  62.    if (!RegisterClass(&wc))
  63.       return (FALSE);
  64.  
  65.    return (TRUE);
  66. }                  /* InitApplication() */
  67.  
  68. //*************************************************************
  69. //
  70. //  InitInstance()
  71. //
  72. //  Purpose:
  73. //
  74. //        Initializes each instance (window creation)
  75. //    Registers main window for Drag Drop messages
  76. //
  77. //
  78. //  Parameters:
  79. //
  80. //      HANDLE hInstance - Instance handle of application.
  81. //      int    nCmdShow  - How window is initially displayed.
  82. //      
  83. //
  84. //  Return: (BOOL)
  85. //
  86. //      TRUE  - Window created and displayed.
  87. //      FALSE - Window not created.
  88. //
  89. //
  90. //  Comments:
  91. //
  92. //
  93. //  History:    Date       Author       Comment
  94. //              12/12/91   Mike Brehm   Created
  95. //
  96. //*************************************************************
  97.  
  98. BOOL InitInstance (HINSTANCE hInstance, int nCmdShow)
  99. {
  100.    RECT rect;      // Client area of main window
  101.  
  102.    //
  103.    // Save this instance and create our main window if we can.
  104.    //
  105.  
  106.    ghInst = hInstance;
  107.    ghWndMain = CreateWindow(szMainClass, "RFC to HTML Converter",
  108.                             WS_OVERLAPPEDWINDOW, 50, 50, 600, 250,
  109.                             NULL, NULL, hInstance, NULL);       // CreateWindowA
  110.  
  111.    if (!ghWndMain)
  112.       return (FALSE);
  113.  
  114.    //
  115.    // Create a list box the size of the main window if we can.
  116.    // The list box will be used to show the file names of the 
  117.    // dragged and dropped files.
  118.    GetClientRect(ghWndMain, &rect);
  119.  
  120.    ghListBox = CreateWindow("ListBox", NULL, WS_CHILD | WS_VSCROLL |
  121.                             LBS_NOINTEGRALHEIGHT | LBS_SORT | WS_VISIBLE,
  122.                             0, 0,
  123.                             rect.right - rect.left, rect.bottom - rect.top,
  124.                             ghWndMain, NULL, hInstance, NULL);
  125.  
  126.    if (!ghListBox)
  127.       return (FALSE);
  128.  
  129.    //
  130.    // Register the application's window for Drag/Drop messages.
  131.    //
  132.    DragAcceptFiles(ghWndMain, TRUE);
  133.  
  134.    ShowWindow(ghWndMain, nCmdShow);
  135.    UpdateWindow(ghWndMain);
  136.  
  137.    return (TRUE);
  138. }                  /* InitInstance() */
  139.  
  140.  
  141. /*** EOF: init.c ***/
  142.