|
// Graph_dll.cpp : Defines the entry point for the DLL application.
//
#include "graph.h"
/************************************************************************
Callback functionality which will handle the message which were posted by
the user
************************************************************************/
LRESULT CALLBACK CustGraphWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
RECT rect;
switch (uMsg)
{
case WM_USER_GRAPH:
{
User_Data = (struct lp *) lParam;
hdc = GetDC(hWnd);
GetClientRect(hWnd, &rect);
DrawGraph(hdc, rect);
UpdateGraph(hdc, rect, User_Data->RxValue, User_Data->TxValue, User_Data->GraphNo);
return 1;
}
case WM_USER_PROCESS_BAR:
{
hdc = GetDC(hWnd);
GetClientRect(hWnd, &rect);
DrawBar(hdc, rect, (int) lParam);
return 1;
}
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
void InitCustGraph()
{
WNDCLASSEX wc;
ATOM atom;
HBRUSH hNewBrush;
LOGBRUSH lbrush;
// If our window class is already registered then there's no need to register it again:
if(GetClassInfoEx(NULL, CUST_GRAPH_CLASS_NAME, &wc))
return;
/* Specifies the number of extra bytes to allocate following
the window-class structure. The system initializes the bytes
to zero. We won't use this in our demo app, so set it to zero. */
wc.cbClsExtra = 0;
/* Specifies the size, in bytes, of this structure. Set this
member to sizeof(WNDCLASSEX). */
wc.cbSize = sizeof(WNDCLASSEX);
/* Specifies the number of extra bytes to allocate following
the window handle. */
wc.cbWndExtra = 0;
/* Handle to the class background brush. This member can be
a handle to the physical brush to be used for painting the
background, or it can be a color value. A color value must
be one of the following standard system colors
(the value 1 must be added to the chosen color). */
lbrush.lbStyle = BS_SOLID;
lbrush.lbColor = RGB( 000, 000, 000 );
lbrush.lbHatch = 0;
hNewBrush = CreateBrushIndirect(&lbrush);
wc.hbrBackground = hNewBrush;
/* Handle to the class cursor. This member must be a handle
of a cursor resource. */
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
/* Handle to the class icon. This member must be a handle of
an icon resource. If this member is NULL, an application
must draw an icon whenever the user minimizes the
application's window. */
wc.hIcon = NULL;
/* Handle to a small icon that is associated with the window
class. If this member is NULL, the system searches the
icon resource specified by the hIcon member for an
icon of the appropriate size to use as the small icon.*/
wc.hIconSm = NULL;
/* Handle to the instance that the window procedure of this
class is within. */
wc.hInstance = NULL;
/* Pointer to the window procedure. */
wc.lpfnWndProc = CustGraphWindowProc;
/* Our control's window class name */
wc.lpszClassName = CUST_GRAPH_CLASS_NAME;
/* No menus */
wc.lpszMenuName = NULL;
/* CS_GLOBALCLASS style means that this window class is
an application global class. An application global class is
a window class registered by an executable or dynamic-link
library (.dll) that is available to all other modules in the
process. ...A process that loads the .dll can create instances
of the custom control. (MSDN) */
wc.style = CS_GLOBALCLASS;
/* Finally, register window class */
atom = RegisterClassEx(&wc);
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
if(ul_reason_for_call == DLL_PROCESS_ATTACH)
{
InitCustGraph();
}
return TRUE;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.