Click here to Skip to main content
15,893,722 members
Articles / Desktop Programming / Win32

Programming User Interface in InstallScript

Rate me:
Please Sign up or sign in to vote.
4.56/5 (6 votes)
1 May 2011CPOL8 min read 60.1K   1.2K   13  
This article describes advanced techniques for programming user interface in pure InstallScript projects.
// subclass.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
static WNDPROC oldstaticproc;
static int nCtrlID;

long __stdcall StaticProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{	
	switch(msg)
	{
		case WM_CTLCOLORSTATIC: //WM_CTLCOLOREDIT:
			if(GetDlgCtrlID((HWND)lParam) == nCtrlID) 
			{
				//SetBkMode((HDC)wParam, TRANSPARENT);
				SetBkMode((HDC)wParam, OPAQUE);
				return (INT_PTR)(HBRUSH)GetStockObject(DC_BRUSH);
			}

		case WM_COMMAND:
			if(LOWORD(wParam) == nCtrlID) 
			{
				if(HIWORD(wParam) == EN_SETFOCUS) 
				{
					SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(nCtrlID, EN_CHANGE),(LPARAM)GetDlgItem(hwnd, nCtrlID));
				}
				else if(HIWORD(wParam) == EN_KILLFOCUS)
				{
					SendMessage(GetDlgItem(hwnd, nCtrlID),EM_HIDEBALLOONTIP,0,0);
				}
			}

		case WM_HELP:
			LPHELPINFO lphlp = (LPHELPINFO)lParam;
			if(wParam == 0 && lphlp != 0) 
			{
				if(GetDlgCtrlID((HWND)lphlp->hItemHandle) == nCtrlID) 
				{
					SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(nCtrlID,EN_CHANGE),(LPARAM)GetDlgItem(hwnd, nCtrlID));
				}
			}
	}
	
	return CallWindowProc(oldstaticproc, hwnd, msg, wParam, lParam);
}


extern "C" __declspec(dllexport) void SubClassWindowProc(HWND hWnd,int nvarCtrlID)
{
	oldstaticproc = (WNDPROC)SetWindowLong(hWnd, GWL_WNDPROC, (LONG)StaticProc);
	nCtrlID = nvarCtrlID;
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Israel Israel
Working with .NET since 2005
Expertise in developing tools and services for SharePoint, TFS, BI/SSRS
Technical partner in start-up developing Outlook Add-ins.
Owning CodePlex projects:
http://extreportviewer.codeplex.com/
http://tfsprod.codeplex.com/
http://tfsspconnect.codeplex.com/

Comments and Discussions