aboutsummaryrefslogtreecommitdiff
path: root/win32/examples
diff options
context:
space:
mode:
authorbellard <bellard>2005-04-17 13:10:37 +0000
committerbellard <bellard>2005-04-17 13:10:37 +0000
commit5556cf15656ad1e433ec20502411411e30a4cdc7 (patch)
tree2105947a5bdaefd49ef9db9af5080498ef04ef42 /win32/examples
parent6144d433211b4c5ceb68d6ffa500d6d54c3a2d67 (diff)
downloadtinycc-5556cf15656ad1e433ec20502411411e30a4cdc7.tar.gz
tinycc-5556cf15656ad1e433ec20502411411e30a4cdc7.tar.bz2
dos2unix
Diffstat (limited to 'win32/examples')
-rw-r--r--win32/examples/dll.c30
-rw-r--r--win32/examples/dll.def12
-rw-r--r--win32/examples/hello_dll.c38
-rw-r--r--win32/examples/hello_win.c318
4 files changed, 199 insertions, 199 deletions
diff --git a/win32/examples/dll.c b/win32/examples/dll.c
index 0736459..4202e99 100644
--- a/win32/examples/dll.c
+++ b/win32/examples/dll.c
@@ -1,15 +1,15 @@
-//+---------------------------------------------------------------------------
-//
-// dll.c - Windows DLL example - dynamically linked part
-//
-
-#include <windows.h>
-
-#define DLL_EXPORT __declspec(dllexport)
-
-
-DLL_EXPORT void HelloWorld (void)
-{
- MessageBox (0, "Hello World!", "From DLL", MB_ICONINFORMATION);
-}
-
+//+---------------------------------------------------------------------------
+//
+// dll.c - Windows DLL example - dynamically linked part
+//
+
+#include <windows.h>
+
+#define DLL_EXPORT __declspec(dllexport)
+
+
+DLL_EXPORT void HelloWorld (void)
+{
+ MessageBox (0, "Hello World!", "From DLL", MB_ICONINFORMATION);
+}
+
diff --git a/win32/examples/dll.def b/win32/examples/dll.def
index 14d7349..a14d7f1 100644
--- a/win32/examples/dll.def
+++ b/win32/examples/dll.def
@@ -1,6 +1,6 @@
-; Windows DLL example - export definition for the DLL
-
-LIBRARY dll.dll
-
-EXPORTS
-HelloWorld
+; Windows DLL example - export definition for the DLL
+
+LIBRARY dll.dll
+
+EXPORTS
+HelloWorld
diff --git a/win32/examples/hello_dll.c b/win32/examples/hello_dll.c
index d739758..7adba77 100644
--- a/win32/examples/hello_dll.c
+++ b/win32/examples/hello_dll.c
@@ -1,19 +1,19 @@
-//+---------------------------------------------------------------------------
-//
-// HELLO_DLL.C - Windows DLL example - main application part
-//
-
-#include <windows.h>
-
-void HelloWorld (void);
-
-int WINAPI WinMain(
- HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
-{
- HelloWorld();
- return 0;
-}
-
+//+---------------------------------------------------------------------------
+//
+// HELLO_DLL.C - Windows DLL example - main application part
+//
+
+#include <windows.h>
+
+void HelloWorld (void);
+
+int WINAPI WinMain(
+ HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow)
+{
+ HelloWorld();
+ return 0;
+}
+
diff --git a/win32/examples/hello_win.c b/win32/examples/hello_win.c
index f4becb8..294b727 100644
--- a/win32/examples/hello_win.c
+++ b/win32/examples/hello_win.c
@@ -1,159 +1,159 @@
-//+---------------------------------------------------------------------------
-//
-// HELLO_WIN.C - Windows GUI 'Hello World!' Example
-//
-//+---------------------------------------------------------------------------
-
-#include <windows.h>
-
-#define APPNAME "HELLO_WIN"
-
-char szAppName[] = APPNAME; // The name of this application
-char szTitle[] = APPNAME; // The title bar text
-char *pWindowText;
-
-HINSTANCE g_hInst; // current instance
-
-void CenterWindow(HWND hWnd);
-
-//+---------------------------------------------------------------------------
-//
-// Function: WndProc
-//
-// Synopsis: very unusual type of function - gets called by system to
-// process windows messages.
-//
-// Arguments: same as always.
-//----------------------------------------------------------------------------
-
-LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch (message)
- {
- // ----------------------- first and last
- case WM_CREATE:
- CenterWindow(hwnd);
- break;
-
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
-
-
- // ----------------------- get out of it...
- case WM_RBUTTONUP:
- DestroyWindow(hwnd);
- break;
-
- case WM_KEYDOWN:
- if (VK_ESCAPE == wParam)
- DestroyWindow(hwnd);
- break;
-
-
- // ----------------------- display our minimal info
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hdc;
- RECT rc;
- hdc = BeginPaint(hwnd, &ps);
-
- GetClientRect(hwnd, &rc);
- SetTextColor(hdc, RGB(240,240,96));
- SetBkMode(hdc, TRANSPARENT);
- DrawText(hdc, pWindowText, -1, &rc, DT_CENTER|DT_SINGLELINE|DT_VCENTER);
-
- EndPaint(hwnd, &ps);
- break;
- }
-
- // ----------------------- let windows do all other stuff
- default:
- return DefWindowProc(hwnd, message, wParam, lParam);
- }
- return 0;
-}
-
-//+---------------------------------------------------------------------------
-//
-// Function: WinMain
-//
-// Synopsis: standard entrypoint for GUI Win32 apps
-//
-//----------------------------------------------------------------------------
-int APIENTRY WinMain(
- HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
-{
- MSG msg;
-
- WNDCLASS wc;
-
- HWND hwnd;
-
- // Fill in window class structure with parameters that describe
- // the main window.
-
- ZeroMemory(&wc, sizeof wc);
- wc.hInstance = hInstance;
- wc.lpszClassName = szAppName;
- wc.lpfnWndProc = (WNDPROC)WndProc;
- wc.style = CS_DBLCLKS|CS_VREDRAW|CS_HREDRAW;
- wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
-
- if (FALSE == RegisterClass(&wc)) return 0;
-
- // create the browser
- hwnd = CreateWindow(
- szAppName,
- szTitle,
- WS_OVERLAPPEDWINDOW|WS_VISIBLE,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 360,//CW_USEDEFAULT,
- 240,//CW_USEDEFAULT,
- 0,
- 0,
- g_hInst,
- 0);
-
- if (NULL == hwnd) return 0;
-
- pWindowText = lpCmdLine[0] ? lpCmdLine : "Hello Windows!";
-
- // Main message loop:
- while (GetMessage(&msg, NULL, 0, 0) > 0)
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-
- return msg.wParam;
-}
-
-//+---------------------------------------------------------------------------
-
-//+---------------------------------------------------------------------------
-
-void CenterWindow(HWND hwnd_self)
-{
- RECT rw_self, rc_parent, rw_parent; HWND hwnd_parent;
- hwnd_parent = GetParent(hwnd_self);
- if (NULL==hwnd_parent) hwnd_parent = GetDesktopWindow();
- GetWindowRect(hwnd_parent, &rw_parent);
- GetClientRect(hwnd_parent, &rc_parent);
- GetWindowRect(hwnd_self, &rw_self);
- SetWindowPos(hwnd_self, NULL,
- rw_parent.left + (rc_parent.right + rw_self.left - rw_self.right) / 2,
- rw_parent.top + (rc_parent.bottom + rw_self.top - rw_self.bottom) / 2,
- 0, 0,
- SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE
- );
-}
-
-//+---------------------------------------------------------------------------
+//+---------------------------------------------------------------------------
+//
+// HELLO_WIN.C - Windows GUI 'Hello World!' Example
+//
+//+---------------------------------------------------------------------------
+
+#include <windows.h>
+
+#define APPNAME "HELLO_WIN"
+
+char szAppName[] = APPNAME; // The name of this application
+char szTitle[] = APPNAME; // The title bar text
+char *pWindowText;
+
+HINSTANCE g_hInst; // current instance
+
+void CenterWindow(HWND hWnd);
+
+//+---------------------------------------------------------------------------
+//
+// Function: WndProc
+//
+// Synopsis: very unusual type of function - gets called by system to
+// process windows messages.
+//
+// Arguments: same as always.
+//----------------------------------------------------------------------------
+
+LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ // ----------------------- first and last
+ case WM_CREATE:
+ CenterWindow(hwnd);
+ break;
+
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+
+
+ // ----------------------- get out of it...
+ case WM_RBUTTONUP:
+ DestroyWindow(hwnd);
+ break;
+
+ case WM_KEYDOWN:
+ if (VK_ESCAPE == wParam)
+ DestroyWindow(hwnd);
+ break;
+
+
+ // ----------------------- display our minimal info
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ HDC hdc;
+ RECT rc;
+ hdc = BeginPaint(hwnd, &ps);
+
+ GetClientRect(hwnd, &rc);
+ SetTextColor(hdc, RGB(240,240,96));
+ SetBkMode(hdc, TRANSPARENT);
+ DrawText(hdc, pWindowText, -1, &rc, DT_CENTER|DT_SINGLELINE|DT_VCENTER);
+
+ EndPaint(hwnd, &ps);
+ break;
+ }
+
+ // ----------------------- let windows do all other stuff
+ default:
+ return DefWindowProc(hwnd, message, wParam, lParam);
+ }
+ return 0;
+}
+
+//+---------------------------------------------------------------------------
+//
+// Function: WinMain
+//
+// Synopsis: standard entrypoint for GUI Win32 apps
+//
+//----------------------------------------------------------------------------
+int APIENTRY WinMain(
+ HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow)
+{
+ MSG msg;
+
+ WNDCLASS wc;
+
+ HWND hwnd;
+
+ // Fill in window class structure with parameters that describe
+ // the main window.
+
+ ZeroMemory(&wc, sizeof wc);
+ wc.hInstance = hInstance;
+ wc.lpszClassName = szAppName;
+ wc.lpfnWndProc = (WNDPROC)WndProc;
+ wc.style = CS_DBLCLKS|CS_VREDRAW|CS_HREDRAW;
+ wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
+ wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+
+ if (FALSE == RegisterClass(&wc)) return 0;
+
+ // create the browser
+ hwnd = CreateWindow(
+ szAppName,
+ szTitle,
+ WS_OVERLAPPEDWINDOW|WS_VISIBLE,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ 360,//CW_USEDEFAULT,
+ 240,//CW_USEDEFAULT,
+ 0,
+ 0,
+ g_hInst,
+ 0);
+
+ if (NULL == hwnd) return 0;
+
+ pWindowText = lpCmdLine[0] ? lpCmdLine : "Hello Windows!";
+
+ // Main message loop:
+ while (GetMessage(&msg, NULL, 0, 0) > 0)
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ return msg.wParam;
+}
+
+//+---------------------------------------------------------------------------
+
+//+---------------------------------------------------------------------------
+
+void CenterWindow(HWND hwnd_self)
+{
+ RECT rw_self, rc_parent, rw_parent; HWND hwnd_parent;
+ hwnd_parent = GetParent(hwnd_self);
+ if (NULL==hwnd_parent) hwnd_parent = GetDesktopWindow();
+ GetWindowRect(hwnd_parent, &rw_parent);
+ GetClientRect(hwnd_parent, &rc_parent);
+ GetWindowRect(hwnd_self, &rw_self);
+ SetWindowPos(hwnd_self, NULL,
+ rw_parent.left + (rc_parent.right + rw_self.left - rw_self.right) / 2,
+ rw_parent.top + (rc_parent.bottom + rw_self.top - rw_self.bottom) / 2,
+ 0, 0,
+ SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE
+ );
+}
+
+//+---------------------------------------------------------------------------