]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.excel/native/SimanticsExcel2008/SimanticsExcel2008/SimanticsExcel2008.cpp
(refs #7362) Creation of new SCL modules in SCL module browser
[simantics/platform.git] / bundles / org.simantics.excel / native / SimanticsExcel2008 / SimanticsExcel2008 / SimanticsExcel2008.cpp
1 // SimanticsExcel2008.cpp : Defines the entry point for the application.
2 //
3
4 #include "stdafx.h"
5 #include "SimanticsExcel2008.h"
6
7 #define MAX_LOADSTRING 100
8
9 // Global Variables:
10 HINSTANCE hInst;                                                                // current instance
11 TCHAR szTitle[MAX_LOADSTRING];                                  // The title bar text
12 TCHAR szWindowClass[MAX_LOADSTRING];                    // the main window class name
13
14 // Forward declarations of functions included in this code module:
15 ATOM                            MyRegisterClass(HINSTANCE hInstance);
16 BOOL                            InitInstance(HINSTANCE, int);
17 LRESULT CALLBACK        WndProc(HWND, UINT, WPARAM, LPARAM);
18 INT_PTR CALLBACK        About(HWND, UINT, WPARAM, LPARAM);
19
20 int APIENTRY _tWinMain(HINSTANCE hInstance,
21                      HINSTANCE hPrevInstance,
22                      LPTSTR    lpCmdLine,
23                      int       nCmdShow)
24 {
25         UNREFERENCED_PARAMETER(hPrevInstance);
26         UNREFERENCED_PARAMETER(lpCmdLine);
27
28         // TODO: Place code here.
29         MSG msg;
30         HACCEL hAccelTable;
31
32         // Initialize global strings
33         LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
34         LoadString(hInstance, IDC_SIMANTICSEXCEL2008, szWindowClass, MAX_LOADSTRING);
35         MyRegisterClass(hInstance);
36
37         // Perform application initialization:
38         if (!InitInstance (hInstance, nCmdShow))
39         {
40                 return FALSE;
41         }
42
43         hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SIMANTICSEXCEL2008));
44
45         // Main message loop:
46         while (GetMessage(&msg, NULL, 0, 0))
47         {
48                 if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
49                 {
50                         TranslateMessage(&msg);
51                         DispatchMessage(&msg);
52                 }
53         }
54
55         return (int) msg.wParam;
56 }
57
58
59
60 //
61 //  FUNCTION: MyRegisterClass()
62 //
63 //  PURPOSE: Registers the window class.
64 //
65 //  COMMENTS:
66 //
67 //    This function and its usage are only necessary if you want this code
68 //    to be compatible with Win32 systems prior to the 'RegisterClassEx'
69 //    function that was added to Windows 95. It is important to call this function
70 //    so that the application will get 'well formed' small icons associated
71 //    with it.
72 //
73 ATOM MyRegisterClass(HINSTANCE hInstance)
74 {
75         WNDCLASSEX wcex;
76
77         wcex.cbSize = sizeof(WNDCLASSEX);
78
79         wcex.style                      = CS_HREDRAW | CS_VREDRAW;
80         wcex.lpfnWndProc        = WndProc;
81         wcex.cbClsExtra         = 0;
82         wcex.cbWndExtra         = 0;
83         wcex.hInstance          = hInstance;
84         wcex.hIcon                      = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SIMANTICSEXCEL2008));
85         wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);
86         wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW+1);
87         wcex.lpszMenuName       = MAKEINTRESOURCE(IDC_SIMANTICSEXCEL2008);
88         wcex.lpszClassName      = szWindowClass;
89         wcex.hIconSm            = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
90
91         return RegisterClassEx(&wcex);
92 }
93
94 //
95 //   FUNCTION: InitInstance(HINSTANCE, int)
96 //
97 //   PURPOSE: Saves instance handle and creates main window
98 //
99 //   COMMENTS:
100 //
101 //        In this function, we save the instance handle in a global variable and
102 //        create and display the main program window.
103 //
104 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
105 {
106    HWND hWnd;
107
108    hInst = hInstance; // Store instance handle in our global variable
109
110    hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
111       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
112
113    if (!hWnd)
114    {
115       return FALSE;
116    }
117
118    ShowWindow(hWnd, nCmdShow);
119    UpdateWindow(hWnd);
120
121    return TRUE;
122 }
123
124 //
125 //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
126 //
127 //  PURPOSE:  Processes messages for the main window.
128 //
129 //  WM_COMMAND  - process the application menu
130 //  WM_PAINT    - Paint the main window
131 //  WM_DESTROY  - post a quit message and return
132 //
133 //
134 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
135 {
136         int wmId, wmEvent;
137         PAINTSTRUCT ps;
138         HDC hdc;
139
140         switch (message)
141         {
142         case WM_COMMAND:
143                 wmId    = LOWORD(wParam);
144                 wmEvent = HIWORD(wParam);
145                 // Parse the menu selections:
146                 switch (wmId)
147                 {
148                 case IDM_ABOUT:
149                         DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
150                         break;
151                 case IDM_EXIT:
152                         DestroyWindow(hWnd);
153                         break;
154                 default:
155                         return DefWindowProc(hWnd, message, wParam, lParam);
156                 }
157                 break;
158         case WM_PAINT:
159                 hdc = BeginPaint(hWnd, &ps);
160                 // TODO: Add any drawing code here...
161                 EndPaint(hWnd, &ps);
162                 break;
163         case WM_DESTROY:
164                 PostQuitMessage(0);
165                 break;
166         default:
167                 return DefWindowProc(hWnd, message, wParam, lParam);
168         }
169         return 0;
170 }
171
172 // Message handler for about box.
173 INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
174 {
175         UNREFERENCED_PARAMETER(lParam);
176         switch (message)
177         {
178         case WM_INITDIALOG:
179                 return (INT_PTR)TRUE;
180
181         case WM_COMMAND:
182                 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
183                 {
184                         EndDialog(hDlg, LOWORD(wParam));
185                         return (INT_PTR)TRUE;
186                 }
187                 break;
188         }
189         return (INT_PTR)FALSE;
190 }