home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************
-
- Scraper.c
-
- Tests the Scraper control
-
- ****************************************************************/
- #define STRICT
- #include <windows.h>
- #include <stdlib.h>
- #include "Scraper.h"
- #include "test.h"
-
- //These are globals for convenience only.
- HINSTANCE hInstMain;
- HWND hWndScraper;
- HWND hWndConfig;
- HWND hWndScrape;
- HWND hWndData;
-
- /***************************************************************
-
- Main Window Procedure
-
- ****************************************************************/
- int PASCAL WinMain (HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpszCmdLine,
- int nCmdShow)
- {
- WNDCLASS wc;
- HWND hWnd;
- MSG msg;
-
- if (!hPrevInstance)
- {
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = testWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(hInstance, "testIcon");
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- wc.lpszMenuName = "testMenu";
- wc.lpszClassName = "Scrapertest";
-
-
- if (!RegisterClass(&wc))
- return FALSE;
- }
-
- hInstMain=hInstance;
-
- //Create and show main window.
- hWnd=CreateWindow("Scrapertest", "Scraper Test",
- WS_MINIMIZEBOX | WS_OVERLAPPEDWINDOW,
- 35, 35, 350, 340,
- NULL, NULL, hInstance, NULL);
-
- ShowWindow(hWnd, nCmdShow);
- UpdateWindow(hWnd);
-
- // Force the dll to load
- registerScraper();
-
- // Create a scraper control
- hWndScraper=CreateWindow("Scraper", "Scraper1",
- WS_CHILD | WS_VISIBLE,
- 35, 35, 350, 340,
- hWnd, NULL, hInstance, NULL);
-
- // Set the scraper ID
- SendMessage(hWndScraper,SCM_SETSCRAPEID,0,(LPARAM)(LPSTR)"scrape1");
-
- // Create a button to do the "configure" command
- hWndConfig=CreateWindow("Button", "Configure",
- WS_CHILD | WS_VISIBLE,
- 80, 33, 76, 22,
- hWnd, (HMENU)IDC_CONFIGURE, hInstance, NULL);
-
- // Create a button to do the "Scrape" command
- hWndScrape=CreateWindow("Button", "Scrape",
- WS_CHILD | WS_VISIBLE,
- 80, 60, 76, 22,
- hWnd, (HMENU)IDC_SCRAPE, hInstance, NULL);
-
- // Create a label for the scraped data
- CreateWindow("Static", "Scraped Data:",
- WS_CHILD | WS_VISIBLE,
- 35, 110, 120, 16,
- hWnd, (HMENU)-1, hInstance, NULL);
-
- // Create a window for the scraped data
- hWndData=CreateWindow("Static", "",
- WS_CHILD | WS_VISIBLE,
- 35, 130, 200, 100,
- hWnd, (HMENU)IDC_DATA, hInstance, NULL);
-
-
- // Create frame
- CreateWindow("Static", "",
- WS_CHILD|SS_BLACKFRAME|WS_VISIBLE,
- 34, 129, 202, 102,
- hWnd, (HMENU)-1, hInstance, NULL);
-
-
-
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-
- return msg.wParam;
- }
-
-
-
- /*
- * testWndProc
- *
- * Purpose:
- * Window class procedure. Standard callback.
- *
- */
- long FAR PASCAL testWndProc(HWND hWnd, UINT iMessage,
- WPARAM wParam, LPARAM lParam)
- {
- LRESULT lResult;
- char buf[500];
- int nLen;
-
-
- switch (iMessage)
- {
- case WM_CREATE:
- break;
-
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
-
- case WM_COMMAND:
- switch (wParam)
- {
- case IDC_CONFIGURE:
- SendMessage(hWndScraper,SCM_SETCOMMAND,SCC_CONFIGURE,0L);
- break;
-
- case IDC_SCRAPE:
- lResult=SendMessage(hWndScraper,SCM_SETCOMMAND,SCC_SCRAPE,0L);
- switch (lResult)
- {
- case ERR_TASKNOTFOUND:
- MessageBox(hWnd,"Task Not Running","Scraper Test",MB_OK);
- break;
-
- case ERR_WINDOWNOTFOUND:
- MessageBox(hWnd,"Window not found","Scraper Test",MB_OK);
- break;
-
- case ERR_INVALIDACTION:
- MessageBox(hWnd,"Invalid Action Specified","Scraper Test",MB_OK);
- break;
-
- case ERR_NODATA:
- MessageBox(hWnd,"No Data to Scrape","Scraper Test",MB_OK);
- break;
-
- case ERR_INVALIDLPARAM:
- MessageBox(hWnd,"Invalid Parameter Sent","Scraper Test",MB_OK);
- break;
-
- case 0:
-
- // Successful scrape - get the data
- nLen=(int)SendMessage(hWndScraper,SCM_GETDATA,sizeof(buf),(LPARAM)(LPSTR)&buf);
-
- //Display the data
- SetDlgItemText(hWnd,IDC_DATA,buf);
- break;
-
- default:
- // Unknown error
- break;
- }
- break;
-
- case IDM_EXIT:
- PostMessage(hWnd, WM_CLOSE, 0, 0L);
- break;
- }
- break;
-
- default:
- return (DefWindowProc(hWnd, iMessage, wParam, lParam));
- }
-
- return 0L;
- }
-
-