Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Custom Control Graph and Process Bar

, 13 Dec 2006
An article on a Win32 custom graph control and process bar creation.
// 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)  
			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;
			hdc = GetDC(hWnd);
			GetClientRect(hWnd, &rect);
			DrawBar(hdc, rect, (int) lParam);
			return 1;
	return DefWindowProc(hWnd, uMsg, wParam, lParam);

void InitCustGraph()
	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))

	/* 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)	*/ = CS_GLOBALCLASS;

	/* Finally, register window class  */
	atom = RegisterClassEx(&wc);

                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
	if(ul_reason_for_call == DLL_PROCESS_ATTACH)

    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 article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Shanmuga Sundar.V
India India
Module Lead working in leading MNC company, india - bangalore.

| Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 13 Dec 2006
Article Copyright 2006 by Shanmuga Sundar.V
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid