Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i ass a "Status Bar" to my Win32API Applaction??

Status
Not open for further replies.

NeoC

Programmer
Jan 12, 2005
3
IL
hi, i'm writing a notepad is visual c++ 6
and i would like to add a status bar that can
tell me what line and colum am i.

how can i do that??


tnx
 
This is a piece of code that establishes the status bar. The calls to fill the parts with text use the SB_SETTEXT message.

Code:
#include <windows.h>
#include <commctrl.h>

// Startout status bar control routine.  Creates a status bar, divides it into nParts sections.
// hStatus must be zero on first call to StatusBar:
HWND StatusBar (HWND hWndParent, HWND hStatus, HINSTANCE hInst, int nParts)
{
	RECT		rcClient;
	HLOCAL		hloc;
	LPINT		lpParts;
	int			i, nWidth;

	if (hStatus == 0) {
		hStatus = CreateWindowEx (0, STATUSCLASSNAME, (LPCTSTR) NULL, WS_CHILD, 0, 0, 0, 0,
									hWndParent,(HMENU) NULL, hInst, NULL);
		ShowWindow (hStatus, SW_SHOWNORMAL);
		UpdateWindow (hStatus);
	}

	// Get the coordinates of the parent window's client area.
	GetClientRect (hWndParent, &rcClient);

	// Allocate an array for holding the right edge coordinates.
	hloc = LocalAlloc (LHND, sizeof (int) * (nParts + 1));
	lpParts = (int*) LocalLock (hloc);

	// Calculate the right edge coordinate for each part, and
	// copy the coordinates to the array.
	nWidth = (rcClient.right - 12) / nParts;
	for (i = 0; i < nParts; i++)
		lpParts[i] = i * nWidth;
	lpParts [nParts] = nParts * nWidth;

	// Tell the status bar to create the window parts.
	SendMessage (hStatus, SB_SETPARTS, (WPARAM) nParts + 1, (LPARAM) lpParts);

	// Free the array, and return.
	LocalUnlock (hloc);
	LocalFree (hloc);

	return hStatus;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top