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

Resource ID Organiser Add-In for Visual C++ 5.0/6.0/.NET

, 10 Jan 2005 CPOL
An application/add-in to organise and renumber resource symbol IDs
resorg103.zip
ResOrg103.exe
resorg104.zip
ResOrg104.exe
resorgaddinsetup.zip
ResOrgAddInSetup.exe
resorgaddin_executables.zip
ResOrg.exe
BXFileDialog.dll
CJ609Lib.dll
NGLib103.dll
ResOrgAddIn.dll
ResOrgCore.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
resorgnetaddinsetup.zip
ResOrgNETAddInSetup.msi
resorgnetaddin_executables.zip
ResOrgNETAddInToolWindows.ocx
ResOrgNET.exe
CJ609LibVc7.dll
NGLib103Vc7.dll
ResOrgNETAddIn.dll
ResOrgNETCore.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
ReadMe.rtf
Licence.rtf
resorgnet_executables.zip
ResOrgNET_executables
CJ609LibVc7.dll
NGLib103Vc7.dll
QHTMLight.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
ResOrgNETAddIn.dll
ResOrgNETAddInToolWindows.ocx
ResOrgNETCore.dll
resorg_demo.zip
ResOrg103.exe
resorg_executables.zip
ResOrgAddIn.dll
BXFileDialog.dll
CJ609Lib.dll
ResOrg.exe
ResOrg.cnt
resorg.fts
ResOrg.hlp
ResOrgCore.dll
NGLib103.dll
resorg_src.zip
BXFileDialog
BXFileDialog.dsp
Lib
Release
Res
bitmap2.bmp
FileOpen.bmp
filesave.bmp
CJLibrary
CJLibrary
CJLibrary.def
CJLibrary.dsp
CJLibrary.dsw
CJLibrarydep.jpg
CJLibraryStatic.dsp
Debug_Unicode
Release
Release_Unicode
res
Include
res
btn_arro.bmp
btn_explorer.bmp
button_images.bmp
cj_logo.bmp
dragging.cur
handcur.cur
headerba.bmp
hsplitba.cur
icr_hand.cur
nodraggi.cur
PushPin.bmp
Toolbar.bmp
vsplitba.cur
Lib
default.doxygen
NGLibrary
Bin
NGLibrary.def
NGLibrary.dsp
NGLibrary.dsw
Release
Res
Drives.bmp
Release
ResOrg.dsw
ResOrgAddIn
Release
Res
HtmlDoc.ico
ResOrg.ico
ResOrgDoc.ico
TBarLrge.bmp
TBarMedm.bmp
Toolbar.bmp
WorkspaceTabs.bmp
ResOrgAddIn.def
ResOrgAddIn.dsp
ResOrgAddIn.odl
ResOrgAddIn_Res.hm
ResOrgApp
Lint
Release
Res
HtmlDoc.ico
MAINFRAM.BMP
ResOrg.ico
ResOrgDoc.ico
TBarLrge.bmp
TBarMedm.bmp
Toolbar.bmp
workspace.ico
WorkspaceTabs.bmp
ResOrgApp.dsp
ResOrgApp_Res.hm
ResOrgApp_Res.resorg
ResOrgCore
Lint
Release
Res
Anna.bmp
BuildOptions.ico
ComCtl Version Prompt.rtf
File Reload Warning Ex.rtf
File Reload Warning.rtf
Global Next Symbol Value Warning Prompt.rtf
information.ico
Invalid Symbol Name.rtf
Mailing List Prompt.rtf
Next Symbol Value Warning Prompt.rtf
project context menu.bmp
project.ico
RenumWiz Completion.rtf
Report.ico
ResOrg Logo.bmp
ResOrg Updated.rtf
ResOrg.ico
resource file.ico
riverblade_logo.bmp
solution.ico
Symbol Delete Warning.rtf
Symbol Name Warning.rtf
Symbol Rename Warning.rtf
SymbolFile.ico
Symbols Delete Warning.rtf
sym_binary.ico
sym_bitmap.ico
sym_command.ico
sym_control.ico
sym_dialog.ico
sym_icon.ico
sym_menu.ico
sym_prompt.ico
sym_resource.ico
sym_string.ico
Toolbar.bmp
VcAddIn.ico
VersionCheck.ico
warning.ico
WizardHeader256.bmp
WizardWatermark256.bmp
ResOrgCore.def
ResOrgCore.dsp
ResOrgCore_Res.hm
ResOrgCore_Res.resorg
Xml
ProblemSymbolReportHtml.xsl
SymbolsReportHtml.xsl
ResOrgNETAddIn
AddIn.def
Release
Res
AddIn.rgs
HtmlDoc.ico
ResOrg.ico
ResOrgDoc.ico
Toolbar.bmp
WorkspaceTabs.bmp
ResOrgNETAddInSetup
Banner.jpg
Intro screen.jpg
Licence.rtf
ReadMe.rtf
Release
ResOrg.ico
ResOrgNETAddInSetup.vdproj
ResOrgNETAddInToolWindows
Release
Res
Edit.ico
Properties.ico
Renumber.ico
ResOrgNETAddInToolWindows.ico
ResOrgNETAddInToolWindowsCtrl.bmp
ResOrgNETAddInToolWindows.def
SatelliteDll
Release
res
AboutBoxCmd.bmp
OpenResOrgCmd.bmp
OptionsCmd.bmp
ViewMainToolWinCmd.bmp
//****************************************************************************
// File: mainwnd.c
//
// Purpose: Main overlapped window's message handler
//
// Functions:
//    MainWndProc() - message handler for main overlapped window
//    DoCommands() - called by MainWndProc to handle all WM_COMMAND messages
//
// Development Team:  HHR
//
//
// Written by Microsoft Product Support Services, Windows Developer Support
// Copyright (c) 1992 Microsoft Corporation. All rights reserved.
//****************************************************************************


#pragma warning (disable:4115)
#pragma warning (disable:4201)
#pragma warning (disable:4214)
#pragma warning (disable:4514)


#include <windows.h>

#define	NGLIB_BUILD_DLL				// Force classes to be EXPORTED
#include "NGLibrary_DllDefs.h"		// DLL export/import definitions



// Global variables used by the scalable dialog.
static float xMult, yMult;

// Local function prototypes.
static void HandleCBCtrls(HWND hWnd, LPRECT lprc);
static void StoreWindowRect(HWND hWnd,LPRECT lprc);
static void RetrieveWindowRect(HWND hWnd, LPRECT lprc);
static void DeleteWindowRect(HWND hWnd);
static void CalcMultiplier(HWND hWnd);
static void CalcNewSize(LPRECT lprc);

//****************************************************************************
// Function: HandleCBCtrls
//
// Purpose: Called by ScalableDlg() to handle Combo boxes special case
//          situation with the drop down list size.
//
// Parameters:
//    hWnd    == Handle to the control child window.
//    lprc    == Pointer to the controls dimentions obtained through 
//               GetWindowRect()
//
// Returns : None.
//
// Comments:  CBS_DROPDOWN and CBS_DROPDOWNLIST dimensions return by 
//            GetWindowRect() does not include the drop down list.  What
//            this function does is adds the height of the list box to 
//            the RECT.
//
// History:  Date       Author        Reason
//           6/10/93    HHR           Created
//****************************************************************************
static void HandleCBCtrls(HWND hWnd, LPRECT lprc)
{
	char ClassName[20];
	RECT rcl;
	LONG CBStyles;
	
	// Get the class name 
	GetClassName(hWnd,(LPSTR)ClassName,20);
	
	// Check to see if it is a combo box then check to see if it is either
	// CBS_DROPDOWN or CBS_DROPDOWNLIST, if so then get the list boxes 
	// dimentions and add in its height.
	if (!lstrcmpi(ClassName,"COMBOBOX")){
		CBStyles = GetWindowLong(hWnd,GWL_STYLE);
		if ((CBStyles & CBS_DROPDOWN) || (CBStyles & CBS_DROPDOWNLIST)){
			SendMessage(hWnd,CB_GETDROPPEDCONTROLRECT,0,(DWORD)((LPRECT)&rcl));
			lprc->bottom = rcl.bottom;      // Take the the height of the CB
								            // including its drop down list box
		}
	}
	return;
}

//****************************************************************************
// Function: StoreWindowRect
//
// Purpose: Called by ScalableDlg() to calculate and store the initial 
//          rect values in the windows property.
//
// Parameters:
//    hWnd    == Handle to the dialog or its child controls
//    lprc    == The rect dimentions to be stored.
//
// Returns : None.
//
// Comments: This functions should be called only once at the very begining
//           to store the initial values.
//
// History:  Date       Author        Reason
//           6/10/93    HHR           Created
//****************************************************************************
static void StoreWindowRect(HWND hWnd,LPRECT lprc)
{
	SetProp(hWnd,"top",(HANDLE)lprc->top);
	SetProp(hWnd,"bottom",(HANDLE)lprc->bottom);
	SetProp(hWnd,"left",(HANDLE)lprc->left);
	SetProp(hWnd,"right",(HANDLE)lprc->right);
	
	return;
}

//****************************************************************************
// Function: RetrieveWindowRect
//
// Purpose: Called by ScalableDlg() to handle retrieve the initial dimentions
//          for either the dialog or its child controls.
//
// Parameters:
//    hWnd    == Handle to either dialog or its child controls
//    lprc    == Pointer to the RECT structure used to return the saved 
//               values
//
// Returns : None.
//
// Comments: This function must be called after StoreWindowRect is called to
//           store the values.
//
// History:  Date       Author        Reason
//           6/10/93    HHR           Created
//****************************************************************************
static void RetrieveWindowRect(HWND hWnd, LPRECT lprc)
{
	lprc->top    = (int) GetProp(hWnd,"top");
	lprc->bottom = (int) GetProp(hWnd,"bottom");
	lprc->left   = (int) GetProp(hWnd,"left");
	lprc->right  = (int) GetProp(hWnd,"right");
	
	return;
}

//****************************************************************************
// Function: DeleteWindowRect
//
// Purpose: Called by ScalableDlg() to delete the stored properties for the
//          given window.
//
// Parameters:
//    hWnd    == Handle to either the dialog or its child controls.
//
// Returns : None.
//
// Comments: This must be called before the dialog is closed and only if 
//           StoreWindowRect was called to install them.
//
// History:  Date       Author        Reason
//           6/10/93    HHR           Created
//****************************************************************************
static void DeleteWindowRect(HWND hWnd)
{
	RemoveProp(hWnd,"top");
	RemoveProp(hWnd,"bottom");
	RemoveProp(hWnd,"left");
	RemoveProp(hWnd,"right");
	
	return;
}

//****************************************************************************
// Function: CalcMultiplier
//
// Purpose: Called by ScalableDlg() to Calculate the expansion or reduction
//          ratio based on the dialog size for use to adjust the child conrol
//          sizes
//
// Parameters:
//    hWnd    == Handle to the dialog
//
// Returns : None.  
//
// Comments: xMult and yMult two global variables are set to be used by
//           CalcNewSize() to calculate the child controls new sizes.
//
// History:  Date       Author        Reason
//           6/10/93    HHR           Created
//****************************************************************************
static void CalcMultiplier(HWND hWnd)
{
	RECT rc,rcInit;
		
	GetClientRect(hWnd,&rc);               // Get the new Rect of Dialog
	RetrieveWindowRect(hWnd,&rcInit);      // Get the Original Rect of Dialog
		
	//  Calculate the multiplier to calculate the new size of controls.
	xMult =                                // Width's change ratio
		(float)(rc.right - rc.left) /      // New Width of the dialog
			(rcInit.right - rcInit.left);  // Original Width of the dialog
	yMult =                                // Height's change ratio
		(float)(rc.bottom - rc.top) /      // New Height of the dialog
			(rcInit.bottom - rcInit.top);  // Original Height of the dialog
		
	return;
}

//****************************************************************************
// Function: CalcNewSize
//
// Purpose: Called by ScalableDlg() to calculate the child controls new
//          size.
//
// Parameters:
//    lprc    == Child control's initial size
//
// Returns : None.
//
// Comments: The new dimentions are returned via lprc.
//
// History:  Date       Author        Reason
//           6/10/93    HHR           Created
//****************************************************************************
static void CalcNewSize(LPRECT lprc)
{
	lprc->top    = (int)((yMult * lprc->top) + 0.5);
	lprc->bottom = (int)((yMult * lprc->bottom) + 0.5);
	lprc->left   = (int)((xMult * lprc->left) + 0.5);
	lprc->right  = (int)((xMult * lprc->right) + 0.5);
	
	return;
}

//****************************************************************************
// Function: ScalableDlg
//
// Purpose: Called by DoCommands() when want Scalable dialog box.
//
// Parameters:
//    hDlg    == Handle to _this_ window.
//    message == Message to process.
//    wParam  == WORD parameter -- depends on message
//    lParam  == LONG parameter -- depends on message
//
// Returns: Depends on message.
//
// Comments: The Scalable dialog has proportionally sized controls.
//
// History:  Date       Author        Reason
//           6/10/93    HHR           Created
//****************************************************************************
#pragma warning (disable:4100)
BOOL FAR PASCAL ScalableDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	HWND hCtl;
	RECT rc;

	switch (message){
		case WM_INITDIALOG:{
			// Get the font used by the dialog. Will be NULL if system font is
			// used.
			HFONT hDlgFont = (HFONT)SendMessage(hDlg, WM_GETFONT,0,0L);;
			
			// if the handle is NULL get the handle to the system font.
			if (!hDlgFont)
				hDlgFont = GetStockObject(SYSTEM_FONT);
					
			//Save Font Handle as Window Property  
			SetProp(hDlg, "hDlgFont", (HANDLE)hDlgFont);
					
			// Get the original size of the dialog and Store it.
			GetClientRect(hDlg,&rc);
			StoreWindowRect(hDlg,&rc);
					
			// Cycle through all dialog controls and store their original sizes.
			hCtl = GetWindow(hDlg,GW_CHILD);
			while (hCtl){
				GetWindowRect(hCtl,&rc);        // Get the Window dimentions
				HandleCBCtrls(hCtl,&rc);        // special case handling for
				                                // CBS_DROPDOWN/LIST
				ScreenToClient(hDlg,(LPPOINT)&rc.left);
				ScreenToClient(hDlg,(LPPOINT)&rc.right);
				StoreWindowRect(hCtl,&rc);
						
				hCtl = GetWindow(hCtl,GW_HWNDNEXT);
			}
		}
		break;

		case WM_DESTROY:
			// Cycle through all dialog controls and store their original sizes.
			hCtl = GetWindow(hDlg,GW_CHILD);
			while (hCtl){
				DeleteWindowRect(hCtl);
				hCtl = GetWindow(hCtl,GW_HWNDNEXT);
			}
			
			DeleteWindowRect(hDlg);
			         
			//Remove Font properties
			{
				HFONT hNewFont = (HFONT)RemoveProp(hDlg, "hNewFont");
			 	if (hNewFont)
			    	DeleteObject(hNewFont);
			            
			    RemoveProp(hDlg, "hDlgFont");
			}			         
         break;

		case WM_GETMINMAXINFO:{
			MINMAXINFO FAR* lpmmi;
			RECT rc;

			// Set the minimum size of the dialog so the controls do not run
			// into one another.
			lpmmi = (MINMAXINFO FAR*) lParam;
			RetrieveWindowRect(hDlg,&rc);

			// Set the minimum size at 90% of the original size.
			lpmmi->ptMinTrackSize.x =
				(int)(((rc.right - rc.left) * 0.25) + 0.5); // Min width of Dialog
			lpmmi->ptMinTrackSize.y =
				(int)(((rc.bottom - rc.top) * 0.25) + 0.5); // Min Height of Dialog

		}
       	break;

		case WM_SIZE:{
			HFONT hDlgFont = (HFONT)GetProp(hDlg, "hDlgFont");
			if (hDlgFont && GetWindowLong(hDlg, GWL_STYLE)&WS_THICKFRAME){
				HFONT hNewFont = (HFONT)RemoveProp(hDlg, "hNewFont");
				LOGFONT lf;
				// Calculate the new size ratio.
				CalcMultiplier(hDlg);
	
				// Get the LOGFONT structure for the original font
				GetObject(hDlgFont, sizeof(LOGFONT), (LPSTR) &lf);
	
				// Scale up or down the font
				if (yMult < 1.0 ) lf.lfHeight = (int)((yMult * lf.lfHeight) + 0.5);
				if (xMult < 1.0 ) lf.lfWidth  = (int)((xMult * lf.lfWidth) + 0.5);
	
				// Delete old font and Create ans Save the new font
				if (hNewFont)
					DeleteObject(hNewFont);
				hNewFont = CreateFontIndirect(&lf);
				SetProp(hDlg, "hNewFont", (HANDLE)hNewFont);
	         
				// Set the font for the dialog
				SendMessage(hDlg,WM_SETFONT,(WPARAM) hNewFont,0L);
	
				// Start with the first control and cycle through all controls
				hCtl = GetWindow(hDlg,GW_CHILD);
				while (hCtl) {
					// Set the font for the Control
					SendMessage(hCtl,WM_SETFONT,(WPARAM) hNewFont,0L);
	
					// Retrieve the original size of the control and calculate its new
					// size then resize the control.
					RetrieveWindowRect(hCtl,&rc);
					CalcNewSize(&rc);            
					MoveWindow(hCtl,rc.left,rc.top,
	                       (rc.right-rc.left),(rc.bottom-rc.top),FALSE);
					InvalidateRect(hCtl,NULL,TRUE);
	
					// Get the next control.
					hCtl = GetWindow(hCtl,GW_HWNDNEXT);
				}
	
				// Make the dialog to repaint entirely.
				InvalidateRect(hDlg,NULL,TRUE);
			}
		}
		break;

	}//switch

	return (FALSE); // Didn't process a message
}
#pragma warning (default:4100)

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)

Share

About the Author

Anna-Jayne Metcalfe
Founder Riverblade Limited
United Kingdom United Kingdom
I haven't always written software for a living. When I graduated from Surrey University in 1989, it was with an Electronic Engineering degree, but unfortunately that never really gave me the opportunity to do anything particularly interesting (with the possible exception of designing Darth Vader's Codpiece * for the UK Army in 1990).
    * Also known as the Standard Army Bootswitch. But that's another story...
Since the opportunity arose to lead a software team developing C++ software for Avionic Test Systems in 1996, I've not looked back. More recently I've been involved in the development of subsea acoustic navigation systems, digital TV broadcast systems, port security/tracking systems, and most recently software development tools with my own company, Riverblade Ltd.
 
One of my personal specialities is IDE plug-in development. ResOrg was my first attempt at a plug-in, but my day to day work is with Visual Lint, an interactive code analysis tool environment with works within the Visual Studio and Eclipse IDEs or on build servers.
 
I love lots of things, but particularly music, photography and anything connected with history or engineering. I despise ignorant, intolerant and obstructive people - and it shows...I can be a bolshy cow if you wind me up the wrong way...Laugh | :laugh:
 
I'm currently based 15 minutes walk from the beach in Bournemouth on the south coast of England. Since I moved here I've grown to love the place - even if it is full of grockles in Summer!
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141216.1 | Last Updated 10 Jan 2005
Article Copyright 2001 by Anna-Jayne Metcalfe
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid